blob: b25ed63d6c9a8e5736f20a074961b7daf4899426 [file] [log] [blame]
Dan Gohman54392c12008-04-19 00:24:39 +00001/* A Bison parser, made by GNU Bison 2.3. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002
Dan Gohman54392c12008-04-19 00:24:39 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Dan Gohman54392c12008-04-19 00:24:39 +00005 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007
Dan Gohman54392c12008-04-19 00:24:39 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
49/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
61/* Substitute the variable and function names. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062#define yyparse llvmAsmparse
Dan Gohman54392c12008-04-19 00:24:39 +000063#define yylex llvmAsmlex
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064#define yyerror llvmAsmerror
Dan Gohman54392c12008-04-19 00:24:39 +000065#define yylval llvmAsmlval
66#define yychar llvmAsmchar
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067#define yydebug llvmAsmdebug
68#define yynerrs llvmAsmnerrs
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069
Dan Gohman54392c12008-04-19 00:24:39 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 ESAPINTVAL = 260,
80 EUAPINTVAL = 261,
81 LOCALVAL_ID = 262,
82 GLOBALVAL_ID = 263,
83 FPVAL = 264,
84 VOID = 265,
85 INTTYPE = 266,
86 FLOAT = 267,
87 DOUBLE = 268,
88 X86_FP80 = 269,
89 FP128 = 270,
90 PPC_FP128 = 271,
91 LABEL = 272,
92 TYPE = 273,
93 LOCALVAR = 274,
94 GLOBALVAR = 275,
95 LABELSTR = 276,
96 STRINGCONSTANT = 277,
97 ATSTRINGCONSTANT = 278,
98 PCTSTRINGCONSTANT = 279,
99 ZEROINITIALIZER = 280,
100 TRUETOK = 281,
101 FALSETOK = 282,
102 BEGINTOK = 283,
103 ENDTOK = 284,
104 DECLARE = 285,
105 DEFINE = 286,
106 GLOBAL = 287,
107 CONSTANT = 288,
108 SECTION = 289,
109 ALIAS = 290,
110 VOLATILE = 291,
111 THREAD_LOCAL = 292,
112 TO = 293,
113 DOTDOTDOT = 294,
114 NULL_TOK = 295,
115 UNDEF = 296,
116 INTERNAL = 297,
117 LINKONCE = 298,
118 WEAK = 299,
119 APPENDING = 300,
120 DLLIMPORT = 301,
121 DLLEXPORT = 302,
122 EXTERN_WEAK = 303,
Dale Johannesen280e7bc2008-05-14 20:13:36 +0000123 COMMON = 304,
124 OPAQUE = 305,
125 EXTERNAL = 306,
126 TARGET = 307,
127 TRIPLE = 308,
128 ALIGN = 309,
129 ADDRSPACE = 310,
130 DEPLIBS = 311,
131 CALL = 312,
132 TAIL = 313,
133 ASM_TOK = 314,
134 MODULE = 315,
135 SIDEEFFECT = 316,
136 CC_TOK = 317,
137 CCC_TOK = 318,
138 FASTCC_TOK = 319,
139 COLDCC_TOK = 320,
140 X86_STDCALLCC_TOK = 321,
141 X86_FASTCALLCC_TOK = 322,
Dale Johannesenf4581482008-09-26 19:32:34 +0000142 DATALAYOUT = 323,
143 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 VICMP = 347,
167 VFCMP = 348,
168 EQ = 349,
169 NE = 350,
170 SLT = 351,
171 SGT = 352,
172 SLE = 353,
173 SGE = 354,
174 ULT = 355,
175 UGT = 356,
176 ULE = 357,
177 UGE = 358,
178 OEQ = 359,
179 ONE = 360,
180 OLT = 361,
181 OGT = 362,
182 OLE = 363,
183 OGE = 364,
184 ORD = 365,
185 UNO = 366,
186 UEQ = 367,
187 UNE = 368,
188 MALLOC = 369,
189 ALLOCA = 370,
190 FREE = 371,
191 LOAD = 372,
192 STORE = 373,
193 GETELEMENTPTR = 374,
194 TRUNC = 375,
195 ZEXT = 376,
196 SEXT = 377,
197 FPTRUNC = 378,
198 FPEXT = 379,
199 BITCAST = 380,
200 UITOFP = 381,
201 SITOFP = 382,
202 FPTOUI = 383,
203 FPTOSI = 384,
204 INTTOPTR = 385,
205 PTRTOINT = 386,
206 PHI_TOK = 387,
207 SELECT = 388,
208 VAARG = 389,
209 EXTRACTELEMENT = 390,
210 INSERTELEMENT = 391,
211 SHUFFLEVECTOR = 392,
212 GETRESULT = 393,
213 EXTRACTVALUE = 394,
214 INSERTVALUE = 395,
215 SIGNEXT = 396,
216 ZEROEXT = 397,
217 NORETURN = 398,
218 INREG = 399,
219 SRET = 400,
220 NOUNWIND = 401,
221 NOALIAS = 402,
222 BYVAL = 403,
223 NEST = 404,
224 READNONE = 405,
225 READONLY = 406,
226 GC = 407,
Devang Patelcd842482008-09-29 20:49:50 +0000227 OPTSIZE = 408,
228 NOINLINE = 409,
229 ALWAYSINLINE = 410,
230 DEFAULT = 411,
231 HIDDEN = 412,
232 PROTECTED = 413
Dan Gohman54392c12008-04-19 00:24:39 +0000233 };
234#endif
235/* Tokens. */
236#define ESINT64VAL 258
237#define EUINT64VAL 259
238#define ESAPINTVAL 260
239#define EUAPINTVAL 261
240#define LOCALVAL_ID 262
241#define GLOBALVAL_ID 263
242#define FPVAL 264
243#define VOID 265
244#define INTTYPE 266
245#define FLOAT 267
246#define DOUBLE 268
247#define X86_FP80 269
248#define FP128 270
249#define PPC_FP128 271
250#define LABEL 272
251#define TYPE 273
252#define LOCALVAR 274
253#define GLOBALVAR 275
254#define LABELSTR 276
255#define STRINGCONSTANT 277
256#define ATSTRINGCONSTANT 278
257#define PCTSTRINGCONSTANT 279
258#define ZEROINITIALIZER 280
259#define TRUETOK 281
260#define FALSETOK 282
261#define BEGINTOK 283
262#define ENDTOK 284
263#define DECLARE 285
264#define DEFINE 286
265#define GLOBAL 287
266#define CONSTANT 288
267#define SECTION 289
268#define ALIAS 290
269#define VOLATILE 291
270#define THREAD_LOCAL 292
271#define TO 293
272#define DOTDOTDOT 294
273#define NULL_TOK 295
274#define UNDEF 296
275#define INTERNAL 297
276#define LINKONCE 298
277#define WEAK 299
278#define APPENDING 300
279#define DLLIMPORT 301
280#define DLLEXPORT 302
281#define EXTERN_WEAK 303
Dale Johannesen280e7bc2008-05-14 20:13:36 +0000282#define COMMON 304
283#define OPAQUE 305
284#define EXTERNAL 306
285#define TARGET 307
286#define TRIPLE 308
287#define ALIGN 309
288#define ADDRSPACE 310
289#define DEPLIBS 311
290#define CALL 312
291#define TAIL 313
292#define ASM_TOK 314
293#define MODULE 315
294#define SIDEEFFECT 316
295#define CC_TOK 317
296#define CCC_TOK 318
297#define FASTCC_TOK 319
298#define COLDCC_TOK 320
299#define X86_STDCALLCC_TOK 321
300#define X86_FASTCALLCC_TOK 322
Dale Johannesenf4581482008-09-26 19:32:34 +0000301#define DATALAYOUT 323
302#define RET 324
303#define BR 325
304#define SWITCH 326
305#define INVOKE 327
306#define UNWIND 328
307#define UNREACHABLE 329
308#define ADD 330
309#define SUB 331
310#define MUL 332
311#define UDIV 333
312#define SDIV 334
313#define FDIV 335
314#define UREM 336
315#define SREM 337
316#define FREM 338
317#define AND 339
318#define OR 340
319#define XOR 341
320#define SHL 342
321#define LSHR 343
322#define ASHR 344
323#define ICMP 345
324#define FCMP 346
325#define VICMP 347
326#define VFCMP 348
327#define EQ 349
328#define NE 350
329#define SLT 351
330#define SGT 352
331#define SLE 353
332#define SGE 354
333#define ULT 355
334#define UGT 356
335#define ULE 357
336#define UGE 358
337#define OEQ 359
338#define ONE 360
339#define OLT 361
340#define OGT 362
341#define OLE 363
342#define OGE 364
343#define ORD 365
344#define UNO 366
345#define UEQ 367
346#define UNE 368
347#define MALLOC 369
348#define ALLOCA 370
349#define FREE 371
350#define LOAD 372
351#define STORE 373
352#define GETELEMENTPTR 374
353#define TRUNC 375
354#define ZEXT 376
355#define SEXT 377
356#define FPTRUNC 378
357#define FPEXT 379
358#define BITCAST 380
359#define UITOFP 381
360#define SITOFP 382
361#define FPTOUI 383
362#define FPTOSI 384
363#define INTTOPTR 385
364#define PTRTOINT 386
365#define PHI_TOK 387
366#define SELECT 388
367#define VAARG 389
368#define EXTRACTELEMENT 390
369#define INSERTELEMENT 391
370#define SHUFFLEVECTOR 392
371#define GETRESULT 393
372#define EXTRACTVALUE 394
373#define INSERTVALUE 395
374#define SIGNEXT 396
375#define ZEROEXT 397
376#define NORETURN 398
377#define INREG 399
378#define SRET 400
379#define NOUNWIND 401
380#define NOALIAS 402
381#define BYVAL 403
382#define NEST 404
383#define READNONE 405
384#define READONLY 406
385#define GC 407
Devang Patelcd842482008-09-29 20:49:50 +0000386#define OPTSIZE 408
387#define NOINLINE 409
388#define ALWAYSINLINE 410
389#define DEFAULT 411
390#define HIDDEN 412
391#define PROTECTED 413
Dan Gohman54392c12008-04-19 00:24:39 +0000392
393
394
395
396/* Copy the first part of user declarations. */
Chris Lattner8f5544c2008-10-15 06:03:48 +0000397#line 14 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398
399#include "ParserInternals.h"
400#include "llvm/CallingConv.h"
401#include "llvm/InlineAsm.h"
402#include "llvm/Instructions.h"
403#include "llvm/Module.h"
404#include "llvm/ValueSymbolTable.h"
Chandler Carruth563d4a42007-08-04 01:56:21 +0000405#include "llvm/AutoUpgrade.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406#include "llvm/Support/GetElementPtrTypeIterator.h"
407#include "llvm/Support/CommandLine.h"
408#include "llvm/ADT/SmallVector.h"
409#include "llvm/ADT/STLExtras.h"
410#include "llvm/Support/MathExtras.h"
411#include "llvm/Support/Streams.h"
412#include <algorithm>
413#include <list>
414#include <map>
415#include <utility>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416
417// The following is a gross hack. In order to rid the libAsmParser library of
418// exceptions, we have to have a way of getting the yyparse function to go into
419// an error situation. So, whenever we want an error to occur, the GenerateError
Eric Christopher329d2672008-09-24 04:55:49 +0000420// function (see bottom of file) sets TriggerError. Then, at the end of each
421// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
422// (a goto) to put YACC in error state. Furthermore, several calls to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423// GenerateError are made from inside productions and they must simulate the
424// previous exception behavior by exiting the production immediately. We have
425// replaced these with the GEN_ERROR macro which calls GeneratError and then
Eric Christopher329d2672008-09-24 04:55:49 +0000426// immediately invokes YYERROR. This would be so much cleaner if it was a
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000427// recursive descent parser.
428static bool TriggerError = false;
429#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
430#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
431
432int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
433int yylex(); // declaration" of xxx warnings.
434int yyparse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435using namespace llvm;
436
437static Module *ParserResult;
438
439// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
440// relating to upreferences in the input stream.
441//
442//#define DEBUG_UPREFS 1
443#ifdef DEBUG_UPREFS
444#define UR_OUT(X) cerr << X
445#else
446#define UR_OUT(X)
447#endif
448
449#define YYERROR_VERBOSE 1
450
451static GlobalVariable *CurGV;
452
453
454// This contains info used when building the body of a function. It is
455// destroyed when the function is completed.
456//
457typedef std::vector<Value *> ValueList; // Numbered defs
458
Eric Christopher329d2672008-09-24 04:55:49 +0000459static void
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
461
462static struct PerModuleInfo {
463 Module *CurrentModule;
464 ValueList Values; // Module level numbered definitions
465 ValueList LateResolveValues;
466 std::vector<PATypeHolder> Types;
467 std::map<ValID, PATypeHolder> LateResolveTypes;
468
469 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
470 /// how they were referenced and on which line of the input they came from so
471 /// that we can resolve them later and print error messages as appropriate.
472 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
473
474 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
475 // references to global values. Global values may be referenced before they
476 // are defined, and if so, the temporary object that they represent is held
477 // here. This is used for forward references of GlobalValues.
478 //
479 typedef std::map<std::pair<const PointerType *,
480 ValID>, GlobalValue*> GlobalRefsType;
481 GlobalRefsType GlobalRefs;
482
483 void ModuleDone() {
484 // If we could not resolve some functions at function compilation time
485 // (calls to functions before they are defined), resolve them now... Types
486 // are resolved when the constant pool has been completely parsed.
487 //
488 ResolveDefinitions(LateResolveValues);
489 if (TriggerError)
490 return;
491
492 // Check to make sure that all global value forward references have been
493 // resolved!
494 //
495 if (!GlobalRefs.empty()) {
496 std::string UndefinedReferences = "Unresolved global references exist:\n";
497
498 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
499 I != E; ++I) {
500 UndefinedReferences += " " + I->first.first->getDescription() + " " +
501 I->first.second.getName() + "\n";
502 }
503 GenerateError(UndefinedReferences);
504 return;
505 }
506
Chandler Carruth563d4a42007-08-04 01:56:21 +0000507 // Look for intrinsic functions and CallInst that need to be upgraded
508 for (Module::iterator FI = CurrentModule->begin(),
509 FE = CurrentModule->end(); FI != FE; )
510 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
511
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 Values.clear(); // Clear out function local definitions
513 Types.clear();
514 CurrentModule = 0;
515 }
516
517 // GetForwardRefForGlobal - Check to see if there is a forward reference
518 // for this global. If so, remove it from the GlobalRefs map and return it.
519 // If not, just return null.
520 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
521 // Check to see if there is a forward reference to this global variable...
522 // if there is, eliminate it and patch the reference to use the new def'n.
523 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
524 GlobalValue *Ret = 0;
525 if (I != GlobalRefs.end()) {
526 Ret = I->second;
527 GlobalRefs.erase(I);
528 }
529 return Ret;
530 }
531
532 bool TypeIsUnresolved(PATypeHolder* PATy) {
533 // If it isn't abstract, its resolved
534 const Type* Ty = PATy->get();
535 if (!Ty->isAbstract())
536 return false;
537 // Traverse the type looking for abstract types. If it isn't abstract then
Eric Christopher329d2672008-09-24 04:55:49 +0000538 // we don't need to traverse that leg of the type.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539 std::vector<const Type*> WorkList, SeenList;
540 WorkList.push_back(Ty);
541 while (!WorkList.empty()) {
542 const Type* Ty = WorkList.back();
543 SeenList.push_back(Ty);
544 WorkList.pop_back();
545 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
546 // Check to see if this is an unresolved type
547 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
548 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
549 for ( ; I != E; ++I) {
550 if (I->second.get() == OpTy)
551 return true;
552 }
553 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
554 const Type* TheTy = SeqTy->getElementType();
555 if (TheTy->isAbstract() && TheTy != Ty) {
Eric Christopher329d2672008-09-24 04:55:49 +0000556 std::vector<const Type*>::iterator I = SeenList.begin(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557 E = SeenList.end();
558 for ( ; I != E; ++I)
559 if (*I == TheTy)
560 break;
561 if (I == E)
562 WorkList.push_back(TheTy);
563 }
564 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
565 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
566 const Type* TheTy = StrTy->getElementType(i);
567 if (TheTy->isAbstract() && TheTy != Ty) {
Eric Christopher329d2672008-09-24 04:55:49 +0000568 std::vector<const Type*>::iterator I = SeenList.begin(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569 E = SeenList.end();
570 for ( ; I != E; ++I)
571 if (*I == TheTy)
572 break;
573 if (I == E)
574 WorkList.push_back(TheTy);
575 }
576 }
577 }
578 }
579 return false;
580 }
581} CurModule;
582
583static struct PerFunctionInfo {
584 Function *CurrentFunction; // Pointer to current function being created
585
586 ValueList Values; // Keep track of #'d definitions
587 unsigned NextValNum;
588 ValueList LateResolveValues;
589 bool isDeclare; // Is this function a forward declararation?
590 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
591 GlobalValue::VisibilityTypes Visibility;
592
593 /// BBForwardRefs - When we see forward references to basic blocks, keep
594 /// track of them here.
595 std::map<ValID, BasicBlock*> BBForwardRefs;
596
597 inline PerFunctionInfo() {
598 CurrentFunction = 0;
599 isDeclare = false;
600 Linkage = GlobalValue::ExternalLinkage;
601 Visibility = GlobalValue::DefaultVisibility;
602 }
603
604 inline void FunctionStart(Function *M) {
605 CurrentFunction = M;
606 NextValNum = 0;
607 }
608
609 void FunctionDone() {
610 // Any forward referenced blocks left?
611 if (!BBForwardRefs.empty()) {
612 GenerateError("Undefined reference to label " +
613 BBForwardRefs.begin()->second->getName());
614 return;
615 }
616
617 // Resolve all forward references now.
618 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
619
620 Values.clear(); // Clear out function local definitions
621 BBForwardRefs.clear();
622 CurrentFunction = 0;
623 isDeclare = false;
624 Linkage = GlobalValue::ExternalLinkage;
625 Visibility = GlobalValue::DefaultVisibility;
626 }
627} CurFun; // Info for the current function...
628
629static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
630
631
632//===----------------------------------------------------------------------===//
633// Code to handle definitions of all the types
634//===----------------------------------------------------------------------===//
635
Chris Lattner906773a2008-08-29 17:20:18 +0000636/// InsertValue - Insert a value into the value table. If it is named, this
637/// returns -1, otherwise it returns the slot number for the value.
638static int InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639 // Things that have names or are void typed don't get slot numbers
640 if (V->hasName() || (V->getType() == Type::VoidTy))
Chris Lattner906773a2008-08-29 17:20:18 +0000641 return -1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642
643 // In the case of function values, we have to allow for the forward reference
644 // of basic blocks, which are included in the numbering. Consequently, we keep
Eric Christopher329d2672008-09-24 04:55:49 +0000645 // track of the next insertion location with NextValNum. When a BB gets
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000646 // inserted, it could change the size of the CurFun.Values vector.
647 if (&ValueTab == &CurFun.Values) {
648 if (ValueTab.size() <= CurFun.NextValNum)
649 ValueTab.resize(CurFun.NextValNum+1);
650 ValueTab[CurFun.NextValNum++] = V;
Chris Lattner906773a2008-08-29 17:20:18 +0000651 return CurFun.NextValNum-1;
Eric Christopher329d2672008-09-24 04:55:49 +0000652 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653 // For all other lists, its okay to just tack it on the back of the vector.
654 ValueTab.push_back(V);
Chris Lattner906773a2008-08-29 17:20:18 +0000655 return ValueTab.size()-1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656}
657
658static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
659 switch (D.Type) {
660 case ValID::LocalID: // Is it a numbered definition?
661 // Module constants occupy the lowest numbered slots...
662 if (D.Num < CurModule.Types.size())
663 return CurModule.Types[D.Num];
664 break;
665 case ValID::LocalName: // Is it a named definition?
666 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
667 D.destroy(); // Free old strdup'd memory...
668 return N;
669 }
670 break;
671 default:
672 GenerateError("Internal parser error: Invalid symbol type reference");
673 return 0;
674 }
675
676 // If we reached here, we referenced either a symbol that we don't know about
677 // or an id number that hasn't been read yet. We may be referencing something
678 // forward, so just create an entry to be resolved later and get to it...
679 //
680 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
681
682
683 if (inFunctionScope()) {
684 if (D.Type == ValID::LocalName) {
685 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
686 return 0;
687 } else {
688 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
689 return 0;
690 }
691 }
692
693 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
694 if (I != CurModule.LateResolveTypes.end())
695 return I->second;
696
697 Type *Typ = OpaqueType::get();
698 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
699 return Typ;
700 }
701
702// getExistingVal - Look up the value specified by the provided type and
703// the provided ValID. If the value exists and has already been defined, return
704// it. Otherwise return null.
705//
706static Value *getExistingVal(const Type *Ty, const ValID &D) {
707 if (isa<FunctionType>(Ty)) {
708 GenerateError("Functions are not values and "
709 "must be referenced as pointers");
710 return 0;
711 }
712
713 switch (D.Type) {
714 case ValID::LocalID: { // Is it a numbered definition?
715 // Check that the number is within bounds.
Eric Christopher329d2672008-09-24 04:55:49 +0000716 if (D.Num >= CurFun.Values.size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 return 0;
718 Value *Result = CurFun.Values[D.Num];
719 if (Ty != Result->getType()) {
720 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
Eric Christopher329d2672008-09-24 04:55:49 +0000721 Result->getType()->getDescription() + "' does not match "
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 "expected type, '" + Ty->getDescription() + "'");
723 return 0;
724 }
725 return Result;
726 }
727 case ValID::GlobalID: { // Is it a numbered definition?
Eric Christopher329d2672008-09-24 04:55:49 +0000728 if (D.Num >= CurModule.Values.size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729 return 0;
730 Value *Result = CurModule.Values[D.Num];
731 if (Ty != Result->getType()) {
732 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
Eric Christopher329d2672008-09-24 04:55:49 +0000733 Result->getType()->getDescription() + "' does not match "
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 "expected type, '" + Ty->getDescription() + "'");
735 return 0;
736 }
737 return Result;
738 }
Eric Christopher329d2672008-09-24 04:55:49 +0000739
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740 case ValID::LocalName: { // Is it a named definition?
Eric Christopher329d2672008-09-24 04:55:49 +0000741 if (!inFunctionScope())
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742 return 0;
743 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
744 Value *N = SymTab.lookup(D.getName());
Eric Christopher329d2672008-09-24 04:55:49 +0000745 if (N == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 return 0;
747 if (N->getType() != Ty)
748 return 0;
Eric Christopher329d2672008-09-24 04:55:49 +0000749
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750 D.destroy(); // Free old strdup'd memory...
751 return N;
752 }
753 case ValID::GlobalName: { // Is it a named definition?
754 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
755 Value *N = SymTab.lookup(D.getName());
Eric Christopher329d2672008-09-24 04:55:49 +0000756 if (N == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 return 0;
758 if (N->getType() != Ty)
759 return 0;
760
761 D.destroy(); // Free old strdup'd memory...
762 return N;
763 }
764
765 // Check to make sure that "Ty" is an integral type, and that our
766 // value will fit into the specified type...
767 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner59363a32008-02-19 04:36:25 +0000768 if (!isa<IntegerType>(Ty) ||
769 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 GenerateError("Signed integral constant '" +
771 itostr(D.ConstPool64) + "' is invalid for type '" +
772 Ty->getDescription() + "'");
773 return 0;
774 }
775 return ConstantInt::get(Ty, D.ConstPool64, true);
776
777 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner59363a32008-02-19 04:36:25 +0000778 if (isa<IntegerType>(Ty) &&
779 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner59363a32008-02-19 04:36:25 +0000781
782 if (!isa<IntegerType>(Ty) ||
783 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
784 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
785 "' is invalid or out of range for type '" +
786 Ty->getDescription() + "'");
787 return 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 }
Chris Lattner59363a32008-02-19 04:36:25 +0000789 // This is really a signed reference. Transmogrify.
790 return ConstantInt::get(Ty, D.ConstPool64, true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791
Chris Lattnerf3d40022008-07-11 00:30:39 +0000792 case ValID::ConstAPInt: // Is it an unsigned const pool reference?
793 if (!isa<IntegerType>(Ty)) {
794 GenerateError("Integral constant '" + D.getName() +
795 "' is invalid or out of range for type '" +
796 Ty->getDescription() + "'");
797 return 0;
798 }
Eric Christopher329d2672008-09-24 04:55:49 +0000799
Chris Lattnerf3d40022008-07-11 00:30:39 +0000800 {
801 APSInt Tmp = *D.ConstPoolInt;
802 Tmp.extOrTrunc(Ty->getPrimitiveSizeInBits());
803 return ConstantInt::get(Tmp);
804 }
Eric Christopher329d2672008-09-24 04:55:49 +0000805
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner59363a32008-02-19 04:36:25 +0000807 if (!Ty->isFloatingPoint() ||
808 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809 GenerateError("FP constant invalid for type");
810 return 0;
811 }
Eric Christopher329d2672008-09-24 04:55:49 +0000812 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesen255b8fe2007-09-11 18:33:39 +0000813 // as double. Fix this here. Long double does not need this.
814 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
Dale Johannesen5ba85fd2008-10-09 23:01:34 +0000815 Ty==Type::FloatTy) {
816 bool ignored;
817 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
818 &ignored);
819 }
Chris Lattner05ba86e2008-04-20 00:41:19 +0000820 return ConstantFP::get(*D.ConstPoolFP);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821
822 case ValID::ConstNullVal: // Is it a null value?
823 if (!isa<PointerType>(Ty)) {
824 GenerateError("Cannot create a a non pointer null");
825 return 0;
826 }
827 return ConstantPointerNull::get(cast<PointerType>(Ty));
828
829 case ValID::ConstUndefVal: // Is it an undef value?
830 return UndefValue::get(Ty);
831
832 case ValID::ConstZeroVal: // Is it a zero value?
833 return Constant::getNullValue(Ty);
Eric Christopher329d2672008-09-24 04:55:49 +0000834
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835 case ValID::ConstantVal: // Fully resolved constant?
836 if (D.ConstantValue->getType() != Ty) {
837 GenerateError("Constant expression type different from required type");
838 return 0;
839 }
840 return D.ConstantValue;
841
842 case ValID::InlineAsmVal: { // Inline asm expression
843 const PointerType *PTy = dyn_cast<PointerType>(Ty);
844 const FunctionType *FTy =
845 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
846 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
847 GenerateError("Invalid type for asm constraint string");
848 return 0;
849 }
850 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
851 D.IAD->HasSideEffects);
852 D.destroy(); // Free InlineAsmDescriptor.
853 return IA;
854 }
855 default:
856 assert(0 && "Unhandled case!");
857 return 0;
858 } // End of switch
859
860 assert(0 && "Unhandled case!");
861 return 0;
862}
863
864// getVal - This function is identical to getExistingVal, except that if a
865// value is not already defined, it "improvises" by creating a placeholder var
866// that looks and acts just like the requested variable. When the value is
867// defined later, all uses of the placeholder variable are replaced with the
868// real thing.
869//
870static Value *getVal(const Type *Ty, const ValID &ID) {
871 if (Ty == Type::LabelTy) {
872 GenerateError("Cannot use a basic block here");
873 return 0;
874 }
875
876 // See if the value has already been defined.
877 Value *V = getExistingVal(Ty, ID);
878 if (V) return V;
879 if (TriggerError) return 0;
880
881 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Dan Gohmane6b1ee62008-05-23 01:55:30 +0000882 GenerateError("Invalid use of a non-first-class type");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883 return 0;
884 }
885
886 // If we reached here, we referenced either a symbol that we don't know about
887 // or an id number that hasn't been read yet. We may be referencing something
888 // forward, so just create an entry to be resolved later and get to it...
889 //
890 switch (ID.Type) {
891 case ValID::GlobalName:
892 case ValID::GlobalID: {
893 const PointerType *PTy = dyn_cast<PointerType>(Ty);
894 if (!PTy) {
895 GenerateError("Invalid type for reference to global" );
896 return 0;
897 }
898 const Type* ElTy = PTy->getElementType();
899 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greif89f01162008-04-06 23:07:54 +0000900 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901 else
Christopher Lamb0a243582007-12-11 09:02:08 +0000902 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
903 (Module*)0, false, PTy->getAddressSpace());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904 break;
905 }
906 default:
907 V = new Argument(Ty);
908 }
Eric Christopher329d2672008-09-24 04:55:49 +0000909
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910 // Remember where this forward reference came from. FIXME, shouldn't we try
911 // to recycle these things??
912 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsf5588dc2007-11-27 13:23:08 +0000913 LLLgetLineNo())));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914
915 if (inFunctionScope())
916 InsertValue(V, CurFun.LateResolveValues);
917 else
918 InsertValue(V, CurModule.LateResolveValues);
919 return V;
920}
921
922/// defineBBVal - This is a definition of a new basic block with the specified
923/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Chris Lattnere7e9b602008-05-04 17:18:47 +0000924static BasicBlock *defineBBVal(const ValID &ID) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 assert(inFunctionScope() && "Can't get basic block at global scope!");
926
927 BasicBlock *BB = 0;
928
929 // First, see if this was forward referenced
930
931 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
932 if (BBI != CurFun.BBForwardRefs.end()) {
933 BB = BBI->second;
934 // The forward declaration could have been inserted anywhere in the
935 // function: insert it into the correct place now.
936 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
937 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
938
939 // We're about to erase the entry, save the key so we can clean it up.
940 ValID Tmp = BBI->first;
941
942 // Erase the forward ref from the map as its no longer "forward"
943 CurFun.BBForwardRefs.erase(ID);
944
Eric Christopher329d2672008-09-24 04:55:49 +0000945 // The key has been removed from the map but so we don't want to leave
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 // strdup'd memory around so destroy it too.
947 Tmp.destroy();
948
949 // If its a numbered definition, bump the number and set the BB value.
950 if (ID.Type == ValID::LocalID) {
951 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
952 InsertValue(BB);
953 }
Eric Christopher329d2672008-09-24 04:55:49 +0000954 } else {
955 // We haven't seen this BB before and its first mention is a definition.
Devang Patel890cc572008-03-03 18:58:47 +0000956 // Just create it and return it.
957 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greif89f01162008-04-06 23:07:54 +0000958 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel890cc572008-03-03 18:58:47 +0000959 if (ID.Type == ValID::LocalID) {
960 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
961 InsertValue(BB);
962 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 }
964
Devang Patel890cc572008-03-03 18:58:47 +0000965 ID.destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 return BB;
967}
968
969/// getBBVal - get an existing BB value or create a forward reference for it.
Eric Christopher329d2672008-09-24 04:55:49 +0000970///
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971static BasicBlock *getBBVal(const ValID &ID) {
972 assert(inFunctionScope() && "Can't get basic block at global scope!");
973
974 BasicBlock *BB = 0;
975
976 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
977 if (BBI != CurFun.BBForwardRefs.end()) {
978 BB = BBI->second;
979 } if (ID.Type == ValID::LocalName) {
980 std::string Name = ID.getName();
981 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikov21c1eeb2008-02-20 12:10:37 +0000982 if (N) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 if (N->getType()->getTypeID() == Type::LabelTyID)
984 BB = cast<BasicBlock>(N);
985 else
986 GenerateError("Reference to label '" + Name + "' is actually of type '"+
987 N->getType()->getDescription() + "'");
Anton Korobeynikov21c1eeb2008-02-20 12:10:37 +0000988 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 } else if (ID.Type == ValID::LocalID) {
990 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
991 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
992 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
993 else
Eric Christopher329d2672008-09-24 04:55:49 +0000994 GenerateError("Reference to label '%" + utostr(ID.Num) +
995 "' is actually of type '"+
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
997 }
998 } else {
999 GenerateError("Illegal label reference " + ID.getName());
1000 return 0;
1001 }
1002
1003 // If its already been defined, return it now.
1004 if (BB) {
1005 ID.destroy(); // Free strdup'd memory.
1006 return BB;
1007 }
1008
1009 // Otherwise, this block has not been seen before, create it.
1010 std::string Name;
1011 if (ID.Type == ValID::LocalName)
1012 Name = ID.getName();
Gabor Greif89f01162008-04-06 23:07:54 +00001013 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014
1015 // Insert it in the forward refs map.
1016 CurFun.BBForwardRefs[ID] = BB;
1017
1018 return BB;
1019}
1020
1021
1022//===----------------------------------------------------------------------===//
1023// Code to handle forward references in instructions
1024//===----------------------------------------------------------------------===//
1025//
1026// This code handles the late binding needed with statements that reference
1027// values not defined yet... for example, a forward branch, or the PHI node for
1028// a loop body.
1029//
1030// This keeps a table (CurFun.LateResolveValues) of all such forward references
1031// and back patchs after we are done.
1032//
1033
1034// ResolveDefinitions - If we could not resolve some defs at parsing
1035// time (forward branches, phi functions for loops, etc...) resolve the
1036// defs now...
1037//
Eric Christopher329d2672008-09-24 04:55:49 +00001038static void
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
1040 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1041 while (!LateResolvers.empty()) {
1042 Value *V = LateResolvers.back();
1043 LateResolvers.pop_back();
1044
1045 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1046 CurModule.PlaceHolderInfo.find(V);
1047 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
1048
1049 ValID &DID = PHI->second.first;
1050
1051 Value *TheRealValue = getExistingVal(V->getType(), DID);
1052 if (TriggerError)
1053 return;
1054 if (TheRealValue) {
1055 V->replaceAllUsesWith(TheRealValue);
1056 delete V;
1057 CurModule.PlaceHolderInfo.erase(PHI);
1058 } else if (FutureLateResolvers) {
1059 // Functions have their unresolved items forwarded to the module late
1060 // resolver table
1061 InsertValue(V, *FutureLateResolvers);
1062 } else {
1063 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1064 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1065 "' of type '" + V->getType()->getDescription() + "'",
1066 PHI->second.second);
1067 return;
1068 } else {
1069 GenerateError("Reference to an invalid definition: #" +
1070 itostr(DID.Num) + " of type '" +
1071 V->getType()->getDescription() + "'",
1072 PHI->second.second);
1073 return;
1074 }
1075 }
1076 }
1077 LateResolvers.clear();
1078}
1079
1080// ResolveTypeTo - A brand new type was just declared. This means that (if
1081// name is not null) things referencing Name can be resolved. Otherwise, things
1082// refering to the number can be resolved. Do this now.
1083//
1084static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
1085 ValID D;
1086 if (Name)
1087 D = ValID::createLocalName(*Name);
Eric Christopher329d2672008-09-24 04:55:49 +00001088 else
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 D = ValID::createLocalID(CurModule.Types.size());
1090
1091 std::map<ValID, PATypeHolder>::iterator I =
1092 CurModule.LateResolveTypes.find(D);
1093 if (I != CurModule.LateResolveTypes.end()) {
1094 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
1095 CurModule.LateResolveTypes.erase(I);
1096 }
Nuno Lopes1697e8b2008-10-03 15:52:39 +00001097 D.destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098}
1099
1100// setValueName - Set the specified value to the name given. The name may be
1101// null potentially, in which case this is a noop. The string passed in is
1102// assumed to be a malloc'd string buffer, and is free'd by this function.
1103//
1104static void setValueName(Value *V, std::string *NameStr) {
1105 if (!NameStr) return;
1106 std::string Name(*NameStr); // Copy string
1107 delete NameStr; // Free old string
1108
1109 if (V->getType() == Type::VoidTy) {
1110 GenerateError("Can't assign name '" + Name+"' to value with void type");
1111 return;
1112 }
1113
1114 assert(inFunctionScope() && "Must be in function scope!");
1115 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1116 if (ST.lookup(Name)) {
1117 GenerateError("Redefinition of value '" + Name + "' of type '" +
1118 V->getType()->getDescription() + "'");
1119 return;
1120 }
1121
1122 // Set the name.
1123 V->setName(Name);
1124}
1125
1126/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1127/// this is a declaration, otherwise it is a definition.
1128static GlobalVariable *
1129ParseGlobalVariable(std::string *NameStr,
1130 GlobalValue::LinkageTypes Linkage,
1131 GlobalValue::VisibilityTypes Visibility,
1132 bool isConstantGlobal, const Type *Ty,
Christopher Lamb0a243582007-12-11 09:02:08 +00001133 Constant *Initializer, bool IsThreadLocal,
1134 unsigned AddressSpace = 0) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135 if (isa<FunctionType>(Ty)) {
1136 GenerateError("Cannot declare global vars of function type");
1137 return 0;
1138 }
Dan Gohmane5febe42008-05-31 00:58:22 +00001139 if (Ty == Type::LabelTy) {
1140 GenerateError("Cannot declare global vars of label type");
1141 return 0;
1142 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143
Christopher Lamb0a243582007-12-11 09:02:08 +00001144 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145
1146 std::string Name;
1147 if (NameStr) {
1148 Name = *NameStr; // Copy string
1149 delete NameStr; // Free old string
1150 }
1151
1152 // See if this global value was forward referenced. If so, recycle the
1153 // object.
1154 ValID ID;
1155 if (!Name.empty()) {
1156 ID = ValID::createGlobalName(Name);
1157 } else {
1158 ID = ValID::createGlobalID(CurModule.Values.size());
1159 }
1160
1161 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1162 // Move the global to the end of the list, from whereever it was
1163 // previously inserted.
1164 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1165 CurModule.CurrentModule->getGlobalList().remove(GV);
1166 CurModule.CurrentModule->getGlobalList().push_back(GV);
1167 GV->setInitializer(Initializer);
1168 GV->setLinkage(Linkage);
1169 GV->setVisibility(Visibility);
1170 GV->setConstant(isConstantGlobal);
1171 GV->setThreadLocal(IsThreadLocal);
1172 InsertValue(GV, CurModule.Values);
Nuno Lopes1697e8b2008-10-03 15:52:39 +00001173 ID.destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 return GV;
1175 }
1176
Nuno Lopes1697e8b2008-10-03 15:52:39 +00001177 ID.destroy();
1178
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 // If this global has a name
1180 if (!Name.empty()) {
1181 // if the global we're parsing has an initializer (is a definition) and
1182 // has external linkage.
1183 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1184 // If there is already a global with external linkage with this name
1185 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1186 // If we allow this GVar to get created, it will be renamed in the
1187 // symbol table because it conflicts with an existing GVar. We can't
1188 // allow redefinition of GVars whose linking indicates that their name
1189 // must stay the same. Issue the error.
1190 GenerateError("Redefinition of global variable named '" + Name +
1191 "' of type '" + Ty->getDescription() + "'");
1192 return 0;
1193 }
1194 }
1195
1196 // Otherwise there is no existing GV to use, create one now.
1197 GlobalVariable *GV =
1198 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamb0a243582007-12-11 09:02:08 +00001199 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200 GV->setVisibility(Visibility);
1201 InsertValue(GV, CurModule.Values);
1202 return GV;
1203}
1204
1205// setTypeName - Set the specified type to the name given. The name may be
1206// null potentially, in which case this is a noop. The string passed in is
1207// assumed to be a malloc'd string buffer, and is freed by this function.
1208//
1209// This function returns true if the type has already been defined, but is
1210// allowed to be redefined in the specified context. If the name is a new name
1211// for the type plane, it is inserted and false is returned.
1212static bool setTypeName(const Type *T, std::string *NameStr) {
1213 assert(!inFunctionScope() && "Can't give types function-local names!");
1214 if (NameStr == 0) return false;
Eric Christopher329d2672008-09-24 04:55:49 +00001215
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 std::string Name(*NameStr); // Copy string
1217 delete NameStr; // Free old string
1218
1219 // We don't allow assigning names to void type
1220 if (T == Type::VoidTy) {
1221 GenerateError("Can't assign name '" + Name + "' to the void type");
1222 return false;
1223 }
1224
1225 // Set the type name, checking for conflicts as we do so.
1226 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1227
1228 if (AlreadyExists) { // Inserting a name that is already defined???
1229 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1230 assert(Existing && "Conflict but no matching type?!");
1231
1232 // There is only one case where this is allowed: when we are refining an
1233 // opaque type. In this case, Existing will be an opaque type.
1234 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1235 // We ARE replacing an opaque type!
1236 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1237 return true;
1238 }
1239
1240 // Otherwise, this is an attempt to redefine a type. That's okay if
1241 // the redefinition is identical to the original. This will be so if
1242 // Existing and T point to the same Type object. In this one case we
1243 // allow the equivalent redefinition.
1244 if (Existing == T) return true; // Yes, it's equal.
1245
1246 // Any other kind of (non-equivalent) redefinition is an error.
1247 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1248 T->getDescription() + "'");
1249 }
1250
1251 return false;
1252}
1253
1254//===----------------------------------------------------------------------===//
1255// Code for handling upreferences in type names...
1256//
1257
1258// TypeContains - Returns true if Ty directly contains E in it.
1259//
1260static bool TypeContains(const Type *Ty, const Type *E) {
1261 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1262 E) != Ty->subtype_end();
1263}
1264
1265namespace {
1266 struct UpRefRecord {
1267 // NestingLevel - The number of nesting levels that need to be popped before
1268 // this type is resolved.
1269 unsigned NestingLevel;
1270
1271 // LastContainedTy - This is the type at the current binding level for the
1272 // type. Every time we reduce the nesting level, this gets updated.
1273 const Type *LastContainedTy;
1274
1275 // UpRefTy - This is the actual opaque type that the upreference is
1276 // represented with.
1277 OpaqueType *UpRefTy;
1278
1279 UpRefRecord(unsigned NL, OpaqueType *URTy)
1280 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1281 };
1282}
1283
1284// UpRefs - A list of the outstanding upreferences that need to be resolved.
1285static std::vector<UpRefRecord> UpRefs;
1286
1287/// HandleUpRefs - Every time we finish a new layer of types, this function is
1288/// called. It loops through the UpRefs vector, which is a list of the
1289/// currently active types. For each type, if the up reference is contained in
1290/// the newly completed type, we decrement the level count. When the level
1291/// count reaches zero, the upreferenced type is the type that is passed in:
1292/// thus we can complete the cycle.
1293///
1294static PATypeHolder HandleUpRefs(const Type *ty) {
1295 // If Ty isn't abstract, or if there are no up-references in it, then there is
1296 // nothing to resolve here.
1297 if (!ty->isAbstract() || UpRefs.empty()) return ty;
Eric Christopher329d2672008-09-24 04:55:49 +00001298
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 PATypeHolder Ty(ty);
1300 UR_OUT("Type '" << Ty->getDescription() <<
1301 "' newly formed. Resolving upreferences.\n" <<
1302 UpRefs.size() << " upreferences active!\n");
1303
1304 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1305 // to zero), we resolve them all together before we resolve them to Ty. At
1306 // the end of the loop, if there is anything to resolve to Ty, it will be in
1307 // this variable.
1308 OpaqueType *TypeToResolve = 0;
1309
1310 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1311 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1312 << UpRefs[i].second->getDescription() << ") = "
1313 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1314 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1315 // Decrement level of upreference
1316 unsigned Level = --UpRefs[i].NestingLevel;
1317 UpRefs[i].LastContainedTy = Ty;
1318 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1319 if (Level == 0) { // Upreference should be resolved!
1320 if (!TypeToResolve) {
1321 TypeToResolve = UpRefs[i].UpRefTy;
1322 } else {
1323 UR_OUT(" * Resolving upreference for "
1324 << UpRefs[i].second->getDescription() << "\n";
1325 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1326 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1327 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1328 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1329 }
1330 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1331 --i; // Do not skip the next element...
1332 }
1333 }
1334 }
1335
1336 if (TypeToResolve) {
1337 UR_OUT(" * Resolving upreference for "
1338 << UpRefs[i].second->getDescription() << "\n";
1339 std::string OldName = TypeToResolve->getDescription());
1340 TypeToResolve->refineAbstractTypeTo(Ty);
1341 }
1342
1343 return Ty;
1344}
1345
1346//===----------------------------------------------------------------------===//
1347// RunVMAsmParser - Define an interface to this parser
1348//===----------------------------------------------------------------------===//
1349//
1350static Module* RunParser(Module * M);
1351
Duncan Sandsf5588dc2007-11-27 13:23:08 +00001352Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1353 InitLLLexer(MB);
1354 Module *M = RunParser(new Module(LLLgetFilename()));
1355 FreeLexer();
1356 return M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001357}
1358
1359
Dan Gohman54392c12008-04-19 00:24:39 +00001360
1361/* Enabling traces. */
1362#ifndef YYDEBUG
1363# define YYDEBUG 0
1364#endif
1365
1366/* Enabling verbose error messages. */
1367#ifdef YYERROR_VERBOSE
1368# undef YYERROR_VERBOSE
1369# define YYERROR_VERBOSE 1
1370#else
1371# define YYERROR_VERBOSE 0
1372#endif
1373
1374/* Enabling the token table. */
1375#ifndef YYTOKEN_TABLE
1376# define YYTOKEN_TABLE 0
1377#endif
1378
1379#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1380typedef union YYSTYPE
Chris Lattner8f5544c2008-10-15 06:03:48 +00001381#line 977 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00001382{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383 llvm::Module *ModuleVal;
1384 llvm::Function *FunctionVal;
1385 llvm::BasicBlock *BasicBlockVal;
1386 llvm::TerminatorInst *TermInstVal;
1387 llvm::Instruction *InstVal;
1388 llvm::Constant *ConstVal;
1389
1390 const llvm::Type *PrimType;
1391 std::list<llvm::PATypeHolder> *TypeList;
1392 llvm::PATypeHolder *TypeVal;
1393 llvm::Value *ValueVal;
1394 std::vector<llvm::Value*> *ValueList;
Dan Gohmane5febe42008-05-31 00:58:22 +00001395 std::vector<unsigned> *ConstantList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001396 llvm::ArgListType *ArgList;
1397 llvm::TypeWithAttrs TypeWithAttrs;
1398 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johannesencfb19e62007-11-05 21:20:28 +00001399 llvm::ParamList *ParamList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400
1401 // Represent the RHS of PHI node
1402 std::list<std::pair<llvm::Value*,
1403 llvm::BasicBlock*> > *PHIList;
1404 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1405 std::vector<llvm::Constant*> *ConstVector;
1406
1407 llvm::GlobalValue::LinkageTypes Linkage;
1408 llvm::GlobalValue::VisibilityTypes Visibility;
Devang Pateld222f862008-09-25 21:00:45 +00001409 llvm::Attributes Attributes;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410 llvm::APInt *APIntVal;
1411 int64_t SInt64Val;
1412 uint64_t UInt64Val;
1413 int SIntVal;
1414 unsigned UIntVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00001415 llvm::APFloat *FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001416 bool BoolVal;
1417
1418 std::string *StrVal; // This memory must be deleted
1419 llvm::ValID ValIDVal;
1420
1421 llvm::Instruction::BinaryOps BinaryOpVal;
1422 llvm::Instruction::TermOps TermOpVal;
1423 llvm::Instruction::MemoryOps MemOpVal;
1424 llvm::Instruction::CastOps CastOpVal;
1425 llvm::Instruction::OtherOps OtherOpVal;
1426 llvm::ICmpInst::Predicate IPredicate;
1427 llvm::FCmpInst::Predicate FPredicate;
Dan Gohman54392c12008-04-19 00:24:39 +00001428}
Chris Lattner5a0f2fe2008-10-08 06:44:45 +00001429/* Line 193 of yacc.c. */
Dale Johannesen5ba85fd2008-10-09 23:01:34 +00001430#line 1431 "llvmAsmParser.tab.c"
Dan Gohman54392c12008-04-19 00:24:39 +00001431 YYSTYPE;
1432# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1433# define YYSTYPE_IS_DECLARED 1
1434# define YYSTYPE_IS_TRIVIAL 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001435#endif
1436
1437
1438
Dan Gohman54392c12008-04-19 00:24:39 +00001439/* Copy the second part of user declarations. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001441
Dan Gohman54392c12008-04-19 00:24:39 +00001442/* Line 216 of yacc.c. */
Dale Johannesen5ba85fd2008-10-09 23:01:34 +00001443#line 1444 "llvmAsmParser.tab.c"
Reid Spenceraa8ae282007-07-31 03:50:36 +00001444
Dan Gohman54392c12008-04-19 00:24:39 +00001445#ifdef short
1446# undef short
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447#endif
1448
Dan Gohman54392c12008-04-19 00:24:39 +00001449#ifdef YYTYPE_UINT8
1450typedef YYTYPE_UINT8 yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451#else
Dan Gohman54392c12008-04-19 00:24:39 +00001452typedef unsigned char yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453#endif
1454
Dan Gohman54392c12008-04-19 00:24:39 +00001455#ifdef YYTYPE_INT8
1456typedef YYTYPE_INT8 yytype_int8;
1457#elif (defined __STDC__ || defined __C99__FUNC__ \
1458 || defined __cplusplus || defined _MSC_VER)
1459typedef signed char yytype_int8;
1460#else
1461typedef short int yytype_int8;
1462#endif
1463
1464#ifdef YYTYPE_UINT16
1465typedef YYTYPE_UINT16 yytype_uint16;
1466#else
1467typedef unsigned short int yytype_uint16;
1468#endif
1469
1470#ifdef YYTYPE_INT16
1471typedef YYTYPE_INT16 yytype_int16;
1472#else
1473typedef short int yytype_int16;
1474#endif
1475
1476#ifndef YYSIZE_T
1477# ifdef __SIZE_TYPE__
1478# define YYSIZE_T __SIZE_TYPE__
1479# elif defined size_t
1480# define YYSIZE_T size_t
1481# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1482 || defined __cplusplus || defined _MSC_VER)
1483# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1484# define YYSIZE_T size_t
1485# else
1486# define YYSIZE_T unsigned int
1487# endif
1488#endif
1489
1490#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1491
1492#ifndef YY_
Chris Lattner5a0f2fe2008-10-08 06:44:45 +00001493# if defined YYENABLE_NLS && YYENABLE_NLS
Dan Gohman54392c12008-04-19 00:24:39 +00001494# if ENABLE_NLS
1495# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1496# define YY_(msgid) dgettext ("bison-runtime", msgid)
1497# endif
1498# endif
1499# ifndef YY_
1500# define YY_(msgid) msgid
1501# endif
1502#endif
1503
1504/* Suppress unused-variable warnings by "using" E. */
1505#if ! defined lint || defined __GNUC__
1506# define YYUSE(e) ((void) (e))
1507#else
1508# define YYUSE(e) /* empty */
1509#endif
1510
1511/* Identity function, used to suppress warnings about constant conditions. */
1512#ifndef lint
1513# define YYID(n) (n)
1514#else
1515#if (defined __STDC__ || defined __C99__FUNC__ \
1516 || defined __cplusplus || defined _MSC_VER)
1517static int
1518YYID (int i)
1519#else
1520static int
1521YYID (i)
1522 int i;
1523#endif
1524{
1525 return i;
1526}
1527#endif
1528
1529#if ! defined yyoverflow || YYERROR_VERBOSE
1530
1531/* The parser invokes alloca or malloc; define the necessary symbols. */
1532
1533# ifdef YYSTACK_USE_ALLOCA
1534# if YYSTACK_USE_ALLOCA
1535# ifdef __GNUC__
1536# define YYSTACK_ALLOC __builtin_alloca
1537# elif defined __BUILTIN_VA_ARG_INCR
1538# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1539# elif defined _AIX
1540# define YYSTACK_ALLOC __alloca
1541# elif defined _MSC_VER
1542# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1543# define alloca _alloca
1544# else
1545# define YYSTACK_ALLOC alloca
1546# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1547 || defined __cplusplus || defined _MSC_VER)
1548# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1549# ifndef _STDLIB_H
1550# define _STDLIB_H 1
1551# endif
1552# endif
1553# endif
1554# endif
1555# endif
1556
1557# ifdef YYSTACK_ALLOC
1558 /* Pacify GCC's `empty if-body' warning. */
1559# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1560# ifndef YYSTACK_ALLOC_MAXIMUM
1561 /* The OS might guarantee only one guard page at the bottom of the stack,
1562 and a page size can be as small as 4096 bytes. So we cannot safely
1563 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1564 to allow for a few compiler-allocated temporary stack slots. */
1565# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1566# endif
1567# else
1568# define YYSTACK_ALLOC YYMALLOC
1569# define YYSTACK_FREE YYFREE
1570# ifndef YYSTACK_ALLOC_MAXIMUM
1571# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1572# endif
1573# if (defined __cplusplus && ! defined _STDLIB_H \
1574 && ! ((defined YYMALLOC || defined malloc) \
1575 && (defined YYFREE || defined free)))
1576# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1577# ifndef _STDLIB_H
1578# define _STDLIB_H 1
1579# endif
1580# endif
1581# ifndef YYMALLOC
1582# define YYMALLOC malloc
1583# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1584 || defined __cplusplus || defined _MSC_VER)
1585void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1586# endif
1587# endif
1588# ifndef YYFREE
1589# define YYFREE free
1590# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1591 || defined __cplusplus || defined _MSC_VER)
1592void free (void *); /* INFRINGES ON USER NAME SPACE */
1593# endif
1594# endif
1595# endif
1596#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1597
1598
1599#if (! defined yyoverflow \
1600 && (! defined __cplusplus \
1601 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1602
1603/* A type that is properly aligned for any stack member. */
1604union yyalloc
1605{
1606 yytype_int16 yyss;
1607 YYSTYPE yyvs;
1608 };
1609
1610/* The size of the maximum gap between one aligned stack and the next. */
1611# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1612
1613/* The size of an array large to enough to hold all stacks, each with
1614 N elements. */
1615# define YYSTACK_BYTES(N) \
1616 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1617 + YYSTACK_GAP_MAXIMUM)
1618
1619/* Copy COUNT objects from FROM to TO. The source and destination do
1620 not overlap. */
1621# ifndef YYCOPY
1622# if defined __GNUC__ && 1 < __GNUC__
1623# define YYCOPY(To, From, Count) \
1624 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1625# else
1626# define YYCOPY(To, From, Count) \
1627 do \
1628 { \
1629 YYSIZE_T yyi; \
1630 for (yyi = 0; yyi < (Count); yyi++) \
1631 (To)[yyi] = (From)[yyi]; \
1632 } \
1633 while (YYID (0))
1634# endif
1635# endif
1636
1637/* Relocate STACK from its old location to the new one. The
1638 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1639 elements in the stack, and YYPTR gives the new location of the
1640 stack. Advance YYPTR to a properly aligned location for the next
1641 stack. */
1642# define YYSTACK_RELOCATE(Stack) \
1643 do \
1644 { \
1645 YYSIZE_T yynewbytes; \
1646 YYCOPY (&yyptr->Stack, Stack, yysize); \
1647 Stack = &yyptr->Stack; \
1648 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1649 yyptr += yynewbytes / sizeof (*yyptr); \
1650 } \
1651 while (YYID (0))
1652
1653#endif
1654
1655/* YYFINAL -- State number of the termination state. */
Dale Johannesen280e7bc2008-05-14 20:13:36 +00001656#define YYFINAL 44
Dan Gohman54392c12008-04-19 00:24:39 +00001657/* YYLAST -- Last index in YYTABLE. */
Chris Lattnerc5320232008-10-15 06:16:57 +00001658#define YYLAST 2377
Dan Gohman54392c12008-04-19 00:24:39 +00001659
1660/* YYNTOKENS -- Number of terminals. */
Devang Patelcd842482008-09-29 20:49:50 +00001661#define YYNTOKENS 173
Dan Gohman54392c12008-04-19 00:24:39 +00001662/* YYNNTS -- Number of nonterminals. */
Chris Lattnerc5320232008-10-15 06:16:57 +00001663#define YYNNTS 87
Dan Gohman54392c12008-04-19 00:24:39 +00001664/* YYNRULES -- Number of rules. */
Chris Lattnerc5320232008-10-15 06:16:57 +00001665#define YYNRULES 348
Dan Gohman54392c12008-04-19 00:24:39 +00001666/* YYNRULES -- Number of states. */
Chris Lattnerc5320232008-10-15 06:16:57 +00001667#define YYNSTATES 708
Dan Gohman54392c12008-04-19 00:24:39 +00001668
1669/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1670#define YYUNDEFTOK 2
Devang Patelcd842482008-09-29 20:49:50 +00001671#define YYMAXUTOK 413
Dan Gohman54392c12008-04-19 00:24:39 +00001672
1673#define YYTRANSLATE(YYX) \
1674 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1675
1676/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1677static const yytype_uint8 yytranslate[] =
1678{
1679 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1680 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1681 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1682 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patelcd842482008-09-29 20:49:50 +00001683 159, 160, 163, 2, 162, 2, 2, 2, 2, 2,
Dan Gohman54392c12008-04-19 00:24:39 +00001684 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patelcd842482008-09-29 20:49:50 +00001685 168, 161, 169, 2, 2, 2, 2, 2, 2, 2,
Dan Gohman54392c12008-04-19 00:24:39 +00001686 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patelcd842482008-09-29 20:49:50 +00001688 2, 165, 164, 167, 2, 2, 2, 2, 2, 172,
Dan Gohman54392c12008-04-19 00:24:39 +00001689 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1690 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patelcd842482008-09-29 20:49:50 +00001691 166, 2, 2, 170, 2, 171, 2, 2, 2, 2,
Dan Gohman54392c12008-04-19 00:24:39 +00001692 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1693 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1694 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1695 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1696 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1697 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1698 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1699 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1700 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1701 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1702 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1703 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1704 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1705 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1706 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1707 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1708 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1709 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1710 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1711 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1712 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1713 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1714 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1715 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1716 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1717 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1718 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Dan Gohmane6b1ee62008-05-23 01:55:30 +00001719 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
Devang Patelcd842482008-09-29 20:49:50 +00001720 155, 156, 157, 158
Dan Gohman54392c12008-04-19 00:24:39 +00001721};
1722
1723#if YYDEBUG
1724/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1725 YYRHS. */
1726static const yytype_uint16 yyprhs[] =
1727{
1728 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1729 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1730 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1731 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1732 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1733 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
Chris Lattnerc5320232008-10-15 06:16:57 +00001734 118, 123, 124, 127, 128, 131, 133, 135, 137, 138,
1735 141, 143, 145, 147, 149, 151, 153, 155, 157, 159,
1736 160, 162, 164, 166, 167, 169, 171, 172, 174, 176,
1737 178, 180, 181, 183, 185, 186, 188, 190, 192, 194,
1738 196, 199, 201, 203, 205, 207, 209, 211, 213, 215,
1739 217, 220, 221, 224, 226, 228, 230, 231, 234, 236,
1740 238, 240, 242, 244, 246, 248, 250, 252, 254, 255,
1741 258, 259, 262, 263, 266, 267, 271, 274, 275, 277,
1742 278, 282, 284, 287, 289, 291, 293, 295, 297, 299,
1743 301, 303, 305, 309, 311, 314, 320, 326, 332, 338,
1744 342, 345, 351, 356, 359, 361, 363, 365, 369, 371,
1745 375, 377, 378, 380, 384, 389, 393, 397, 402, 407,
1746 411, 418, 424, 427, 430, 433, 436, 439, 442, 445,
1747 448, 451, 454, 457, 460, 467, 473, 482, 489, 496,
1748 504, 512, 520, 528, 535, 544, 553, 559, 567, 571,
1749 573, 575, 577, 579, 580, 583, 590, 592, 593, 595,
1750 598, 599, 603, 604, 608, 612, 616, 620, 621, 630,
1751 631, 641, 642, 652, 658, 661, 665, 667, 671, 675,
1752 679, 683, 685, 686, 692, 696, 698, 702, 704, 705,
1753 717, 719, 721, 726, 728, 730, 733, 737, 738, 740,
1754 742, 744, 746, 748, 750, 752, 754, 756, 758, 760,
1755 764, 768, 771, 774, 778, 781, 787, 792, 794, 800,
1756 802, 804, 806, 808, 810, 812, 815, 817, 821, 824,
1757 827, 831, 835, 838, 839, 841, 844, 847, 851, 861,
1758 871, 880, 896, 898, 900, 907, 913, 916, 919, 926,
1759 934, 939, 944, 951, 958, 959, 960, 964, 967, 971,
1760 974, 976, 982, 988, 995, 1002, 1009, 1016, 1021, 1028,
1761 1033, 1038, 1045, 1052, 1055, 1065, 1067, 1069, 1070, 1074,
1762 1081, 1085, 1092, 1095, 1101, 1109, 1115, 1120, 1125
Dan Gohman54392c12008-04-19 00:24:39 +00001763};
1764
1765/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1766static const yytype_int16 yyrhs[] =
1767{
Chris Lattnerc5320232008-10-15 06:16:57 +00001768 220, 0, -1, 75, -1, 76, -1, 77, -1, 78,
Dale Johannesenf4581482008-09-26 19:32:34 +00001769 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
1770 -1, 87, -1, 88, -1, 89, -1, 84, -1, 85,
1771 -1, 86, -1, 120, -1, 121, -1, 122, -1, 123,
1772 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
1773 -1, 129, -1, 130, -1, 131, -1, 94, -1, 95,
1774 -1, 96, -1, 97, -1, 98, -1, 99, -1, 100,
1775 -1, 101, -1, 102, -1, 103, -1, 104, -1, 105,
1776 -1, 106, -1, 107, -1, 108, -1, 109, -1, 110,
1777 -1, 111, -1, 112, -1, 113, -1, 100, -1, 101,
Chris Lattnerc5320232008-10-15 06:16:57 +00001778 -1, 102, -1, 103, -1, 26, -1, 27, -1, 19,
1779 -1, 22, -1, 24, -1, 179, -1, -1, 55, 159,
1780 4, 160, -1, -1, 179, 161, -1, -1, 7, 161,
1781 -1, 20, -1, 23, -1, 186, -1, -1, 184, 161,
Chris Lattner8f5544c2008-10-15 06:03:48 +00001782 -1, 42, -1, 44, -1, 43, -1, 45, -1, 47,
1783 -1, 49, -1, 46, -1, 48, -1, 51, -1, -1,
1784 156, -1, 157, -1, 158, -1, -1, 46, -1, 48,
1785 -1, -1, 42, -1, 43, -1, 44, -1, 47, -1,
1786 -1, 44, -1, 42, -1, -1, 63, -1, 64, -1,
1787 65, -1, 66, -1, 67, -1, 62, 4, -1, 142,
1788 -1, 121, -1, 141, -1, 122, -1, 144, -1, 145,
1789 -1, 147, -1, 148, -1, 149, -1, 54, 4, -1,
Chris Lattnerc5320232008-10-15 06:16:57 +00001790 -1, 195, 194, -1, 144, -1, 142, -1, 141, -1,
1791 -1, 197, 196, -1, 143, -1, 146, -1, 144, -1,
Chris Lattner8f5544c2008-10-15 06:03:48 +00001792 142, -1, 141, -1, 150, -1, 151, -1, 154, -1,
Chris Lattnerc5320232008-10-15 06:16:57 +00001793 155, -1, 153, -1, -1, 199, 198, -1, -1, 152,
Chris Lattner8f5544c2008-10-15 06:03:48 +00001794 22, -1, -1, 54, 4, -1, -1, 162, 54, 4,
Chris Lattnerc5320232008-10-15 06:16:57 +00001795 -1, 34, 22, -1, -1, 203, -1, -1, 162, 206,
1796 205, -1, 203, -1, 54, 4, -1, 11, -1, 12,
Chris Lattner8f5544c2008-10-15 06:03:48 +00001797 -1, 13, -1, 16, -1, 15, -1, 14, -1, 17,
Chris Lattnerc5320232008-10-15 06:16:57 +00001798 -1, 50, -1, 207, -1, 208, 181, 163, -1, 242,
1799 -1, 164, 4, -1, 208, 159, 212, 160, 199, -1,
1800 10, 159, 212, 160, 199, -1, 165, 4, 166, 208,
1801 167, -1, 168, 4, 166, 208, 169, -1, 170, 213,
1802 171, -1, 170, 171, -1, 168, 170, 213, 171, 169,
1803 -1, 168, 170, 171, 169, -1, 208, 195, -1, 208,
1804 -1, 10, -1, 209, -1, 211, 162, 209, -1, 211,
1805 -1, 211, 162, 39, -1, 39, -1, -1, 208, -1,
1806 213, 162, 208, -1, 208, 165, 216, 167, -1, 208,
1807 165, 167, -1, 208, 172, 22, -1, 208, 168, 216,
1808 169, -1, 208, 170, 216, 171, -1, 208, 170, 171,
1809 -1, 208, 168, 170, 216, 171, 169, -1, 208, 168,
1810 170, 171, 169, -1, 208, 40, -1, 208, 41, -1,
1811 208, 242, -1, 208, 215, -1, 208, 25, -1, 208,
1812 3, -1, 208, 5, -1, 208, 4, -1, 208, 6,
1813 -1, 208, 26, -1, 208, 27, -1, 208, 9, -1,
1814 176, 159, 214, 38, 208, 160, -1, 119, 159, 214,
1815 254, 160, -1, 133, 159, 214, 162, 214, 162, 214,
1816 160, -1, 174, 159, 214, 162, 214, 160, -1, 175,
1817 159, 214, 162, 214, 160, -1, 90, 177, 159, 214,
1818 162, 214, 160, -1, 91, 178, 159, 214, 162, 214,
1819 160, -1, 92, 177, 159, 214, 162, 214, 160, -1,
1820 93, 178, 159, 214, 162, 214, 160, -1, 135, 159,
1821 214, 162, 214, 160, -1, 136, 159, 214, 162, 214,
1822 162, 214, 160, -1, 137, 159, 214, 162, 214, 162,
1823 214, 160, -1, 139, 159, 214, 255, 160, -1, 140,
1824 159, 214, 162, 214, 255, 160, -1, 216, 162, 214,
1825 -1, 214, -1, 32, -1, 33, -1, 37, -1, -1,
1826 210, 242, -1, 125, 159, 219, 38, 208, 160, -1,
1827 221, -1, -1, 222, -1, 221, 222, -1, -1, 31,
1828 223, 238, -1, -1, 30, 224, 239, -1, 60, 59,
1829 228, -1, 182, 18, 208, -1, 182, 18, 10, -1,
1830 -1, 185, 189, 218, 217, 214, 181, 225, 205, -1,
1831 -1, 185, 187, 189, 218, 217, 214, 181, 226, 205,
1832 -1, -1, 185, 188, 189, 218, 217, 208, 181, 227,
1833 205, -1, 185, 189, 35, 192, 219, -1, 52, 229,
1834 -1, 56, 161, 230, -1, 22, -1, 53, 161, 22,
1835 -1, 68, 161, 22, -1, 165, 231, 167, -1, 231,
1836 162, 22, -1, 22, -1, -1, 232, 162, 208, 195,
1837 180, -1, 208, 195, 180, -1, 232, -1, 232, 162,
1838 39, -1, 39, -1, -1, 193, 197, 210, 184, 159,
1839 233, 160, 199, 204, 201, 200, -1, 28, -1, 170,
1840 -1, 191, 189, 234, 235, -1, 29, -1, 171, -1,
1841 246, 237, -1, 190, 189, 234, -1, -1, 61, -1,
Chris Lattner8f5544c2008-10-15 06:03:48 +00001842 3, -1, 4, -1, 5, -1, 6, -1, 9, -1,
1843 26, -1, 27, -1, 40, -1, 41, -1, 25, -1,
Chris Lattnerc5320232008-10-15 06:16:57 +00001844 168, 216, 169, -1, 165, 216, 167, -1, 165, 167,
1845 -1, 172, 22, -1, 170, 216, 171, -1, 170, 171,
1846 -1, 168, 170, 216, 171, 169, -1, 168, 170, 171,
1847 169, -1, 215, -1, 59, 240, 22, 162, 22, -1,
1848 7, -1, 8, -1, 179, -1, 184, -1, 242, -1,
1849 241, -1, 208, 243, -1, 244, -1, 245, 162, 244,
1850 -1, 246, 247, -1, 236, 247, -1, 248, 182, 249,
1851 -1, 248, 183, 249, -1, 248, 251, -1, -1, 21,
1852 -1, 69, 245, -1, 69, 10, -1, 70, 17, 243,
1853 -1, 70, 11, 243, 162, 17, 243, 162, 17, 243,
1854 -1, 71, 11, 243, 162, 17, 243, 165, 250, 167,
1855 -1, 71, 11, 243, 162, 17, 243, 165, 167, -1,
1856 72, 193, 197, 210, 243, 159, 253, 160, 199, 38,
1857 17, 243, 73, 17, 243, -1, 73, -1, 74, -1,
1858 250, 11, 241, 162, 17, 243, -1, 11, 241, 162,
1859 17, 243, -1, 182, 257, -1, 183, 257, -1, 208,
1860 165, 243, 162, 243, 167, -1, 252, 162, 165, 243,
1861 162, 243, 167, -1, 208, 195, 243, 195, -1, 17,
1862 195, 243, 195, -1, 253, 162, 208, 195, 243, 195,
1863 -1, 253, 162, 17, 195, 243, 195, -1, -1, -1,
1864 254, 162, 244, -1, 162, 4, -1, 255, 162, 4,
1865 -1, 58, 57, -1, 57, -1, 174, 208, 243, 162,
1866 243, -1, 175, 208, 243, 162, 243, -1, 90, 177,
1867 208, 243, 162, 243, -1, 91, 178, 208, 243, 162,
1868 243, -1, 92, 177, 208, 243, 162, 243, -1, 93,
1869 178, 208, 243, 162, 243, -1, 176, 244, 38, 208,
1870 -1, 133, 244, 162, 244, 162, 244, -1, 134, 244,
1871 162, 208, -1, 135, 244, 162, 244, -1, 136, 244,
1872 162, 244, 162, 244, -1, 137, 244, 162, 244, 162,
1873 244, -1, 132, 252, -1, 256, 193, 197, 210, 243,
1874 159, 253, 160, 199, -1, 259, -1, 36, -1, -1,
1875 114, 208, 202, -1, 114, 208, 162, 11, 243, 202,
1876 -1, 115, 208, 202, -1, 115, 208, 162, 11, 243,
1877 202, -1, 116, 244, -1, 258, 117, 208, 243, 202,
1878 -1, 258, 118, 244, 162, 208, 243, 202, -1, 138,
1879 208, 243, 162, 4, -1, 119, 208, 243, 254, -1,
1880 139, 208, 243, 255, -1, 140, 208, 243, 162, 208,
1881 243, 255, -1
Dan Gohman54392c12008-04-19 00:24:39 +00001882};
1883
1884/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1885static const yytype_uint16 yyrline[] =
1886{
Dale Johannesen5ba85fd2008-10-09 23:01:34 +00001887 0, 1143, 1143, 1143, 1143, 1143, 1143, 1143, 1143, 1143,
1888 1143, 1144, 1144, 1144, 1144, 1144, 1144, 1145, 1145, 1145,
1889 1145, 1145, 1145, 1146, 1146, 1146, 1146, 1146, 1146, 1149,
1890 1149, 1150, 1150, 1151, 1151, 1152, 1152, 1153, 1153, 1157,
1891 1157, 1158, 1158, 1159, 1159, 1160, 1160, 1161, 1161, 1162,
Chris Lattnerc5320232008-10-15 06:16:57 +00001892 1162, 1163, 1163, 1164, 1165, 1168, 1168, 1168, 1169, 1169,
1893 1171, 1172, 1176, 1180, 1185, 1191, 1191, 1193, 1194, 1199,
1894 1205, 1206, 1207, 1208, 1209, 1210, 1214, 1215, 1216, 1220,
1895 1221, 1222, 1223, 1227, 1228, 1229, 1233, 1234, 1235, 1236,
1896 1237, 1241, 1242, 1243, 1246, 1247, 1248, 1249, 1250, 1251,
1897 1252, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267,
1898 1268, 1272, 1273, 1278, 1279, 1280, 1283, 1284, 1290, 1291,
1899 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1302, 1303,
1900 1309, 1310, 1317, 1318, 1324, 1325, 1334, 1342, 1343, 1348,
1901 1349, 1350, 1355, 1368, 1368, 1368, 1368, 1368, 1368, 1368,
1902 1371, 1375, 1379, 1386, 1391, 1399, 1434, 1465, 1470, 1480,
1903 1490, 1494, 1504, 1511, 1520, 1527, 1532, 1537, 1544, 1545,
1904 1552, 1559, 1567, 1573, 1585, 1613, 1629, 1656, 1684, 1710,
1905 1730, 1756, 1776, 1788, 1795, 1861, 1871, 1881, 1892, 1905,
1906 1916, 1930, 1937, 1944, 1962, 1974, 1995, 2003, 2009, 2020,
1907 2025, 2030, 2035, 2040, 2046, 2052, 2058, 2066, 2077, 2081,
1908 2089, 2089, 2092, 2092, 2095, 2107, 2128, 2133, 2141, 2142,
1909 2146, 2146, 2150, 2150, 2153, 2156, 2180, 2192, 2191, 2203,
1910 2202, 2212, 2211, 2222, 2262, 2265, 2271, 2281, 2285, 2290,
1911 2292, 2297, 2302, 2311, 2321, 2332, 2336, 2345, 2354, 2359,
1912 2508, 2508, 2510, 2519, 2519, 2521, 2526, 2538, 2542, 2547,
1913 2551, 2555, 2560, 2565, 2569, 2573, 2577, 2581, 2585, 2589,
1914 2611, 2633, 2639, 2652, 2664, 2669, 2681, 2687, 2691, 2701,
1915 2705, 2709, 2714, 2721, 2721, 2727, 2736, 2741, 2746, 2750,
1916 2759, 2768, 2781, 2790, 2794, 2802, 2822, 2826, 2831, 2842,
1917 2861, 2870, 2974, 2978, 2985, 2996, 3009, 3018, 3031, 3042,
1918 3052, 3063, 3071, 3081, 3088, 3091, 3092, 3100, 3106, 3115,
1919 3119, 3124, 3140, 3157, 3169, 3181, 3195, 3209, 3221, 3242,
1920 3249, 3255, 3261, 3267, 3282, 3392, 3397, 3401, 3408, 3415,
1921 3425, 3432, 3442, 3450, 3464, 3481, 3495, 3510, 3525
Dan Gohman54392c12008-04-19 00:24:39 +00001922};
1923#endif
1924
1925#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1926/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1927 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1928static const char *const yytname[] =
1929{
1930 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1931 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1932 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1933 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1934 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1935 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1936 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1937 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
Dale Johannesen280e7bc2008-05-14 20:13:36 +00001938 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "COMMON", "OPAQUE",
Dan Gohman54392c12008-04-19 00:24:39 +00001939 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1940 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1941 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Dale Johannesenf4581482008-09-26 19:32:34 +00001942 "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
1943 "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
1944 "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "VICMP",
1945 "VFCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1946 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1947 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1948 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1949 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1950 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1951 "GETRESULT", "EXTRACTVALUE", "INSERTVALUE", "SIGNEXT", "ZEROEXT",
1952 "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST",
Devang Patelcd842482008-09-29 20:49:50 +00001953 "READNONE", "READONLY", "GC", "OPTSIZE", "NOINLINE", "ALWAYSINLINE",
1954 "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'",
1955 "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'",
1956 "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates",
Chris Lattnerc5320232008-10-15 06:16:57 +00001957 "FPredicates", "LocalName", "OptLocalName", "OptAddrSpace",
Chris Lattner8f5544c2008-10-15 06:03:48 +00001958 "OptLocalAssign", "LocalNumber", "GlobalName", "OptGlobalAssign",
1959 "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1960 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1961 "AliasLinkage", "OptCallingConv", "Attribute", "OptAttributes",
1962 "RetAttr", "OptRetAttrs", "FuncAttr", "OptFuncAttrs", "OptGC",
1963 "OptAlign", "OptCAlign", "SectionString", "OptSection",
Devang Patelcd842482008-09-29 20:49:50 +00001964 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1965 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1966 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "ThreadLocal",
1967 "AliaseeRef", "Module", "DefinitionList", "Definition", "@1", "@2", "@3",
1968 "@4", "@5", "AsmBlock", "TargetDefinition", "LibrariesDefinition",
1969 "LibList", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1970 "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect",
1971 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1972 "ReturnedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1973 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ParamList",
1974 "IndexList", "ConstantIndexList", "OptTailCall", "InstVal",
Chris Lattner906773a2008-08-29 17:20:18 +00001975 "OptVolatile", "MemoryInst", 0
Dan Gohman54392c12008-04-19 00:24:39 +00001976};
1977#endif
1978
1979# ifdef YYPRINT
1980/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1981 token YYLEX-NUM. */
1982static const yytype_uint16 yytoknum[] =
1983{
1984 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1985 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1986 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1987 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1988 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1989 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1990 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1991 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1992 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1993 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1994 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1995 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1996 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1997 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1998 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Devang Patelcd842482008-09-29 20:49:50 +00001999 405, 406, 407, 408, 409, 410, 411, 412, 413, 40,
2000 41, 61, 44, 42, 92, 91, 120, 93, 60, 62,
2001 123, 125, 99
Dan Gohman54392c12008-04-19 00:24:39 +00002002};
2003# endif
2004
2005/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Dale Johannesen9cdf0652008-08-13 18:41:46 +00002006static const yytype_uint16 yyr1[] =
Dan Gohman54392c12008-04-19 00:24:39 +00002007{
Devang Patelcd842482008-09-29 20:49:50 +00002008 0, 173, 174, 174, 174, 174, 174, 174, 174, 174,
2009 174, 175, 175, 175, 175, 175, 175, 176, 176, 176,
2010 176, 176, 176, 176, 176, 176, 176, 176, 176, 177,
2011 177, 177, 177, 177, 177, 177, 177, 177, 177, 178,
2012 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
Chris Lattnerc5320232008-10-15 06:16:57 +00002013 178, 178, 178, 178, 178, 179, 179, 179, 180, 180,
2014 181, 181, 182, 182, 183, 184, 184, 185, 185, 186,
2015 187, 187, 187, 187, 187, 187, 188, 188, 188, 189,
2016 189, 189, 189, 190, 190, 190, 191, 191, 191, 191,
2017 191, 192, 192, 192, 193, 193, 193, 193, 193, 193,
2018 193, 194, 194, 194, 194, 194, 194, 194, 194, 194,
2019 194, 195, 195, 196, 196, 196, 197, 197, 198, 198,
2020 198, 198, 198, 198, 198, 198, 198, 198, 199, 199,
2021 200, 200, 201, 201, 202, 202, 203, 204, 204, 205,
2022 205, 206, 206, 207, 207, 207, 207, 207, 207, 207,
2023 208, 208, 208, 208, 208, 208, 208, 208, 208, 208,
2024 208, 208, 208, 209, 210, 210, 211, 211, 212, 212,
2025 212, 212, 213, 213, 214, 214, 214, 214, 214, 214,
2026 214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
2027 214, 214, 214, 214, 215, 215, 215, 215, 215, 215,
2028 215, 215, 215, 215, 215, 215, 215, 215, 216, 216,
2029 217, 217, 218, 218, 219, 219, 220, 220, 221, 221,
2030 223, 222, 224, 222, 222, 222, 222, 225, 222, 226,
2031 222, 227, 222, 222, 222, 222, 228, 229, 229, 230,
2032 231, 231, 231, 232, 232, 233, 233, 233, 233, 234,
2033 235, 235, 236, 237, 237, 238, 239, 240, 240, 241,
2034 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2035 241, 241, 241, 241, 241, 241, 241, 241, 241, 242,
2036 242, 242, 242, 243, 243, 244, 245, 245, 246, 246,
2037 247, 247, 248, 248, 248, 249, 249, 249, 249, 249,
2038 249, 249, 249, 249, 250, 250, 251, 251, 252, 252,
2039 253, 253, 253, 253, 253, 254, 254, 255, 255, 256,
2040 256, 257, 257, 257, 257, 257, 257, 257, 257, 257,
2041 257, 257, 257, 257, 257, 257, 258, 258, 259, 259,
2042 259, 259, 259, 259, 259, 259, 259, 259, 259
Dan Gohman54392c12008-04-19 00:24:39 +00002043};
2044
2045/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2046static const yytype_uint8 yyr2[] =
2047{
2048 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2049 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2050 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2051 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2052 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Chris Lattnerc5320232008-10-15 06:16:57 +00002053 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
2054 4, 0, 2, 0, 2, 1, 1, 1, 0, 2,
2055 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
2056 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
2057 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
2058 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2059 2, 0, 2, 1, 1, 1, 0, 2, 1, 1,
2060 1, 1, 1, 1, 1, 1, 1, 1, 0, 2,
2061 0, 2, 0, 2, 0, 3, 2, 0, 1, 0,
2062 3, 1, 2, 1, 1, 1, 1, 1, 1, 1,
2063 1, 1, 3, 1, 2, 5, 5, 5, 5, 3,
2064 2, 5, 4, 2, 1, 1, 1, 3, 1, 3,
2065 1, 0, 1, 3, 4, 3, 3, 4, 4, 3,
2066 6, 5, 2, 2, 2, 2, 2, 2, 2, 2,
2067 2, 2, 2, 2, 6, 5, 8, 6, 6, 7,
2068 7, 7, 7, 6, 8, 8, 5, 7, 3, 1,
2069 1, 1, 1, 0, 2, 6, 1, 0, 1, 2,
2070 0, 3, 0, 3, 3, 3, 3, 0, 8, 0,
2071 9, 0, 9, 5, 2, 3, 1, 3, 3, 3,
2072 3, 1, 0, 5, 3, 1, 3, 1, 0, 11,
2073 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
2074 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
2075 3, 2, 2, 3, 2, 5, 4, 1, 5, 1,
2076 1, 1, 1, 1, 1, 2, 1, 3, 2, 2,
2077 3, 3, 2, 0, 1, 2, 2, 3, 9, 9,
2078 8, 15, 1, 1, 6, 5, 2, 2, 6, 7,
2079 4, 4, 6, 6, 0, 0, 3, 2, 3, 2,
2080 1, 5, 5, 6, 6, 6, 6, 4, 6, 4,
2081 4, 6, 6, 2, 9, 1, 1, 0, 3, 6,
2082 3, 6, 2, 5, 7, 5, 4, 4, 7
Dan Gohman54392c12008-04-19 00:24:39 +00002083};
2084
2085/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2086 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2087 means the default is an error. */
2088static const yytype_uint16 yydefact[] =
2089{
Chris Lattnerc5320232008-10-15 06:16:57 +00002090 68, 55, 65, 56, 66, 57, 222, 220, 0, 0,
2091 0, 0, 0, 0, 79, 67, 0, 68, 218, 83,
2092 86, 0, 0, 234, 0, 0, 62, 0, 69, 70,
2093 72, 71, 73, 76, 74, 77, 75, 78, 80, 81,
2094 82, 79, 79, 213, 1, 219, 84, 85, 79, 223,
2095 87, 88, 89, 90, 79, 293, 221, 293, 0, 0,
2096 242, 235, 236, 224, 279, 280, 226, 143, 144, 145,
2097 148, 147, 146, 149, 150, 0, 0, 0, 0, 281,
2098 282, 151, 225, 153, 213, 213, 91, 212, 0, 94,
2099 94, 294, 289, 63, 253, 254, 255, 288, 237, 238,
2100 241, 0, 171, 154, 0, 0, 0, 0, 160, 172,
2101 0, 0, 171, 0, 0, 0, 93, 92, 0, 210,
2102 211, 0, 0, 95, 96, 97, 98, 99, 116, 256,
2103 0, 0, 337, 337, 292, 0, 239, 170, 111, 166,
2104 168, 0, 0, 0, 0, 0, 0, 159, 0, 0,
2105 152, 0, 0, 165, 0, 164, 0, 233, 61, 61,
2106 100, 0, 250, 251, 252, 64, 336, 320, 0, 0,
2107 0, 0, 94, 302, 303, 2, 3, 4, 5, 6,
2108 7, 8, 9, 10, 14, 15, 16, 11, 12, 13,
2109 0, 0, 0, 0, 0, 0, 0, 0, 17, 18,
2110 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
Nate Begeman646fa482008-05-12 19:01:56 +00002111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerc5320232008-10-15 06:16:57 +00002112 0, 0, 290, 94, 306, 0, 335, 291, 307, 240,
2113 163, 0, 128, 61, 61, 162, 0, 173, 0, 128,
2114 61, 61, 0, 214, 187, 189, 188, 190, 193, 186,
2115 191, 192, 182, 183, 0, 0, 0, 0, 0, 0,
2116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2117 0, 0, 185, 184, 227, 115, 114, 113, 117, 0,
2118 319, 296, 61, 286, 295, 0, 0, 0, 116, 29,
2119 30, 31, 32, 33, 34, 35, 36, 37, 38, 0,
2120 53, 54, 49, 50, 51, 52, 39, 40, 41, 42,
2121 43, 44, 45, 46, 47, 48, 0, 0, 0, 134,
2122 134, 342, 61, 61, 333, 0, 0, 0, 0, 0,
2123 61, 61, 61, 61, 61, 0, 116, 0, 0, 0,
2124 102, 104, 103, 101, 105, 106, 107, 108, 109, 112,
2125 169, 167, 156, 157, 158, 161, 60, 155, 229, 231,
2126 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2127 0, 0, 175, 209, 0, 0, 0, 179, 0, 176,
2128 0, 0, 0, 139, 0, 259, 260, 261, 262, 263,
2129 268, 264, 265, 266, 267, 257, 0, 0, 0, 0,
2130 277, 284, 283, 285, 0, 0, 297, 0, 0, 61,
2131 61, 61, 61, 0, 338, 0, 340, 315, 0, 0,
2132 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2133 0, 0, 61, 0, 110, 122, 121, 118, 120, 119,
2134 123, 124, 127, 125, 126, 129, 139, 139, 0, 0,
2135 0, 0, 0, 315, 0, 0, 0, 0, 0, 0,
2136 0, 174, 160, 172, 0, 177, 178, 0, 0, 0,
2137 0, 228, 248, 258, 0, 271, 0, 0, 0, 274,
2138 0, 272, 287, 0, 0, 0, 0, 0, 0, 0,
2139 0, 0, 0, 346, 0, 0, 0, 329, 330, 0,
2140 0, 0, 0, 347, 0, 0, 0, 327, 0, 134,
2141 0, 230, 232, 61, 0, 0, 0, 0, 0, 0,
2142 0, 0, 0, 0, 0, 208, 181, 0, 0, 0,
2143 0, 0, 0, 141, 139, 247, 111, 245, 0, 0,
2144 270, 160, 0, 269, 273, 0, 0, 0, 0, 0,
2145 0, 0, 134, 135, 134, 0, 0, 0, 0, 0,
2146 0, 345, 317, 0, 61, 321, 322, 0, 0, 343,
2147 61, 215, 0, 0, 0, 0, 195, 0, 0, 0,
2148 0, 206, 0, 180, 0, 0, 61, 136, 142, 140,
2149 59, 0, 128, 0, 276, 0, 0, 0, 314, 323,
2150 324, 325, 326, 339, 341, 316, 0, 0, 328, 331,
2151 332, 318, 0, 314, 134, 0, 0, 0, 0, 0,
2152 203, 0, 0, 0, 197, 198, 194, 58, 244, 246,
2153 111, 137, 278, 275, 0, 0, 111, 111, 0, 308,
2154 0, 348, 0, 344, 199, 200, 201, 202, 0, 0,
2155 0, 207, 59, 138, 132, 0, 0, 300, 0, 0,
2156 0, 128, 0, 309, 128, 196, 204, 205, 243, 0,
2157 130, 298, 0, 0, 299, 102, 104, 111, 111, 0,
2158 111, 111, 334, 133, 0, 249, 0, 0, 311, 310,
2159 0, 0, 0, 131, 0, 0, 0, 111, 111, 305,
2160 0, 0, 313, 312, 304, 0, 0, 301
Dan Gohman54392c12008-04-19 00:24:39 +00002161};
2162
2163/* YYDEFGOTO[NTERM-NUM]. */
2164static const yytype_int16 yydefgoto[] =
2165{
Chris Lattnerc5320232008-10-15 06:16:57 +00002166 -1, 269, 270, 271, 299, 316, 79, 628, 113, 12,
2167 133, 80, 14, 15, 41, 42, 43, 48, 54, 118,
2168 128, 349, 230, 278, 161, 445, 352, 685, 670, 414,
2169 533, 654, 471, 534, 81, 158, 139, 156, 140, 141,
2170 110, 373, 400, 374, 121, 88, 157, 16, 17, 18,
2171 20, 19, 383, 446, 447, 63, 23, 61, 101, 537,
2172 538, 129, 164, 55, 96, 56, 49, 474, 401, 83,
2173 403, 283, 284, 57, 92, 93, 222, 658, 134, 324,
2174 638, 493, 503, 223, 224, 225, 226
Dan Gohman54392c12008-04-19 00:24:39 +00002175};
2176
2177/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2178 STATE-NUM. */
Chris Lattnerc5320232008-10-15 06:16:57 +00002179#define YYPACT_NINF -624
Dan Gohman54392c12008-04-19 00:24:39 +00002180static const yytype_int16 yypact[] =
2181{
Chris Lattnerc5320232008-10-15 06:16:57 +00002182 815, -624, -624, -624, -624, -624, -624, -624, 14, -114,
2183 16, -73, 78, -31, 299, -624, 163, 2187, -624, 164,
2184 80, 19, 22, -624, 2, 179, -624, 1912, -624, -624,
2185 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2186 -624, 68, 68, 201, -624, -624, -624, -624, 68, -624,
2187 -624, -624, -624, -624, 68, 200, -624, 5, 215, 222,
2188 225, -624, -624, -624, -624, -624, 117, -624, -624, -624,
2189 -624, -624, -624, -624, -624, 264, 277, 7, 49, -624,
2190 -624, -624, -12, -624, 252, 252, 198, -624, 79, 231,
2191 231, -624, -624, 83, -624, -624, -624, -624, -624, -624,
2192 -624, -21, 649, -624, 138, 149, 627, 117, -624, -12,
2193 -120, 159, 649, 158, 79, 79, -624, -624, 1557, -624,
2194 -624, 2012, 320, -624, -624, -624, -624, -624, -624, -624,
2195 -13, 173, 2237, 2237, -624, 313, -624, -624, -12, -624,
2196 174, 177, 2012, 2012, 169, -118, 2012, -624, 336, 191,
2197 -624, 2012, 2012, 117, 193, -12, 226, -624, 1296, 308,
2198 -624, 1516, -624, -624, -624, -624, -624, -624, 307, 2031,
2199 108, 357, 231, -624, -624, -624, -624, -624, -624, -624,
2200 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2201 454, 958, 454, 958, 2012, 2012, 2012, 2012, -624, -624,
2202 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2203 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2204 2012, 2012, -624, 231, -624, 55, -624, -624, -624, -624,
2205 161, 1748, -624, -23, -41, -624, 203, -12, 214, -624,
2206 308, -20, 1557, -624, -624, -624, -624, -624, -624, -624,
2207 -624, -624, -624, -624, 454, 958, 454, 958, 216, 217,
2208 218, 220, 221, 224, 227, 1789, 2076, 732, 351, 228,
2209 229, 230, -624, -624, -624, -624, -624, -624, -624, 109,
2210 -624, 117, 956, -624, 219, 1466, 1466, 1466, -624, -624,
2211 -624, -624, -624, -624, -624, -624, -624, -624, -624, 2012,
2212 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2213 -624, -624, -624, -624, -624, -624, 2012, 2012, 2012, -10,
2214 3, -624, 956, -17, 223, 237, 238, 239, 240, 241,
2215 956, 956, 956, 956, 956, 352, -624, 2012, 2012, 387,
2216 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2217 -624, -624, 539, -624, -624, -624, -624, 539, -624, 158,
2218 354, 234, 248, 249, 250, 2012, 2012, 2012, 2012, 2012,
2219 2012, 2012, -624, -624, 42, 1006, -121, -624, -116, -624,
2220 2012, 2012, 2012, 253, 251, -624, -624, -624, -624, -624,
2221 -624, -624, -624, -624, -624, 353, 1807, 2094, 1175, 390,
2222 -624, -624, -624, -624, 2012, 255, -624, 256, 1516, 956,
2223 956, 956, 956, 20, -624, 29, -624, -624, 1466, 254,
2224 2012, 2012, 2012, 2012, 2012, 258, 259, 261, 262, 263,
2225 2012, 1516, 956, 266, -624, -624, -624, -624, -624, -624,
2226 -624, -624, -624, -624, -624, -624, 253, 253, 2012, 2012,
2227 2012, 2012, 2012, -624, 269, 270, 272, 273, 259, 274,
2228 2012, -624, 268, 1126, -84, -624, -624, 280, 281, 406,
2229 -5, -624, 1830, -624, 423, -624, 61, 1345, -56, -624,
2230 -77, -624, -624, 430, 431, 1466, 288, 290, 291, 292,
2231 1466, 455, 1466, 296, 298, 1466, 300, -12, -624, 301,
2232 302, 457, 461, 306, 2012, 1466, 1466, -12, 1466, 311,
2233 2012, -624, -624, -1, 312, 314, 317, 319, 101, 2012,
2234 2012, 2012, 2012, 112, 2012, -624, -624, 318, 2012, 2012,
2235 2012, 453, 478, -624, 253, -624, -12, 321, 326, 327,
2236 -624, 323, -67, -624, -624, 1466, 1466, 329, 1466, 1466,
2237 1466, 1466, 311, -624, 311, 2012, 1466, 328, 2012, 2012,
2238 2012, -624, -624, 489, 956, -624, -624, 335, 441, -624,
2239 956, -624, 2012, 2012, 2012, 2012, -624, 334, 337, 339,
2240 340, -624, 259, -624, 343, 345, 15, -624, -624, -624,
2241 178, 1848, -624, 484, -624, 338, 350, 349, 2117, -624,
2242 -624, -624, -624, -624, -624, -624, 348, 1466, -624, -624,
2243 -624, -624, 259, 2117, 311, 356, 359, 360, 361, 2012,
2244 -624, 2012, 2012, 115, -624, -624, -624, -624, -624, -624,
2245 -12, 116, -624, -624, 505, -7, 59, -12, 118, -624,
2246 358, 306, 124, -624, -624, -624, -624, -624, 363, 364,
2247 366, -624, 178, -624, 473, 1466, 1614, -624, -6, 802,
2248 802, -624, 2135, -624, -624, -624, -624, -624, -624, 526,
2249 379, -624, 374, 1614, -624, 378, 380, -624, -624, 442,
2250 59, -12, 539, -624, 516, -624, 523, 396, 161, 161,
2251 524, 802, 802, -624, 1466, 525, 1466, -624, -624, -624,
2252 1466, 486, 161, 161, -624, 543, 1466, -624
Dan Gohman54392c12008-04-19 00:24:39 +00002253};
2254
2255/* YYPGOTO[NTERM-NUM]. */
2256static const yytype_int16 yypgoto[] =
2257{
Chris Lattnerc5320232008-10-15 06:16:57 +00002258 -624, 132, 155, 181, -165, -154, 0, -86, -143, 474,
2259 -624, 6, -624, -624, -624, -624, 67, -624, -624, -624,
2260 -142, -624, -499, -624, -252, -624, -231, -624, -624, -313,
2261 -63, -624, -434, -624, -624, -26, 342, -152, -624, 458,
2262 463, -11, -156, -242, 202, 244, 332, -624, -624, 554,
2263 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2264 -624, 485, -624, -624, -624, -624, -624, -624, -623, -79,
2265 213, -193, -624, -624, 520, -624, 445, -624, -624, -624,
2266 -34, 129, -448, -624, 456, -624, -624
Dan Gohman54392c12008-04-19 00:24:39 +00002267};
2268
2269/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2270 positive, shift that token. If negative, reduce the rule which
2271 number is the opposite. If zero, do what YYDEFACT says.
2272 If YYTABLE_NINF, syntax error. */
Chris Lattnerc5320232008-10-15 06:16:57 +00002273#define YYTABLE_NINF -218
Dan Gohman54392c12008-04-19 00:24:39 +00002274static const yytype_int16 yytable[] =
2275{
Chris Lattnerc5320232008-10-15 06:16:57 +00002276 11, 82, 272, 321, 656, 673, 13, 416, 357, 279,
2277 523, 105, 511, 512, 111, 162, 274, 11, 325, 326,
2278 327, 328, 329, 13, 376, 378, 91, 317, 335, 531,
2279 288, 490, 111, 672, 94, 111, 408, 590, 111, 318,
2280 492, 460, 146, 111, 146, 111, 460, 24, 465, 532,
2281 687, 147, 109, 236, 111, 466, 64, 65, 111, 107,
2282 67, 68, 69, 70, 71, 72, 73, 21, 1, 2,
2283 111, 3, 4, 5, 491, 25, 138, 243, 460, 273,
2284 109, 336, 22, 491, 431, 460, 138, 527, 26, 361,
2285 131, 363, 155, 11, 544, 460, 27, 358, 359, 74,
2286 589, 362, 1, 364, 595, 3, 460, 5, 84, 85,
2287 159, 119, 120, 543, -149, 89, 233, 234, 112, 285,
2288 237, 90, 50, 51, 52, 286, 241, 53, 354, 2,
2289 28, 652, 4, 464, 623, 155, 112, 659, 660, 112,
2290 240, 135, 112, 282, 353, 433, 136, 112, 418, 112,
2291 531, -61, 413, -61, 476, 478, 480, 163, 112, 571,
2292 657, 674, 112, 44, 641, 415, -61, 60, 319, 320,
2293 282, 322, 337, 338, 112, 626, 95, 106, 688, 689,
2294 58, 691, 692, 59, 323, 282, 282, 282, 282, 282,
2295 330, 331, 332, 333, 334, 282, 569, 1, 702, 703,
2296 3, 62, 5, 402, 460, 138, 402, 402, 402, 461,
2297 46, 482, 47, 75, 76, 339, 155, 77, -149, 78,
2298 108, 91, -149, 460, 38, 39, 40, 496, 540, 498,
2299 499, 500, 339, 64, 65, 542, 86, 98, 87, 603,
2300 116, 604, 117, 402, 99, 1, 2, 100, 3, 4,
2301 5, 402, 402, 402, 402, 402, 485, 435, 436, 437,
2302 438, 576, 439, 555, 219, 219, 440, 441, 103, 442,
2303 443, 444, 581, 409, 563, 651, 102, 563, 661, 508,
2304 662, 104, 340, 341, 664, 384, 662, 220, 220, 87,
2305 410, 411, 412, 122, 123, 124, 125, 126, 127, 340,
2306 341, 643, 342, 343, 142, 344, 345, 272, 346, 347,
2307 348, 432, 282, 221, 221, 143, 151, 152, 148, 342,
2308 343, 150, 344, 345, 160, 346, 347, 348, 114, 115,
2309 402, 402, 402, 402, 165, 229, 231, 232, 235, 402,
2310 238, 29, 30, 31, 32, 33, 34, 35, 36, 463,
2311 37, 239, 242, 402, 453, 454, 455, 456, 457, 458,
2312 459, 631, 605, 111, 280, 608, 609, 610, 287, 467,
2313 468, 469, 355, 379, 356, 365, 366, 367, 282, 368,
2314 369, 404, 155, 370, 273, 419, 371, 380, 381, 382,
2315 430, 434, 448, 449, 282, 497, 282, 282, 282, 420,
2316 421, 422, 423, 424, 507, 155, 402, 450, 451, 452,
2317 472, 402, 481, 402, 473, 470, 402, 483, 484, 495,
2318 501, 502, 513, 504, 505, 506, 402, 402, 510, 402,
2319 679, 519, 520, 682, 521, 522, 524, 526, 514, 515,
2320 516, 517, 528, 529, 530, 539, 536, 545, 546, 525,
2321 548, 463, 549, 550, 551, 38, 39, 40, 555, 553,
2322 556, 561, 558, 559, 560, 562, 402, 402, 563, 402,
2323 402, 402, 402, 568, 572, 587, 573, 402, 564, 574,
2324 690, 575, 588, 591, 570, 402, 592, 583, 598, 593,
2325 607, 402, 594, 611, 613, 491, 619, 620, 405, 406,
2326 407, 621, 622, 624, 586, 625, 632, 633, 577, 578,
2327 579, 580, 634, 582, 635, 639, 644, 584, 585, 645,
2328 646, 647, 655, 665, 666, 663, 667, 669, 402, 282,
2329 683, 684, 282, 282, 282, 417, 686, -18, 693, -19,
2330 694, 696, 700, 425, 426, 427, 428, 429, 289, 290,
2331 291, 292, 293, 294, 295, 296, 297, 298, 695, 705,
2332 706, 615, 616, 617, 618, 630, 668, 132, 653, 145,
2333 149, 45, 637, 351, 360, 130, 402, 97, 227, 642,
2334 402, 402, 518, 435, 436, 437, 438, 637, 439, 228,
2335 627, 0, 440, 441, 0, 442, 443, 444, 0, 0,
2336 0, 0, 0, 0, 0, 0, 0, 0, 648, 0,
2337 649, 650, 402, 402, 0, 402, 0, 402, 0, 0,
2338 0, 402, 486, 487, 488, 489, 0, 402, 0, 0,
2339 0, 494, 0, 0, 64, 65, 681, 107, 67, 68,
2340 69, 70, 71, 72, 73, 509, 1, 2, 0, 3,
2341 4, 5, 627, 0, 0, 0, 64, 65, 0, 107,
2342 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2343 0, 3, 4, 5, 0, 0, 0, 74, 0, 0,
2344 435, 436, 437, 438, 0, 439, 0, 0, 137, 440,
2345 441, 0, 442, 443, 444, 0, 0, 0, 547, 74,
2346 0, 0, 0, 552, 0, 554, 0, 0, 557, 0,
2347 0, 0, 0, 0, 0, 0, 0, 0, 565, 566,
2348 0, 567, 0, 0, 0, 0, 0, 0, 0, 0,
2349 0, 0, 0, 0, 0, 0, 0, 0, 0, 64,
2350 65, 0, 107, 67, 68, 69, 70, 71, 72, 73,
2351 0, 1, 2, 0, 3, 4, 5, 0, 596, 597,
2352 0, 599, 600, 601, 602, 0, 0, 0, 0, 606,
2353 0, 0, 0, 0, 0, 0, 0, 612, 0, 0,
2354 0, 0, 74, 614, 0, 0, 0, 0, 0, 0,
2355 0, 75, 76, 0, 0, 77, 0, 78, 144, 0,
2356 0, 0, 0, 0, 0, 385, 386, 387, 388, 64,
2357 65, 389, 0, 75, 76, -217, 0, 77, 0, 78,
2358 640, 1, 2, 0, 3, 4, 5, 390, 391, 392,
2359 0, 0, 0, -63, 1, 2, 0, 3, 4, 5,
2360 0, 0, 393, 394, 0, 6, 7, 0, 0, 0,
2361 0, 0, 0, 0, 0, 0, 339, 0, 0, 0,
2362 0, 395, 0, 0, 0, 0, 0, 8, 671, 0,
2363 0, 9, 677, 678, 0, 10, 0, 175, 176, 177,
2364 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2365 188, 189, 254, 255, 256, 257, 75, 76, 0, 0,
2366 77, 0, 78, 377, 697, 698, 0, 699, 0, 701,
2367 0, 0, 0, 704, 0, 0, 0, 0, 0, 707,
2368 0, 258, 198, 675, 676, 201, 202, 203, 204, 205,
2369 206, 207, 208, 209, 0, 259, 0, 260, 261, 262,
2370 0, 263, 264, 342, 343, 0, 344, 345, 0, 346,
2371 347, 348, 0, 0, 0, 0, 0, 0, 0, 385,
2372 386, 387, 388, 64, 65, 389, 0, 396, 0, 0,
2373 397, 0, 398, 0, 399, 1, 2, 0, 3, 4,
2374 5, 390, 391, 392, 300, 301, 0, 0, 0, 0,
2375 0, 0, 0, 0, 0, 0, 393, 394, 0, 0,
Chris Lattnerf6bbfbc2008-09-23 21:18:31 +00002376 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerc5320232008-10-15 06:16:57 +00002377 0, 111, 0, 64, 65, 395, 107, 67, 68, 69,
Chris Lattner8f5544c2008-10-15 06:03:48 +00002378 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
Chris Lattnerc5320232008-10-15 06:16:57 +00002379 5, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2380 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2381 0, 0, 0, 0, 0, 0, 74, 0, 302, 303,
2382 304, 305, 306, 307, 308, 309, 310, 311, 312, 313,
2383 314, 315, 0, 0, 0, 258, 198, 199, 200, 201,
2384 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2385 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
Chris Lattnerf6bbfbc2008-09-23 21:18:31 +00002386 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerc5320232008-10-15 06:16:57 +00002387 0, 0, 0, 0, 0, 112, 0, 0, 0, 0,
2388 0, 396, 0, 0, 397, 0, 398, 0, 399, 244,
2389 245, 246, 247, 64, 65, 248, 0, 0, 0, 0,
2390 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2391 5, 249, 250, 251, 0, 0, 0, 0, 0, 0,
2392 0, 0, 0, 0, 0, 0, 252, 253, 0, 0,
2393 75, 76, 0, 0, 77, 0, 78, 462, 0, 0,
2394 0, 111, 64, 65, 0, 107, 67, 68, 69, 70,
2395 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2396 0, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2397 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2398 0, 0, 0, 0, 0, 74, 0, 0, 0, 0,
Dale Johannesenf4581482008-09-26 19:32:34 +00002399 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerc5320232008-10-15 06:16:57 +00002400 0, 0, 0, 0, 0, 258, 198, 199, 200, 201,
2401 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2402 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
Devang Patelcd842482008-09-29 20:49:50 +00002403 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerc5320232008-10-15 06:16:57 +00002404 0, 0, 0, 0, 0, 112, 0, 0, 0, -61,
2405 0, 265, 0, 0, 266, 0, 267, 0, 268, 244,
2406 245, 246, 247, 64, 65, 248, 0, 0, 0, 0,
2407 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2408 5, 249, 250, 251, 0, 0, 0, 0, 0, 0,
2409 0, 0, 0, 0, 0, 0, 252, 253, 0, 75,
2410 76, 0, 0, 77, 0, 78, 479, 0, 0, 0,
2411 0, 111, 64, 65, 0, 107, 67, 68, 69, 70,
2412 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2413 0, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2414 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2415 0, 0, 0, 0, 0, 74, 0, 0, 0, 0,
Devang Patelcd842482008-09-29 20:49:50 +00002416 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerc5320232008-10-15 06:16:57 +00002417 0, 0, 0, 0, 0, 258, 198, 199, 200, 201,
2418 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2419 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
2420 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2421 0, 0, 0, 0, 0, 112, 0, 0, 0, 0,
2422 0, 265, 0, 0, 266, 0, 267, 0, 268, 385,
2423 386, 387, 388, 64, 65, 389, 0, 0, 0, 0,
2424 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2425 5, 390, 391, 392, 0, 0, 0, 0, 0, 0,
2426 0, 0, 0, 0, 0, 0, 393, 394, 0, 75,
2427 76, 0, 0, 77, 0, 78, 541, 0, 0, 0,
2428 0, 0, 0, 64, 65, 395, 153, 67, 68, 69,
2429 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
2430 5, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2431 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2432 0, 0, 0, 0, 64, 65, 74, 153, 67, 68,
Chris Lattner8f5544c2008-10-15 06:03:48 +00002433 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
Chris Lattnerc5320232008-10-15 06:16:57 +00002434 4, 5, 0, 0, 0, 258, 198, 199, 200, 201,
2435 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2436 0, 260, 261, 262, 0, 263, 264, 74, 0, 0,
2437 0, 0, 0, 0, 0, 0, 0, 385, 386, 387,
2438 388, 0, 0, 389, 0, 0, 0, 0, 0, 0,
2439 0, 396, 0, 0, 397, 0, 398, 0, 399, 390,
2440 391, 392, 0, 0, 0, 0, 0, 0, 0, 0,
2441 0, 0, 0, 0, 393, 394, 0, 275, 276, 0,
2442 277, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2443 0, 0, 0, 395, 0, 0, 0, 0, 0, 0,
2444 75, 76, 154, 0, 77, 0, 78, 0, 0, 175,
2445 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2446 186, 187, 188, 189, 254, 255, 256, 257, 0, 0,
Devang Patelcd842482008-09-29 20:49:50 +00002447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8f5544c2008-10-15 06:03:48 +00002448 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
Chris Lattnerc5320232008-10-15 06:16:57 +00002449 0, 0, 0, 258, 198, 199, 200, 201, 202, 203,
2450 204, 205, 206, 207, 208, 209, 0, 259, 0, 260,
2451 261, 262, 0, 263, 264, 64, 65, 0, 107, 67,
2452 68, 69, 70, 71, 72, 73, 0, 1, 2, 0,
2453 3, 4, 5, 0, 0, 0, 0, 0, 0, 396,
2454 0, 0, 397, 0, 398, 0, 399, 350, 0, 0,
2455 0, 0, 0, 0, 0, 0, 64, 65, 74, 107,
2456 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2457 0, 3, 4, 5, 64, 65, 0, 107, 67, 68,
2458 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
2459 4, 5, 0, 0, 0, 0, 0, 64, 65, 74,
2460 107, 67, 68, 69, 70, 71, 72, 73, 0, 1,
2461 2, 0, 3, 4, 5, 64, 65, 74, 107, 67,
2462 68, 69, 70, 71, 72, 73, 0, 1, 2, 535,
2463 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2464 74, 0, 0, 0, 0, 0, 0, 629, 0, 0,
2465 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
Dale Johannesenf4581482008-09-26 19:32:34 +00002466 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerc5320232008-10-15 06:16:57 +00002467 0, 0, 75, 76, 0, 0, 77, 0, 78, 64,
2468 65, 0, 66, 67, 68, 69, 70, 71, 72, 73,
2469 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2470 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2471 0, 0, 0, 75, 76, 0, 372, 77, 0, 78,
2472 0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
2473 0, 75, 76, 0, 475, 77, 0, 78, 0, 0,
2474 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2475 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2476 78, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2477 0, 0, 75, 76, 0, 0, 77, 0, 78, 64,
2478 65, 0, 107, 67, 68, 69, 70, 71, 72, 73,
2479 0, 1, 2, 0, 3, 4, 5, 0, 64, 65,
2480 0, 281, 67, 68, 69, 70, 71, 72, 73, 0,
2481 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2482 0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
2483 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2484 77, 74, 78, 64, 65, 0, 107, 67, 68, 69,
2485 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
2486 5, 64, 65, 0, 107, 67, 68, 69, 70, 71,
2487 72, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2488 0, 0, 0, 0, 64, 65, 74, 107, 67, 68,
2489 69, 70, 71, 72, 636, 0, 1, 2, 0, 3,
2490 4, 5, 64, 65, 74, 107, 67, 68, 69, 70,
2491 71, 72, 680, 0, 1, 2, 0, 3, 4, 5,
2492 0, 0, 0, 0, 0, 0, 0, 74, 0, 0,
2493 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2494 77, 0, 78, 0, 0, 74, 0, -216, 0, 0,
2495 0, 0, 0, 0, 0, 75, 76, 0, 0, 77,
2496 0, 78, 0, 0, 0, -63, 1, 2, 0, 3,
2497 4, 5, 0, 0, 0, 0, 0, 6, 7, 0,
2498 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2499 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
2500 75, 76, 0, 9, 77, 0, 375, 10, 0, 0,
2501 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2502 0, 0, 77, 0, 477, 0, 0, 0, 0, 0,
2503 0, 0, 0, 166, 0, 0, 0, 0, 0, 0,
2504 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
2505 0, 0, 0, 0, 167, 168, 0, 0, 0, 75,
2506 76, 0, 0, 77, 0, 78, 169, 170, 171, 172,
2507 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
Chris Lattner8f5544c2008-10-15 06:03:48 +00002508 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
Chris Lattnerc5320232008-10-15 06:16:57 +00002509 193, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2510 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2511 0, 194, 195, 196, 0, 0, 197, 198, 199, 200,
2512 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
2513 211, 212, 213, 214, 215, 216, 217, 218
Dan Gohman54392c12008-04-19 00:24:39 +00002514};
2515
2516static const yytype_int16 yycheck[] =
2517{
Chris Lattnerc5320232008-10-15 06:16:57 +00002518 0, 27, 158, 196, 11, 11, 0, 320, 239, 161,
2519 458, 4, 446, 447, 55, 28, 159, 17, 211, 212,
2520 213, 214, 215, 17, 266, 267, 21, 192, 221, 34,
2521 172, 11, 55, 656, 29, 55, 288, 536, 55, 193,
2522 11, 162, 162, 55, 162, 55, 162, 161, 169, 54,
2523 673, 171, 78, 171, 55, 171, 7, 8, 55, 10,
2524 11, 12, 13, 14, 15, 16, 17, 53, 19, 20,
2525 55, 22, 23, 24, 54, 59, 102, 156, 162, 158,
2526 106, 223, 68, 54, 336, 162, 112, 171, 161, 254,
2527 7, 256, 118, 93, 171, 162, 18, 240, 241, 50,
2528 534, 255, 19, 257, 171, 22, 162, 24, 41, 42,
2529 121, 32, 33, 169, 55, 48, 142, 143, 159, 11,
2530 146, 54, 42, 43, 44, 17, 152, 47, 169, 20,
2531 161, 630, 23, 375, 582, 161, 159, 636, 637, 159,
2532 151, 162, 159, 169, 167, 338, 167, 159, 165, 159,
2533 34, 163, 162, 163, 396, 397, 398, 170, 159, 160,
2534 167, 167, 159, 0, 612, 162, 163, 165, 194, 195,
2535 196, 197, 117, 118, 159, 160, 171, 170, 677, 678,
2536 161, 680, 681, 161, 210, 211, 212, 213, 214, 215,
2537 216, 217, 218, 219, 220, 221, 509, 19, 697, 698,
2538 22, 22, 24, 282, 162, 231, 285, 286, 287, 167,
2539 46, 404, 48, 164, 165, 54, 242, 168, 159, 170,
2540 171, 21, 163, 162, 156, 157, 158, 420, 167, 422,
2541 423, 424, 54, 7, 8, 477, 35, 22, 37, 552,
2542 42, 554, 44, 322, 22, 19, 20, 22, 22, 23,
2543 24, 330, 331, 332, 333, 334, 408, 141, 142, 143,
2544 144, 160, 146, 162, 132, 133, 150, 151, 4, 153,
2545 154, 155, 160, 299, 162, 160, 159, 162, 160, 431,
2546 162, 4, 121, 122, 160, 279, 162, 132, 133, 37,
2547 316, 317, 318, 62, 63, 64, 65, 66, 67, 121,
2548 122, 614, 141, 142, 166, 144, 145, 463, 147, 148,
2549 149, 337, 338, 132, 133, 166, 114, 115, 159, 141,
2550 142, 163, 144, 145, 4, 147, 148, 149, 84, 85,
2551 409, 410, 411, 412, 161, 22, 162, 160, 169, 418,
2552 4, 42, 43, 44, 45, 46, 47, 48, 49, 375,
2553 51, 160, 159, 432, 365, 366, 367, 368, 369, 370,
2554 371, 592, 555, 55, 57, 558, 559, 560, 11, 380,
2555 381, 382, 169, 22, 160, 159, 159, 159, 404, 159,
2556 159, 162, 408, 159, 463, 162, 159, 159, 159, 159,
2557 38, 4, 38, 159, 420, 421, 422, 423, 424, 162,
2558 162, 162, 162, 162, 430, 431, 485, 159, 159, 159,
2559 159, 490, 22, 492, 61, 162, 495, 162, 162, 165,
2560 162, 162, 448, 162, 162, 162, 505, 506, 162, 508,
2561 661, 162, 162, 664, 162, 162, 162, 169, 449, 450,
2562 451, 452, 162, 162, 38, 22, 472, 17, 17, 460,
2563 162, 477, 162, 162, 162, 156, 157, 158, 162, 4,
2564 162, 4, 162, 162, 162, 4, 545, 546, 162, 548,
2565 549, 550, 551, 162, 162, 22, 162, 556, 504, 162,
2566 38, 162, 4, 162, 510, 564, 160, 169, 159, 162,
2567 162, 570, 169, 4, 159, 54, 162, 160, 285, 286,
2568 287, 162, 162, 160, 530, 160, 22, 169, 519, 520,
2569 521, 522, 162, 524, 165, 167, 160, 528, 529, 160,
2570 160, 160, 17, 160, 160, 167, 160, 54, 607, 555,
2571 4, 152, 558, 559, 560, 322, 162, 159, 22, 159,
2572 17, 17, 17, 330, 331, 332, 333, 334, 94, 95,
2573 96, 97, 98, 99, 100, 101, 102, 103, 162, 73,
2574 17, 572, 573, 574, 575, 591, 652, 93, 631, 106,
2575 112, 17, 598, 231, 242, 90, 655, 57, 133, 613,
2576 659, 660, 453, 141, 142, 143, 144, 613, 146, 133,
2577 590, -1, 150, 151, -1, 153, 154, 155, -1, -1,
2578 -1, -1, -1, -1, -1, -1, -1, -1, 619, -1,
2579 621, 622, 691, 692, -1, 694, -1, 696, -1, -1,
2580 -1, 700, 409, 410, 411, 412, -1, 706, -1, -1,
2581 -1, 418, -1, -1, 7, 8, 662, 10, 11, 12,
2582 13, 14, 15, 16, 17, 432, 19, 20, -1, 22,
2583 23, 24, 652, -1, -1, -1, 7, 8, -1, 10,
Chris Lattnerf6bbfbc2008-09-23 21:18:31 +00002584 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Chris Lattnerc5320232008-10-15 06:16:57 +00002585 -1, 22, 23, 24, -1, -1, -1, 50, -1, -1,
2586 141, 142, 143, 144, -1, 146, -1, -1, 39, 150,
2587 151, -1, 153, 154, 155, -1, -1, -1, 485, 50,
2588 -1, -1, -1, 490, -1, 492, -1, -1, 495, -1,
2589 -1, -1, -1, -1, -1, -1, -1, -1, 505, 506,
2590 -1, 508, -1, -1, -1, -1, -1, -1, -1, -1,
2591 -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
Devang Patelcd842482008-09-29 20:49:50 +00002592 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
Chris Lattnerc5320232008-10-15 06:16:57 +00002593 -1, 19, 20, -1, 22, 23, 24, -1, 545, 546,
2594 -1, 548, 549, 550, 551, -1, -1, -1, -1, 556,
2595 -1, -1, -1, -1, -1, -1, -1, 564, -1, -1,
2596 -1, -1, 50, 570, -1, -1, -1, -1, -1, -1,
2597 -1, 164, 165, -1, -1, 168, -1, 170, 171, -1,
2598 -1, -1, -1, -1, -1, 3, 4, 5, 6, 7,
2599 8, 9, -1, 164, 165, 0, -1, 168, -1, 170,
2600 607, 19, 20, -1, 22, 23, 24, 25, 26, 27,
2601 -1, -1, -1, 18, 19, 20, -1, 22, 23, 24,
2602 -1, -1, 40, 41, -1, 30, 31, -1, -1, -1,
2603 -1, -1, -1, -1, -1, -1, 54, -1, -1, -1,
2604 -1, 59, -1, -1, -1, -1, -1, 52, 655, -1,
2605 -1, 56, 659, 660, -1, 60, -1, 75, 76, 77,
2606 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
2607 88, 89, 90, 91, 92, 93, 164, 165, -1, -1,
2608 168, -1, 170, 171, 691, 692, -1, 694, -1, 696,
2609 -1, -1, -1, 700, -1, -1, -1, -1, -1, 706,
2610 -1, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2611 128, 129, 130, 131, -1, 133, -1, 135, 136, 137,
2612 -1, 139, 140, 141, 142, -1, 144, 145, -1, 147,
2613 148, 149, -1, -1, -1, -1, -1, -1, -1, 3,
2614 4, 5, 6, 7, 8, 9, -1, 165, -1, -1,
2615 168, -1, 170, -1, 172, 19, 20, -1, 22, 23,
2616 24, 25, 26, 27, 26, 27, -1, -1, -1, -1,
2617 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
Dale Johannesenf4581482008-09-26 19:32:34 +00002618 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerc5320232008-10-15 06:16:57 +00002619 -1, 55, -1, 7, 8, 59, 10, 11, 12, 13,
2620 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2621 24, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2622 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2623 -1, -1, -1, -1, -1, -1, 50, -1, 100, 101,
2624 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
2625 112, 113, -1, -1, -1, 119, 120, 121, 122, 123,
2626 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2627 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
2628 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2629 -1, -1, -1, -1, -1, 159, -1, -1, -1, -1,
2630 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2631 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2632 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2633 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2634 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
2635 164, 165, -1, -1, 168, -1, 170, 171, -1, -1,
2636 -1, 55, 7, 8, -1, 10, 11, 12, 13, 14,
Dale Johannesenf4581482008-09-26 19:32:34 +00002637 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
Chris Lattnerc5320232008-10-15 06:16:57 +00002638 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2639 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2640 -1, -1, -1, -1, -1, 50, -1, -1, -1, -1,
Devang Patelcd842482008-09-29 20:49:50 +00002641 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerc5320232008-10-15 06:16:57 +00002642 -1, -1, -1, -1, -1, 119, 120, 121, 122, 123,
2643 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2644 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
Chris Lattner8f5544c2008-10-15 06:03:48 +00002645 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerc5320232008-10-15 06:16:57 +00002646 -1, -1, -1, -1, -1, 159, -1, -1, -1, 163,
2647 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2648 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2649 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2650 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2651 -1, -1, -1, -1, -1, -1, 40, 41, -1, 164,
2652 165, -1, -1, 168, -1, 170, 171, -1, -1, -1,
2653 -1, 55, 7, 8, -1, 10, 11, 12, 13, 14,
2654 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2655 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2656 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2657 -1, -1, -1, -1, -1, 50, -1, -1, -1, -1,
Chris Lattner906773a2008-08-29 17:20:18 +00002658 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerc5320232008-10-15 06:16:57 +00002659 -1, -1, -1, -1, -1, 119, 120, 121, 122, 123,
2660 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2661 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
2662 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2663 -1, -1, -1, -1, -1, 159, -1, -1, -1, -1,
2664 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2665 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2666 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2667 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2668 -1, -1, -1, -1, -1, -1, 40, 41, -1, 164,
2669 165, -1, -1, 168, -1, 170, 171, -1, -1, -1,
2670 -1, -1, -1, 7, 8, 59, 10, 11, 12, 13,
2671 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2672 24, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2673 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2674 -1, -1, -1, -1, 7, 8, 50, 10, 11, 12,
2675 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2676 23, 24, -1, -1, -1, 119, 120, 121, 122, 123,
2677 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2678 -1, 135, 136, 137, -1, 139, 140, 50, -1, -1,
2679 -1, -1, -1, -1, -1, -1, -1, 3, 4, 5,
2680 6, -1, -1, 9, -1, -1, -1, -1, -1, -1,
2681 -1, 165, -1, -1, 168, -1, 170, -1, 172, 25,
2682 26, 27, -1, -1, -1, -1, -1, -1, -1, -1,
2683 -1, -1, -1, -1, 40, 41, -1, 141, 142, -1,
2684 144, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2685 -1, -1, -1, 59, -1, -1, -1, -1, -1, -1,
2686 164, 165, 125, -1, 168, -1, 170, -1, -1, 75,
Chris Lattner8f5544c2008-10-15 06:03:48 +00002687 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2688 86, 87, 88, 89, 90, 91, 92, 93, -1, -1,
Chris Lattnerc5320232008-10-15 06:16:57 +00002689 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2690 -1, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2691 -1, -1, -1, 119, 120, 121, 122, 123, 124, 125,
2692 126, 127, 128, 129, 130, 131, -1, 133, -1, 135,
2693 136, 137, -1, 139, 140, 7, 8, -1, 10, 11,
2694 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2695 22, 23, 24, -1, -1, -1, -1, -1, -1, 165,
2696 -1, -1, 168, -1, 170, -1, 172, 39, -1, -1,
2697 -1, -1, -1, -1, -1, -1, 7, 8, 50, 10,
2698 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2699 -1, 22, 23, 24, 7, 8, -1, 10, 11, 12,
2700 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2701 23, 24, -1, -1, -1, -1, -1, 7, 8, 50,
2702 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2703 20, -1, 22, 23, 24, 7, 8, 50, 10, 11,
2704 12, 13, 14, 15, 16, 17, -1, 19, 20, 39,
2705 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2706 50, -1, -1, -1, -1, -1, -1, 39, -1, -1,
2707 -1, -1, -1, -1, -1, -1, -1, -1, 50, -1,
2708 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2709 -1, -1, 164, 165, -1, -1, 168, -1, 170, 7,
2710 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2711 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2712 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2713 -1, -1, -1, 164, 165, -1, 167, 168, -1, 170,
2714 -1, -1, 50, -1, -1, -1, -1, -1, -1, -1,
2715 -1, 164, 165, -1, 167, 168, -1, 170, -1, -1,
2716 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2717 -1, -1, -1, -1, 164, 165, -1, -1, 168, -1,
2718 170, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2719 -1, -1, 164, 165, -1, -1, 168, -1, 170, 7,
2720 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2721 -1, 19, 20, -1, 22, 23, 24, -1, 7, 8,
2722 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2723 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2724 -1, -1, 50, -1, -1, -1, -1, -1, -1, -1,
2725 -1, -1, -1, -1, -1, -1, 164, 165, -1, -1,
2726 168, 50, 170, 7, 8, -1, 10, 11, 12, 13,
2727 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2728 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2729 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2730 -1, -1, -1, -1, 7, 8, 50, 10, 11, 12,
2731 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2732 23, 24, 7, 8, 50, 10, 11, 12, 13, 14,
2733 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2734 -1, -1, -1, -1, -1, -1, -1, 50, -1, -1,
2735 -1, -1, -1, -1, -1, -1, 164, 165, -1, -1,
2736 168, -1, 170, -1, -1, 50, -1, 0, -1, -1,
2737 -1, -1, -1, -1, -1, 164, 165, -1, -1, 168,
2738 -1, 170, -1, -1, -1, 18, 19, 20, -1, 22,
2739 23, 24, -1, -1, -1, -1, -1, 30, 31, -1,
2740 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2741 -1, -1, -1, -1, -1, -1, -1, -1, -1, 52,
2742 164, 165, -1, 56, 168, -1, 170, 60, -1, -1,
2743 -1, -1, -1, -1, -1, -1, -1, -1, 164, 165,
2744 -1, -1, 168, -1, 170, -1, -1, -1, -1, -1,
2745 -1, -1, -1, 36, -1, -1, -1, -1, -1, -1,
2746 -1, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2747 -1, -1, -1, -1, 57, 58, -1, -1, -1, 164,
2748 165, -1, -1, 168, -1, 170, 69, 70, 71, 72,
2749 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2750 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2751 93, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2752 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2753 -1, 114, 115, 116, -1, -1, 119, 120, 121, 122,
2754 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
2755 133, 134, 135, 136, 137, 138, 139, 140
Dan Gohman54392c12008-04-19 00:24:39 +00002756};
2757
2758/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2759 symbol of state STATE-NUM. */
Dale Johannesen9cdf0652008-08-13 18:41:46 +00002760static const yytype_uint16 yystos[] =
Dan Gohman54392c12008-04-19 00:24:39 +00002761{
Dale Johannesen280e7bc2008-05-14 20:13:36 +00002762 0, 19, 20, 22, 23, 24, 30, 31, 52, 56,
Chris Lattnerc5320232008-10-15 06:16:57 +00002763 60, 179, 182, 184, 185, 186, 220, 221, 222, 224,
2764 223, 53, 68, 229, 161, 59, 161, 18, 161, 42,
Devang Patelcd842482008-09-29 20:49:50 +00002765 43, 44, 45, 46, 47, 48, 49, 51, 156, 157,
Chris Lattnerc5320232008-10-15 06:16:57 +00002766 158, 187, 188, 189, 0, 222, 46, 48, 190, 239,
2767 42, 43, 44, 47, 191, 236, 238, 246, 161, 161,
2768 165, 230, 22, 228, 7, 8, 10, 11, 12, 13,
2769 14, 15, 16, 17, 50, 164, 165, 168, 170, 179,
2770 184, 207, 208, 242, 189, 189, 35, 37, 218, 189,
2771 189, 21, 247, 248, 29, 171, 237, 247, 22, 22,
2772 22, 231, 159, 4, 4, 4, 170, 10, 171, 208,
2773 213, 55, 159, 181, 218, 218, 42, 44, 192, 32,
2774 33, 217, 62, 63, 64, 65, 66, 67, 193, 234,
2775 234, 7, 182, 183, 251, 162, 167, 39, 208, 209,
2776 211, 212, 166, 166, 171, 213, 162, 171, 159, 212,
2777 163, 217, 217, 10, 125, 208, 210, 219, 208, 214,
2778 4, 197, 28, 170, 235, 161, 36, 57, 58, 69,
2779 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2780 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2781 90, 91, 92, 93, 114, 115, 116, 119, 120, 121,
2782 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
2783 132, 133, 134, 135, 136, 137, 138, 139, 140, 174,
2784 175, 176, 249, 256, 257, 258, 259, 249, 257, 22,
2785 195, 162, 160, 208, 208, 169, 171, 208, 4, 160,
2786 214, 208, 159, 242, 3, 4, 5, 6, 9, 25,
2787 26, 27, 40, 41, 90, 91, 92, 93, 119, 133,
2788 135, 136, 137, 139, 140, 165, 168, 170, 172, 174,
2789 175, 176, 215, 242, 181, 141, 142, 144, 196, 210,
2790 57, 10, 208, 244, 245, 11, 17, 11, 193, 94,
2791 95, 96, 97, 98, 99, 100, 101, 102, 103, 177,
2792 26, 27, 100, 101, 102, 103, 104, 105, 106, 107,
2793 108, 109, 110, 111, 112, 113, 178, 177, 178, 208,
2794 208, 244, 208, 208, 252, 244, 244, 244, 244, 244,
2795 208, 208, 208, 208, 208, 244, 193, 117, 118, 54,
2796 121, 122, 141, 142, 144, 145, 147, 148, 149, 194,
2797 39, 209, 199, 167, 169, 169, 160, 199, 181, 181,
2798 219, 177, 178, 177, 178, 159, 159, 159, 159, 159,
2799 159, 159, 167, 214, 216, 170, 216, 171, 216, 22,
2800 159, 159, 159, 225, 184, 3, 4, 5, 6, 9,
2801 25, 26, 27, 40, 41, 59, 165, 168, 170, 172,
2802 215, 241, 242, 243, 162, 243, 243, 243, 197, 208,
2803 208, 208, 208, 162, 202, 162, 202, 243, 165, 162,
2804 162, 162, 162, 162, 162, 243, 243, 243, 243, 243,
2805 38, 197, 208, 244, 4, 141, 142, 143, 144, 146,
2806 150, 151, 153, 154, 155, 198, 226, 227, 38, 159,
2807 159, 159, 159, 214, 214, 214, 214, 214, 214, 214,
2808 162, 167, 171, 208, 216, 169, 171, 214, 214, 214,
2809 162, 205, 159, 61, 240, 167, 216, 170, 216, 171,
2810 216, 22, 244, 162, 162, 210, 243, 243, 243, 243,
2811 11, 54, 11, 254, 243, 165, 244, 208, 244, 244,
2812 244, 162, 162, 255, 162, 162, 162, 208, 210, 243,
2813 162, 205, 205, 208, 214, 214, 214, 214, 254, 162,
2814 162, 162, 162, 255, 162, 214, 169, 171, 162, 162,
2815 38, 34, 54, 203, 206, 39, 208, 232, 233, 22,
2816 167, 171, 216, 169, 171, 17, 17, 243, 162, 162,
2817 162, 162, 243, 4, 243, 162, 162, 243, 162, 162,
2818 162, 4, 4, 162, 208, 243, 243, 243, 162, 202,
2819 208, 160, 162, 162, 162, 162, 160, 214, 214, 214,
2820 214, 160, 214, 169, 214, 214, 208, 22, 4, 205,
2821 195, 162, 160, 162, 169, 171, 243, 243, 159, 243,
2822 243, 243, 243, 202, 202, 244, 243, 162, 244, 244,
2823 244, 4, 243, 159, 243, 214, 214, 214, 214, 162,
2824 160, 162, 162, 255, 160, 160, 160, 179, 180, 39,
2825 208, 199, 22, 169, 162, 165, 17, 208, 253, 167,
2826 243, 255, 253, 202, 160, 160, 160, 160, 214, 214,
2827 214, 160, 195, 203, 204, 17, 11, 167, 250, 195,
2828 195, 160, 162, 167, 160, 160, 160, 160, 180, 54,
2829 201, 243, 241, 11, 167, 121, 122, 243, 243, 199,
2830 17, 208, 199, 4, 152, 200, 162, 241, 195, 195,
2831 38, 195, 195, 22, 17, 162, 17, 243, 243, 243,
2832 17, 243, 195, 195, 243, 73, 17, 243
Dan Gohman54392c12008-04-19 00:24:39 +00002833};
David Greene9145dd22007-08-01 03:59:32 +00002834
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002835#define yyerrok (yyerrstatus = 0)
2836#define yyclearin (yychar = YYEMPTY)
Dan Gohman54392c12008-04-19 00:24:39 +00002837#define YYEMPTY (-2)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002838#define YYEOF 0
Dan Gohman54392c12008-04-19 00:24:39 +00002839
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002840#define YYACCEPT goto yyacceptlab
Dan Gohman54392c12008-04-19 00:24:39 +00002841#define YYABORT goto yyabortlab
2842#define YYERROR goto yyerrorlab
2843
2844
2845/* Like YYERROR except do call yyerror. This remains here temporarily
2846 to ease the transition to the new meaning of YYERROR, for GCC.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002847 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohman54392c12008-04-19 00:24:39 +00002848
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002849#define YYFAIL goto yyerrlab
Dan Gohman54392c12008-04-19 00:24:39 +00002850
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002851#define YYRECOVERING() (!!yyerrstatus)
Dan Gohman54392c12008-04-19 00:24:39 +00002852
2853#define YYBACKUP(Token, Value) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854do \
2855 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohman54392c12008-04-19 00:24:39 +00002856 { \
2857 yychar = (Token); \
2858 yylval = (Value); \
2859 yytoken = YYTRANSLATE (yychar); \
2860 YYPOPSTACK (1); \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002861 goto yybackup; \
2862 } \
2863 else \
Dan Gohman54392c12008-04-19 00:24:39 +00002864 { \
2865 yyerror (YY_("syntax error: cannot back up")); \
2866 YYERROR; \
2867 } \
2868while (YYID (0))
2869
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002870
2871#define YYTERROR 1
2872#define YYERRCODE 256
2873
Dan Gohman54392c12008-04-19 00:24:39 +00002874
2875/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2876 If N is 0, then set CURRENT to the empty location which ends
2877 the previous symbol: RHS[0] (always defined). */
2878
2879#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2880#ifndef YYLLOC_DEFAULT
2881# define YYLLOC_DEFAULT(Current, Rhs, N) \
2882 do \
2883 if (YYID (N)) \
2884 { \
2885 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2886 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2887 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2888 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2889 } \
2890 else \
2891 { \
2892 (Current).first_line = (Current).last_line = \
2893 YYRHSLOC (Rhs, 0).last_line; \
2894 (Current).first_column = (Current).last_column = \
2895 YYRHSLOC (Rhs, 0).last_column; \
2896 } \
2897 while (YYID (0))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002898#endif
2899
Dan Gohman54392c12008-04-19 00:24:39 +00002900
2901/* YY_LOCATION_PRINT -- Print the location on the stream.
2902 This macro was not mandated originally: define only if we know
2903 we won't break user code: when these are the locations we know. */
2904
2905#ifndef YY_LOCATION_PRINT
Chris Lattner5a0f2fe2008-10-08 06:44:45 +00002906# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
Dan Gohman54392c12008-04-19 00:24:39 +00002907# define YY_LOCATION_PRINT(File, Loc) \
2908 fprintf (File, "%d.%d-%d.%d", \
2909 (Loc).first_line, (Loc).first_column, \
2910 (Loc).last_line, (Loc).last_column)
2911# else
2912# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2913# endif
2914#endif
2915
2916
2917/* YYLEX -- calling `yylex' with the right arguments. */
2918
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002919#ifdef YYLEX_PARAM
Dan Gohman54392c12008-04-19 00:24:39 +00002920# define YYLEX yylex (YYLEX_PARAM)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002921#else
Dan Gohman54392c12008-04-19 00:24:39 +00002922# define YYLEX yylex ()
Gabor Greif89f01162008-04-06 23:07:54 +00002923#endif
Dan Gohman54392c12008-04-19 00:24:39 +00002924
2925/* Enable debugging if requested. */
2926#if YYDEBUG
2927
2928# ifndef YYFPRINTF
2929# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2930# define YYFPRINTF fprintf
2931# endif
2932
2933# define YYDPRINTF(Args) \
2934do { \
2935 if (yydebug) \
2936 YYFPRINTF Args; \
2937} while (YYID (0))
2938
2939# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2940do { \
2941 if (yydebug) \
2942 { \
2943 YYFPRINTF (stderr, "%s ", Title); \
2944 yy_symbol_print (stderr, \
2945 Type, Value); \
2946 YYFPRINTF (stderr, "\n"); \
2947 } \
2948} while (YYID (0))
2949
2950
2951/*--------------------------------.
2952| Print this symbol on YYOUTPUT. |
2953`--------------------------------*/
2954
2955/*ARGSUSED*/
2956#if (defined __STDC__ || defined __C99__FUNC__ \
2957 || defined __cplusplus || defined _MSC_VER)
2958static void
2959yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greif89f01162008-04-06 23:07:54 +00002960#else
Dan Gohman54392c12008-04-19 00:24:39 +00002961static void
2962yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2963 FILE *yyoutput;
2964 int yytype;
2965 YYSTYPE const * const yyvaluep;
Gabor Greif89f01162008-04-06 23:07:54 +00002966#endif
Dan Gohman54392c12008-04-19 00:24:39 +00002967{
2968 if (!yyvaluep)
2969 return;
2970# ifdef YYPRINT
2971 if (yytype < YYNTOKENS)
2972 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2973# else
2974 YYUSE (yyoutput);
2975# endif
2976 switch (yytype)
2977 {
2978 default:
2979 break;
2980 }
2981}
2982
2983
2984/*--------------------------------.
2985| Print this symbol on YYOUTPUT. |
2986`--------------------------------*/
2987
2988#if (defined __STDC__ || defined __C99__FUNC__ \
2989 || defined __cplusplus || defined _MSC_VER)
2990static void
2991yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2992#else
2993static void
2994yy_symbol_print (yyoutput, yytype, yyvaluep)
2995 FILE *yyoutput;
2996 int yytype;
2997 YYSTYPE const * const yyvaluep;
Scott Michel6d1aba82008-01-30 03:10:00 +00002998#endif
Dan Gohman54392c12008-04-19 00:24:39 +00002999{
3000 if (yytype < YYNTOKENS)
3001 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3002 else
3003 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner59363a32008-02-19 04:36:25 +00003004
Dan Gohman54392c12008-04-19 00:24:39 +00003005 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3006 YYFPRINTF (yyoutput, ")");
3007}
Chris Lattner59363a32008-02-19 04:36:25 +00003008
Dan Gohman54392c12008-04-19 00:24:39 +00003009/*------------------------------------------------------------------.
3010| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3011| TOP (included). |
3012`------------------------------------------------------------------*/
Chris Lattner59363a32008-02-19 04:36:25 +00003013
Dan Gohman54392c12008-04-19 00:24:39 +00003014#if (defined __STDC__ || defined __C99__FUNC__ \
3015 || defined __cplusplus || defined _MSC_VER)
3016static void
3017yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3018#else
3019static void
3020yy_stack_print (bottom, top)
3021 yytype_int16 *bottom;
3022 yytype_int16 *top;
Scott Michel6d1aba82008-01-30 03:10:00 +00003023#endif
Dan Gohman54392c12008-04-19 00:24:39 +00003024{
3025 YYFPRINTF (stderr, "Stack now");
3026 for (; bottom <= top; ++bottom)
3027 YYFPRINTF (stderr, " %d", *bottom);
3028 YYFPRINTF (stderr, "\n");
3029}
Chris Lattner59363a32008-02-19 04:36:25 +00003030
Dan Gohman54392c12008-04-19 00:24:39 +00003031# define YY_STACK_PRINT(Bottom, Top) \
3032do { \
3033 if (yydebug) \
3034 yy_stack_print ((Bottom), (Top)); \
3035} while (YYID (0))
Chris Lattner59363a32008-02-19 04:36:25 +00003036
Dan Gohman54392c12008-04-19 00:24:39 +00003037
3038/*------------------------------------------------.
3039| Report that the YYRULE is going to be reduced. |
3040`------------------------------------------------*/
3041
3042#if (defined __STDC__ || defined __C99__FUNC__ \
3043 || defined __cplusplus || defined _MSC_VER)
3044static void
3045yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3046#else
3047static void
3048yy_reduce_print (yyvsp, yyrule)
3049 YYSTYPE *yyvsp;
3050 int yyrule;
Christopher Lamb0a243582007-12-11 09:02:08 +00003051#endif
Dan Gohman54392c12008-04-19 00:24:39 +00003052{
3053 int yynrhs = yyr2[yyrule];
3054 int yyi;
3055 unsigned long int yylno = yyrline[yyrule];
3056 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3057 yyrule - 1, yylno);
3058 /* The symbols being reduced. */
3059 for (yyi = 0; yyi < yynrhs; yyi++)
3060 {
3061 fprintf (stderr, " $%d = ", yyi + 1);
3062 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3063 &(yyvsp[(yyi + 1) - (yynrhs)])
3064 );
3065 fprintf (stderr, "\n");
3066 }
3067}
Scott Michel5a6f17b2008-01-30 02:55:46 +00003068
Dan Gohman54392c12008-04-19 00:24:39 +00003069# define YY_REDUCE_PRINT(Rule) \
3070do { \
3071 if (yydebug) \
3072 yy_reduce_print (yyvsp, Rule); \
3073} while (YYID (0))
Scott Michel5a6f17b2008-01-30 02:55:46 +00003074
Dan Gohman54392c12008-04-19 00:24:39 +00003075/* Nonzero means print parse trace. It is left uninitialized so that
3076 multiple parsers can coexist. */
3077int yydebug;
3078#else /* !YYDEBUG */
3079# define YYDPRINTF(Args)
3080# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3081# define YY_STACK_PRINT(Bottom, Top)
3082# define YY_REDUCE_PRINT(Rule)
3083#endif /* !YYDEBUG */
3084
3085
3086/* YYINITDEPTH -- initial size of the parser's stacks. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003087#ifndef YYINITDEPTH
Dan Gohman54392c12008-04-19 00:24:39 +00003088# define YYINITDEPTH 200
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003089#endif
3090
Dan Gohman54392c12008-04-19 00:24:39 +00003091/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3092 if the built-in stack extension method is used).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003093
Dan Gohman54392c12008-04-19 00:24:39 +00003094 Do not make this value too large; the results are undefined if
3095 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3096 evaluated with infinite-precision integer arithmetic. */
David Greene9145dd22007-08-01 03:59:32 +00003097
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003098#ifndef YYMAXDEPTH
Dan Gohman54392c12008-04-19 00:24:39 +00003099# define YYMAXDEPTH 10000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003100#endif
Dan Gohman54392c12008-04-19 00:24:39 +00003101
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003102
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003103
Dan Gohman54392c12008-04-19 00:24:39 +00003104#if YYERROR_VERBOSE
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003105
Dan Gohman54392c12008-04-19 00:24:39 +00003106# ifndef yystrlen
3107# if defined __GLIBC__ && defined _STRING_H
3108# define yystrlen strlen
3109# else
3110/* Return the length of YYSTR. */
3111#if (defined __STDC__ || defined __C99__FUNC__ \
3112 || defined __cplusplus || defined _MSC_VER)
3113static YYSIZE_T
3114yystrlen (const char *yystr)
Chris Lattner59363a32008-02-19 04:36:25 +00003115#else
Dan Gohman54392c12008-04-19 00:24:39 +00003116static YYSIZE_T
3117yystrlen (yystr)
3118 const char *yystr;
3119#endif
3120{
3121 YYSIZE_T yylen;
3122 for (yylen = 0; yystr[yylen]; yylen++)
3123 continue;
3124 return yylen;
3125}
3126# endif
3127# endif
3128
3129# ifndef yystpcpy
3130# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3131# define yystpcpy stpcpy
3132# else
3133/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3134 YYDEST. */
3135#if (defined __STDC__ || defined __C99__FUNC__ \
3136 || defined __cplusplus || defined _MSC_VER)
3137static char *
3138yystpcpy (char *yydest, const char *yysrc)
3139#else
3140static char *
3141yystpcpy (yydest, yysrc)
3142 char *yydest;
3143 const char *yysrc;
3144#endif
3145{
3146 char *yyd = yydest;
3147 const char *yys = yysrc;
3148
3149 while ((*yyd++ = *yys++) != '\0')
3150 continue;
3151
3152 return yyd - 1;
3153}
3154# endif
3155# endif
3156
3157# ifndef yytnamerr
3158/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3159 quotes and backslashes, so that it's suitable for yyerror. The
3160 heuristic is that double-quoting is unnecessary unless the string
3161 contains an apostrophe, a comma, or backslash (other than
3162 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3163 null, do not copy; instead, return the length of what the result
3164 would have been. */
3165static YYSIZE_T
3166yytnamerr (char *yyres, const char *yystr)
3167{
3168 if (*yystr == '"')
3169 {
3170 YYSIZE_T yyn = 0;
3171 char const *yyp = yystr;
3172
3173 for (;;)
3174 switch (*++yyp)
3175 {
3176 case '\'':
3177 case ',':
3178 goto do_not_strip_quotes;
3179
3180 case '\\':
3181 if (*++yyp != '\\')
3182 goto do_not_strip_quotes;
3183 /* Fall through. */
3184 default:
3185 if (yyres)
3186 yyres[yyn] = *yyp;
3187 yyn++;
3188 break;
3189
3190 case '"':
3191 if (yyres)
3192 yyres[yyn] = '\0';
3193 return yyn;
3194 }
3195 do_not_strip_quotes: ;
3196 }
3197
3198 if (! yyres)
3199 return yystrlen (yystr);
3200
3201 return yystpcpy (yyres, yystr) - yyres;
3202}
3203# endif
3204
3205/* Copy into YYRESULT an error message about the unexpected token
3206 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3207 including the terminating null byte. If YYRESULT is null, do not
3208 copy anything; just return the number of bytes that would be
3209 copied. As a special case, return 0 if an ordinary "syntax error"
3210 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3211 size calculation. */
3212static YYSIZE_T
3213yysyntax_error (char *yyresult, int yystate, int yychar)
3214{
3215 int yyn = yypact[yystate];
3216
3217 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3218 return 0;
3219 else
3220 {
3221 int yytype = YYTRANSLATE (yychar);
3222 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3223 YYSIZE_T yysize = yysize0;
3224 YYSIZE_T yysize1;
3225 int yysize_overflow = 0;
3226 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3227 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3228 int yyx;
3229
3230# if 0
3231 /* This is so xgettext sees the translatable formats that are
3232 constructed on the fly. */
3233 YY_("syntax error, unexpected %s");
3234 YY_("syntax error, unexpected %s, expecting %s");
3235 YY_("syntax error, unexpected %s, expecting %s or %s");
3236 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3237 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3238# endif
3239 char *yyfmt;
3240 char const *yyf;
3241 static char const yyunexpected[] = "syntax error, unexpected %s";
3242 static char const yyexpecting[] = ", expecting %s";
3243 static char const yyor[] = " or %s";
3244 char yyformat[sizeof yyunexpected
3245 + sizeof yyexpecting - 1
3246 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3247 * (sizeof yyor - 1))];
3248 char const *yyprefix = yyexpecting;
3249
3250 /* Start YYX at -YYN if negative to avoid negative indexes in
3251 YYCHECK. */
3252 int yyxbegin = yyn < 0 ? -yyn : 0;
3253
3254 /* Stay within bounds of both yycheck and yytname. */
3255 int yychecklim = YYLAST - yyn + 1;
3256 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3257 int yycount = 1;
3258
3259 yyarg[0] = yytname[yytype];
3260 yyfmt = yystpcpy (yyformat, yyunexpected);
3261
3262 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3263 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3264 {
3265 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3266 {
3267 yycount = 1;
3268 yysize = yysize0;
3269 yyformat[sizeof yyunexpected - 1] = '\0';
3270 break;
3271 }
3272 yyarg[yycount++] = yytname[yyx];
3273 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3274 yysize_overflow |= (yysize1 < yysize);
3275 yysize = yysize1;
3276 yyfmt = yystpcpy (yyfmt, yyprefix);
3277 yyprefix = yyor;
3278 }
3279
3280 yyf = YY_(yyformat);
3281 yysize1 = yysize + yystrlen (yyf);
3282 yysize_overflow |= (yysize1 < yysize);
3283 yysize = yysize1;
3284
3285 if (yysize_overflow)
3286 return YYSIZE_MAXIMUM;
3287
3288 if (yyresult)
3289 {
3290 /* Avoid sprintf, as that infringes on the user's name space.
3291 Don't have undefined behavior even if the translation
3292 produced a string with the wrong number of "%s"s. */
3293 char *yyp = yyresult;
3294 int yyi = 0;
3295 while ((*yyp = *yyf) != '\0')
3296 {
3297 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3298 {
3299 yyp += yytnamerr (yyp, yyarg[yyi++]);
3300 yyf += 2;
3301 }
3302 else
3303 {
3304 yyp++;
3305 yyf++;
3306 }
3307 }
3308 }
3309 return yysize;
3310 }
3311}
3312#endif /* YYERROR_VERBOSE */
3313
3314
3315/*-----------------------------------------------.
3316| Release the memory associated to this symbol. |
3317`-----------------------------------------------*/
3318
3319/*ARGSUSED*/
3320#if (defined __STDC__ || defined __C99__FUNC__ \
3321 || defined __cplusplus || defined _MSC_VER)
3322static void
3323yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3324#else
3325static void
3326yydestruct (yymsg, yytype, yyvaluep)
3327 const char *yymsg;
3328 int yytype;
3329 YYSTYPE *yyvaluep;
3330#endif
3331{
3332 YYUSE (yyvaluep);
3333
3334 if (!yymsg)
3335 yymsg = "Deleting";
3336 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3337
3338 switch (yytype)
3339 {
3340
3341 default:
3342 break;
3343 }
3344}
3345
3346
3347/* Prevent warnings from -Wmissing-prototypes. */
3348
3349#ifdef YYPARSE_PARAM
3350#if defined __STDC__ || defined __cplusplus
3351int yyparse (void *YYPARSE_PARAM);
3352#else
3353int yyparse ();
3354#endif
3355#else /* ! YYPARSE_PARAM */
3356#if defined __STDC__ || defined __cplusplus
David Greene48556392007-09-04 18:46:50 +00003357int yyparse (void);
Gabor Greif89f01162008-04-06 23:07:54 +00003358#else
Dan Gohman54392c12008-04-19 00:24:39 +00003359int yyparse ();
Scott Michel6d1aba82008-01-30 03:10:00 +00003360#endif
Dan Gohman54392c12008-04-19 00:24:39 +00003361#endif /* ! YYPARSE_PARAM */
Scott Michel5a6f17b2008-01-30 02:55:46 +00003362
Chris Lattner59363a32008-02-19 04:36:25 +00003363
Dan Gohman54392c12008-04-19 00:24:39 +00003364
3365/* The look-ahead symbol. */
3366int yychar;
3367
3368/* The semantic value of the look-ahead symbol. */
3369YYSTYPE yylval;
3370
3371/* Number of syntax errors so far. */
3372int yynerrs;
3373
3374
3375
3376/*----------.
3377| yyparse. |
3378`----------*/
3379
3380#ifdef YYPARSE_PARAM
3381#if (defined __STDC__ || defined __C99__FUNC__ \
3382 || defined __cplusplus || defined _MSC_VER)
3383int
3384yyparse (void *YYPARSE_PARAM)
3385#else
3386int
3387yyparse (YYPARSE_PARAM)
3388 void *YYPARSE_PARAM;
3389#endif
3390#else /* ! YYPARSE_PARAM */
3391#if (defined __STDC__ || defined __C99__FUNC__ \
3392 || defined __cplusplus || defined _MSC_VER)
3393int
3394yyparse (void)
3395#else
3396int
3397yyparse ()
3398
Gabor Greif89f01162008-04-06 23:07:54 +00003399#endif
3400#endif
Dan Gohman54392c12008-04-19 00:24:39 +00003401{
3402
3403 int yystate;
3404 int yyn;
3405 int yyresult;
3406 /* Number of tokens to shift before error messages enabled. */
3407 int yyerrstatus;
3408 /* Look-ahead token as an internal (translated) token number. */
3409 int yytoken = 0;
3410#if YYERROR_VERBOSE
3411 /* Buffer for error messages, and its allocated size. */
3412 char yymsgbuf[128];
3413 char *yymsg = yymsgbuf;
3414 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greif89f01162008-04-06 23:07:54 +00003415#endif
Chris Lattner59363a32008-02-19 04:36:25 +00003416
Dan Gohman54392c12008-04-19 00:24:39 +00003417 /* Three stacks and their tools:
3418 `yyss': related to states,
3419 `yyvs': related to semantic values,
3420 `yyls': related to locations.
3421
3422 Refer to the stacks thru separate pointers, to allow yyoverflow
3423 to reallocate them elsewhere. */
3424
3425 /* The state stack. */
3426 yytype_int16 yyssa[YYINITDEPTH];
3427 yytype_int16 *yyss = yyssa;
3428 yytype_int16 *yyssp;
3429
3430 /* The semantic value stack. */
3431 YYSTYPE yyvsa[YYINITDEPTH];
3432 YYSTYPE *yyvs = yyvsa;
3433 YYSTYPE *yyvsp;
3434
3435
3436
3437#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3438
3439 YYSIZE_T yystacksize = YYINITDEPTH;
3440
3441 /* The variables used to return semantic value and location from the
3442 action routines. */
3443 YYSTYPE yyval;
3444
3445
3446 /* The number of symbols on the RHS of the reduced rule.
3447 Keep to zero when no symbol should be popped. */
3448 int yylen = 0;
3449
3450 YYDPRINTF ((stderr, "Starting parse\n"));
3451
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003452 yystate = 0;
3453 yyerrstatus = 0;
3454 yynerrs = 0;
3455 yychar = YYEMPTY; /* Cause a token to be read. */
3456
3457 /* Initialize stack pointers.
3458 Waste one element of value and location stack
3459 so that they stay on the same level as the state stack.
3460 The wasted elements are never initialized. */
3461
Dan Gohman54392c12008-04-19 00:24:39 +00003462 yyssp = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003463 yyvsp = yyvs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003464
Dan Gohman54392c12008-04-19 00:24:39 +00003465 goto yysetstate;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003466
Dan Gohman54392c12008-04-19 00:24:39 +00003467/*------------------------------------------------------------.
3468| yynewstate -- Push a new state, which is found in yystate. |
3469`------------------------------------------------------------*/
3470 yynewstate:
3471 /* In all cases, when you get here, the value and location stacks
3472 have just been pushed. So pushing a state here evens the stacks. */
3473 yyssp++;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003474
Dan Gohman54392c12008-04-19 00:24:39 +00003475 yysetstate:
3476 *yyssp = yystate;
3477
3478 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003479 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003480 /* Get the current used size of the three stacks, in elements. */
Dan Gohman54392c12008-04-19 00:24:39 +00003481 YYSIZE_T yysize = yyssp - yyss + 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003482
3483#ifdef yyoverflow
Dan Gohman54392c12008-04-19 00:24:39 +00003484 {
3485 /* Give user a chance to reallocate the stack. Use copies of
3486 these so that the &'s don't force the real ones into
3487 memory. */
3488 YYSTYPE *yyvs1 = yyvs;
3489 yytype_int16 *yyss1 = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003490
Dan Gohman54392c12008-04-19 00:24:39 +00003491
3492 /* Each stack pointer address is followed by the size of the
3493 data in use in that stack, in bytes. This used to be a
3494 conditional around just the two extra args, but that might
3495 be undefined if yyoverflow is a macro. */
3496 yyoverflow (YY_("memory exhausted"),
3497 &yyss1, yysize * sizeof (*yyssp),
3498 &yyvs1, yysize * sizeof (*yyvsp),
3499
3500 &yystacksize);
3501
3502 yyss = yyss1;
3503 yyvs = yyvs1;
3504 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003505#else /* no yyoverflow */
Dan Gohman54392c12008-04-19 00:24:39 +00003506# ifndef YYSTACK_RELOCATE
3507 goto yyexhaustedlab;
3508# else
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003509 /* Extend the stack our own way. */
Dan Gohman54392c12008-04-19 00:24:39 +00003510 if (YYMAXDEPTH <= yystacksize)
3511 goto yyexhaustedlab;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003512 yystacksize *= 2;
Dan Gohman54392c12008-04-19 00:24:39 +00003513 if (YYMAXDEPTH < yystacksize)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003514 yystacksize = YYMAXDEPTH;
Dan Gohman54392c12008-04-19 00:24:39 +00003515
3516 {
3517 yytype_int16 *yyss1 = yyss;
3518 union yyalloc *yyptr =
3519 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3520 if (! yyptr)
3521 goto yyexhaustedlab;
3522 YYSTACK_RELOCATE (yyss);
3523 YYSTACK_RELOCATE (yyvs);
3524
3525# undef YYSTACK_RELOCATE
3526 if (yyss1 != yyssa)
3527 YYSTACK_FREE (yyss1);
3528 }
3529# endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003530#endif /* no yyoverflow */
3531
Dan Gohman54392c12008-04-19 00:24:39 +00003532 yyssp = yyss + yysize - 1;
3533 yyvsp = yyvs + yysize - 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003534
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003535
Dan Gohman54392c12008-04-19 00:24:39 +00003536 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3537 (unsigned long int) yystacksize));
3538
3539 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003540 YYABORT;
3541 }
3542
Dan Gohman54392c12008-04-19 00:24:39 +00003543 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003544
3545 goto yybackup;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003546
Dan Gohman54392c12008-04-19 00:24:39 +00003547/*-----------.
3548| yybackup. |
3549`-----------*/
3550yybackup:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003551
Dan Gohman54392c12008-04-19 00:24:39 +00003552 /* Do appropriate processing given the current state. Read a
3553 look-ahead token if we need one and don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003554
Dan Gohman54392c12008-04-19 00:24:39 +00003555 /* First try to decide what to do without reference to look-ahead token. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003556 yyn = yypact[yystate];
Dan Gohman54392c12008-04-19 00:24:39 +00003557 if (yyn == YYPACT_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003558 goto yydefault;
3559
Dan Gohman54392c12008-04-19 00:24:39 +00003560 /* Not known => get a look-ahead token if don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003561
Dan Gohman54392c12008-04-19 00:24:39 +00003562 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003563 if (yychar == YYEMPTY)
3564 {
Dan Gohman54392c12008-04-19 00:24:39 +00003565 YYDPRINTF ((stderr, "Reading a token: "));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003566 yychar = YYLEX;
3567 }
3568
Dan Gohman54392c12008-04-19 00:24:39 +00003569 if (yychar <= YYEOF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003570 {
Dan Gohman54392c12008-04-19 00:24:39 +00003571 yychar = yytoken = YYEOF;
3572 YYDPRINTF ((stderr, "Now at end of input.\n"));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003573 }
3574 else
3575 {
Dan Gohman54392c12008-04-19 00:24:39 +00003576 yytoken = YYTRANSLATE (yychar);
3577 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003578 }
3579
Dan Gohman54392c12008-04-19 00:24:39 +00003580 /* If the proper action on seeing token YYTOKEN is to reduce or to
3581 detect an error, take that action. */
3582 yyn += yytoken;
3583 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003584 goto yydefault;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003585 yyn = yytable[yyn];
Dan Gohman54392c12008-04-19 00:24:39 +00003586 if (yyn <= 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003587 {
Dan Gohman54392c12008-04-19 00:24:39 +00003588 if (yyn == 0 || yyn == YYTABLE_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003589 goto yyerrlab;
3590 yyn = -yyn;
3591 goto yyreduce;
3592 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003593
3594 if (yyn == YYFINAL)
3595 YYACCEPT;
3596
Dan Gohman54392c12008-04-19 00:24:39 +00003597 /* Count tokens shifted since error; after three, turn off error
3598 status. */
3599 if (yyerrstatus)
3600 yyerrstatus--;
Dale Johannesen3afee192007-09-07 21:07:57 +00003601
Dan Gohman54392c12008-04-19 00:24:39 +00003602 /* Shift the look-ahead token. */
3603 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003604
Dan Gohman54392c12008-04-19 00:24:39 +00003605 /* Discard the shifted token unless it is eof. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003606 if (yychar != YYEOF)
3607 yychar = YYEMPTY;
3608
Gabor Greif89f01162008-04-06 23:07:54 +00003609 yystate = yyn;
Dan Gohman54392c12008-04-19 00:24:39 +00003610 *++yyvsp = yylval;
3611
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003612 goto yynewstate;
3613
Gabor Greif89f01162008-04-06 23:07:54 +00003614
Dan Gohman54392c12008-04-19 00:24:39 +00003615/*-----------------------------------------------------------.
3616| yydefault -- do the default action for the current state. |
3617`-----------------------------------------------------------*/
3618yydefault:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003619 yyn = yydefact[yystate];
3620 if (yyn == 0)
3621 goto yyerrlab;
Dan Gohman54392c12008-04-19 00:24:39 +00003622 goto yyreduce;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003623
Dan Gohman54392c12008-04-19 00:24:39 +00003624
3625/*-----------------------------.
3626| yyreduce -- Do a reduction. |
3627`-----------------------------*/
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003628yyreduce:
Dan Gohman54392c12008-04-19 00:24:39 +00003629 /* yyn is the number of a rule to reduce with. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003630 yylen = yyr2[yyn];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003631
Dan Gohman54392c12008-04-19 00:24:39 +00003632 /* If YYLEN is nonzero, implement the default value of the action:
3633 `$$ = $1'.
3634
3635 Otherwise, the following line sets YYVAL to garbage.
3636 This behavior is undocumented and Bison
3637 users should not rely upon it. Assigning to YYVAL
3638 unconditionally makes the parser a bit smaller, and it avoids a
3639 GCC warning that YYVAL may be used uninitialized. */
3640 yyval = yyvsp[1-yylen];
3641
3642
3643 YY_REDUCE_PRINT (yyn);
3644 switch (yyn)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003645 {
Dan Gohman54392c12008-04-19 00:24:39 +00003646 case 29:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003647#line 1149 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003648 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3649 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003650
Dan Gohman54392c12008-04-19 00:24:39 +00003651 case 30:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003652#line 1149 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003653 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3654 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003655
Dan Gohman54392c12008-04-19 00:24:39 +00003656 case 31:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003657#line 1150 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003658 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3659 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003660
Dan Gohman54392c12008-04-19 00:24:39 +00003661 case 32:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003662#line 1150 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003663 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3664 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003665
Dan Gohman54392c12008-04-19 00:24:39 +00003666 case 33:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003667#line 1151 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003668 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3669 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003670
Dan Gohman54392c12008-04-19 00:24:39 +00003671 case 34:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003672#line 1151 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003673 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3674 break;
3675
3676 case 35:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003677#line 1152 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003678 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3679 break;
3680
3681 case 36:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003682#line 1152 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003683 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3684 break;
3685
3686 case 37:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003687#line 1153 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003688 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3689 break;
3690
3691 case 38:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003692#line 1153 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003693 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3694 break;
3695
3696 case 39:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003697#line 1157 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003698 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3699 break;
3700
3701 case 40:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003702#line 1157 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003703 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3704 break;
3705
3706 case 41:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003707#line 1158 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003708 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3709 break;
3710
3711 case 42:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003712#line 1158 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003713 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3714 break;
3715
3716 case 43:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003717#line 1159 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003718 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3719 break;
3720
3721 case 44:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003722#line 1159 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003723 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3724 break;
3725
3726 case 45:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003727#line 1160 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003728 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3729 break;
3730
3731 case 46:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003732#line 1160 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003733 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3734 break;
3735
3736 case 47:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003737#line 1161 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003738 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3739 break;
3740
3741 case 48:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003742#line 1161 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003743 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3744 break;
3745
3746 case 49:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003747#line 1162 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003748 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3749 break;
3750
3751 case 50:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003752#line 1162 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003753 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3754 break;
3755
3756 case 51:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003757#line 1163 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003758 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3759 break;
3760
3761 case 52:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003762#line 1163 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003763 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3764 break;
3765
3766 case 53:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003767#line 1164 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003768 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3769 break;
3770
3771 case 54:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003772#line 1165 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003773 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3774 break;
3775
Chris Lattnerc5320232008-10-15 06:16:57 +00003776 case 59:
3777#line 1169 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003778 { (yyval.StrVal) = 0; ;}
3779 break;
3780
Chris Lattnerc5320232008-10-15 06:16:57 +00003781 case 60:
3782#line 1171 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003783 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3784 break;
3785
Chris Lattnerc5320232008-10-15 06:16:57 +00003786 case 61:
3787#line 1172 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003788 { (yyval.UIntVal)=0; ;}
3789 break;
3790
Chris Lattnerc5320232008-10-15 06:16:57 +00003791 case 62:
3792#line 1176 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003793 {
3794 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003795 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003796 ;}
3797 break;
3798
Chris Lattnerc5320232008-10-15 06:16:57 +00003799 case 63:
3800#line 1180 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3801 {
3802 (yyval.StrVal) = 0;
3803 CHECK_FOR_ERROR
3804 ;}
3805 break;
3806
3807 case 64:
3808#line 1185 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3809 {
3810 (yyval.UIntVal) = (yyvsp[(1) - (2)].UIntVal);
3811 CHECK_FOR_ERROR
3812;}
3813 break;
3814
Chris Lattner8f5544c2008-10-15 06:03:48 +00003815 case 68:
Chris Lattnerc5320232008-10-15 06:16:57 +00003816#line 1194 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003817 {
3818 (yyval.StrVal) = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003819 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003820 ;}
3821 break;
3822
Chris Lattner8f5544c2008-10-15 06:03:48 +00003823 case 69:
Chris Lattnerc5320232008-10-15 06:16:57 +00003824#line 1199 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003825 {
3826 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00003827 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003828 ;}
3829 break;
3830
Chris Lattnerc5320232008-10-15 06:16:57 +00003831 case 70:
3832#line 1205 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003833 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3834 break;
3835
Chris Lattnerc5320232008-10-15 06:16:57 +00003836 case 71:
3837#line 1206 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003838 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3839 break;
3840
Chris Lattnerc5320232008-10-15 06:16:57 +00003841 case 72:
3842#line 1207 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003843 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3844 break;
3845
Chris Lattnerc5320232008-10-15 06:16:57 +00003846 case 73:
3847#line 1208 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003848 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3849 break;
3850
Chris Lattnerc5320232008-10-15 06:16:57 +00003851 case 74:
3852#line 1209 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003853 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3854 break;
3855
Chris Lattnerc5320232008-10-15 06:16:57 +00003856 case 75:
3857#line 1210 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen280e7bc2008-05-14 20:13:36 +00003858 { (yyval.Linkage) = GlobalValue::CommonLinkage; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00003859 break;
3860
Chris Lattnerc5320232008-10-15 06:16:57 +00003861 case 76:
3862#line 1214 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen280e7bc2008-05-14 20:13:36 +00003863 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00003864 break;
3865
Chris Lattnerc5320232008-10-15 06:16:57 +00003866 case 77:
3867#line 1215 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen280e7bc2008-05-14 20:13:36 +00003868 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00003869 break;
3870
Chris Lattnerc5320232008-10-15 06:16:57 +00003871 case 78:
3872#line 1216 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3873 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3874 break;
3875
3876 case 79:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003877#line 1220 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerc5320232008-10-15 06:16:57 +00003878 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3879 break;
3880
3881 case 80:
3882#line 1221 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3883 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3884 break;
3885
3886 case 81:
3887#line 1222 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3888 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3889 break;
3890
3891 case 82:
3892#line 1223 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3893 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3894 break;
3895
3896 case 83:
3897#line 1227 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen280e7bc2008-05-14 20:13:36 +00003898 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00003899 break;
3900
Chris Lattner8f5544c2008-10-15 06:03:48 +00003901 case 84:
Chris Lattnerc5320232008-10-15 06:16:57 +00003902#line 1228 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00003903 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohmane5febe42008-05-31 00:58:22 +00003904 break;
3905
Chris Lattnerc5320232008-10-15 06:16:57 +00003906 case 85:
3907#line 1229 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00003908 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohmane5febe42008-05-31 00:58:22 +00003909 break;
3910
Chris Lattnerc5320232008-10-15 06:16:57 +00003911 case 86:
3912#line 1233 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3913 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3914 break;
3915
3916 case 87:
3917#line 1234 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3918 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3919 break;
3920
3921 case 88:
3922#line 1235 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3923 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3924 break;
3925
3926 case 89:
3927#line 1236 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3928 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3929 break;
3930
3931 case 90:
Chris Lattner8f5544c2008-10-15 06:03:48 +00003932#line 1237 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerc5320232008-10-15 06:16:57 +00003933 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3934 break;
3935
3936 case 91:
3937#line 1241 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane5febe42008-05-31 00:58:22 +00003938 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3939 break;
3940
Chris Lattner8f5544c2008-10-15 06:03:48 +00003941 case 92:
Chris Lattnerc5320232008-10-15 06:16:57 +00003942#line 1242 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3943 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Chris Lattner8f5544c2008-10-15 06:03:48 +00003944 break;
3945
Chris Lattner906773a2008-08-29 17:20:18 +00003946 case 93:
Chris Lattnerc5320232008-10-15 06:16:57 +00003947#line 1243 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00003948 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00003949 break;
3950
Chris Lattnerc5320232008-10-15 06:16:57 +00003951 case 94:
3952#line 1246 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8f5544c2008-10-15 06:03:48 +00003953 { (yyval.UIntVal) = CallingConv::C; ;}
3954 break;
3955
Chris Lattnerc5320232008-10-15 06:16:57 +00003956 case 95:
3957#line 1247 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen280e7bc2008-05-14 20:13:36 +00003958 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00003959 break;
3960
Chris Lattnerc5320232008-10-15 06:16:57 +00003961 case 96:
3962#line 1248 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00003963 { (yyval.UIntVal) = CallingConv::Fast; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00003964 break;
3965
Chris Lattnerc5320232008-10-15 06:16:57 +00003966 case 97:
3967#line 1249 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00003968 { (yyval.UIntVal) = CallingConv::Cold; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00003969 break;
3970
Chris Lattnerc5320232008-10-15 06:16:57 +00003971 case 98:
3972#line 1250 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00003973 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Dale Johannesen280e7bc2008-05-14 20:13:36 +00003974 break;
3975
Chris Lattnerc5320232008-10-15 06:16:57 +00003976 case 99:
3977#line 1251 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00003978 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Dale Johannesen9cdf0652008-08-13 18:41:46 +00003979 break;
3980
Chris Lattnerc5320232008-10-15 06:16:57 +00003981 case 100:
3982#line 1252 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003983 {
3984 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003985 GEN_ERROR("Calling conv too large");
Dan Gohman54392c12008-04-19 00:24:39 +00003986 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003987 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003988 ;}
3989 break;
3990
Chris Lattnerc5320232008-10-15 06:16:57 +00003991 case 101:
3992#line 1259 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3993 { (yyval.Attributes) = Attribute::ZExt; ;}
3994 break;
3995
3996 case 102:
3997#line 1260 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3998 { (yyval.Attributes) = Attribute::ZExt; ;}
3999 break;
4000
4001 case 103:
4002#line 1261 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4003 { (yyval.Attributes) = Attribute::SExt; ;}
4004 break;
4005
4006 case 104:
4007#line 1262 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4008 { (yyval.Attributes) = Attribute::SExt; ;}
4009 break;
4010
4011 case 105:
Chris Lattner8f5544c2008-10-15 06:03:48 +00004012#line 1263 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004013 { (yyval.Attributes) = Attribute::InReg; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00004014 break;
4015
Chris Lattnerc5320232008-10-15 06:16:57 +00004016 case 106:
4017#line 1264 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004018 { (yyval.Attributes) = Attribute::StructRet; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00004019 break;
4020
Chris Lattnerc5320232008-10-15 06:16:57 +00004021 case 107:
4022#line 1265 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004023 { (yyval.Attributes) = Attribute::NoAlias; ;}
Dale Johannesen280e7bc2008-05-14 20:13:36 +00004024 break;
4025
Chris Lattnerc5320232008-10-15 06:16:57 +00004026 case 108:
4027#line 1266 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004028 { (yyval.Attributes) = Attribute::ByVal; ;}
Dale Johannesen9cdf0652008-08-13 18:41:46 +00004029 break;
4030
Chris Lattnerc5320232008-10-15 06:16:57 +00004031 case 109:
4032#line 1267 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004033 { (yyval.Attributes) = Attribute::Nest; ;}
Chris Lattner906773a2008-08-29 17:20:18 +00004034 break;
4035
Chris Lattnerc5320232008-10-15 06:16:57 +00004036 case 110:
4037#line 1268 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004038 { (yyval.Attributes) =
4039 Attribute::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
Dan Gohman54392c12008-04-19 00:24:39 +00004040 break;
4041
Chris Lattnerc5320232008-10-15 06:16:57 +00004042 case 111:
4043#line 1272 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004044 { (yyval.Attributes) = Attribute::None; ;}
Dan Gohman54392c12008-04-19 00:24:39 +00004045 break;
4046
Chris Lattnerc5320232008-10-15 06:16:57 +00004047 case 112:
4048#line 1273 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenf4581482008-09-26 19:32:34 +00004049 {
4050 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4051 ;}
4052 break;
4053
Chris Lattnerc5320232008-10-15 06:16:57 +00004054 case 113:
4055#line 1278 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004056 { (yyval.Attributes) = Attribute::InReg; ;}
Chris Lattner906773a2008-08-29 17:20:18 +00004057 break;
4058
Chris Lattnerc5320232008-10-15 06:16:57 +00004059 case 114:
4060#line 1279 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004061 { (yyval.Attributes) = Attribute::ZExt; ;}
Chris Lattner906773a2008-08-29 17:20:18 +00004062 break;
4063
Chris Lattnerc5320232008-10-15 06:16:57 +00004064 case 115:
4065#line 1280 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004066 { (yyval.Attributes) = Attribute::SExt; ;}
Chris Lattner906773a2008-08-29 17:20:18 +00004067 break;
4068
Chris Lattnerc5320232008-10-15 06:16:57 +00004069 case 116:
4070#line 1283 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld222f862008-09-25 21:00:45 +00004071 { (yyval.Attributes) = Attribute::None; ;}
Chris Lattnerf6bbfbc2008-09-23 21:18:31 +00004072 break;
4073
Chris Lattnerc5320232008-10-15 06:16:57 +00004074 case 117:
4075#line 1284 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00004076 {
4077 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4078 ;}
4079 break;
4080
Chris Lattnerc5320232008-10-15 06:16:57 +00004081 case 118:
4082#line 1290 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00004083 { (yyval.Attributes) = Attribute::NoReturn; ;}
4084 break;
4085
Chris Lattnerc5320232008-10-15 06:16:57 +00004086 case 119:
4087#line 1291 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00004088 { (yyval.Attributes) = Attribute::NoUnwind; ;}
4089 break;
4090
Chris Lattnerc5320232008-10-15 06:16:57 +00004091 case 120:
4092#line 1292 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00004093 { (yyval.Attributes) = Attribute::InReg; ;}
4094 break;
4095
Chris Lattnerc5320232008-10-15 06:16:57 +00004096 case 121:
4097#line 1293 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00004098 { (yyval.Attributes) = Attribute::ZExt; ;}
4099 break;
4100
Chris Lattnerc5320232008-10-15 06:16:57 +00004101 case 122:
4102#line 1294 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00004103 { (yyval.Attributes) = Attribute::SExt; ;}
4104 break;
4105
Chris Lattnerc5320232008-10-15 06:16:57 +00004106 case 123:
4107#line 1295 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00004108 { (yyval.Attributes) = Attribute::ReadNone; ;}
4109 break;
4110
Chris Lattnerc5320232008-10-15 06:16:57 +00004111 case 124:
4112#line 1296 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00004113 { (yyval.Attributes) = Attribute::ReadOnly; ;}
4114 break;
4115
Chris Lattnerc5320232008-10-15 06:16:57 +00004116 case 125:
4117#line 1297 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner5a0f2fe2008-10-08 06:44:45 +00004118 { (yyval.Attributes) = Attribute::NoInline; ;}
Devang Patelcd842482008-09-29 20:49:50 +00004119 break;
4120
Chris Lattnerc5320232008-10-15 06:16:57 +00004121 case 126:
4122#line 1298 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner5a0f2fe2008-10-08 06:44:45 +00004123 { (yyval.Attributes) = Attribute::AlwaysInline; ;}
Devang Patelcd842482008-09-29 20:49:50 +00004124 break;
4125
Chris Lattnerc5320232008-10-15 06:16:57 +00004126 case 127:
4127#line 1299 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner5a0f2fe2008-10-08 06:44:45 +00004128 { (yyval.Attributes) = Attribute::OptimizeForSize; ;}
Devang Patelcd842482008-09-29 20:49:50 +00004129 break;
4130
Chris Lattnerc5320232008-10-15 06:16:57 +00004131 case 128:
4132#line 1302 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00004133 { (yyval.Attributes) = Attribute::None; ;}
4134 break;
4135
Chris Lattnerc5320232008-10-15 06:16:57 +00004136 case 129:
4137#line 1303 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00004138 {
Devang Pateld222f862008-09-25 21:00:45 +00004139 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
Chris Lattner906773a2008-08-29 17:20:18 +00004140 ;}
Dale Johannesen9cdf0652008-08-13 18:41:46 +00004141 break;
4142
Chris Lattnerc5320232008-10-15 06:16:57 +00004143 case 130:
4144#line 1309 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel5df692d2008-09-02 20:52:40 +00004145 { (yyval.StrVal) = 0; ;}
4146 break;
4147
Chris Lattnerc5320232008-10-15 06:16:57 +00004148 case 131:
4149#line 1310 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004150 {
4151 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4152 ;}
4153 break;
4154
Chris Lattnerc5320232008-10-15 06:16:57 +00004155 case 132:
4156#line 1317 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004157 { (yyval.UIntVal) = 0; ;}
4158 break;
4159
Chris Lattnerc5320232008-10-15 06:16:57 +00004160 case 133:
4161#line 1318 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004162 {
4163 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4164 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004165 GEN_ERROR("Alignment must be a power of two");
4166 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004167;}
4168 break;
4169
Chris Lattnerc5320232008-10-15 06:16:57 +00004170 case 134:
4171#line 1324 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004172 { (yyval.UIntVal) = 0; ;}
4173 break;
4174
Chris Lattnerc5320232008-10-15 06:16:57 +00004175 case 135:
4176#line 1325 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004177 {
4178 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4179 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lamb668d9a02007-12-12 08:45:45 +00004180 GEN_ERROR("Alignment must be a power of two");
4181 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004182;}
4183 break;
4184
Chris Lattnerc5320232008-10-15 06:16:57 +00004185 case 136:
4186#line 1334 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004187 {
4188 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
4189 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004190 GEN_ERROR("Invalid character in section name");
Dan Gohman54392c12008-04-19 00:24:39 +00004191 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004192 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004193;}
4194 break;
4195
Chris Lattnerc5320232008-10-15 06:16:57 +00004196 case 137:
4197#line 1342 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004198 { (yyval.StrVal) = 0; ;}
4199 break;
4200
Chris Lattnerc5320232008-10-15 06:16:57 +00004201 case 138:
4202#line 1343 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004203 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4204 break;
4205
Chris Lattnerc5320232008-10-15 06:16:57 +00004206 case 139:
4207#line 1348 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8f5544c2008-10-15 06:03:48 +00004208 {;}
4209 break;
4210
Chris Lattnerc5320232008-10-15 06:16:57 +00004211 case 140:
4212#line 1349 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00004213 {;}
4214 break;
4215
Chris Lattnerc5320232008-10-15 06:16:57 +00004216 case 141:
4217#line 1350 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004218 {
4219 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4220 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004221 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004222 ;}
4223 break;
4224
Chris Lattnerc5320232008-10-15 06:16:57 +00004225 case 142:
4226#line 1355 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004227 {
4228 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004229 GEN_ERROR("Alignment must be a power of two");
Dan Gohman54392c12008-04-19 00:24:39 +00004230 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004231 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004232 ;}
4233 break;
4234
Chris Lattnerc5320232008-10-15 06:16:57 +00004235 case 150:
4236#line 1371 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004237 {
4238 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004239 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004240 ;}
4241 break;
4242
Chris Lattnerc5320232008-10-15 06:16:57 +00004243 case 151:
4244#line 1375 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004245 {
4246 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004247 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004248 ;}
4249 break;
4250
Chris Lattnerc5320232008-10-15 06:16:57 +00004251 case 152:
4252#line 1379 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004253 { // Pointer type?
4254 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lamb668d9a02007-12-12 08:45:45 +00004255 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohman54392c12008-04-19 00:24:39 +00004256 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4257 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00004258 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004259 ;}
4260 break;
4261
Chris Lattnerc5320232008-10-15 06:16:57 +00004262 case 153:
4263#line 1386 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004264 { // Named types are also simple types...
4265 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamb0a243582007-12-11 09:02:08 +00004266 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004267 (yyval.TypeVal) = new PATypeHolder(tmp);
4268 ;}
4269 break;
4270
Chris Lattnerc5320232008-10-15 06:16:57 +00004271 case 154:
4272#line 1391 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004273 { // Type UpReference
4274 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004275 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohman54392c12008-04-19 00:24:39 +00004276 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4277 (yyval.TypeVal) = new PATypeHolder(OT);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004278 UR_OUT("New Upreference!\n");
4279 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004280 ;}
4281 break;
4282
Chris Lattnerc5320232008-10-15 06:16:57 +00004283 case 155:
4284#line 1399 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004285 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004286 // Allow but ignore attributes on function types; this permits auto-upgrade.
4287 // FIXME: remove in LLVM 3.0.
Chris Lattner73de3c02008-04-23 05:37:08 +00004288 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4289 if (!FunctionType::isValidReturnType(RetTy))
4290 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher329d2672008-09-24 04:55:49 +00004291
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004292 std::vector<const Type*> Params;
Dan Gohman54392c12008-04-19 00:24:39 +00004293 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004294 for (; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004295 const Type *Ty = I->Ty->get();
4296 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004297 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004298
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004299 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4300 if (isVarArg) Params.pop_back();
4301
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004302 for (unsigned i = 0; i != Params.size(); ++i)
4303 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4304 GEN_ERROR("Function arguments must be value types!");
4305
4306 CHECK_FOR_ERROR
4307
Anton Korobeynikov0cdd2692007-12-03 19:17:47 +00004308 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohman54392c12008-04-19 00:24:39 +00004309 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
Eric Christopher329d2672008-09-24 04:55:49 +00004310 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Nuno Lopes896f4572008-10-05 16:49:34 +00004311
4312 // Delete the argument list
4313 for (I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin() ; I != E; ++I ) {
4314 delete I->Ty;
4315 }
4316 delete (yyvsp[(3) - (5)].TypeWithAttrsList);
4317
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004318 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004319 ;}
4320 break;
4321
Chris Lattnerc5320232008-10-15 06:16:57 +00004322 case 156:
4323#line 1434 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004324 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004325 // Allow but ignore attributes on function types; this permits auto-upgrade.
4326 // FIXME: remove in LLVM 3.0.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004327 std::vector<const Type*> Params;
Dan Gohman54392c12008-04-19 00:24:39 +00004328 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004329 for ( ; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004330 const Type* Ty = I->Ty->get();
4331 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004332 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004333
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004334 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4335 if (isVarArg) Params.pop_back();
4336
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004337 for (unsigned i = 0; i != Params.size(); ++i)
4338 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4339 GEN_ERROR("Function arguments must be value types!");
4340
4341 CHECK_FOR_ERROR
4342
Dan Gohman54392c12008-04-19 00:24:39 +00004343 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
Eric Christopher329d2672008-09-24 04:55:49 +00004344 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Nuno Lopes896f4572008-10-05 16:49:34 +00004345
4346 // Delete the argument list
4347 for (I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin() ; I != E; ++I ) {
4348 delete I->Ty;
4349 }
4350 delete (yyvsp[(3) - (5)].TypeWithAttrsList);
4351
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004352 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004353 ;}
4354 break;
4355
Chris Lattnerc5320232008-10-15 06:16:57 +00004356 case 157:
4357#line 1465 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004358 { // Sized array type?
Dan Gohmane5febe42008-05-31 00:58:22 +00004359 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (yyvsp[(2) - (5)].UInt64Val))));
Dan Gohman54392c12008-04-19 00:24:39 +00004360 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004361 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004362 ;}
4363 break;
4364
Chris Lattnerc5320232008-10-15 06:16:57 +00004365 case 158:
4366#line 1470 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004367 { // Vector type?
4368 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4369 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004370 GEN_ERROR("Unsigned result not equal to signed result");
4371 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4372 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohman54392c12008-04-19 00:24:39 +00004373 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4374 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004375 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004376 ;}
4377 break;
4378
Chris Lattnerc5320232008-10-15 06:16:57 +00004379 case 159:
4380#line 1480 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004381 { // Structure type?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004382 std::vector<const Type*> Elements;
Dan Gohman54392c12008-04-19 00:24:39 +00004383 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4384 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004385 Elements.push_back(*I);
4386
Dan Gohman54392c12008-04-19 00:24:39 +00004387 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4388 delete (yyvsp[(2) - (3)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004389 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004390 ;}
4391 break;
4392
Chris Lattnerc5320232008-10-15 06:16:57 +00004393 case 160:
4394#line 1490 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004395 { // Empty structure type?
4396 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004397 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004398 ;}
4399 break;
4400
Chris Lattnerc5320232008-10-15 06:16:57 +00004401 case 161:
4402#line 1494 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004403 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004404 std::vector<const Type*> Elements;
Dan Gohman54392c12008-04-19 00:24:39 +00004405 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4406 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004407 Elements.push_back(*I);
4408
Dan Gohman54392c12008-04-19 00:24:39 +00004409 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4410 delete (yyvsp[(3) - (5)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004411 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004412 ;}
4413 break;
4414
Chris Lattnerc5320232008-10-15 06:16:57 +00004415 case 162:
4416#line 1504 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004417 { // Empty structure type?
4418 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004419 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004420 ;}
4421 break;
4422
Chris Lattnerc5320232008-10-15 06:16:57 +00004423 case 163:
4424#line 1511 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004425 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004426 // Allow but ignore attributes on function types; this permits auto-upgrade.
4427 // FIXME: remove in LLVM 3.0.
Eric Christopher329d2672008-09-24 04:55:49 +00004428 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
Devang Pateld222f862008-09-25 21:00:45 +00004429 (yyval.TypeWithAttrs).Attrs = Attribute::None;
Dan Gohman54392c12008-04-19 00:24:39 +00004430 ;}
4431 break;
4432
Chris Lattnerc5320232008-10-15 06:16:57 +00004433 case 164:
4434#line 1520 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004435 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004436 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004437 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4438 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004439 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohman54392c12008-04-19 00:24:39 +00004440 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4441 ;}
4442 break;
4443
Chris Lattnerc5320232008-10-15 06:16:57 +00004444 case 165:
4445#line 1527 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004446 {
4447 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4448 ;}
4449 break;
4450
Chris Lattnerc5320232008-10-15 06:16:57 +00004451 case 166:
4452#line 1532 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004453 {
4454 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4455 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004456 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004457 ;}
4458 break;
4459
Chris Lattnerc5320232008-10-15 06:16:57 +00004460 case 167:
4461#line 1537 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004462 {
4463 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004464 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004465 ;}
4466 break;
4467
Chris Lattnerc5320232008-10-15 06:16:57 +00004468 case 169:
4469#line 1545 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004470 {
4471 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Devang Pateld222f862008-09-25 21:00:45 +00004472 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004473 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohman54392c12008-04-19 00:24:39 +00004474 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004475 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004476 ;}
4477 break;
4478
Chris Lattnerc5320232008-10-15 06:16:57 +00004479 case 170:
4480#line 1552 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004481 {
4482 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Devang Pateld222f862008-09-25 21:00:45 +00004483 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004484 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohman54392c12008-04-19 00:24:39 +00004485 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004486 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004487 ;}
4488 break;
4489
Chris Lattnerc5320232008-10-15 06:16:57 +00004490 case 171:
4491#line 1559 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004492 {
4493 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004494 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004495 ;}
4496 break;
4497
Chris Lattnerc5320232008-10-15 06:16:57 +00004498 case 172:
4499#line 1567 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004500 {
4501 (yyval.TypeList) = new std::list<PATypeHolder>();
Eric Christopher329d2672008-09-24 04:55:49 +00004502 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
Dan Gohman54392c12008-04-19 00:24:39 +00004503 delete (yyvsp[(1) - (1)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004504 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004505 ;}
4506 break;
4507
Chris Lattnerc5320232008-10-15 06:16:57 +00004508 case 173:
4509#line 1573 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004510 {
Eric Christopher329d2672008-09-24 04:55:49 +00004511 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohman54392c12008-04-19 00:24:39 +00004512 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004513 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004514 ;}
4515 break;
4516
Chris Lattnerc5320232008-10-15 06:16:57 +00004517 case 174:
4518#line 1585 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004519 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004520 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004521 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4522 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004523 if (ATy == 0)
Eric Christopher329d2672008-09-24 04:55:49 +00004524 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004525 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004526 const Type *ETy = ATy->getElementType();
Dan Gohman7185e4b2008-06-23 18:43:26 +00004527 uint64_t NumElements = ATy->getNumElements();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004528
4529 // Verify that we have the correct size...
Mon P Wang6bde9ec2008-06-25 08:15:39 +00004530 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004531 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Eric Christopher329d2672008-09-24 04:55:49 +00004532 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang6bde9ec2008-06-25 08:15:39 +00004533 utostr(NumElements) + "");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004534
4535 // Verify all elements are correct type!
Dan Gohman54392c12008-04-19 00:24:39 +00004536 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4537 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher329d2672008-09-24 04:55:49 +00004538 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004539 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohman54392c12008-04-19 00:24:39 +00004540 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004541 }
4542
Dan Gohman54392c12008-04-19 00:24:39 +00004543 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4544 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004545 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004546 ;}
4547 break;
4548
Chris Lattnerc5320232008-10-15 06:16:57 +00004549 case 175:
4550#line 1613 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004551 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004552 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004553 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4554 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004555 if (ATy == 0)
Eric Christopher329d2672008-09-24 04:55:49 +00004556 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004557 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004558
Dan Gohman7185e4b2008-06-23 18:43:26 +00004559 uint64_t NumElements = ATy->getNumElements();
Eric Christopher329d2672008-09-24 04:55:49 +00004560 if (NumElements != uint64_t(-1) && NumElements != 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004561 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Mon P Wang6bde9ec2008-06-25 08:15:39 +00004562 " arguments, but has size of " + utostr(NumElements) +"");
Dan Gohman54392c12008-04-19 00:24:39 +00004563 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4564 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004565 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004566 ;}
4567 break;
4568
Chris Lattnerc5320232008-10-15 06:16:57 +00004569 case 176:
4570#line 1629 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004571 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004572 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004573 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4574 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004575 if (ATy == 0)
Eric Christopher329d2672008-09-24 04:55:49 +00004576 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004577 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004578
Dan Gohman7185e4b2008-06-23 18:43:26 +00004579 uint64_t NumElements = ATy->getNumElements();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004580 const Type *ETy = ATy->getElementType();
Mon P Wang6bde9ec2008-06-25 08:15:39 +00004581 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (3)].StrVal)->length())
Eric Christopher329d2672008-09-24 04:55:49 +00004582 GEN_ERROR("Can't build string constant of size " +
Mon P Wang6bde9ec2008-06-25 08:15:39 +00004583 utostr((yyvsp[(3) - (3)].StrVal)->length()) +
4584 " when array has size " + utostr(NumElements) + "");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004585 std::vector<Constant*> Vals;
4586 if (ETy == Type::Int8Ty) {
Mon P Wang6bde9ec2008-06-25 08:15:39 +00004587 for (uint64_t i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
Dan Gohman54392c12008-04-19 00:24:39 +00004588 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004589 } else {
Dan Gohman54392c12008-04-19 00:24:39 +00004590 delete (yyvsp[(3) - (3)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004591 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4592 }
Dan Gohman54392c12008-04-19 00:24:39 +00004593 delete (yyvsp[(3) - (3)].StrVal);
4594 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4595 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004596 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004597 ;}
4598 break;
4599
Chris Lattnerc5320232008-10-15 06:16:57 +00004600 case 177:
4601#line 1656 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004602 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004603 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004604 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4605 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004606 if (PTy == 0)
Eric Christopher329d2672008-09-24 04:55:49 +00004607 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004608 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004609 const Type *ETy = PTy->getElementType();
Dan Gohman7185e4b2008-06-23 18:43:26 +00004610 unsigned NumElements = PTy->getNumElements();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004611
4612 // Verify that we have the correct size...
Mon P Wang6bde9ec2008-06-25 08:15:39 +00004613 if (NumElements != unsigned(-1) && NumElements != (unsigned)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004614 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Eric Christopher329d2672008-09-24 04:55:49 +00004615 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang6bde9ec2008-06-25 08:15:39 +00004616 utostr(NumElements) + "");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004617
4618 // Verify all elements are correct type!
Dan Gohman54392c12008-04-19 00:24:39 +00004619 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4620 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher329d2672008-09-24 04:55:49 +00004621 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004622 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohman54392c12008-04-19 00:24:39 +00004623 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004624 }
4625
Dan Gohman54392c12008-04-19 00:24:39 +00004626 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4627 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004628 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004629 ;}
4630 break;
4631
Chris Lattnerc5320232008-10-15 06:16:57 +00004632 case 178:
4633#line 1684 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004634 {
4635 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004636 if (STy == 0)
Eric Christopher329d2672008-09-24 04:55:49 +00004637 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004638 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004639
Dan Gohman54392c12008-04-19 00:24:39 +00004640 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004641 GEN_ERROR("Illegal number of initializers for structure type");
4642
4643 // Check to ensure that constants are compatible with the type initializer!
Dan Gohman54392c12008-04-19 00:24:39 +00004644 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4645 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004646 GEN_ERROR("Expected type '" +
4647 STy->getElementType(i)->getDescription() +
4648 "' for element #" + utostr(i) +
4649 " of structure initializer");
4650
4651 // Check to ensure that Type is not packed
4652 if (STy->isPacked())
4653 GEN_ERROR("Unpacked Initializer to vector type '" +
4654 STy->getDescription() + "'");
4655
Dan Gohman54392c12008-04-19 00:24:39 +00004656 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4657 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004658 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004659 ;}
4660 break;
4661
Chris Lattnerc5320232008-10-15 06:16:57 +00004662 case 179:
4663#line 1710 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004664 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004665 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004666 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4667 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004668 if (STy == 0)
Eric Christopher329d2672008-09-24 04:55:49 +00004669 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004670 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004671
4672 if (STy->getNumContainedTypes() != 0)
4673 GEN_ERROR("Illegal number of initializers for structure type");
4674
4675 // Check to ensure that Type is not packed
4676 if (STy->isPacked())
4677 GEN_ERROR("Unpacked Initializer to vector type '" +
4678 STy->getDescription() + "'");
4679
Dan Gohman54392c12008-04-19 00:24:39 +00004680 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4681 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004682 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004683 ;}
4684 break;
4685
Chris Lattnerc5320232008-10-15 06:16:57 +00004686 case 180:
4687#line 1730 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004688 {
4689 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004690 if (STy == 0)
Eric Christopher329d2672008-09-24 04:55:49 +00004691 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004692 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004693
Dan Gohman54392c12008-04-19 00:24:39 +00004694 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004695 GEN_ERROR("Illegal number of initializers for structure type");
4696
4697 // Check to ensure that constants are compatible with the type initializer!
Dan Gohman54392c12008-04-19 00:24:39 +00004698 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4699 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004700 GEN_ERROR("Expected type '" +
4701 STy->getElementType(i)->getDescription() +
4702 "' for element #" + utostr(i) +
4703 " of structure initializer");
4704
4705 // Check to ensure that Type is packed
4706 if (!STy->isPacked())
Eric Christopher329d2672008-09-24 04:55:49 +00004707 GEN_ERROR("Vector initializer to non-vector type '" +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004708 STy->getDescription() + "'");
4709
Dan Gohman54392c12008-04-19 00:24:39 +00004710 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4711 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004712 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004713 ;}
4714 break;
4715
Chris Lattnerc5320232008-10-15 06:16:57 +00004716 case 181:
4717#line 1756 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004718 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004719 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004720 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4721 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004722 if (STy == 0)
Eric Christopher329d2672008-09-24 04:55:49 +00004723 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004724 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004725
4726 if (STy->getNumContainedTypes() != 0)
4727 GEN_ERROR("Illegal number of initializers for structure type");
4728
4729 // Check to ensure that Type is packed
4730 if (!STy->isPacked())
Eric Christopher329d2672008-09-24 04:55:49 +00004731 GEN_ERROR("Vector initializer to non-vector type '" +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004732 STy->getDescription() + "'");
4733
Dan Gohman54392c12008-04-19 00:24:39 +00004734 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4735 delete (yyvsp[(1) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004736 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004737 ;}
4738 break;
4739
Chris Lattnerc5320232008-10-15 06:16:57 +00004740 case 182:
4741#line 1776 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004742 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004743 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004744 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4745 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004746 if (PTy == 0)
Eric Christopher329d2672008-09-24 04:55:49 +00004747 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004748 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004749
Dan Gohman54392c12008-04-19 00:24:39 +00004750 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4751 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004752 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004753 ;}
4754 break;
4755
Chris Lattnerc5320232008-10-15 06:16:57 +00004756 case 183:
4757#line 1788 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004758 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004759 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004760 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4761 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4762 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004763 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004764 ;}
4765 break;
4766
Chris Lattnerc5320232008-10-15 06:16:57 +00004767 case 184:
4768#line 1795 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004769 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004770 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004771 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4772 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004773 if (Ty == 0)
Dan Gohman54392c12008-04-19 00:24:39 +00004774 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004775
4776 // ConstExprs can exist in the body of a function, thus creating
4777 // GlobalValues whenever they refer to a variable. Because we are in
4778 // the context of a function, getExistingVal will search the functions
4779 // symbol table instead of the module symbol table for the global symbol,
4780 // which throws things all off. To get around this, we just tell
4781 // getExistingVal that we are at global scope here.
4782 //
4783 Function *SavedCurFn = CurFun.CurrentFunction;
4784 CurFun.CurrentFunction = 0;
4785
Dan Gohman54392c12008-04-19 00:24:39 +00004786 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004787 CHECK_FOR_ERROR
4788
4789 CurFun.CurrentFunction = SavedCurFn;
4790
4791 // If this is an initializer for a constant pointer, which is referencing a
4792 // (currently) undefined variable, create a stub now that shall be replaced
4793 // in the future with the right type of variable.
4794 //
4795 if (V == 0) {
4796 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
4797 const PointerType *PT = cast<PointerType>(Ty);
4798
4799 // First check to see if the forward references value is already created!
4800 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohman54392c12008-04-19 00:24:39 +00004801 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Eric Christopher329d2672008-09-24 04:55:49 +00004802
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004803 if (I != CurModule.GlobalRefs.end()) {
4804 V = I->second; // Placeholder already exists, use it...
Dan Gohman54392c12008-04-19 00:24:39 +00004805 (yyvsp[(2) - (2)].ValIDVal).destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004806 } else {
4807 std::string Name;
Dan Gohman54392c12008-04-19 00:24:39 +00004808 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4809 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4810 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004811 GEN_ERROR("Invalid reference to global");
4812
4813 // Create the forward referenced global.
4814 GlobalValue *GV;
Eric Christopher329d2672008-09-24 04:55:49 +00004815 if (const FunctionType *FTy =
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004816 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greif89f01162008-04-06 23:07:54 +00004817 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4818 CurModule.CurrentModule);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004819 } else {
4820 GV = new GlobalVariable(PT->getElementType(), false,
4821 GlobalValue::ExternalWeakLinkage, 0,
4822 Name, CurModule.CurrentModule);
4823 }
4824
4825 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohman54392c12008-04-19 00:24:39 +00004826 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004827 V = GV;
4828 }
4829 }
4830
Dan Gohman54392c12008-04-19 00:24:39 +00004831 (yyval.ConstVal) = cast<GlobalValue>(V);
4832 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004833 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004834 ;}
4835 break;
4836
Chris Lattnerc5320232008-10-15 06:16:57 +00004837 case 185:
4838#line 1861 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004839 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004840 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004841 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4842 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Eric Christopher329d2672008-09-24 04:55:49 +00004843 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohman54392c12008-04-19 00:24:39 +00004844 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4845 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4846 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004847 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004848 ;}
4849 break;
4850
Chris Lattnerc5320232008-10-15 06:16:57 +00004851 case 186:
4852#line 1871 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004853 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004854 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004855 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4856 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004857 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4858 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohman54392c12008-04-19 00:24:39 +00004859 (yyval.ConstVal) = Constant::getNullValue(Ty);
4860 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004861 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004862 ;}
4863 break;
4864
Chris Lattnerc5320232008-10-15 06:16:57 +00004865 case 187:
4866#line 1881 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004867 { // integral constants
Chris Lattnerc5320232008-10-15 06:16:57 +00004868 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4869 if (!ConstantInt::isValueValidForType(IT, (yyvsp[(2) - (2)].SInt64Val)))
4870 GEN_ERROR("Constant value doesn't fit in type");
4871 (yyval.ConstVal) = ConstantInt::get(IT, (yyvsp[(2) - (2)].SInt64Val), true);
4872 } else {
4873 GEN_ERROR("integer constant must have integer type");
4874 }
4875 delete (yyvsp[(1) - (2)].TypeVal);
4876 CHECK_FOR_ERROR
4877 ;}
4878 break;
4879
4880 case 188:
4881#line 1892 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4882 { // arbitrary precision integer constants
4883 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4884 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > IT->getBitWidth())
4885 GEN_ERROR("Constant value does not fit in type");
4886 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(IT->getBitWidth());
4887 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4888 } else {
4889 GEN_ERROR("integer constant must have integer type");
4890 }
4891 delete (yyvsp[(1) - (2)].TypeVal);
4892 delete (yyvsp[(2) - (2)].APIntVal);
4893 CHECK_FOR_ERROR
4894 ;}
4895 break;
4896
4897 case 189:
4898#line 1905 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4899 { // integral constants
4900 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4901 if (!ConstantInt::isValueValidForType(IT, (yyvsp[(2) - (2)].UInt64Val)))
4902 GEN_ERROR("Constant value doesn't fit in type");
4903 (yyval.ConstVal) = ConstantInt::get(IT, (yyvsp[(2) - (2)].UInt64Val), false);
4904 } else {
4905 GEN_ERROR("integer constant must have integer type");
4906 }
4907 delete (yyvsp[(1) - (2)].TypeVal);
4908 CHECK_FOR_ERROR
4909 ;}
4910 break;
4911
4912 case 190:
4913#line 1916 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4914 { // arbitrary precision integer constants
4915 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4916 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > IT->getBitWidth())
4917 GEN_ERROR("Constant value does not fit in type");
4918 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(IT->getBitWidth());
4919 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4920 } else {
4921 GEN_ERROR("integer constant must have integer type");
4922 }
4923
4924 delete (yyvsp[(2) - (2)].APIntVal);
4925 delete (yyvsp[(1) - (2)].TypeVal);
4926 CHECK_FOR_ERROR
4927 ;}
4928 break;
4929
4930 case 191:
4931#line 1930 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4932 { // Boolean constants
4933 if ((yyvsp[(1) - (2)].TypeVal)->get() != Type::Int1Ty)
4934 GEN_ERROR("Constant true must have type i1");
4935 (yyval.ConstVal) = ConstantInt::getTrue();
4936 delete (yyvsp[(1) - (2)].TypeVal);
4937 CHECK_FOR_ERROR
4938 ;}
4939 break;
4940
4941 case 192:
4942#line 1937 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4943 { // Boolean constants
4944 if ((yyvsp[(1) - (2)].TypeVal)->get() != Type::Int1Ty)
4945 GEN_ERROR("Constant false must have type i1");
4946 (yyval.ConstVal) = ConstantInt::getFalse();
4947 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004948 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004949 ;}
4950 break;
4951
Chris Lattner8f5544c2008-10-15 06:03:48 +00004952 case 193:
Chris Lattnerc5320232008-10-15 06:16:57 +00004953#line 1944 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004954 { // Floating point constants
Chris Lattnerc5320232008-10-15 06:16:57 +00004955 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].TypeVal)->get(), *(yyvsp[(2) - (2)].FPVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004956 GEN_ERROR("Floating point constant invalid for type");
Chris Lattnerc5320232008-10-15 06:16:57 +00004957
Eric Christopher329d2672008-09-24 04:55:49 +00004958 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesen255b8fe2007-09-11 18:33:39 +00004959 // as double. Fix this here. Long double is done right.
Chris Lattnerc5320232008-10-15 06:16:57 +00004960 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].TypeVal)->get()==Type::FloatTy) {
Dale Johannesen5ba85fd2008-10-09 23:01:34 +00004961 bool ignored;
4962 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
4963 &ignored);
4964 }
Chris Lattner05ba86e2008-04-20 00:41:19 +00004965 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Chris Lattnerc5320232008-10-15 06:16:57 +00004966 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohman54392c12008-04-19 00:24:39 +00004967 delete (yyvsp[(2) - (2)].FPVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004968 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004969 ;}
4970 break;
4971
Chris Lattnerc5320232008-10-15 06:16:57 +00004972 case 194:
4973#line 1962 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004974 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004975 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004976 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4977 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4978 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4979 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004980 GEN_ERROR("invalid cast opcode for cast from '" +
4981 Val->getType()->getDescription() + "' to '" +
Eric Christopher329d2672008-09-24 04:55:49 +00004982 DestTy->getDescription() + "'");
Dan Gohman54392c12008-04-19 00:24:39 +00004983 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4984 delete (yyvsp[(5) - (6)].TypeVal);
4985 ;}
4986 break;
4987
Chris Lattnerc5320232008-10-15 06:16:57 +00004988 case 195:
4989#line 1974 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004990 {
4991 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004992 GEN_ERROR("GetElementPtr requires a pointer operand");
4993
4994 const Type *IdxTy =
Dan Gohman8055f772008-05-15 19:50:34 +00004995 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004996 if (!IdxTy)
4997 GEN_ERROR("Index list invalid for constant getelementptr");
4998
4999 SmallVector<Constant*, 8> IdxVec;
Dan Gohman54392c12008-04-19 00:24:39 +00005000 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
5001 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005002 IdxVec.push_back(C);
5003 else
5004 GEN_ERROR("Indices to constant getelementptr must be constants");
5005
Dan Gohman54392c12008-04-19 00:24:39 +00005006 delete (yyvsp[(4) - (5)].ValueList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005007
Dan Gohman54392c12008-04-19 00:24:39 +00005008 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005009 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005010 ;}
5011 break;
5012
Chris Lattnerc5320232008-10-15 06:16:57 +00005013 case 196:
5014#line 1995 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005015 {
5016 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005017 GEN_ERROR("Select condition must be of boolean type");
Dan Gohman54392c12008-04-19 00:24:39 +00005018 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005019 GEN_ERROR("Select operand types must match");
Dan Gohman54392c12008-04-19 00:24:39 +00005020 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005021 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005022 ;}
5023 break;
5024
Chris Lattnerc5320232008-10-15 06:16:57 +00005025 case 197:
5026#line 2003 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005027 {
5028 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005029 GEN_ERROR("Binary operator types must match");
5030 CHECK_FOR_ERROR;
Dan Gohman54392c12008-04-19 00:24:39 +00005031 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
5032 ;}
5033 break;
5034
Chris Lattnerc5320232008-10-15 06:16:57 +00005035 case 198:
5036#line 2009 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005037 {
5038 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005039 GEN_ERROR("Logical operator types must match");
Dan Gohman54392c12008-04-19 00:24:39 +00005040 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
Eric Christopher329d2672008-09-24 04:55:49 +00005041 if (!isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
Dan Gohman54392c12008-04-19 00:24:39 +00005042 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005043 GEN_ERROR("Logical operator requires integral operands");
5044 }
Dan Gohman54392c12008-04-19 00:24:39 +00005045 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005046 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005047 ;}
5048 break;
5049
Chris Lattnerc5320232008-10-15 06:16:57 +00005050 case 199:
5051#line 2020 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005052 {
5053 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005054 GEN_ERROR("icmp operand types must match");
Dan Gohman54392c12008-04-19 00:24:39 +00005055 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5056 ;}
5057 break;
5058
Chris Lattnerc5320232008-10-15 06:16:57 +00005059 case 200:
5060#line 2025 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005061 {
5062 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005063 GEN_ERROR("fcmp operand types must match");
Dan Gohman54392c12008-04-19 00:24:39 +00005064 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5065 ;}
5066 break;
5067
Chris Lattnerc5320232008-10-15 06:16:57 +00005068 case 201:
5069#line 2030 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman646fa482008-05-12 19:01:56 +00005070 {
5071 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5072 GEN_ERROR("vicmp operand types must match");
5073 (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5074 ;}
5075 break;
5076
Chris Lattnerc5320232008-10-15 06:16:57 +00005077 case 202:
5078#line 2035 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman646fa482008-05-12 19:01:56 +00005079 {
5080 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5081 GEN_ERROR("vfcmp operand types must match");
5082 (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5083 ;}
5084 break;
5085
Chris Lattnerc5320232008-10-15 06:16:57 +00005086 case 203:
5087#line 2040 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005088 {
5089 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005090 GEN_ERROR("Invalid extractelement operands");
Dan Gohman54392c12008-04-19 00:24:39 +00005091 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005092 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005093 ;}
5094 break;
5095
Chris Lattnerc5320232008-10-15 06:16:57 +00005096 case 204:
5097#line 2046 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005098 {
5099 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005100 GEN_ERROR("Invalid insertelement operands");
Dan Gohman54392c12008-04-19 00:24:39 +00005101 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005102 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005103 ;}
5104 break;
5105
Chris Lattnerc5320232008-10-15 06:16:57 +00005106 case 205:
5107#line 2052 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005108 {
5109 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005110 GEN_ERROR("Invalid shufflevector operands");
Dan Gohman54392c12008-04-19 00:24:39 +00005111 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005112 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005113 ;}
5114 break;
5115
Chris Lattnerc5320232008-10-15 06:16:57 +00005116 case 206:
5117#line 2058 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane6b1ee62008-05-23 01:55:30 +00005118 {
5119 if (!isa<StructType>((yyvsp[(3) - (5)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (5)].ConstVal)->getType()))
5120 GEN_ERROR("ExtractValue requires an aggregate operand");
5121
Dan Gohmane5febe42008-05-31 00:58:22 +00005122 (yyval.ConstVal) = ConstantExpr::getExtractValue((yyvsp[(3) - (5)].ConstVal), &(*(yyvsp[(4) - (5)].ConstantList))[0], (yyvsp[(4) - (5)].ConstantList)->size());
5123 delete (yyvsp[(4) - (5)].ConstantList);
Dan Gohmane6b1ee62008-05-23 01:55:30 +00005124 CHECK_FOR_ERROR
5125 ;}
5126 break;
5127
Chris Lattnerc5320232008-10-15 06:16:57 +00005128 case 207:
5129#line 2066 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane6b1ee62008-05-23 01:55:30 +00005130 {
5131 if (!isa<StructType>((yyvsp[(3) - (7)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (7)].ConstVal)->getType()))
5132 GEN_ERROR("InsertValue requires an aggregate operand");
5133
Dan Gohmane5febe42008-05-31 00:58:22 +00005134 (yyval.ConstVal) = ConstantExpr::getInsertValue((yyvsp[(3) - (7)].ConstVal), (yyvsp[(5) - (7)].ConstVal), &(*(yyvsp[(6) - (7)].ConstantList))[0], (yyvsp[(6) - (7)].ConstantList)->size());
5135 delete (yyvsp[(6) - (7)].ConstantList);
Dan Gohmane6b1ee62008-05-23 01:55:30 +00005136 CHECK_FOR_ERROR
5137 ;}
5138 break;
5139
Chris Lattnerc5320232008-10-15 06:16:57 +00005140 case 208:
5141#line 2077 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005142 {
5143 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005144 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005145 ;}
5146 break;
5147
Chris Lattnerc5320232008-10-15 06:16:57 +00005148 case 209:
5149#line 2081 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005150 {
5151 (yyval.ConstVector) = new std::vector<Constant*>();
5152 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005153 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005154 ;}
5155 break;
5156
Chris Lattnerc5320232008-10-15 06:16:57 +00005157 case 210:
5158#line 2089 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane6b1ee62008-05-23 01:55:30 +00005159 { (yyval.BoolVal) = false; ;}
Nate Begeman646fa482008-05-12 19:01:56 +00005160 break;
5161
Chris Lattnerc5320232008-10-15 06:16:57 +00005162 case 211:
5163#line 2089 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8f5544c2008-10-15 06:03:48 +00005164 { (yyval.BoolVal) = true; ;}
5165 break;
5166
Chris Lattnerc5320232008-10-15 06:16:57 +00005167 case 212:
5168#line 2092 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00005169 { (yyval.BoolVal) = true; ;}
Dale Johannesen9cdf0652008-08-13 18:41:46 +00005170 break;
5171
Chris Lattnerc5320232008-10-15 06:16:57 +00005172 case 213:
5173#line 2092 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00005174 { (yyval.BoolVal) = false; ;}
5175 break;
5176
Chris Lattnerc5320232008-10-15 06:16:57 +00005177 case 214:
5178#line 2095 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005179 {
5180 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
5181 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattnerbb856a32007-08-06 21:00:46 +00005182 CHECK_FOR_ERROR
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005183 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
5184 if (!Aliasee)
5185 GEN_ERROR("Aliases can be created only to global values");
5186
Dan Gohman54392c12008-04-19 00:24:39 +00005187 (yyval.ConstVal) = Aliasee;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005188 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005189 delete (yyvsp[(1) - (2)].TypeVal);
5190 ;}
5191 break;
5192
Chris Lattnerc5320232008-10-15 06:16:57 +00005193 case 215:
5194#line 2107 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005195 {
5196 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
5197 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
5198 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005199 GEN_ERROR("invalid cast opcode for cast from '" +
5200 Val->getType()->getDescription() + "' to '" +
5201 DestTy->getDescription() + "'");
Eric Christopher329d2672008-09-24 04:55:49 +00005202
Dan Gohman54392c12008-04-19 00:24:39 +00005203 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005204 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005205 delete (yyvsp[(5) - (6)].TypeVal);
5206 ;}
5207 break;
5208
Chris Lattnerc5320232008-10-15 06:16:57 +00005209 case 216:
5210#line 2128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8f5544c2008-10-15 06:03:48 +00005211 {
5212 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5213 CurModule.ModuleDone();
5214 CHECK_FOR_ERROR;
5215 ;}
5216 break;
5217
Chris Lattnerc5320232008-10-15 06:16:57 +00005218 case 217:
5219#line 2133 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00005220 {
5221 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5222 CurModule.ModuleDone();
5223 CHECK_FOR_ERROR;
5224 ;}
Dale Johannesen9cdf0652008-08-13 18:41:46 +00005225 break;
5226
Chris Lattnerc5320232008-10-15 06:16:57 +00005227 case 220:
5228#line 2146 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patelcd842482008-09-29 20:49:50 +00005229 { CurFun.isDeclare = false; ;}
5230 break;
5231
Chris Lattnerc5320232008-10-15 06:16:57 +00005232 case 221:
5233#line 2146 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005234 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005235 CurFun.FunctionDone();
5236 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005237 ;}
5238 break;
5239
Chris Lattnerc5320232008-10-15 06:16:57 +00005240 case 222:
5241#line 2150 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005242 { CurFun.isDeclare = true; ;}
5243 break;
5244
Chris Lattnerc5320232008-10-15 06:16:57 +00005245 case 223:
5246#line 2150 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8f5544c2008-10-15 06:03:48 +00005247 {
5248 CHECK_FOR_ERROR
5249 ;}
5250 break;
5251
Chris Lattnerc5320232008-10-15 06:16:57 +00005252 case 224:
5253#line 2153 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00005254 {
5255 CHECK_FOR_ERROR
5256 ;}
5257 break;
5258
Chris Lattnerc5320232008-10-15 06:16:57 +00005259 case 225:
5260#line 2156 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005261 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005262 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005263 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005264 // Eagerly resolve types. This is not an optimization, this is a
5265 // requirement that is due to the fact that we could have this:
5266 //
5267 // %list = type { %list * }
5268 // %list = type { %list * } ; repeated type decl
5269 //
5270 // If types are not resolved eagerly, then the two types will not be
5271 // determined to be the same type!
5272 //
Dan Gohman54392c12008-04-19 00:24:39 +00005273 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005274
Dan Gohman54392c12008-04-19 00:24:39 +00005275 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005276 CHECK_FOR_ERROR
5277 // If this is a named type that is not a redefinition, add it to the slot
5278 // table.
Dan Gohman54392c12008-04-19 00:24:39 +00005279 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005280 }
5281
Dan Gohman54392c12008-04-19 00:24:39 +00005282 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005283 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005284 ;}
5285 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00005286
Chris Lattnerc5320232008-10-15 06:16:57 +00005287 case 226:
5288#line 2180 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005289 {
5290 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
5291
5292 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005293 CHECK_FOR_ERROR
5294 // If this is a named type that is not a redefinition, add it to the slot
5295 // table.
Dan Gohman54392c12008-04-19 00:24:39 +00005296 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005297 }
5298 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005299 ;}
5300 break;
5301
Chris Lattnerc5320232008-10-15 06:16:57 +00005302 case 227:
5303#line 2192 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher329d2672008-09-24 04:55:49 +00005304 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005305 /* "Externally Visible" Linkage */
Eric Christopher329d2672008-09-24 04:55:49 +00005306 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005307 GEN_ERROR("Global value initializer is not a constant");
Dan Gohman54392c12008-04-19 00:24:39 +00005308 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5309 (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 +00005310 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005311 ;}
5312 break;
5313
Chris Lattnerc5320232008-10-15 06:16:57 +00005314 case 228:
5315#line 2199 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005316 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005317 CurGV = 0;
Dan Gohman54392c12008-04-19 00:24:39 +00005318 ;}
5319 break;
5320
Chris Lattnerc5320232008-10-15 06:16:57 +00005321 case 229:
5322#line 2203 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005323 {
Eric Christopher329d2672008-09-24 04:55:49 +00005324 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lamb668d9a02007-12-12 08:45:45 +00005325 GEN_ERROR("Global value initializer is not a constant");
Dan Gohman54392c12008-04-19 00:24:39 +00005326 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 +00005327 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005328 ;}
5329 break;
5330
Chris Lattnerc5320232008-10-15 06:16:57 +00005331 case 230:
5332#line 2208 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005333 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005334 CurGV = 0;
Dan Gohman54392c12008-04-19 00:24:39 +00005335 ;}
5336 break;
5337
Chris Lattnerc5320232008-10-15 06:16:57 +00005338 case 231:
5339#line 2212 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005340 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005341 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005342 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5343 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 +00005344 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005345 delete (yyvsp[(6) - (7)].TypeVal);
5346 ;}
5347 break;
5348
Chris Lattnerc5320232008-10-15 06:16:57 +00005349 case 232:
5350#line 2218 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005351 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005352 CurGV = 0;
5353 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005354 ;}
5355 break;
5356
Chris Lattnerc5320232008-10-15 06:16:57 +00005357 case 233:
5358#line 2222 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005359 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005360 std::string Name;
Dan Gohman54392c12008-04-19 00:24:39 +00005361 if ((yyvsp[(1) - (5)].StrVal)) {
5362 Name = *(yyvsp[(1) - (5)].StrVal);
5363 delete (yyvsp[(1) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005364 }
5365 if (Name.empty())
5366 GEN_ERROR("Alias name cannot be empty");
Eric Christopher329d2672008-09-24 04:55:49 +00005367
Dan Gohman54392c12008-04-19 00:24:39 +00005368 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005369 if (Aliasee == 0)
5370 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
5371
Dan Gohman54392c12008-04-19 00:24:39 +00005372 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005373 CurModule.CurrentModule);
Dan Gohman54392c12008-04-19 00:24:39 +00005374 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005375 InsertValue(GA, CurModule.Values);
Eric Christopher329d2672008-09-24 04:55:49 +00005376
5377
Chris Lattner5eefce32007-09-10 23:24:14 +00005378 // If there was a forward reference of this alias, resolve it now.
Eric Christopher329d2672008-09-24 04:55:49 +00005379
Chris Lattner5eefce32007-09-10 23:24:14 +00005380 ValID ID;
5381 if (!Name.empty())
5382 ID = ValID::createGlobalName(Name);
5383 else
5384 ID = ValID::createGlobalID(CurModule.Values.size()-1);
Eric Christopher329d2672008-09-24 04:55:49 +00005385
Chris Lattner5eefce32007-09-10 23:24:14 +00005386 if (GlobalValue *FWGV =
5387 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5388 // Replace uses of the fwdref with the actual alias.
5389 FWGV->replaceAllUsesWith(GA);
5390 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5391 GV->eraseFromParent();
5392 else
5393 cast<Function>(FWGV)->eraseFromParent();
5394 }
5395 ID.destroy();
Eric Christopher329d2672008-09-24 04:55:49 +00005396
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005397 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005398 ;}
5399 break;
5400
Chris Lattnerc5320232008-10-15 06:16:57 +00005401 case 234:
5402#line 2262 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8f5544c2008-10-15 06:03:48 +00005403 {
5404 CHECK_FOR_ERROR
5405 ;}
5406 break;
5407
Chris Lattnerc5320232008-10-15 06:16:57 +00005408 case 235:
5409#line 2265 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher329d2672008-09-24 04:55:49 +00005410 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005411 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005412 ;}
5413 break;
5414
Chris Lattnerc5320232008-10-15 06:16:57 +00005415 case 236:
5416#line 2271 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005417 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005418 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5419 if (AsmSoFar.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005420 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005421 else
Dan Gohman54392c12008-04-19 00:24:39 +00005422 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5423 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005424 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005425;}
5426 break;
5427
Chris Lattnerc5320232008-10-15 06:16:57 +00005428 case 237:
5429#line 2281 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005430 {
5431 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5432 delete (yyvsp[(3) - (3)].StrVal);
5433 ;}
5434 break;
5435
Chris Lattnerc5320232008-10-15 06:16:57 +00005436 case 238:
5437#line 2285 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005438 {
5439 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5440 delete (yyvsp[(3) - (3)].StrVal);
5441 ;}
5442 break;
5443
Chris Lattnerc5320232008-10-15 06:16:57 +00005444 case 240:
5445#line 2292 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005446 {
5447 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5448 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00005449 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005450 ;}
5451 break;
5452
Chris Lattnerc5320232008-10-15 06:16:57 +00005453 case 241:
5454#line 2297 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005455 {
5456 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5457 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer47470022007-07-31 14:41:17 +00005458 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005459 ;}
5460 break;
5461
Chris Lattnerc5320232008-10-15 06:16:57 +00005462 case 242:
5463#line 2302 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005464 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005465 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005466 ;}
5467 break;
5468
Chris Lattnerc5320232008-10-15 06:16:57 +00005469 case 243:
5470#line 2311 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005471 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005472 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005473 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
Dan Gohmane5febe42008-05-31 00:58:22 +00005474 if (!(*(yyvsp[(3) - (5)].TypeVal))->isFirstClassType())
5475 GEN_ERROR("Argument types must be first-class");
Devang Pateld222f862008-09-25 21:00:45 +00005476 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].Attributes); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
Dan Gohman54392c12008-04-19 00:24:39 +00005477 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5478 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005479 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005480 ;}
5481 break;
5482
Chris Lattnerc5320232008-10-15 06:16:57 +00005483 case 244:
5484#line 2321 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005485 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005486 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005487 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohmane5febe42008-05-31 00:58:22 +00005488 if (!(*(yyvsp[(1) - (3)].TypeVal))->isFirstClassType())
5489 GEN_ERROR("Argument types must be first-class");
Devang Pateld222f862008-09-25 21:00:45 +00005490 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].Attributes); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
Dan Gohman54392c12008-04-19 00:24:39 +00005491 (yyval.ArgList) = new ArgListType;
5492 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005493 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005494 ;}
5495 break;
5496
Chris Lattnerc5320232008-10-15 06:16:57 +00005497 case 245:
5498#line 2332 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005499 {
5500 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005501 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005502 ;}
5503 break;
5504
Chris Lattnerc5320232008-10-15 06:16:57 +00005505 case 246:
5506#line 2336 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005507 {
5508 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005509 struct ArgListEntry E;
5510 E.Ty = new PATypeHolder(Type::VoidTy);
5511 E.Name = 0;
Devang Pateld222f862008-09-25 21:00:45 +00005512 E.Attrs = Attribute::None;
Dan Gohman54392c12008-04-19 00:24:39 +00005513 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005514 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005515 ;}
5516 break;
5517
Chris Lattnerc5320232008-10-15 06:16:57 +00005518 case 247:
5519#line 2345 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005520 {
5521 (yyval.ArgList) = new ArgListType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005522 struct ArgListEntry E;
5523 E.Ty = new PATypeHolder(Type::VoidTy);
5524 E.Name = 0;
Devang Pateld222f862008-09-25 21:00:45 +00005525 E.Attrs = Attribute::None;
Dan Gohman54392c12008-04-19 00:24:39 +00005526 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005527 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005528 ;}
5529 break;
5530
Chris Lattnerc5320232008-10-15 06:16:57 +00005531 case 248:
5532#line 2354 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005533 {
5534 (yyval.ArgList) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005535 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005536 ;}
5537 break;
5538
Chris Lattnerc5320232008-10-15 06:16:57 +00005539 case 249:
5540#line 2360 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005541 {
Devang Patelcd842482008-09-29 20:49:50 +00005542 std::string FunctionName(*(yyvsp[(4) - (11)].StrVal));
5543 delete (yyvsp[(4) - (11)].StrVal); // Free strdup'd memory!
Eric Christopher329d2672008-09-24 04:55:49 +00005544
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005545 // Check the function result for abstractness if this is a define. We should
5546 // have no abstract types at this point
Devang Patelcd842482008-09-29 20:49:50 +00005547 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(3) - (11)].TypeVal)))
5548 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(3) - (11)].TypeVal)->get()->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005549
Devang Patelcd842482008-09-29 20:49:50 +00005550 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (11)].TypeVal)))
Chris Lattner73de3c02008-04-23 05:37:08 +00005551 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher329d2672008-09-24 04:55:49 +00005552
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005553 std::vector<const Type*> ParamTypeList;
Devang Pateld222f862008-09-25 21:00:45 +00005554 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesen38ee4102008-09-26 23:46:20 +00005555 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
5556 //attributes.
Devang Patelcd842482008-09-29 20:49:50 +00005557 Attributes RetAttrs = (yyvsp[(2) - (11)].Attributes);
5558 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None) {
5559 if ((yyvsp[(8) - (11)].Attributes) & Attribute::ZExt) {
Dale Johannesen38ee4102008-09-26 23:46:20 +00005560 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patelcd842482008-09-29 20:49:50 +00005561 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::ZExt;
Dale Johannesen38ee4102008-09-26 23:46:20 +00005562 }
Devang Patelcd842482008-09-29 20:49:50 +00005563 if ((yyvsp[(8) - (11)].Attributes) & Attribute::SExt) {
Dale Johannesen38ee4102008-09-26 23:46:20 +00005564 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patelcd842482008-09-29 20:49:50 +00005565 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::SExt;
Dale Johannesen38ee4102008-09-26 23:46:20 +00005566 }
Devang Patelcd842482008-09-29 20:49:50 +00005567 if ((yyvsp[(8) - (11)].Attributes) & Attribute::InReg) {
Dale Johannesen38ee4102008-09-26 23:46:20 +00005568 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patelcd842482008-09-29 20:49:50 +00005569 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::InReg;
Dale Johannesen38ee4102008-09-26 23:46:20 +00005570 }
Dale Johannesen38ee4102008-09-26 23:46:20 +00005571 }
Devang Patelcd842482008-09-29 20:49:50 +00005572 if (RetAttrs != Attribute::None)
5573 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
5574 if ((yyvsp[(6) - (11)].ArgList)) { // If there are arguments...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005575 unsigned index = 1;
Devang Patelcd842482008-09-29 20:49:50 +00005576 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin(); I != (yyvsp[(6) - (11)].ArgList)->end(); ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005577 const Type* Ty = I->Ty->get();
5578 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5579 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
5580 ParamTypeList.push_back(Ty);
Devang Pateld222f862008-09-25 21:00:45 +00005581 if (Ty != Type::VoidTy && I->Attrs != Attribute::None)
5582 Attrs.push_back(AttributeWithIndex::get(index, I->Attrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005583 }
5584 }
Devang Patelcd842482008-09-29 20:49:50 +00005585 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None)
5586 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(8) - (11)].Attributes)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005587
5588 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5589 if (isVarArg) ParamTypeList.pop_back();
5590
Devang Pateld222f862008-09-25 21:00:45 +00005591 AttrListPtr PAL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005592 if (!Attrs.empty())
Devang Pateld222f862008-09-25 21:00:45 +00005593 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005594
Devang Patelcd842482008-09-29 20:49:50 +00005595 FunctionType *FT = FunctionType::get(*(yyvsp[(3) - (11)].TypeVal), ParamTypeList, isVarArg);
Christopher Lambfb623c62007-12-17 01:17:35 +00005596 const PointerType *PFT = PointerType::getUnqual(FT);
Devang Patelcd842482008-09-29 20:49:50 +00005597 delete (yyvsp[(3) - (11)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005598
5599 ValID ID;
5600 if (!FunctionName.empty()) {
5601 ID = ValID::createGlobalName((char*)FunctionName.c_str());
5602 } else {
5603 ID = ValID::createGlobalID(CurModule.Values.size());
5604 }
5605
5606 Function *Fn = 0;
5607 // See if this function was forward referenced. If so, recycle the object.
5608 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
Eric Christopher329d2672008-09-24 04:55:49 +00005609 // Move the function to the end of the list, from whereever it was
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005610 // previously inserted.
5611 Fn = cast<Function>(FWRef);
Devang Pateld222f862008-09-25 21:00:45 +00005612 assert(Fn->getAttributes().isEmpty() &&
Chris Lattner1c8733e2008-03-12 17:45:29 +00005613 "Forward reference has parameter attributes!");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005614 CurModule.CurrentModule->getFunctionList().remove(Fn);
5615 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5616 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5617 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005618 if (Fn->getFunctionType() != FT ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005619 // The existing function doesn't have the same type. This is an overload
5620 // error.
5621 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Devang Pateld222f862008-09-25 21:00:45 +00005622 } else if (Fn->getAttributes() != PAL) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005623 // The existing function doesn't have the same parameter attributes.
5624 // This is an overload error.
5625 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005626 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
5627 // Neither the existing or the current function is a declaration and they
5628 // have the same name and same type. Clearly this is a redefinition.
5629 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005630 } else if (Fn->isDeclaration()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005631 // Make sure to strip off any argument names so we can't get conflicts.
5632 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5633 AI != AE; ++AI)
5634 AI->setName("");
5635 }
5636 } else { // Not already defined?
Gabor Greif89f01162008-04-06 23:07:54 +00005637 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5638 CurModule.CurrentModule);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005639 InsertValue(Fn, CurModule.Values);
5640 }
5641
Nuno Lopese20dbca2008-10-03 15:45:58 +00005642 ID.destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005643 CurFun.FunctionStart(Fn);
5644
5645 if (CurFun.isDeclare) {
5646 // If we have declaration, always overwrite linkage. This will allow us to
5647 // correctly handle cases, when pointer to function is passed as argument to
5648 // another function.
5649 Fn->setLinkage(CurFun.Linkage);
5650 Fn->setVisibility(CurFun.Visibility);
5651 }
Devang Patel5df692d2008-09-02 20:52:40 +00005652 Fn->setCallingConv((yyvsp[(1) - (11)].UIntVal));
Devang Pateld222f862008-09-25 21:00:45 +00005653 Fn->setAttributes(PAL);
Devang Patelcd842482008-09-29 20:49:50 +00005654 Fn->setAlignment((yyvsp[(10) - (11)].UIntVal));
5655 if ((yyvsp[(9) - (11)].StrVal)) {
5656 Fn->setSection(*(yyvsp[(9) - (11)].StrVal));
5657 delete (yyvsp[(9) - (11)].StrVal);
Gordon Henriksen13fe5e32007-12-10 03:18:06 +00005658 }
Devang Patelcd842482008-09-29 20:49:50 +00005659 if ((yyvsp[(11) - (11)].StrVal)) {
5660 Fn->setGC((yyvsp[(11) - (11)].StrVal)->c_str());
5661 delete (yyvsp[(11) - (11)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005662 }
5663
5664 // Add all of the arguments we parsed to the function...
Devang Patelcd842482008-09-29 20:49:50 +00005665 if ((yyvsp[(6) - (11)].ArgList)) { // Is null if empty...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005666 if (isVarArg) { // Nuke the last entry
Devang Patelcd842482008-09-29 20:49:50 +00005667 assert((yyvsp[(6) - (11)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(6) - (11)].ArgList)->back().Name == 0 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005668 "Not a varargs marker!");
Devang Patelcd842482008-09-29 20:49:50 +00005669 delete (yyvsp[(6) - (11)].ArgList)->back().Ty;
5670 (yyvsp[(6) - (11)].ArgList)->pop_back(); // Delete the last entry
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005671 }
5672 Function::arg_iterator ArgIt = Fn->arg_begin();
5673 Function::arg_iterator ArgEnd = Fn->arg_end();
5674 unsigned Idx = 1;
Devang Patelcd842482008-09-29 20:49:50 +00005675 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin();
5676 I != (yyvsp[(6) - (11)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005677 delete I->Ty; // Delete the typeholder...
5678 setValueName(ArgIt, I->Name); // Insert arg into symtab...
5679 CHECK_FOR_ERROR
5680 InsertValue(ArgIt);
5681 Idx++;
5682 }
5683
Devang Patelcd842482008-09-29 20:49:50 +00005684 delete (yyvsp[(6) - (11)].ArgList); // We're now done with the argument list
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005685 }
5686 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005687;}
5688 break;
5689
Chris Lattnerc5320232008-10-15 06:16:57 +00005690 case 252:
5691#line 2510 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005692 {
5693 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005694
5695 // Make sure that we keep track of the linkage type even if there was a
5696 // previous "declare".
Dan Gohman54392c12008-04-19 00:24:39 +00005697 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5698 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5699;}
5700 break;
5701
Chris Lattnerc5320232008-10-15 06:16:57 +00005702 case 255:
5703#line 2521 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005704 {
5705 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005706 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005707;}
5708 break;
5709
Chris Lattnerc5320232008-10-15 06:16:57 +00005710 case 256:
5711#line 2526 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005712 {
5713 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5714 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5715 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005716 CurFun.FunctionDone();
5717 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005718 ;}
5719 break;
5720
Chris Lattnerc5320232008-10-15 06:16:57 +00005721 case 257:
5722#line 2538 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005723 {
5724 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005725 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005726 ;}
5727 break;
5728
Chris Lattnerc5320232008-10-15 06:16:57 +00005729 case 258:
5730#line 2542 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005731 {
5732 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005733 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005734 ;}
5735 break;
5736
Chris Lattnerc5320232008-10-15 06:16:57 +00005737 case 259:
5738#line 2547 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005739 { // A reference to a direct constant
5740 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005741 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005742 ;}
5743 break;
5744
Chris Lattnerc5320232008-10-15 06:16:57 +00005745 case 260:
5746#line 2551 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005747 {
5748 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005749 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005750 ;}
5751 break;
5752
Chris Lattnerc5320232008-10-15 06:16:57 +00005753 case 261:
5754#line 2555 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf3d40022008-07-11 00:30:39 +00005755 { // arbitrary precision integer constants
5756 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), true);
5757 delete (yyvsp[(1) - (1)].APIntVal);
5758 CHECK_FOR_ERROR
5759 ;}
5760 break;
5761
Chris Lattnerc5320232008-10-15 06:16:57 +00005762 case 262:
5763#line 2560 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf3d40022008-07-11 00:30:39 +00005764 { // arbitrary precision integer constants
5765 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), false);
5766 delete (yyvsp[(1) - (1)].APIntVal);
5767 CHECK_FOR_ERROR
5768 ;}
5769 break;
5770
Chris Lattnerc5320232008-10-15 06:16:57 +00005771 case 263:
5772#line 2565 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005773 { // Perhaps it's an FP constant?
5774 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005775 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005776 ;}
5777 break;
5778
Chris Lattnerc5320232008-10-15 06:16:57 +00005779 case 264:
5780#line 2569 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005781 {
5782 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005783 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005784 ;}
5785 break;
5786
Chris Lattnerc5320232008-10-15 06:16:57 +00005787 case 265:
5788#line 2573 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005789 {
5790 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005791 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005792 ;}
5793 break;
5794
Chris Lattnerc5320232008-10-15 06:16:57 +00005795 case 266:
5796#line 2577 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005797 {
5798 (yyval.ValIDVal) = ValID::createNull();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005799 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005800 ;}
5801 break;
5802
Chris Lattnerc5320232008-10-15 06:16:57 +00005803 case 267:
5804#line 2581 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005805 {
5806 (yyval.ValIDVal) = ValID::createUndef();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005807 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005808 ;}
5809 break;
5810
Chris Lattnerc5320232008-10-15 06:16:57 +00005811 case 268:
5812#line 2585 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005813 { // A vector zero constant.
5814 (yyval.ValIDVal) = ValID::createZeroInit();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005815 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005816 ;}
5817 break;
5818
Chris Lattnerc5320232008-10-15 06:16:57 +00005819 case 269:
5820#line 2589 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005821 { // Nonempty unsized packed vector
5822 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher329d2672008-09-24 04:55:49 +00005823 unsigned NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmane5febe42008-05-31 00:58:22 +00005824
5825 if (!ETy->isInteger() && !ETy->isFloatingPoint())
5826 GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
Eric Christopher329d2672008-09-24 04:55:49 +00005827
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005828 VectorType* pt = VectorType::get(ETy, NumElements);
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005829 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
Eric Christopher329d2672008-09-24 04:55:49 +00005830
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005831 // Verify all elements are correct type!
Dan Gohman54392c12008-04-19 00:24:39 +00005832 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5833 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher329d2672008-09-24 04:55:49 +00005834 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005835 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohman54392c12008-04-19 00:24:39 +00005836 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005837 }
5838
Dan Gohman54392c12008-04-19 00:24:39 +00005839 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5840 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005841 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005842 ;}
5843 break;
5844
Chris Lattnerc5320232008-10-15 06:16:57 +00005845 case 270:
5846#line 2611 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005847 { // Nonempty unsized arr
5848 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher329d2672008-09-24 04:55:49 +00005849 uint64_t NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005850
5851 if (!ETy->isFirstClassType())
5852 GEN_ERROR("Invalid array element type: " + ETy->getDescription());
5853
5854 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5855 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
5856
5857 // Verify all elements are correct type!
5858 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5859 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher329d2672008-09-24 04:55:49 +00005860 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005861 ETy->getDescription() +"' as required!\nIt is of type '"+
5862 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
5863 }
5864
5865 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, *(yyvsp[(2) - (3)].ConstVector)));
5866 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5867 CHECK_FOR_ERROR
5868 ;}
5869 break;
5870
Chris Lattnerc5320232008-10-15 06:16:57 +00005871 case 271:
5872#line 2633 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005873 {
Dan Gohman7185e4b2008-06-23 18:43:26 +00005874 // Use undef instead of an array because it's inconvenient to determine
5875 // the element type at this point, there being no elements to examine.
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005876 (yyval.ValIDVal) = ValID::createUndef();
5877 CHECK_FOR_ERROR
5878 ;}
5879 break;
5880
Chris Lattnerc5320232008-10-15 06:16:57 +00005881 case 272:
5882#line 2639 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005883 {
Dan Gohman7185e4b2008-06-23 18:43:26 +00005884 uint64_t NumElements = (yyvsp[(2) - (2)].StrVal)->length();
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005885 const Type *ETy = Type::Int8Ty;
5886
5887 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5888
5889 std::vector<Constant*> Vals;
5890 for (unsigned i = 0; i < (yyvsp[(2) - (2)].StrVal)->length(); ++i)
5891 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(2) - (2)].StrVal))[i]));
5892 delete (yyvsp[(2) - (2)].StrVal);
5893 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, Vals));
5894 CHECK_FOR_ERROR
5895 ;}
5896 break;
5897
Chris Lattnerc5320232008-10-15 06:16:57 +00005898 case 273:
5899#line 2652 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005900 {
5901 std::vector<const Type*> Elements((yyvsp[(2) - (3)].ConstVector)->size());
5902 for (unsigned i = 0, e = (yyvsp[(2) - (3)].ConstVector)->size(); i != e; ++i)
5903 Elements[i] = (*(yyvsp[(2) - (3)].ConstVector))[i]->getType();
5904
5905 const StructType *STy = StructType::get(Elements);
5906 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5907
5908 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(2) - (3)].ConstVector)));
5909 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5910 CHECK_FOR_ERROR
5911 ;}
5912 break;
5913
Chris Lattnerc5320232008-10-15 06:16:57 +00005914 case 274:
5915#line 2664 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005916 {
5917 const StructType *STy = StructType::get(std::vector<const Type*>());
5918 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5919 CHECK_FOR_ERROR
5920 ;}
5921 break;
5922
Chris Lattnerc5320232008-10-15 06:16:57 +00005923 case 275:
5924#line 2669 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005925 {
5926 std::vector<const Type*> Elements((yyvsp[(3) - (5)].ConstVector)->size());
5927 for (unsigned i = 0, e = (yyvsp[(3) - (5)].ConstVector)->size(); i != e; ++i)
5928 Elements[i] = (*(yyvsp[(3) - (5)].ConstVector))[i]->getType();
5929
5930 const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
5931 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5932
5933 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(3) - (5)].ConstVector)));
5934 delete PTy; delete (yyvsp[(3) - (5)].ConstVector);
5935 CHECK_FOR_ERROR
5936 ;}
5937 break;
5938
Chris Lattnerc5320232008-10-15 06:16:57 +00005939 case 276:
5940#line 2681 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman9fc6cb02008-06-09 14:45:02 +00005941 {
5942 const StructType *STy = StructType::get(std::vector<const Type*>(),
5943 /*isPacked=*/true);
5944 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5945 CHECK_FOR_ERROR
5946 ;}
5947 break;
5948
Chris Lattnerc5320232008-10-15 06:16:57 +00005949 case 277:
5950#line 2687 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005951 {
5952 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005953 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005954 ;}
5955 break;
5956
Chris Lattnerc5320232008-10-15 06:16:57 +00005957 case 278:
5958#line 2691 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005959 {
5960 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5961 delete (yyvsp[(3) - (5)].StrVal);
5962 delete (yyvsp[(5) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005963 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005964 ;}
5965 break;
5966
Chris Lattnerc5320232008-10-15 06:16:57 +00005967 case 279:
5968#line 2701 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005969 { // Is it an integer reference...?
5970 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005971 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005972 ;}
5973 break;
5974
Chris Lattnerc5320232008-10-15 06:16:57 +00005975 case 280:
5976#line 2705 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005977 {
5978 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005979 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005980 ;}
5981 break;
5982
Chris Lattnerc5320232008-10-15 06:16:57 +00005983 case 281:
5984#line 2709 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005985 { // Is it a named reference...?
5986 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5987 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005988 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005989 ;}
5990 break;
5991
Chris Lattnerc5320232008-10-15 06:16:57 +00005992 case 282:
5993#line 2714 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005994 { // Is it a named reference...?
5995 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5996 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005997 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005998 ;}
5999 break;
6000
Chris Lattnerc5320232008-10-15 06:16:57 +00006001 case 285:
6002#line 2727 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006003 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006004 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006005 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Eric Christopher329d2672008-09-24 04:55:49 +00006006 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
Dan Gohman54392c12008-04-19 00:24:39 +00006007 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006008 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006009 ;}
6010 break;
6011
Chris Lattnerc5320232008-10-15 06:16:57 +00006012 case 286:
6013#line 2736 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006014 {
6015 (yyval.ValueList) = new std::vector<Value *>();
Eric Christopher329d2672008-09-24 04:55:49 +00006016 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patelbf507402008-02-20 22:40:23 +00006017 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006018 ;}
6019 break;
6020
Chris Lattnerc5320232008-10-15 06:16:57 +00006021 case 287:
6022#line 2741 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006023 {
Eric Christopher329d2672008-09-24 04:55:49 +00006024 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patelbf507402008-02-20 22:40:23 +00006025 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006026 ;}
6027 break;
6028
Chris Lattnerc5320232008-10-15 06:16:57 +00006029 case 288:
6030#line 2746 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006031 {
6032 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006033 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006034 ;}
6035 break;
6036
Chris Lattnerc5320232008-10-15 06:16:57 +00006037 case 289:
6038#line 2750 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher329d2672008-09-24 04:55:49 +00006039 { // Do not allow functions with 0 basic blocks
Dan Gohman54392c12008-04-19 00:24:39 +00006040 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006041 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006042 ;}
6043 break;
6044
Chris Lattnerc5320232008-10-15 06:16:57 +00006045 case 290:
6046#line 2759 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006047 {
6048 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006049 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006050 InsertValue((yyvsp[(3) - (3)].TermInstVal));
6051 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6052 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006053 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006054 ;}
6055 break;
6056
Chris Lattnerc5320232008-10-15 06:16:57 +00006057 case 291:
6058#line 2768 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00006059 {
6060 CHECK_FOR_ERROR
6061 int ValNum = InsertValue((yyvsp[(3) - (3)].TermInstVal));
6062 if (ValNum != (int)(yyvsp[(2) - (3)].UIntVal))
6063 GEN_ERROR("Result value number %" + utostr((yyvsp[(2) - (3)].UIntVal)) +
6064 " is incorrect, expected %" + utostr((unsigned)ValNum));
Eric Christopher329d2672008-09-24 04:55:49 +00006065
Chris Lattner906773a2008-08-29 17:20:18 +00006066 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6067 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
6068 CHECK_FOR_ERROR
6069;}
6070 break;
6071
Chris Lattnerc5320232008-10-15 06:16:57 +00006072 case 292:
6073#line 2781 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006074 {
6075 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006076 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
6077 if (CI2->getParent() == 0)
Dan Gohman54392c12008-04-19 00:24:39 +00006078 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
6079 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
6080 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006081 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006082 ;}
6083 break;
Chris Lattner59363a32008-02-19 04:36:25 +00006084
Chris Lattnerc5320232008-10-15 06:16:57 +00006085 case 293:
6086#line 2790 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006087 { // Empty space between instruction lists
Chris Lattnere7e9b602008-05-04 17:18:47 +00006088 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohman54392c12008-04-19 00:24:39 +00006089 CHECK_FOR_ERROR
6090 ;}
6091 break;
6092
Chris Lattnerc5320232008-10-15 06:16:57 +00006093 case 294:
6094#line 2794 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere7e9b602008-05-04 17:18:47 +00006095 { // Labelled (named) basic block
6096 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
6097 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohman54392c12008-04-19 00:24:39 +00006098 CHECK_FOR_ERROR
Chris Lattnere7e9b602008-05-04 17:18:47 +00006099
Dan Gohman54392c12008-04-19 00:24:39 +00006100 ;}
6101 break;
6102
Chris Lattnerc5320232008-10-15 06:16:57 +00006103 case 295:
6104#line 2802 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006105 { // Return with a result...
6106 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
6107 assert(!VL.empty() && "Invalid ret operands!");
Dan Gohmanb94a0ba2008-07-23 00:54:54 +00006108 const Type *ReturnType = CurFun.CurrentFunction->getReturnType();
6109 if (VL.size() > 1 ||
6110 (isa<StructType>(ReturnType) &&
6111 (VL.empty() || VL[0]->getType() != ReturnType))) {
6112 Value *RV = UndefValue::get(ReturnType);
6113 for (unsigned i = 0, e = VL.size(); i != e; ++i) {
6114 Instruction *I = InsertValueInst::Create(RV, VL[i], i, "mrv");
6115 ((yyvsp[(-1) - (2)].BasicBlockVal))->getInstList().push_back(I);
6116 RV = I;
6117 }
6118 (yyval.TermInstVal) = ReturnInst::Create(RV);
6119 } else {
6120 (yyval.TermInstVal) = ReturnInst::Create(VL[0]);
6121 }
Dan Gohman54392c12008-04-19 00:24:39 +00006122 delete (yyvsp[(2) - (2)].ValueList);
6123 CHECK_FOR_ERROR
6124 ;}
6125 break;
6126
Chris Lattnerc5320232008-10-15 06:16:57 +00006127 case 296:
6128#line 2822 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006129 { // Return with no result...
6130 (yyval.TermInstVal) = ReturnInst::Create();
6131 CHECK_FOR_ERROR
6132 ;}
6133 break;
6134
Chris Lattnerc5320232008-10-15 06:16:57 +00006135 case 297:
6136#line 2826 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006137 { // Unconditional Branch...
6138 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6139 CHECK_FOR_ERROR
6140 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
6141 ;}
6142 break;
6143
Chris Lattnerc5320232008-10-15 06:16:57 +00006144 case 298:
6145#line 2831 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher329d2672008-09-24 04:55:49 +00006146 {
Dan Gohmane5febe42008-05-31 00:58:22 +00006147 if (cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() != 1)
6148 GEN_ERROR("Branch condition must have type i1");
Dan Gohman54392c12008-04-19 00:24:39 +00006149 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6150 CHECK_FOR_ERROR
6151 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6152 CHECK_FOR_ERROR
6153 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6154 CHECK_FOR_ERROR
6155 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
6156 ;}
6157 break;
6158
Chris Lattnerc5320232008-10-15 06:16:57 +00006159 case 299:
6160#line 2842 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006161 {
6162 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
6163 CHECK_FOR_ERROR
6164 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6165 CHECK_FOR_ERROR
6166 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6167 (yyval.TermInstVal) = S;
6168
6169 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6170 E = (yyvsp[(8) - (9)].JumpTable)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006171 for (; I != E; ++I) {
6172 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6173 S->addCase(CI, I->second);
6174 else
6175 GEN_ERROR("Switch case is constant, but not a simple integer");
6176 }
Dan Gohman54392c12008-04-19 00:24:39 +00006177 delete (yyvsp[(8) - (9)].JumpTable);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006178 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006179 ;}
6180 break;
6181
Chris Lattnerc5320232008-10-15 06:16:57 +00006182 case 300:
6183#line 2861 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006184 {
6185 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006186 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006187 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006188 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00006189 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohman54392c12008-04-19 00:24:39 +00006190 (yyval.TermInstVal) = S;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006191 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006192 ;}
6193 break;
6194
Chris Lattnerc5320232008-10-15 06:16:57 +00006195 case 301:
6196#line 2871 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006197 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006198
6199 // Handle the short syntax
6200 const PointerType *PFTy = 0;
6201 const FunctionType *Ty = 0;
Devang Patelcd842482008-09-29 20:49:50 +00006202 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (15)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006203 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6204 // Pull out the types of all of the arguments...
6205 std::vector<const Type*> ParamTypes;
Devang Patelcd842482008-09-29 20:49:50 +00006206 ParamList::iterator I = (yyvsp[(7) - (15)].ParamList)->begin(), E = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006207 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006208 const Type *Ty = I->Val->getType();
6209 if (Ty == Type::VoidTy)
6210 GEN_ERROR("Short call syntax cannot be used with varargs");
6211 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006212 }
Eric Christopher329d2672008-09-24 04:55:49 +00006213
Devang Patelcd842482008-09-29 20:49:50 +00006214 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (15)].TypeVal)))
Chris Lattner73de3c02008-04-23 05:37:08 +00006215 GEN_ERROR("Invalid result type for LLVM function");
6216
Devang Patelcd842482008-09-29 20:49:50 +00006217 Ty = FunctionType::get((yyvsp[(4) - (15)].TypeVal)->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00006218 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006219 }
6220
Devang Patelcd842482008-09-29 20:49:50 +00006221 delete (yyvsp[(4) - (15)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006222
Devang Patelcd842482008-09-29 20:49:50 +00006223 Value *V = getVal(PFTy, (yyvsp[(5) - (15)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006224 CHECK_FOR_ERROR
Devang Patelcd842482008-09-29 20:49:50 +00006225 BasicBlock *Normal = getBBVal((yyvsp[(12) - (15)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006226 CHECK_FOR_ERROR
Devang Patelcd842482008-09-29 20:49:50 +00006227 BasicBlock *Except = getBBVal((yyvsp[(15) - (15)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006228 CHECK_FOR_ERROR
6229
Devang Pateld222f862008-09-25 21:00:45 +00006230 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesen38ee4102008-09-26 23:46:20 +00006231 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6232 //attributes.
Devang Patelcd842482008-09-29 20:49:50 +00006233 Attributes RetAttrs = (yyvsp[(3) - (15)].Attributes);
6234 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None) {
6235 if ((yyvsp[(9) - (15)].Attributes) & Attribute::ZExt) {
Dale Johannesen38ee4102008-09-26 23:46:20 +00006236 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patelcd842482008-09-29 20:49:50 +00006237 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::ZExt;
Dale Johannesen38ee4102008-09-26 23:46:20 +00006238 }
Devang Patelcd842482008-09-29 20:49:50 +00006239 if ((yyvsp[(9) - (15)].Attributes) & Attribute::SExt) {
Dale Johannesen38ee4102008-09-26 23:46:20 +00006240 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patelcd842482008-09-29 20:49:50 +00006241 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::SExt;
Dale Johannesen38ee4102008-09-26 23:46:20 +00006242 }
Devang Patelcd842482008-09-29 20:49:50 +00006243 if ((yyvsp[(9) - (15)].Attributes) & Attribute::InReg) {
Dale Johannesen38ee4102008-09-26 23:46:20 +00006244 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patelcd842482008-09-29 20:49:50 +00006245 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::InReg;
Dale Johannesen38ee4102008-09-26 23:46:20 +00006246 }
Dale Johannesen38ee4102008-09-26 23:46:20 +00006247 }
Devang Patelcd842482008-09-29 20:49:50 +00006248 if (RetAttrs != Attribute::None)
6249 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesen38ee4102008-09-26 23:46:20 +00006250
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006251 // Check the arguments
6252 ValueList Args;
Devang Patelcd842482008-09-29 20:49:50 +00006253 if ((yyvsp[(7) - (15)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006254 // Make sure no arguments is a good thing!
6255 if (Ty->getNumParams() != 0)
6256 GEN_ERROR("No arguments passed to a function that "
6257 "expects arguments");
6258 } else { // Has arguments?
6259 // Loop through FunctionType's arguments and ensure they are specified
6260 // correctly!
6261 FunctionType::param_iterator I = Ty->param_begin();
6262 FunctionType::param_iterator E = Ty->param_end();
Devang Patelcd842482008-09-29 20:49:50 +00006263 ParamList::iterator ArgI = (yyvsp[(7) - (15)].ParamList)->begin(), ArgE = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006264 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006265
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006266 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006267 if (ArgI->Val->getType() != *I)
6268 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
6269 (*I)->getDescription() + "'");
6270 Args.push_back(ArgI->Val);
Devang Pateld222f862008-09-25 21:00:45 +00006271 if (ArgI->Attrs != Attribute::None)
6272 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006273 }
6274
6275 if (Ty->isVarArg()) {
6276 if (I == E)
Chris Lattner59363a32008-02-19 04:36:25 +00006277 for (; ArgI != ArgE; ++ArgI, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006278 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Pateld222f862008-09-25 21:00:45 +00006279 if (ArgI->Attrs != Attribute::None)
6280 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner59363a32008-02-19 04:36:25 +00006281 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006282 } else if (I != E || ArgI != ArgE)
6283 GEN_ERROR("Invalid number of parameters detected");
6284 }
Devang Patelcd842482008-09-29 20:49:50 +00006285 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None)
6286 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (15)].Attributes)));
Devang Pateld222f862008-09-25 21:00:45 +00006287 AttrListPtr PAL;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006288 if (!Attrs.empty())
Devang Pateld222f862008-09-25 21:00:45 +00006289 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006290
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006291 // Create the InvokeInst
Dan Gohman8055f772008-05-15 19:50:34 +00006292 InvokeInst *II = InvokeInst::Create(V, Normal, Except,
6293 Args.begin(), Args.end());
Devang Patelcd842482008-09-29 20:49:50 +00006294 II->setCallingConv((yyvsp[(2) - (15)].UIntVal));
Devang Pateld222f862008-09-25 21:00:45 +00006295 II->setAttributes(PAL);
Dan Gohman54392c12008-04-19 00:24:39 +00006296 (yyval.TermInstVal) = II;
Devang Patelcd842482008-09-29 20:49:50 +00006297 delete (yyvsp[(7) - (15)].ParamList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006298 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006299 ;}
6300 break;
6301
Chris Lattnerc5320232008-10-15 06:16:57 +00006302 case 302:
6303#line 2974 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006304 {
6305 (yyval.TermInstVal) = new UnwindInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006306 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006307 ;}
6308 break;
6309
Chris Lattnerc5320232008-10-15 06:16:57 +00006310 case 303:
6311#line 2978 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006312 {
6313 (yyval.TermInstVal) = new UnreachableInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006314 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006315 ;}
6316 break;
6317
Chris Lattnerc5320232008-10-15 06:16:57 +00006318 case 304:
6319#line 2985 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006320 {
6321 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6322 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006323 CHECK_FOR_ERROR
6324 if (V == 0)
6325 GEN_ERROR("May only switch on a constant pool value");
6326
Dan Gohman54392c12008-04-19 00:24:39 +00006327 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006328 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006329 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6330 ;}
6331 break;
6332
Chris Lattnerc5320232008-10-15 06:16:57 +00006333 case 305:
6334#line 2996 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006335 {
6336 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6337 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006338 CHECK_FOR_ERROR
6339
6340 if (V == 0)
6341 GEN_ERROR("May only switch on a constant pool value");
6342
Dan Gohman54392c12008-04-19 00:24:39 +00006343 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006344 CHECK_FOR_ERROR
Eric Christopher329d2672008-09-24 04:55:49 +00006345 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Dan Gohman54392c12008-04-19 00:24:39 +00006346 ;}
6347 break;
6348
Chris Lattnerc5320232008-10-15 06:16:57 +00006349 case 306:
6350#line 3009 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006351 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006352 // Is this definition named?? if so, assign the name...
Dan Gohman54392c12008-04-19 00:24:39 +00006353 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006354 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006355 InsertValue((yyvsp[(2) - (2)].InstVal));
6356 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006357 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006358 ;}
6359 break;
6360
Chris Lattnerc5320232008-10-15 06:16:57 +00006361 case 307:
6362#line 3018 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner906773a2008-08-29 17:20:18 +00006363 {
6364 CHECK_FOR_ERROR
6365 int ValNum = InsertValue((yyvsp[(2) - (2)].InstVal));
Eric Christopher329d2672008-09-24 04:55:49 +00006366
Chris Lattner906773a2008-08-29 17:20:18 +00006367 if (ValNum != (int)(yyvsp[(1) - (2)].UIntVal))
6368 GEN_ERROR("Result value number %" + utostr((yyvsp[(1) - (2)].UIntVal)) +
6369 " is incorrect, expected %" + utostr((unsigned)ValNum));
6370
6371 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6372 CHECK_FOR_ERROR
6373 ;}
6374 break;
6375
Chris Lattnerc5320232008-10-15 06:16:57 +00006376 case 308:
6377#line 3031 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006378 { // Used for PHI nodes
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006379 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006380 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
6381 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
6382 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006383 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006384 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006385 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006386 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6387 delete (yyvsp[(1) - (6)].TypeVal);
6388 ;}
6389 break;
6390
Chris Lattnerc5320232008-10-15 06:16:57 +00006391 case 309:
6392#line 3042 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006393 {
6394 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6395 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006396 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006397 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006398 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006399 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6400 ;}
6401 break;
6402
Chris Lattnerc5320232008-10-15 06:16:57 +00006403 case 310:
6404#line 3052 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006405 {
Devang Pateld222f862008-09-25 21:00:45 +00006406 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006407 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006408 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006409 // Used for call and invoke instructions
Dan Gohman54392c12008-04-19 00:24:39 +00006410 (yyval.ParamList) = new ParamList();
Devang Pateld222f862008-09-25 21:00:45 +00006411 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].Attributes) | (yyvsp[(4) - (4)].Attributes); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal));
Dan Gohman54392c12008-04-19 00:24:39 +00006412 (yyval.ParamList)->push_back(E);
6413 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006414 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006415 ;}
6416 break;
6417
Chris Lattnerc5320232008-10-15 06:16:57 +00006418 case 311:
6419#line 3063 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006420 {
Devang Pateld222f862008-09-25 21:00:45 +00006421 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dale Johannesencfb19e62007-11-05 21:20:28 +00006422 // Labels are only valid in ASMs
Dan Gohman54392c12008-04-19 00:24:39 +00006423 (yyval.ParamList) = new ParamList();
Devang Pateld222f862008-09-25 21:00:45 +00006424 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].Attributes) | (yyvsp[(4) - (4)].Attributes); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal));
Dan Gohman54392c12008-04-19 00:24:39 +00006425 (yyval.ParamList)->push_back(E);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006426 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006427 ;}
6428 break;
6429
Chris Lattnerc5320232008-10-15 06:16:57 +00006430 case 312:
6431#line 3071 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006432 {
Devang Pateld222f862008-09-25 21:00:45 +00006433 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006434 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006435 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6436 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Pateld222f862008-09-25 21:00:45 +00006437 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].Attributes) | (yyvsp[(6) - (6)].Attributes); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohman54392c12008-04-19 00:24:39 +00006438 (yyval.ParamList)->push_back(E);
6439 delete (yyvsp[(3) - (6)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006440 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006441 ;}
6442 break;
6443
Chris Lattnerc5320232008-10-15 06:16:57 +00006444 case 313:
6445#line 3081 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006446 {
Devang Pateld222f862008-09-25 21:00:45 +00006447 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dan Gohman54392c12008-04-19 00:24:39 +00006448 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Pateld222f862008-09-25 21:00:45 +00006449 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].Attributes) | (yyvsp[(6) - (6)].Attributes); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Dan Gohman54392c12008-04-19 00:24:39 +00006450 (yyval.ParamList)->push_back(E);
Dale Johannesencfb19e62007-11-05 21:20:28 +00006451 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006452 ;}
6453 break;
6454
Chris Lattnerc5320232008-10-15 06:16:57 +00006455 case 314:
6456#line 3088 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006457 { (yyval.ParamList) = new ParamList(); ;}
6458 break;
6459
Chris Lattnerc5320232008-10-15 06:16:57 +00006460 case 315:
6461#line 3091 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006462 { (yyval.ValueList) = new std::vector<Value*>(); ;}
6463 break;
6464
Chris Lattnerc5320232008-10-15 06:16:57 +00006465 case 316:
6466#line 3092 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006467 {
6468 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6469 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006470 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006471 ;}
6472 break;
6473
Chris Lattnerc5320232008-10-15 06:16:57 +00006474 case 317:
6475#line 3100 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane5febe42008-05-31 00:58:22 +00006476 {
6477 (yyval.ConstantList) = new std::vector<unsigned>();
6478 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
6479 GEN_ERROR("Index " + utostr((yyvsp[(2) - (2)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6480 (yyval.ConstantList)->push_back((yyvsp[(2) - (2)].UInt64Val));
6481 ;}
6482 break;
6483
Chris Lattnerc5320232008-10-15 06:16:57 +00006484 case 318:
6485#line 3106 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane5febe42008-05-31 00:58:22 +00006486 {
6487 (yyval.ConstantList) = (yyvsp[(1) - (3)].ConstantList);
6488 if ((unsigned)(yyvsp[(3) - (3)].UInt64Val) != (yyvsp[(3) - (3)].UInt64Val))
6489 GEN_ERROR("Index " + utostr((yyvsp[(3) - (3)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6490 (yyval.ConstantList)->push_back((yyvsp[(3) - (3)].UInt64Val));
6491 CHECK_FOR_ERROR
6492 ;}
6493 break;
6494
Chris Lattnerc5320232008-10-15 06:16:57 +00006495 case 319:
6496#line 3115 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006497 {
6498 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006499 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006500 ;}
6501 break;
6502
Chris Lattnerc5320232008-10-15 06:16:57 +00006503 case 320:
6504#line 3119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006505 {
6506 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006507 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006508 ;}
6509 break;
6510
Chris Lattnerc5320232008-10-15 06:16:57 +00006511 case 321:
6512#line 3124 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006513 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006514 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006515 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
Eric Christopher329d2672008-09-24 04:55:49 +00006516 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
Dan Gohman54392c12008-04-19 00:24:39 +00006517 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006518 GEN_ERROR(
6519 "Arithmetic operator requires integer, FP, or packed operands");
Eric Christopher329d2672008-09-24 04:55:49 +00006520 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006521 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006522 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006523 CHECK_FOR_ERROR
Dan Gohmane6b1ee62008-05-23 01:55:30 +00006524 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
Dan Gohman54392c12008-04-19 00:24:39 +00006525 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006526 GEN_ERROR("binary operator returned null");
Dan Gohman54392c12008-04-19 00:24:39 +00006527 delete (yyvsp[(2) - (5)].TypeVal);
6528 ;}
6529 break;
6530
Chris Lattnerc5320232008-10-15 06:16:57 +00006531 case 322:
6532#line 3140 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006533 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006534 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006535 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6536 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
Nate Begemanbb1ce942008-07-29 15:49:41 +00006537 if (!isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
Dan Gohman54392c12008-04-19 00:24:39 +00006538 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006539 GEN_ERROR("Logical operator requires integral operands");
6540 }
Dan Gohman54392c12008-04-19 00:24:39 +00006541 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006542 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006543 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006544 CHECK_FOR_ERROR
Dan Gohmane6b1ee62008-05-23 01:55:30 +00006545 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
Dan Gohman54392c12008-04-19 00:24:39 +00006546 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006547 GEN_ERROR("binary operator returned null");
Dan Gohman54392c12008-04-19 00:24:39 +00006548 delete (yyvsp[(2) - (5)].TypeVal);
6549 ;}
6550 break;
6551
Chris Lattnerc5320232008-10-15 06:16:57 +00006552 case 323:
6553#line 3157 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006554 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006555 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006556 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohman54392c12008-04-19 00:24:39 +00006557 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006558 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006559 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006560 CHECK_FOR_ERROR
Dan Gohmane6b1ee62008-05-23 01:55:30 +00006561 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Dan Gohman54392c12008-04-19 00:24:39 +00006562 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006563 GEN_ERROR("icmp operator returned null");
Dan Gohman54392c12008-04-19 00:24:39 +00006564 delete (yyvsp[(3) - (6)].TypeVal);
6565 ;}
6566 break;
6567
Chris Lattnerc5320232008-10-15 06:16:57 +00006568 case 324:
6569#line 3169 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006570 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006571 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006572 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohman54392c12008-04-19 00:24:39 +00006573 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006574 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006575 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006576 CHECK_FOR_ERROR
Dan Gohmane6b1ee62008-05-23 01:55:30 +00006577 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Dan Gohman54392c12008-04-19 00:24:39 +00006578 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006579 GEN_ERROR("fcmp operator returned null");
Dan Gohman54392c12008-04-19 00:24:39 +00006580 delete (yyvsp[(3) - (6)].TypeVal);
6581 ;}
6582 break;
6583
Chris Lattnerc5320232008-10-15 06:16:57 +00006584 case 325:
6585#line 3181 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman646fa482008-05-12 19:01:56 +00006586 {
6587 if (!UpRefs.empty())
6588 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6589 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6590 GEN_ERROR("Scalar types not supported by vicmp instruction");
6591 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6592 CHECK_FOR_ERROR
6593 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6594 CHECK_FOR_ERROR
Dan Gohmane6b1ee62008-05-23 01:55:30 +00006595 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Nate Begeman646fa482008-05-12 19:01:56 +00006596 if ((yyval.InstVal) == 0)
Dan Gohman181f4e42008-09-09 01:13:24 +00006597 GEN_ERROR("vicmp operator returned null");
Nate Begeman646fa482008-05-12 19:01:56 +00006598 delete (yyvsp[(3) - (6)].TypeVal);
6599 ;}
6600 break;
6601
Chris Lattnerc5320232008-10-15 06:16:57 +00006602 case 326:
6603#line 3195 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman646fa482008-05-12 19:01:56 +00006604 {
6605 if (!UpRefs.empty())
6606 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6607 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6608 GEN_ERROR("Scalar types not supported by vfcmp instruction");
6609 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6610 CHECK_FOR_ERROR
6611 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6612 CHECK_FOR_ERROR
Dan Gohmane6b1ee62008-05-23 01:55:30 +00006613 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Nate Begeman646fa482008-05-12 19:01:56 +00006614 if ((yyval.InstVal) == 0)
Dan Gohman181f4e42008-09-09 01:13:24 +00006615 GEN_ERROR("vfcmp operator returned null");
Nate Begeman646fa482008-05-12 19:01:56 +00006616 delete (yyvsp[(3) - (6)].TypeVal);
6617 ;}
6618 break;
6619
Chris Lattnerc5320232008-10-15 06:16:57 +00006620 case 327:
6621#line 3209 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006622 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006623 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006624 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6625 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6626 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6627 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006628 GEN_ERROR("invalid cast opcode for cast from '" +
6629 Val->getType()->getDescription() + "' to '" +
Eric Christopher329d2672008-09-24 04:55:49 +00006630 DestTy->getDescription() + "'");
Dan Gohmane6b1ee62008-05-23 01:55:30 +00006631 (yyval.InstVal) = CastInst::Create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
Dan Gohman54392c12008-04-19 00:24:39 +00006632 delete (yyvsp[(4) - (4)].TypeVal);
6633 ;}
6634 break;
6635
Chris Lattnerc5320232008-10-15 06:16:57 +00006636 case 328:
6637#line 3221 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006638 {
Dan Gohman181f4e42008-09-09 01:13:24 +00006639 if (isa<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType())) {
6640 // vector select
6641 if (!isa<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType())
6642 || !isa<VectorType>((yyvsp[(6) - (6)].ValueVal)->getType()) )
6643 GEN_ERROR("vector select value types must be vector types");
6644 const VectorType* cond_type = cast<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType());
6645 const VectorType* select_type = cast<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType());
6646 if (cond_type->getElementType() != Type::Int1Ty)
6647 GEN_ERROR("vector select condition element type must be boolean");
6648 if (cond_type->getNumElements() != select_type->getNumElements())
6649 GEN_ERROR("vector select number of elements must be the same");
6650 } else {
6651 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
6652 GEN_ERROR("select condition must be boolean");
6653 }
Dan Gohman54392c12008-04-19 00:24:39 +00006654 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohman181f4e42008-09-09 01:13:24 +00006655 GEN_ERROR("select value types must match");
Dan Gohman54392c12008-04-19 00:24:39 +00006656 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006657 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006658 ;}
6659 break;
6660
Chris Lattnerc5320232008-10-15 06:16:57 +00006661 case 329:
6662#line 3242 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006663 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006664 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006665 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6666 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6667 delete (yyvsp[(4) - (4)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006668 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006669 ;}
6670 break;
6671
Chris Lattnerc5320232008-10-15 06:16:57 +00006672 case 330:
6673#line 3249 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006674 {
6675 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006676 GEN_ERROR("Invalid extractelement operands");
Dan Gohman54392c12008-04-19 00:24:39 +00006677 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006678 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006679 ;}
6680 break;
6681
Chris Lattnerc5320232008-10-15 06:16:57 +00006682 case 331:
6683#line 3255 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006684 {
6685 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006686 GEN_ERROR("Invalid insertelement operands");
Dan Gohman54392c12008-04-19 00:24:39 +00006687 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006688 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006689 ;}
6690 break;
6691
Chris Lattnerc5320232008-10-15 06:16:57 +00006692 case 332:
6693#line 3261 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006694 {
6695 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006696 GEN_ERROR("Invalid shufflevector operands");
Dan Gohman54392c12008-04-19 00:24:39 +00006697 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006698 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006699 ;}
6700 break;
6701
Chris Lattnerc5320232008-10-15 06:16:57 +00006702 case 333:
6703#line 3267 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006704 {
6705 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006706 if (!Ty->isFirstClassType())
6707 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohman54392c12008-04-19 00:24:39 +00006708 (yyval.InstVal) = PHINode::Create(Ty);
6709 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6710 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
Eric Christopher329d2672008-09-24 04:55:49 +00006711 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006712 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohman54392c12008-04-19 00:24:39 +00006713 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6714 (yyvsp[(2) - (2)].PHIList)->pop_front();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006715 }
Dan Gohman54392c12008-04-19 00:24:39 +00006716 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006717 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006718 ;}
6719 break;
6720
Chris Lattnerc5320232008-10-15 06:16:57 +00006721 case 334:
6722#line 3283 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006723 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006724
6725 // Handle the short syntax
6726 const PointerType *PFTy = 0;
6727 const FunctionType *Ty = 0;
Devang Patelcd842482008-09-29 20:49:50 +00006728 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (9)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006729 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6730 // Pull out the types of all of the arguments...
6731 std::vector<const Type*> ParamTypes;
Devang Patelcd842482008-09-29 20:49:50 +00006732 ParamList::iterator I = (yyvsp[(7) - (9)].ParamList)->begin(), E = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006733 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006734 const Type *Ty = I->Val->getType();
6735 if (Ty == Type::VoidTy)
6736 GEN_ERROR("Short call syntax cannot be used with varargs");
6737 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006738 }
Chris Lattner73de3c02008-04-23 05:37:08 +00006739
Devang Patelcd842482008-09-29 20:49:50 +00006740 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (9)].TypeVal)))
Chris Lattner73de3c02008-04-23 05:37:08 +00006741 GEN_ERROR("Invalid result type for LLVM function");
6742
Devang Patelcd842482008-09-29 20:49:50 +00006743 Ty = FunctionType::get((yyvsp[(4) - (9)].TypeVal)->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00006744 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006745 }
6746
Devang Patelcd842482008-09-29 20:49:50 +00006747 Value *V = getVal(PFTy, (yyvsp[(5) - (9)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006748 CHECK_FOR_ERROR
6749
6750 // Check for call to invalid intrinsic to avoid crashing later.
6751 if (Function *theF = dyn_cast<Function>(V)) {
6752 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
6753 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6754 !theF->getIntrinsicID(true))
6755 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6756 theF->getName() + "'");
6757 }
6758
Devang Pateld222f862008-09-25 21:00:45 +00006759 // Set up the Attributes for the function
6760 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesen38ee4102008-09-26 23:46:20 +00006761 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6762 //attributes.
Devang Patelcd842482008-09-29 20:49:50 +00006763 Attributes RetAttrs = (yyvsp[(3) - (9)].Attributes);
6764 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None) {
6765 if ((yyvsp[(9) - (9)].Attributes) & Attribute::ZExt) {
Dale Johannesen38ee4102008-09-26 23:46:20 +00006766 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patelcd842482008-09-29 20:49:50 +00006767 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::ZExt;
Dale Johannesen38ee4102008-09-26 23:46:20 +00006768 }
Devang Patelcd842482008-09-29 20:49:50 +00006769 if ((yyvsp[(9) - (9)].Attributes) & Attribute::SExt) {
Dale Johannesen38ee4102008-09-26 23:46:20 +00006770 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patelcd842482008-09-29 20:49:50 +00006771 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::SExt;
Dale Johannesen38ee4102008-09-26 23:46:20 +00006772 }
Devang Patelcd842482008-09-29 20:49:50 +00006773 if ((yyvsp[(9) - (9)].Attributes) & Attribute::InReg) {
Dale Johannesen38ee4102008-09-26 23:46:20 +00006774 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patelcd842482008-09-29 20:49:50 +00006775 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::InReg;
Dale Johannesen38ee4102008-09-26 23:46:20 +00006776 }
Dale Johannesen38ee4102008-09-26 23:46:20 +00006777 }
Devang Patelcd842482008-09-29 20:49:50 +00006778 if (RetAttrs != Attribute::None)
6779 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesen38ee4102008-09-26 23:46:20 +00006780
Eric Christopher329d2672008-09-24 04:55:49 +00006781 // Check the arguments
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006782 ValueList Args;
Devang Patelcd842482008-09-29 20:49:50 +00006783 if ((yyvsp[(7) - (9)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006784 // Make sure no arguments is a good thing!
6785 if (Ty->getNumParams() != 0)
6786 GEN_ERROR("No arguments passed to a function that "
6787 "expects arguments");
6788 } else { // Has arguments?
6789 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006790 // correctly. Also, gather any parameter attributes.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006791 FunctionType::param_iterator I = Ty->param_begin();
6792 FunctionType::param_iterator E = Ty->param_end();
Devang Patelcd842482008-09-29 20:49:50 +00006793 ParamList::iterator ArgI = (yyvsp[(7) - (9)].ParamList)->begin(), ArgE = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006794 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006795
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006796 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006797 if (ArgI->Val->getType() != *I)
6798 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
6799 (*I)->getDescription() + "'");
6800 Args.push_back(ArgI->Val);
Devang Pateld222f862008-09-25 21:00:45 +00006801 if (ArgI->Attrs != Attribute::None)
6802 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006803 }
6804 if (Ty->isVarArg()) {
6805 if (I == E)
Chris Lattner59363a32008-02-19 04:36:25 +00006806 for (; ArgI != ArgE; ++ArgI, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006807 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Pateld222f862008-09-25 21:00:45 +00006808 if (ArgI->Attrs != Attribute::None)
6809 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner59363a32008-02-19 04:36:25 +00006810 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006811 } else if (I != E || ArgI != ArgE)
6812 GEN_ERROR("Invalid number of parameters detected");
6813 }
Devang Patelcd842482008-09-29 20:49:50 +00006814 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None)
6815 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (9)].Attributes)));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006816
Devang Pateld222f862008-09-25 21:00:45 +00006817 // Finish off the Attributes and check them
6818 AttrListPtr PAL;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006819 if (!Attrs.empty())
Devang Pateld222f862008-09-25 21:00:45 +00006820 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006821
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006822 // Create the call node
Gabor Greif89f01162008-04-06 23:07:54 +00006823 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Devang Patelcd842482008-09-29 20:49:50 +00006824 CI->setTailCall((yyvsp[(1) - (9)].BoolVal));
6825 CI->setCallingConv((yyvsp[(2) - (9)].UIntVal));
Devang Pateld222f862008-09-25 21:00:45 +00006826 CI->setAttributes(PAL);
Dan Gohman54392c12008-04-19 00:24:39 +00006827 (yyval.InstVal) = CI;
Devang Patelcd842482008-09-29 20:49:50 +00006828 delete (yyvsp[(7) - (9)].ParamList);
6829 delete (yyvsp[(4) - (9)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006830 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006831 ;}
6832 break;
6833
Chris Lattnerc5320232008-10-15 06:16:57 +00006834 case 335:
6835#line 3392 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006836 {
6837 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006838 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006839 ;}
6840 break;
6841
Chris Lattnerc5320232008-10-15 06:16:57 +00006842 case 336:
6843#line 3397 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006844 {
6845 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006846 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006847 ;}
6848 break;
6849
Chris Lattnerc5320232008-10-15 06:16:57 +00006850 case 337:
6851#line 3401 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006852 {
6853 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006854 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006855 ;}
6856 break;
6857
Chris Lattnerc5320232008-10-15 06:16:57 +00006858 case 338:
6859#line 3408 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006860 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006861 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006862 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6863 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6864 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006865 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006866 ;}
6867 break;
6868
Chris Lattnerc5320232008-10-15 06:16:57 +00006869 case 339:
6870#line 3415 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006871 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006872 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006873 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohmane5febe42008-05-31 00:58:22 +00006874 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6875 GEN_ERROR("Malloc array size is not a 32-bit integer!");
Dan Gohman54392c12008-04-19 00:24:39 +00006876 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006877 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006878 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6879 delete (yyvsp[(2) - (6)].TypeVal);
6880 ;}
6881 break;
6882
Chris Lattnerc5320232008-10-15 06:16:57 +00006883 case 340:
6884#line 3425 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006885 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006886 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006887 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6888 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6889 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006890 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006891 ;}
6892 break;
6893
Chris Lattnerc5320232008-10-15 06:16:57 +00006894 case 341:
6895#line 3432 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006896 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006897 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006898 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohmane5febe42008-05-31 00:58:22 +00006899 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6900 GEN_ERROR("Alloca array size is not a 32-bit integer!");
Dan Gohman54392c12008-04-19 00:24:39 +00006901 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006902 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006903 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6904 delete (yyvsp[(2) - (6)].TypeVal);
6905 ;}
6906 break;
6907
Chris Lattnerc5320232008-10-15 06:16:57 +00006908 case 342:
6909#line 3442 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006910 {
6911 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Eric Christopher329d2672008-09-24 04:55:49 +00006912 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohman54392c12008-04-19 00:24:39 +00006913 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6914 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006915 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006916 ;}
6917 break;
6918
Chris Lattnerc5320232008-10-15 06:16:57 +00006919 case 343:
6920#line 3450 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006921 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006922 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006923 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6924 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006925 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohman54392c12008-04-19 00:24:39 +00006926 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6927 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006928 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohman54392c12008-04-19 00:24:39 +00006929 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6930 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006931 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006932 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6933 delete (yyvsp[(3) - (5)].TypeVal);
6934 ;}
6935 break;
6936
Chris Lattnerc5320232008-10-15 06:16:57 +00006937 case 344:
6938#line 3464 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006939 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006940 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006941 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6942 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006943 if (!PT)
6944 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohman54392c12008-04-19 00:24:39 +00006945 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006946 const Type *ElTy = PT->getElementType();
Dan Gohman54392c12008-04-19 00:24:39 +00006947 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6948 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006949 "' into space of type '" + ElTy->getDescription() + "'");
6950
Dan Gohman54392c12008-04-19 00:24:39 +00006951 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006952 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006953 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6954 delete (yyvsp[(5) - (7)].TypeVal);
6955 ;}
6956 break;
6957
Chris Lattnerc5320232008-10-15 06:16:57 +00006958 case 345:
6959#line 3481 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006960 {
Dan Gohmanb94a0ba2008-07-23 00:54:54 +00006961 if (!UpRefs.empty())
6962 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6963 if (!isa<StructType>((yyvsp[(2) - (5)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (5)].TypeVal)->get()))
6964 GEN_ERROR("getresult insn requires an aggregate operand");
6965 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].UInt64Val)))
6966 GEN_ERROR("Invalid getresult index for type '" +
6967 (*(yyvsp[(2) - (5)].TypeVal))->getDescription()+ "'");
6968
6969 Value *tmpVal = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Devang Patel3b8849c2008-02-19 22:27:01 +00006970 CHECK_FOR_ERROR
Dan Gohmanb94a0ba2008-07-23 00:54:54 +00006971 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(5) - (5)].UInt64Val));
6972 delete (yyvsp[(2) - (5)].TypeVal);
Dan Gohman54392c12008-04-19 00:24:39 +00006973 ;}
6974 break;
6975
Chris Lattnerc5320232008-10-15 06:16:57 +00006976 case 346:
6977#line 3495 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006978 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006979 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006980 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6981 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006982 GEN_ERROR("getelementptr insn requires pointer operand");
6983
Dan Gohman8055f772008-05-15 19:50:34 +00006984 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006985 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohman54392c12008-04-19 00:24:39 +00006986 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6987 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006988 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006989 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
Eric Christopher329d2672008-09-24 04:55:49 +00006990 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohman54392c12008-04-19 00:24:39 +00006991 delete (yyvsp[(4) - (4)].ValueList);
6992 ;}
6993 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006994
Chris Lattnerc5320232008-10-15 06:16:57 +00006995 case 347:
6996#line 3510 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane6b1ee62008-05-23 01:55:30 +00006997 {
6998 if (!UpRefs.empty())
6999 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
7000 if (!isa<StructType>((yyvsp[(2) - (4)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (4)].TypeVal)->get()))
7001 GEN_ERROR("extractvalue insn requires an aggregate operand");
7002
Dan Gohmane5febe42008-05-31 00:58:22 +00007003 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end()))
Dan Gohmane6b1ee62008-05-23 01:55:30 +00007004 GEN_ERROR("Invalid extractvalue indices for type '" +
7005 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
7006 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
7007 CHECK_FOR_ERROR
Dan Gohmane5febe42008-05-31 00:58:22 +00007008 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end());
Eric Christopher329d2672008-09-24 04:55:49 +00007009 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohmane5febe42008-05-31 00:58:22 +00007010 delete (yyvsp[(4) - (4)].ConstantList);
Dan Gohmane6b1ee62008-05-23 01:55:30 +00007011 ;}
7012 break;
7013
Chris Lattnerc5320232008-10-15 06:16:57 +00007014 case 348:
7015#line 3525 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane6b1ee62008-05-23 01:55:30 +00007016 {
7017 if (!UpRefs.empty())
7018 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (7)].TypeVal))->getDescription());
7019 if (!isa<StructType>((yyvsp[(2) - (7)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (7)].TypeVal)->get()))
7020 GEN_ERROR("extractvalue insn requires an aggregate operand");
7021
Dan Gohmane5febe42008-05-31 00:58:22 +00007022 if (ExtractValueInst::getIndexedType(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end()) != (yyvsp[(5) - (7)].TypeVal)->get())
Dan Gohmane6b1ee62008-05-23 01:55:30 +00007023 GEN_ERROR("Invalid insertvalue indices for type '" +
7024 (*(yyvsp[(2) - (7)].TypeVal))->getDescription()+ "'");
7025 Value* aggVal = getVal(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(3) - (7)].ValIDVal));
7026 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
7027 CHECK_FOR_ERROR
Dan Gohmane5febe42008-05-31 00:58:22 +00007028 (yyval.InstVal) = InsertValueInst::Create(aggVal, tmpVal, (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end());
Eric Christopher329d2672008-09-24 04:55:49 +00007029 delete (yyvsp[(2) - (7)].TypeVal);
Dan Gohmane6b1ee62008-05-23 01:55:30 +00007030 delete (yyvsp[(5) - (7)].TypeVal);
Dan Gohmane5febe42008-05-31 00:58:22 +00007031 delete (yyvsp[(7) - (7)].ConstantList);
Dan Gohmane6b1ee62008-05-23 01:55:30 +00007032 ;}
7033 break;
7034
Dan Gohman54392c12008-04-19 00:24:39 +00007035
7036/* Line 1267 of yacc.c. */
Chris Lattnerc5320232008-10-15 06:16:57 +00007037#line 7038 "llvmAsmParser.tab.c"
Dan Gohman54392c12008-04-19 00:24:39 +00007038 default: break;
Dale Johannesen3afee192007-09-07 21:07:57 +00007039 }
Dan Gohman54392c12008-04-19 00:24:39 +00007040 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
7041
7042 YYPOPSTACK (yylen);
7043 yylen = 0;
7044 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007045
7046 *++yyvsp = yyval;
7047
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007048
Dan Gohman54392c12008-04-19 00:24:39 +00007049 /* Now `shift' the result of the reduction. Determine what state
7050 that goes to, based on the state we popped back to and the rule
7051 number reduced by. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007052
7053 yyn = yyr1[yyn];
7054
Dan Gohman54392c12008-04-19 00:24:39 +00007055 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
7056 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007057 yystate = yytable[yystate];
7058 else
Dan Gohman54392c12008-04-19 00:24:39 +00007059 yystate = yydefgoto[yyn - YYNTOKENS];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007060
7061 goto yynewstate;
7062
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007063
Dan Gohman54392c12008-04-19 00:24:39 +00007064/*------------------------------------.
7065| yyerrlab -- here on detecting error |
7066`------------------------------------*/
7067yyerrlab:
7068 /* If not already recovering from an error, report this error. */
7069 if (!yyerrstatus)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007070 {
7071 ++yynerrs;
Dan Gohman54392c12008-04-19 00:24:39 +00007072#if ! YYERROR_VERBOSE
7073 yyerror (YY_("syntax error"));
7074#else
7075 {
7076 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
7077 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
7078 {
7079 YYSIZE_T yyalloc = 2 * yysize;
7080 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
7081 yyalloc = YYSTACK_ALLOC_MAXIMUM;
7082 if (yymsg != yymsgbuf)
7083 YYSTACK_FREE (yymsg);
7084 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
7085 if (yymsg)
7086 yymsg_alloc = yyalloc;
7087 else
7088 {
7089 yymsg = yymsgbuf;
7090 yymsg_alloc = sizeof yymsgbuf;
7091 }
7092 }
Dale Johannesen3afee192007-09-07 21:07:57 +00007093
Dan Gohman54392c12008-04-19 00:24:39 +00007094 if (0 < yysize && yysize <= yymsg_alloc)
7095 {
7096 (void) yysyntax_error (yymsg, yystate, yychar);
7097 yyerror (yymsg);
7098 }
7099 else
7100 {
7101 yyerror (YY_("syntax error"));
7102 if (yysize != 0)
7103 goto yyexhaustedlab;
7104 }
7105 }
7106#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007107 }
7108
Dan Gohman54392c12008-04-19 00:24:39 +00007109
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007110
7111 if (yyerrstatus == 3)
7112 {
Dan Gohman54392c12008-04-19 00:24:39 +00007113 /* If just tried and failed to reuse look-ahead token after an
7114 error, discard it. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007115
Dan Gohman54392c12008-04-19 00:24:39 +00007116 if (yychar <= YYEOF)
7117 {
7118 /* Return failure if at end of input. */
7119 if (yychar == YYEOF)
7120 YYABORT;
7121 }
7122 else
7123 {
7124 yydestruct ("Error: discarding",
7125 yytoken, &yylval);
7126 yychar = YYEMPTY;
7127 }
7128 }
7129
7130 /* Else will try to reuse look-ahead token after shifting the error
7131 token. */
7132 goto yyerrlab1;
7133
7134
7135/*---------------------------------------------------.
7136| yyerrorlab -- error raised explicitly by YYERROR. |
7137`---------------------------------------------------*/
7138yyerrorlab:
7139
7140 /* Pacify compilers like GCC when the user code never invokes
7141 YYERROR and the label yyerrorlab therefore never appears in user
7142 code. */
7143 if (/*CONSTCOND*/ 0)
7144 goto yyerrorlab;
7145
7146 /* Do not reclaim the symbols of the rule which action triggered
7147 this YYERROR. */
7148 YYPOPSTACK (yylen);
7149 yylen = 0;
7150 YY_STACK_PRINT (yyss, yyssp);
7151 yystate = *yyssp;
7152 goto yyerrlab1;
7153
7154
7155/*-------------------------------------------------------------.
7156| yyerrlab1 -- common code for both syntax error and YYERROR. |
7157`-------------------------------------------------------------*/
7158yyerrlab1:
7159 yyerrstatus = 3; /* Each real token shifted decrements this. */
7160
7161 for (;;)
7162 {
7163 yyn = yypact[yystate];
7164 if (yyn != YYPACT_NINF)
7165 {
7166 yyn += YYTERROR;
7167 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7168 {
7169 yyn = yytable[yyn];
7170 if (0 < yyn)
7171 break;
7172 }
7173 }
7174
7175 /* Pop the current state because it cannot handle the error token. */
7176 if (yyssp == yyss)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007177 YYABORT;
7178
Dale Johannesen3afee192007-09-07 21:07:57 +00007179
Dan Gohman54392c12008-04-19 00:24:39 +00007180 yydestruct ("Error: popping",
7181 yystos[yystate], yyvsp);
7182 YYPOPSTACK (1);
7183 yystate = *yyssp;
7184 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007185 }
7186
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007187 if (yyn == YYFINAL)
7188 YYACCEPT;
7189
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007190 *++yyvsp = yylval;
Dan Gohman54392c12008-04-19 00:24:39 +00007191
7192
7193 /* Shift the error token. */
7194 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spenceraa8ae282007-07-31 03:50:36 +00007195
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007196 yystate = yyn;
7197 goto yynewstate;
7198
Gabor Greif89f01162008-04-06 23:07:54 +00007199
Dan Gohman54392c12008-04-19 00:24:39 +00007200/*-------------------------------------.
7201| yyacceptlab -- YYACCEPT comes here. |
7202`-------------------------------------*/
7203yyacceptlab:
7204 yyresult = 0;
7205 goto yyreturn;
7206
7207/*-----------------------------------.
7208| yyabortlab -- YYABORT comes here. |
7209`-----------------------------------*/
7210yyabortlab:
7211 yyresult = 1;
7212 goto yyreturn;
7213
7214#ifndef yyoverflow
7215/*-------------------------------------------------.
7216| yyexhaustedlab -- memory exhaustion comes here. |
7217`-------------------------------------------------*/
7218yyexhaustedlab:
7219 yyerror (YY_("memory exhausted"));
7220 yyresult = 2;
7221 /* Fall through. */
Chris Lattner59363a32008-02-19 04:36:25 +00007222#endif
Dan Gohman54392c12008-04-19 00:24:39 +00007223
7224yyreturn:
7225 if (yychar != YYEOF && yychar != YYEMPTY)
7226 yydestruct ("Cleanup: discarding lookahead",
7227 yytoken, &yylval);
7228 /* Do not reclaim the symbols of the rule which action triggered
7229 this YYABORT or YYACCEPT. */
7230 YYPOPSTACK (yylen);
7231 YY_STACK_PRINT (yyss, yyssp);
7232 while (yyssp != yyss)
7233 {
7234 yydestruct ("Cleanup: popping",
7235 yystos[*yyssp], yyvsp);
7236 YYPOPSTACK (1);
Gabor Greif89f01162008-04-06 23:07:54 +00007237 }
Dan Gohman54392c12008-04-19 00:24:39 +00007238#ifndef yyoverflow
7239 if (yyss != yyssa)
7240 YYSTACK_FREE (yyss);
7241#endif
7242#if YYERROR_VERBOSE
7243 if (yymsg != yymsgbuf)
7244 YYSTACK_FREE (yymsg);
7245#endif
7246 /* Make sure YYID is used. */
7247 return YYID (yyresult);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007248}
Dan Gohman54392c12008-04-19 00:24:39 +00007249
7250
Chris Lattnerc5320232008-10-15 06:16:57 +00007251#line 3544 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007252
7253
7254// common code from the two 'RunVMAsmParser' functions
7255static Module* RunParser(Module * M) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007256 CurModule.CurrentModule = M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007257 // Check to make sure the parser succeeded
7258 if (yyparse()) {
7259 if (ParserResult)
7260 delete ParserResult;
7261 return 0;
7262 }
7263
7264 // Emit an error if there are any unresolved types left.
7265 if (!CurModule.LateResolveTypes.empty()) {
7266 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
7267 if (DID.Type == ValID::LocalName) {
7268 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
7269 } else {
7270 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
7271 }
7272 if (ParserResult)
7273 delete ParserResult;
7274 return 0;
7275 }
7276
7277 // Emit an error if there are any unresolved values left.
7278 if (!CurModule.LateResolveValues.empty()) {
7279 Value *V = CurModule.LateResolveValues.back();
7280 std::map<Value*, std::pair<ValID, int> >::iterator I =
7281 CurModule.PlaceHolderInfo.find(V);
7282
7283 if (I != CurModule.PlaceHolderInfo.end()) {
7284 ValID &DID = I->second.first;
7285 if (DID.Type == ValID::LocalName) {
7286 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
7287 } else {
7288 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
7289 }
7290 if (ParserResult)
7291 delete ParserResult;
7292 return 0;
7293 }
7294 }
7295
7296 // Check to make sure that parsing produced a result
7297 if (!ParserResult)
7298 return 0;
7299
7300 // Reset ParserResult variable while saving its value for the result.
7301 Module *Result = ParserResult;
7302 ParserResult = 0;
7303
7304 return Result;
7305}
7306
7307void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00007308 if (LineNo == -1) LineNo = LLLgetLineNo();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007309 // TODO: column number in exception
7310 if (TheParseError)
Duncan Sandsf5588dc2007-11-27 13:23:08 +00007311 TheParseError->setError(LLLgetFilename(), message, LineNo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007312 TriggerError = 1;
7313}
7314
7315int yyerror(const char *ErrorMsg) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00007316 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007317 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00007318 if (yychar != YYEMPTY && yychar != 0) {
7319 errMsg += " while reading token: '";
Eric Christopher329d2672008-09-24 04:55:49 +00007320 errMsg += std::string(LLLgetTokenStart(),
Duncan Sandsf5588dc2007-11-27 13:23:08 +00007321 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
7322 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007323 GenerateError(errMsg);
7324 return 0;
7325}
Dan Gohman54392c12008-04-19 00:24:39 +00007326