blob: 3861ad3c95c2220e07a7f2c8b447415ab0e4690c [file] [log] [blame]
Dan Gohmanf4423b12008-04-19 00:24:39 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Dan Gohmanf4423b12008-04-19 00:24:39 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004
Dan Gohmanf4423b12008-04-19 00:24:39 +00005 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Anton Korobeynikov178a3522007-01-12 19:22:51 +00007
Dan Gohmanf4423b12008-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. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000062#define yyparse llvmAsmparse
Dan Gohmanf4423b12008-04-19 00:24:39 +000063#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000064#define yyerror llvmAsmerror
Dan Gohmanf4423b12008-04-19 00:24:39 +000065#define yylval llvmAsmlval
66#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000067#define yydebug llvmAsmdebug
68#define yynerrs llvmAsmnerrs
69
Dan Gohmanf4423b12008-04-19 00:24:39 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 ESAPINTVAL = 260,
80 EUAPINTVAL = 261,
81 LOCALVAL_ID = 262,
82 GLOBALVAL_ID = 263,
83 FPVAL = 264,
84 VOID = 265,
85 INTTYPE = 266,
86 FLOAT = 267,
87 DOUBLE = 268,
88 X86_FP80 = 269,
89 FP128 = 270,
90 PPC_FP128 = 271,
91 LABEL = 272,
92 TYPE = 273,
93 LOCALVAR = 274,
94 GLOBALVAR = 275,
95 LABELSTR = 276,
96 STRINGCONSTANT = 277,
97 ATSTRINGCONSTANT = 278,
98 PCTSTRINGCONSTANT = 279,
99 ZEROINITIALIZER = 280,
100 TRUETOK = 281,
101 FALSETOK = 282,
102 BEGINTOK = 283,
103 ENDTOK = 284,
104 DECLARE = 285,
105 DEFINE = 286,
106 GLOBAL = 287,
107 CONSTANT = 288,
108 SECTION = 289,
109 ALIAS = 290,
110 VOLATILE = 291,
111 THREAD_LOCAL = 292,
112 TO = 293,
113 DOTDOTDOT = 294,
114 NULL_TOK = 295,
115 UNDEF = 296,
116 INTERNAL = 297,
117 LINKONCE = 298,
118 WEAK = 299,
119 APPENDING = 300,
120 DLLIMPORT = 301,
121 DLLEXPORT = 302,
122 EXTERN_WEAK = 303,
123 OPAQUE = 304,
124 EXTERNAL = 305,
125 TARGET = 306,
126 TRIPLE = 307,
127 ALIGN = 308,
128 ADDRSPACE = 309,
129 DEPLIBS = 310,
130 CALL = 311,
131 TAIL = 312,
132 ASM_TOK = 313,
133 MODULE = 314,
134 SIDEEFFECT = 315,
135 CC_TOK = 316,
136 CCC_TOK = 317,
137 FASTCC_TOK = 318,
138 COLDCC_TOK = 319,
139 X86_STDCALLCC_TOK = 320,
140 X86_FASTCALLCC_TOK = 321,
141 DATALAYOUT = 322,
Chris Lattnercc81d152008-05-04 17:18:47 +0000142 RET = 323,
143 BR = 324,
144 SWITCH = 325,
145 INVOKE = 326,
146 UNWIND = 327,
147 UNREACHABLE = 328,
148 ADD = 329,
149 SUB = 330,
150 MUL = 331,
151 UDIV = 332,
152 SDIV = 333,
153 FDIV = 334,
154 UREM = 335,
155 SREM = 336,
156 FREM = 337,
157 AND = 338,
158 OR = 339,
159 XOR = 340,
160 SHL = 341,
161 LSHR = 342,
162 ASHR = 343,
163 ICMP = 344,
164 FCMP = 345,
Nate Begemanac80ade2008-05-12 19:01:56 +0000165 VICMP = 346,
166 VFCMP = 347,
167 EQ = 348,
168 NE = 349,
169 SLT = 350,
170 SGT = 351,
171 SLE = 352,
172 SGE = 353,
173 ULT = 354,
174 UGT = 355,
175 ULE = 356,
176 UGE = 357,
177 OEQ = 358,
178 ONE = 359,
179 OLT = 360,
180 OGT = 361,
181 OLE = 362,
182 OGE = 363,
183 ORD = 364,
184 UNO = 365,
185 UEQ = 366,
186 UNE = 367,
187 MALLOC = 368,
188 ALLOCA = 369,
189 FREE = 370,
190 LOAD = 371,
191 STORE = 372,
192 GETELEMENTPTR = 373,
193 TRUNC = 374,
194 ZEXT = 375,
195 SEXT = 376,
196 FPTRUNC = 377,
197 FPEXT = 378,
198 BITCAST = 379,
199 UITOFP = 380,
200 SITOFP = 381,
201 FPTOUI = 382,
202 FPTOSI = 383,
203 INTTOPTR = 384,
204 PTRTOINT = 385,
205 PHI_TOK = 386,
206 SELECT = 387,
207 VAARG = 388,
208 EXTRACTELEMENT = 389,
209 INSERTELEMENT = 390,
210 SHUFFLEVECTOR = 391,
211 GETRESULT = 392,
212 SIGNEXT = 393,
213 ZEROEXT = 394,
214 NORETURN = 395,
215 INREG = 396,
216 SRET = 397,
217 NOUNWIND = 398,
218 NOALIAS = 399,
219 BYVAL = 400,
220 NEST = 401,
221 READNONE = 402,
222 READONLY = 403,
223 GC = 404,
224 DEFAULT = 405,
225 HIDDEN = 406,
226 PROTECTED = 407
Dan Gohmanf4423b12008-04-19 00:24:39 +0000227 };
228#endif
229/* Tokens. */
230#define ESINT64VAL 258
231#define EUINT64VAL 259
232#define ESAPINTVAL 260
233#define EUAPINTVAL 261
234#define LOCALVAL_ID 262
235#define GLOBALVAL_ID 263
236#define FPVAL 264
237#define VOID 265
238#define INTTYPE 266
239#define FLOAT 267
240#define DOUBLE 268
241#define X86_FP80 269
242#define FP128 270
243#define PPC_FP128 271
244#define LABEL 272
245#define TYPE 273
246#define LOCALVAR 274
247#define GLOBALVAR 275
248#define LABELSTR 276
249#define STRINGCONSTANT 277
250#define ATSTRINGCONSTANT 278
251#define PCTSTRINGCONSTANT 279
252#define ZEROINITIALIZER 280
253#define TRUETOK 281
254#define FALSETOK 282
255#define BEGINTOK 283
256#define ENDTOK 284
257#define DECLARE 285
258#define DEFINE 286
259#define GLOBAL 287
260#define CONSTANT 288
261#define SECTION 289
262#define ALIAS 290
263#define VOLATILE 291
264#define THREAD_LOCAL 292
265#define TO 293
266#define DOTDOTDOT 294
267#define NULL_TOK 295
268#define UNDEF 296
269#define INTERNAL 297
270#define LINKONCE 298
271#define WEAK 299
272#define APPENDING 300
273#define DLLIMPORT 301
274#define DLLEXPORT 302
275#define EXTERN_WEAK 303
276#define OPAQUE 304
277#define EXTERNAL 305
278#define TARGET 306
279#define TRIPLE 307
280#define ALIGN 308
281#define ADDRSPACE 309
282#define DEPLIBS 310
283#define CALL 311
284#define TAIL 312
285#define ASM_TOK 313
286#define MODULE 314
287#define SIDEEFFECT 315
288#define CC_TOK 316
289#define CCC_TOK 317
290#define FASTCC_TOK 318
291#define COLDCC_TOK 319
292#define X86_STDCALLCC_TOK 320
293#define X86_FASTCALLCC_TOK 321
294#define DATALAYOUT 322
Chris Lattnercc81d152008-05-04 17:18:47 +0000295#define RET 323
296#define BR 324
297#define SWITCH 325
298#define INVOKE 326
299#define UNWIND 327
300#define UNREACHABLE 328
301#define ADD 329
302#define SUB 330
303#define MUL 331
304#define UDIV 332
305#define SDIV 333
306#define FDIV 334
307#define UREM 335
308#define SREM 336
309#define FREM 337
310#define AND 338
311#define OR 339
312#define XOR 340
313#define SHL 341
314#define LSHR 342
315#define ASHR 343
316#define ICMP 344
317#define FCMP 345
Nate Begemanac80ade2008-05-12 19:01:56 +0000318#define VICMP 346
319#define VFCMP 347
320#define EQ 348
321#define NE 349
322#define SLT 350
323#define SGT 351
324#define SLE 352
325#define SGE 353
326#define ULT 354
327#define UGT 355
328#define ULE 356
329#define UGE 357
330#define OEQ 358
331#define ONE 359
332#define OLT 360
333#define OGT 361
334#define OLE 362
335#define OGE 363
336#define ORD 364
337#define UNO 365
338#define UEQ 366
339#define UNE 367
340#define MALLOC 368
341#define ALLOCA 369
342#define FREE 370
343#define LOAD 371
344#define STORE 372
345#define GETELEMENTPTR 373
346#define TRUNC 374
347#define ZEXT 375
348#define SEXT 376
349#define FPTRUNC 377
350#define FPEXT 378
351#define BITCAST 379
352#define UITOFP 380
353#define SITOFP 381
354#define FPTOUI 382
355#define FPTOSI 383
356#define INTTOPTR 384
357#define PTRTOINT 385
358#define PHI_TOK 386
359#define SELECT 387
360#define VAARG 388
361#define EXTRACTELEMENT 389
362#define INSERTELEMENT 390
363#define SHUFFLEVECTOR 391
364#define GETRESULT 392
365#define SIGNEXT 393
366#define ZEROEXT 394
367#define NORETURN 395
368#define INREG 396
369#define SRET 397
370#define NOUNWIND 398
371#define NOALIAS 399
372#define BYVAL 400
373#define NEST 401
374#define READNONE 402
375#define READONLY 403
376#define GC 404
377#define DEFAULT 405
378#define HIDDEN 406
379#define PROTECTED 407
Dan Gohmanf4423b12008-04-19 00:24:39 +0000380
381
382
383
384/* Copy the first part of user declarations. */
Nate Begemanac80ade2008-05-12 19:01:56 +0000385#line 14 "/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000386
387#include "ParserInternals.h"
388#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000389#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000390#include "llvm/Instructions.h"
391#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000392#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000393#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000394#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000395#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000396#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000397#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000398#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000399#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000400#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000401#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000402#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000403#include <utility>
404
Reid Spencere4f47592006-08-18 17:32:55 +0000405// The following is a gross hack. In order to rid the libAsmParser library of
406// exceptions, we have to have a way of getting the yyparse function to go into
407// an error situation. So, whenever we want an error to occur, the GenerateError
408// function (see bottom of file) sets TriggerError. Then, at the end of each
409// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
410// (a goto) to put YACC in error state. Furthermore, several calls to
411// GenerateError are made from inside productions and they must simulate the
412// previous exception behavior by exiting the production immediately. We have
413// replaced these with the GEN_ERROR macro which calls GeneratError and then
414// immediately invokes YYERROR. This would be so much cleaner if it was a
415// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000416static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000417#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000418#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
419
Reid Spencer68a24bd2005-08-27 18:50:39 +0000420int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
421int yylex(); // declaration" of xxx warnings.
422int yyparse();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000423using namespace llvm;
424
425static Module *ParserResult;
426
427// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
428// relating to upreferences in the input stream.
429//
430//#define DEBUG_UPREFS 1
431#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000432#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000433#else
434#define UR_OUT(X)
435#endif
436
437#define YYERROR_VERBOSE 1
438
Chris Lattnerb475c422005-11-12 18:22:38 +0000439static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000440
441
442// This contains info used when building the body of a function. It is
443// destroyed when the function is completed.
444//
445typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000446
Reid Spencer68a24bd2005-08-27 18:50:39 +0000447static void
Reid Spencer93c40032007-03-19 18:40:50 +0000448ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000449
450static struct PerModuleInfo {
451 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000452 ValueList Values; // Module level numbered definitions
453 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000454 std::vector<PATypeHolder> Types;
455 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000456
457 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000458 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000459 /// that we can resolve them later and print error messages as appropriate.
460 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
461
462 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
463 // references to global values. Global values may be referenced before they
464 // are defined, and if so, the temporary object that they represent is held
465 // here. This is used for forward references of GlobalValues.
466 //
467 typedef std::map<std::pair<const PointerType *,
468 ValID>, GlobalValue*> GlobalRefsType;
469 GlobalRefsType GlobalRefs;
470
471 void ModuleDone() {
472 // If we could not resolve some functions at function compilation time
473 // (calls to functions before they are defined), resolve them now... Types
474 // are resolved when the constant pool has been completely parsed.
475 //
476 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000477 if (TriggerError)
478 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000479
480 // Check to make sure that all global value forward references have been
481 // resolved!
482 //
483 if (!GlobalRefs.empty()) {
484 std::string UndefinedReferences = "Unresolved global references exist:\n";
485
486 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
487 I != E; ++I) {
488 UndefinedReferences += " " + I->first.first->getDescription() + " " +
489 I->first.second.getName() + "\n";
490 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000491 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000492 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000493 }
494
Chandler Carruth02202192007-08-04 01:56:21 +0000495 // Look for intrinsic functions and CallInst that need to be upgraded
496 for (Module::iterator FI = CurrentModule->begin(),
497 FE = CurrentModule->end(); FI != FE; )
498 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
499
Reid Spencer68a24bd2005-08-27 18:50:39 +0000500 Values.clear(); // Clear out function local definitions
501 Types.clear();
502 CurrentModule = 0;
503 }
504
Reid Spencer68a24bd2005-08-27 18:50:39 +0000505 // GetForwardRefForGlobal - Check to see if there is a forward reference
506 // for this global. If so, remove it from the GlobalRefs map and return it.
507 // If not, just return null.
508 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
509 // Check to see if there is a forward reference to this global variable...
510 // if there is, eliminate it and patch the reference to use the new def'n.
511 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
512 GlobalValue *Ret = 0;
513 if (I != GlobalRefs.end()) {
514 Ret = I->second;
515 GlobalRefs.erase(I);
516 }
517 return Ret;
518 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000519
520 bool TypeIsUnresolved(PATypeHolder* PATy) {
521 // If it isn't abstract, its resolved
522 const Type* Ty = PATy->get();
523 if (!Ty->isAbstract())
524 return false;
525 // Traverse the type looking for abstract types. If it isn't abstract then
526 // we don't need to traverse that leg of the type.
527 std::vector<const Type*> WorkList, SeenList;
528 WorkList.push_back(Ty);
529 while (!WorkList.empty()) {
530 const Type* Ty = WorkList.back();
531 SeenList.push_back(Ty);
532 WorkList.pop_back();
533 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
534 // Check to see if this is an unresolved type
535 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
536 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
537 for ( ; I != E; ++I) {
538 if (I->second.get() == OpTy)
539 return true;
540 }
541 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
542 const Type* TheTy = SeqTy->getElementType();
543 if (TheTy->isAbstract() && TheTy != Ty) {
544 std::vector<const Type*>::iterator I = SeenList.begin(),
545 E = SeenList.end();
546 for ( ; I != E; ++I)
547 if (*I == TheTy)
548 break;
549 if (I == E)
550 WorkList.push_back(TheTy);
551 }
552 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
553 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
554 const Type* TheTy = StrTy->getElementType(i);
555 if (TheTy->isAbstract() && TheTy != Ty) {
556 std::vector<const Type*>::iterator I = SeenList.begin(),
557 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 }
565 }
566 }
567 return false;
568 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000569} CurModule;
570
571static struct PerFunctionInfo {
572 Function *CurrentFunction; // Pointer to current function being created
573
Reid Spencer93c40032007-03-19 18:40:50 +0000574 ValueList Values; // Keep track of #'d definitions
575 unsigned NextValNum;
576 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000577 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000578 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000579 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000580
581 /// BBForwardRefs - When we see forward references to basic blocks, keep
582 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000583 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584
585 inline PerFunctionInfo() {
586 CurrentFunction = 0;
587 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000588 Linkage = GlobalValue::ExternalLinkage;
589 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000590 }
591
592 inline void FunctionStart(Function *M) {
593 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000594 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000595 }
596
597 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000598 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000599 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000600 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000601 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000602 return;
603 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000604
605 // Resolve all forward references now.
606 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
607
608 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000609 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000610 CurrentFunction = 0;
611 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000612 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000613 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000614 }
615} CurFun; // Info for the current function...
616
617static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
618
619
620//===----------------------------------------------------------------------===//
621// Code to handle definitions of all the types
622//===----------------------------------------------------------------------===//
623
Reid Spencer93c40032007-03-19 18:40:50 +0000624static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
625 // Things that have names or are void typed don't get slot numbers
626 if (V->hasName() || (V->getType() == Type::VoidTy))
627 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000628
Reid Spencer93c40032007-03-19 18:40:50 +0000629 // In the case of function values, we have to allow for the forward reference
630 // of basic blocks, which are included in the numbering. Consequently, we keep
631 // track of the next insertion location with NextValNum. When a BB gets
632 // inserted, it could change the size of the CurFun.Values vector.
633 if (&ValueTab == &CurFun.Values) {
634 if (ValueTab.size() <= CurFun.NextValNum)
635 ValueTab.resize(CurFun.NextValNum+1);
636 ValueTab[CurFun.NextValNum++] = V;
637 return;
638 }
639 // For all other lists, its okay to just tack it on the back of the vector.
640 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641}
642
643static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
644 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000645 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000647 if (D.Num < CurModule.Types.size())
648 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000649 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000650 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000651 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000652 D.destroy(); // Free old strdup'd memory...
653 return N;
654 }
655 break;
656 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000657 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000658 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000659 }
660
661 // If we reached here, we referenced either a symbol that we don't know about
662 // or an id number that hasn't been read yet. We may be referencing something
663 // forward, so just create an entry to be resolved later and get to it...
664 //
665 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
666
667
668 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000669 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000670 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000671 return 0;
672 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000673 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000674 return 0;
675 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000676 }
677
Reid Spencer861d9d62006-11-28 07:29:44 +0000678 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000679 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000680 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000681
Reid Spencer861d9d62006-11-28 07:29:44 +0000682 Type *Typ = OpaqueType::get();
683 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
684 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000685 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000686
Reid Spencer93c40032007-03-19 18:40:50 +0000687// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000688// the provided ValID. If the value exists and has already been defined, return
689// it. Otherwise return null.
690//
Reid Spencer93c40032007-03-19 18:40:50 +0000691static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000692 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000693 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000694 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000695 return 0;
696 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000697
698 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000699 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000700 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000701 if (D.Num >= CurFun.Values.size())
702 return 0;
703 Value *Result = CurFun.Values[D.Num];
704 if (Ty != Result->getType()) {
705 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
706 Result->getType()->getDescription() + "' does not match "
707 "expected type, '" + Ty->getDescription() + "'");
708 return 0;
709 }
710 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000711 }
712 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000713 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000714 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000715 Value *Result = CurModule.Values[D.Num];
716 if (Ty != Result->getType()) {
717 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
718 Result->getType()->getDescription() + "' does not match "
719 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000720 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000721 }
722 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000723 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000724
725 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000726 if (!inFunctionScope())
727 return 0;
728 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000729 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000730 if (N == 0)
731 return 0;
732 if (N->getType() != Ty)
733 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000734
735 D.destroy(); // Free old strdup'd memory...
736 return N;
737 }
738 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000739 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000740 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000741 if (N == 0)
742 return 0;
743 if (N->getType() != Ty)
744 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000745
746 D.destroy(); // Free old strdup'd memory...
747 return N;
748 }
749
750 // Check to make sure that "Ty" is an integral type, and that our
751 // value will fit into the specified type...
752 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner38905612008-02-19 04:36:25 +0000753 if (!isa<IntegerType>(Ty) ||
754 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000755 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000756 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000757 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000758 return 0;
759 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000760 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000761
762 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000763 if (isa<IntegerType>(Ty) &&
764 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Reid Spencerb83eb642006-10-20 07:07:24 +0000765 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner38905612008-02-19 04:36:25 +0000766
767 if (!isa<IntegerType>(Ty) ||
768 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
769 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
770 "' is invalid or out of range for type '" +
771 Ty->getDescription() + "'");
772 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000773 }
Chris Lattner38905612008-02-19 04:36:25 +0000774 // This is really a signed reference. Transmogrify.
775 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776
777 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000778 if (!Ty->isFloatingPoint() ||
779 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000780 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000781 return 0;
782 }
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000783 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +0000784 // as double. Fix this here. Long double does not need this.
785 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
786 Ty==Type::FloatTy)
Dale Johannesencdd509a2007-09-07 21:07:57 +0000787 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000788 return ConstantFP::get(*D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000789
790 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000791 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000792 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000793 return 0;
794 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000795 return ConstantPointerNull::get(cast<PointerType>(Ty));
796
797 case ValID::ConstUndefVal: // Is it an undef value?
798 return UndefValue::get(Ty);
799
Chris Lattner7aa61892005-12-21 17:53:23 +0000800 case ValID::ConstZeroVal: // Is it a zero value?
801 return Constant::getNullValue(Ty);
802
Reid Spencer68a24bd2005-08-27 18:50:39 +0000803 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000804 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000805 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000806 return 0;
807 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000808 return D.ConstantValue;
809
Chris Lattner0e9c3762006-01-25 22:27:16 +0000810 case ValID::InlineAsmVal: { // Inline asm expression
811 const PointerType *PTy = dyn_cast<PointerType>(Ty);
812 const FunctionType *FTy =
813 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000814 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000815 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000816 return 0;
817 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000818 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
819 D.IAD->HasSideEffects);
820 D.destroy(); // Free InlineAsmDescriptor.
821 return IA;
822 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000823 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000824 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000825 return 0;
826 } // End of switch
827
Reid Spencera9720f52007-02-05 17:04:00 +0000828 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829 return 0;
830}
831
Reid Spencer93c40032007-03-19 18:40:50 +0000832// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000833// value is not already defined, it "improvises" by creating a placeholder var
834// that looks and acts just like the requested variable. When the value is
835// defined later, all uses of the placeholder variable are replaced with the
836// real thing.
837//
838static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000839 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000840 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000841 return 0;
842 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000843
844 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000845 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000846 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000847 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000848
Reid Spencer5b7e7532006-09-28 19:28:24 +0000849 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000850 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000851 return 0;
852 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000853
854 // If we reached here, we referenced either a symbol that we don't know about
855 // or an id number that hasn't been read yet. We may be referencing something
856 // forward, so just create an entry to be resolved later and get to it...
857 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000858 switch (ID.Type) {
859 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000860 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000861 const PointerType *PTy = dyn_cast<PointerType>(Ty);
862 if (!PTy) {
863 GenerateError("Invalid type for reference to global" );
864 return 0;
865 }
866 const Type* ElTy = PTy->getElementType();
867 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greife64d2482008-04-06 23:07:54 +0000868 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000869 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000870 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
871 (Module*)0, false, PTy->getAddressSpace());
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000872 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000873 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000874 default:
875 V = new Argument(Ty);
876 }
877
Reid Spencer68a24bd2005-08-27 18:50:39 +0000878 // Remember where this forward reference came from. FIXME, shouldn't we try
879 // to recycle these things??
880 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsdc024672007-11-27 13:23:08 +0000881 LLLgetLineNo())));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000882
883 if (inFunctionScope())
884 InsertValue(V, CurFun.LateResolveValues);
885 else
886 InsertValue(V, CurModule.LateResolveValues);
887 return V;
888}
889
Reid Spencer93c40032007-03-19 18:40:50 +0000890/// defineBBVal - This is a definition of a new basic block with the specified
891/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Chris Lattnercc81d152008-05-04 17:18:47 +0000892static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000893 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000894
Reid Spencer68a24bd2005-08-27 18:50:39 +0000895 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000896
Reid Spencer93c40032007-03-19 18:40:50 +0000897 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000898
Reid Spencer93c40032007-03-19 18:40:50 +0000899 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
900 if (BBI != CurFun.BBForwardRefs.end()) {
901 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000902 // The forward declaration could have been inserted anywhere in the
903 // function: insert it into the correct place now.
904 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
905 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000906
Reid Spencer66728ef2007-03-20 01:13:36 +0000907 // We're about to erase the entry, save the key so we can clean it up.
908 ValID Tmp = BBI->first;
909
Reid Spencer93c40032007-03-19 18:40:50 +0000910 // Erase the forward ref from the map as its no longer "forward"
911 CurFun.BBForwardRefs.erase(ID);
912
Reid Spencer66728ef2007-03-20 01:13:36 +0000913 // The key has been removed from the map but so we don't want to leave
914 // strdup'd memory around so destroy it too.
915 Tmp.destroy();
916
Reid Spencer93c40032007-03-19 18:40:50 +0000917 // If its a numbered definition, bump the number and set the BB value.
918 if (ID.Type == ValID::LocalID) {
919 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
920 InsertValue(BB);
921 }
Devang Patel67909432008-03-03 18:58:47 +0000922 } else {
923 // We haven't seen this BB before and its first mention is a definition.
924 // Just create it and return it.
925 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greife64d2482008-04-06 23:07:54 +0000926 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel67909432008-03-03 18:58:47 +0000927 if (ID.Type == ValID::LocalID) {
928 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
929 InsertValue(BB);
930 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000931 }
Reid Spencer93c40032007-03-19 18:40:50 +0000932
Devang Patel67909432008-03-03 18:58:47 +0000933 ID.destroy();
Reid Spencer93c40032007-03-19 18:40:50 +0000934 return BB;
935}
936
937/// getBBVal - get an existing BB value or create a forward reference for it.
938///
939static BasicBlock *getBBVal(const ValID &ID) {
940 assert(inFunctionScope() && "Can't get basic block at global scope!");
941
942 BasicBlock *BB = 0;
943
944 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
945 if (BBI != CurFun.BBForwardRefs.end()) {
946 BB = BBI->second;
947 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000948 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000949 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000950 if (N) {
Reid Spencer93c40032007-03-19 18:40:50 +0000951 if (N->getType()->getTypeID() == Type::LabelTyID)
952 BB = cast<BasicBlock>(N);
953 else
954 GenerateError("Reference to label '" + Name + "' is actually of type '"+
955 N->getType()->getDescription() + "'");
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000956 }
Reid Spencer93c40032007-03-19 18:40:50 +0000957 } else if (ID.Type == ValID::LocalID) {
958 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
959 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
960 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
961 else
962 GenerateError("Reference to label '%" + utostr(ID.Num) +
963 "' is actually of type '"+
964 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
965 }
966 } else {
967 GenerateError("Illegal label reference " + ID.getName());
968 return 0;
969 }
970
971 // If its already been defined, return it now.
972 if (BB) {
973 ID.destroy(); // Free strdup'd memory.
974 return BB;
975 }
976
977 // Otherwise, this block has not been seen before, create it.
978 std::string Name;
979 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000980 Name = ID.getName();
Gabor Greife64d2482008-04-06 23:07:54 +0000981 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Reid Spencer93c40032007-03-19 18:40:50 +0000982
983 // Insert it in the forward refs map.
984 CurFun.BBForwardRefs[ID] = BB;
985
Reid Spencer68a24bd2005-08-27 18:50:39 +0000986 return BB;
987}
988
989
990//===----------------------------------------------------------------------===//
991// Code to handle forward references in instructions
992//===----------------------------------------------------------------------===//
993//
994// This code handles the late binding needed with statements that reference
995// values not defined yet... for example, a forward branch, or the PHI node for
996// a loop body.
997//
998// This keeps a table (CurFun.LateResolveValues) of all such forward references
999// and back patchs after we are done.
1000//
1001
1002// ResolveDefinitions - If we could not resolve some defs at parsing
1003// time (forward branches, phi functions for loops, etc...) resolve the
1004// defs now...
1005//
1006static void
Reid Spencer93c40032007-03-19 18:40:50 +00001007ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001008 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +00001009 while (!LateResolvers.empty()) {
1010 Value *V = LateResolvers.back();
1011 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001012
Reid Spencer93c40032007-03-19 18:40:50 +00001013 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1014 CurModule.PlaceHolderInfo.find(V);
1015 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001016
Reid Spencer93c40032007-03-19 18:40:50 +00001017 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001018
Reid Spencer93c40032007-03-19 18:40:50 +00001019 Value *TheRealValue = getExistingVal(V->getType(), DID);
1020 if (TriggerError)
1021 return;
1022 if (TheRealValue) {
1023 V->replaceAllUsesWith(TheRealValue);
1024 delete V;
1025 CurModule.PlaceHolderInfo.erase(PHI);
1026 } else if (FutureLateResolvers) {
1027 // Functions have their unresolved items forwarded to the module late
1028 // resolver table
1029 InsertValue(V, *FutureLateResolvers);
1030 } else {
1031 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1032 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1033 "' of type '" + V->getType()->getDescription() + "'",
1034 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001035 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001036 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001037 GenerateError("Reference to an invalid definition: #" +
1038 itostr(DID.Num) + " of type '" +
1039 V->getType()->getDescription() + "'",
1040 PHI->second.second);
1041 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001042 }
1043 }
1044 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001045 LateResolvers.clear();
1046}
1047
1048// ResolveTypeTo - A brand new type was just declared. This means that (if
1049// name is not null) things referencing Name can be resolved. Otherwise, things
1050// refering to the number can be resolved. Do this now.
1051//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001052static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001053 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001054 if (Name)
1055 D = ValID::createLocalName(*Name);
1056 else
1057 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001058
Reid Spencer861d9d62006-11-28 07:29:44 +00001059 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001060 CurModule.LateResolveTypes.find(D);
1061 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001062 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001063 CurModule.LateResolveTypes.erase(I);
1064 }
1065}
1066
1067// setValueName - Set the specified value to the name given. The name may be
1068// null potentially, in which case this is a noop. The string passed in is
1069// assumed to be a malloc'd string buffer, and is free'd by this function.
1070//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001071static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001072 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001073 std::string Name(*NameStr); // Copy string
1074 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001075
Reid Spencer41dff5e2007-01-26 08:05:27 +00001076 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001077 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001078 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001079 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001080
Reid Spencera9720f52007-02-05 17:04:00 +00001081 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001082 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1083 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001084 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001085 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001086 return;
1087 }
1088
1089 // Set the name.
1090 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001091}
1092
1093/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1094/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001095static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001096ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001097 GlobalValue::LinkageTypes Linkage,
1098 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001099 bool isConstantGlobal, const Type *Ty,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001100 Constant *Initializer, bool IsThreadLocal,
1101 unsigned AddressSpace = 0) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001102 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001103 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001104 return 0;
1105 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001106
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001107 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001108
1109 std::string Name;
1110 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001111 Name = *NameStr; // Copy string
1112 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001113 }
1114
1115 // See if this global value was forward referenced. If so, recycle the
1116 // object.
1117 ValID ID;
1118 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001119 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001120 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001121 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001122 }
1123
1124 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1125 // Move the global to the end of the list, from whereever it was
1126 // previously inserted.
1127 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1128 CurModule.CurrentModule->getGlobalList().remove(GV);
1129 CurModule.CurrentModule->getGlobalList().push_back(GV);
1130 GV->setInitializer(Initializer);
1131 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001132 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001133 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001134 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001135 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001136 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001137 }
1138
Reid Spenceref9b9a72007-02-05 20:47:22 +00001139 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001140 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001141 // if the global we're parsing has an initializer (is a definition) and
1142 // has external linkage.
1143 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1144 // If there is already a global with external linkage with this name
1145 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1146 // If we allow this GVar to get created, it will be renamed in the
1147 // symbol table because it conflicts with an existing GVar. We can't
1148 // allow redefinition of GVars whose linking indicates that their name
1149 // must stay the same. Issue the error.
1150 GenerateError("Redefinition of global variable named '" + Name +
1151 "' of type '" + Ty->getDescription() + "'");
1152 return 0;
1153 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001154 }
1155
1156 // Otherwise there is no existing GV to use, create one now.
1157 GlobalVariable *GV =
1158 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001159 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001160 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001161 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001162 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001163}
1164
1165// setTypeName - Set the specified type to the name given. The name may be
1166// null potentially, in which case this is a noop. The string passed in is
1167// assumed to be a malloc'd string buffer, and is freed by this function.
1168//
1169// This function returns true if the type has already been defined, but is
1170// allowed to be redefined in the specified context. If the name is a new name
1171// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001172static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001173 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001174 if (NameStr == 0) return false;
1175
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001176 std::string Name(*NameStr); // Copy string
1177 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001178
1179 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001180 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001181 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001182 return false;
1183 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001184
1185 // Set the type name, checking for conflicts as we do so.
1186 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1187
1188 if (AlreadyExists) { // Inserting a name that is already defined???
1189 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001190 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001191
1192 // There is only one case where this is allowed: when we are refining an
1193 // opaque type. In this case, Existing will be an opaque type.
1194 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1195 // We ARE replacing an opaque type!
1196 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1197 return true;
1198 }
1199
1200 // Otherwise, this is an attempt to redefine a type. That's okay if
1201 // the redefinition is identical to the original. This will be so if
1202 // Existing and T point to the same Type object. In this one case we
1203 // allow the equivalent redefinition.
1204 if (Existing == T) return true; // Yes, it's equal.
1205
1206 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001207 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001208 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001209 }
1210
1211 return false;
1212}
1213
1214//===----------------------------------------------------------------------===//
1215// Code for handling upreferences in type names...
1216//
1217
1218// TypeContains - Returns true if Ty directly contains E in it.
1219//
1220static bool TypeContains(const Type *Ty, const Type *E) {
1221 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1222 E) != Ty->subtype_end();
1223}
1224
1225namespace {
1226 struct UpRefRecord {
1227 // NestingLevel - The number of nesting levels that need to be popped before
1228 // this type is resolved.
1229 unsigned NestingLevel;
1230
1231 // LastContainedTy - This is the type at the current binding level for the
1232 // type. Every time we reduce the nesting level, this gets updated.
1233 const Type *LastContainedTy;
1234
1235 // UpRefTy - This is the actual opaque type that the upreference is
1236 // represented with.
1237 OpaqueType *UpRefTy;
1238
1239 UpRefRecord(unsigned NL, OpaqueType *URTy)
1240 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1241 };
1242}
1243
1244// UpRefs - A list of the outstanding upreferences that need to be resolved.
1245static std::vector<UpRefRecord> UpRefs;
1246
1247/// HandleUpRefs - Every time we finish a new layer of types, this function is
1248/// called. It loops through the UpRefs vector, which is a list of the
1249/// currently active types. For each type, if the up reference is contained in
1250/// the newly completed type, we decrement the level count. When the level
1251/// count reaches zero, the upreferenced type is the type that is passed in:
1252/// thus we can complete the cycle.
1253///
1254static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001255 // If Ty isn't abstract, or if there are no up-references in it, then there is
1256 // nothing to resolve here.
1257 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1258
Reid Spencer68a24bd2005-08-27 18:50:39 +00001259 PATypeHolder Ty(ty);
1260 UR_OUT("Type '" << Ty->getDescription() <<
1261 "' newly formed. Resolving upreferences.\n" <<
1262 UpRefs.size() << " upreferences active!\n");
1263
1264 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1265 // to zero), we resolve them all together before we resolve them to Ty. At
1266 // the end of the loop, if there is anything to resolve to Ty, it will be in
1267 // this variable.
1268 OpaqueType *TypeToResolve = 0;
1269
1270 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1271 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1272 << UpRefs[i].second->getDescription() << ") = "
1273 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1274 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1275 // Decrement level of upreference
1276 unsigned Level = --UpRefs[i].NestingLevel;
1277 UpRefs[i].LastContainedTy = Ty;
1278 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1279 if (Level == 0) { // Upreference should be resolved!
1280 if (!TypeToResolve) {
1281 TypeToResolve = UpRefs[i].UpRefTy;
1282 } else {
1283 UR_OUT(" * Resolving upreference for "
1284 << UpRefs[i].second->getDescription() << "\n";
1285 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1286 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1287 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1288 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1289 }
1290 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1291 --i; // Do not skip the next element...
1292 }
1293 }
1294 }
1295
1296 if (TypeToResolve) {
1297 UR_OUT(" * Resolving upreference for "
1298 << UpRefs[i].second->getDescription() << "\n";
1299 std::string OldName = TypeToResolve->getDescription());
1300 TypeToResolve->refineAbstractTypeTo(Ty);
1301 }
1302
1303 return Ty;
1304}
1305
Reid Spencer68a24bd2005-08-27 18:50:39 +00001306//===----------------------------------------------------------------------===//
1307// RunVMAsmParser - Define an interface to this parser
1308//===----------------------------------------------------------------------===//
1309//
Reid Spencer14310612006-12-31 05:40:51 +00001310static Module* RunParser(Module * M);
1311
Duncan Sandsdc024672007-11-27 13:23:08 +00001312Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1313 InitLLLexer(MB);
1314 Module *M = RunParser(new Module(LLLgetFilename()));
1315 FreeLexer();
1316 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001317}
1318
1319
Dan Gohmanf4423b12008-04-19 00:24:39 +00001320
1321/* Enabling traces. */
1322#ifndef YYDEBUG
1323# define YYDEBUG 0
1324#endif
1325
1326/* Enabling verbose error messages. */
1327#ifdef YYERROR_VERBOSE
1328# undef YYERROR_VERBOSE
1329# define YYERROR_VERBOSE 1
1330#else
1331# define YYERROR_VERBOSE 0
1332#endif
1333
1334/* Enabling the token table. */
1335#ifndef YYTOKEN_TABLE
1336# define YYTOKEN_TABLE 0
1337#endif
1338
1339#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1340typedef union YYSTYPE
Nate Begemanac80ade2008-05-12 19:01:56 +00001341#line 949 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001342{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001343 llvm::Module *ModuleVal;
1344 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001345 llvm::BasicBlock *BasicBlockVal;
1346 llvm::TerminatorInst *TermInstVal;
1347 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001348 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001349
Reid Spencera132e042006-12-03 05:46:11 +00001350 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001351 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001352 llvm::PATypeHolder *TypeVal;
1353 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001354 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001355 llvm::ArgListType *ArgList;
1356 llvm::TypeWithAttrs TypeWithAttrs;
1357 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001358 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001359
Reid Spencer68a24bd2005-08-27 18:50:39 +00001360 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001361 std::list<std::pair<llvm::Value*,
1362 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001363 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001364 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001365
1366 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001367 llvm::GlobalValue::VisibilityTypes Visibility;
Dale Johannesen222ebf72008-02-19 21:40:51 +00001368 llvm::ParameterAttributes ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001369 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001370 int64_t SInt64Val;
1371 uint64_t UInt64Val;
1372 int SIntVal;
1373 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001374 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001375 bool BoolVal;
1376
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001377 std::string *StrVal; // This memory must be deleted
1378 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001379
Reid Spencera132e042006-12-03 05:46:11 +00001380 llvm::Instruction::BinaryOps BinaryOpVal;
1381 llvm::Instruction::TermOps TermOpVal;
1382 llvm::Instruction::MemoryOps MemOpVal;
1383 llvm::Instruction::CastOps CastOpVal;
1384 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001385 llvm::ICmpInst::Predicate IPredicate;
1386 llvm::FCmpInst::Predicate FPredicate;
Dan Gohmanf4423b12008-04-19 00:24:39 +00001387}
1388/* Line 193 of yacc.c. */
Nate Begemanac80ade2008-05-12 19:01:56 +00001389#line 1390 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001390 YYSTYPE;
1391# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1392# define YYSTYPE_IS_DECLARED 1
1393# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001394#endif
1395
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001396
Reid Spencer68a24bd2005-08-27 18:50:39 +00001397
Dan Gohmanf4423b12008-04-19 00:24:39 +00001398/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001399
1400
Dan Gohmanf4423b12008-04-19 00:24:39 +00001401/* Line 216 of yacc.c. */
Nate Begemanac80ade2008-05-12 19:01:56 +00001402#line 1403 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001403
Dan Gohmanf4423b12008-04-19 00:24:39 +00001404#ifdef short
1405# undef short
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001406#endif
1407
Dan Gohmanf4423b12008-04-19 00:24:39 +00001408#ifdef YYTYPE_UINT8
1409typedef YYTYPE_UINT8 yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001410#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00001411typedef unsigned char yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001412#endif
1413
Dan Gohmanf4423b12008-04-19 00:24:39 +00001414#ifdef YYTYPE_INT8
1415typedef YYTYPE_INT8 yytype_int8;
1416#elif (defined __STDC__ || defined __C99__FUNC__ \
1417 || defined __cplusplus || defined _MSC_VER)
1418typedef signed char yytype_int8;
1419#else
1420typedef short int yytype_int8;
1421#endif
1422
1423#ifdef YYTYPE_UINT16
1424typedef YYTYPE_UINT16 yytype_uint16;
1425#else
1426typedef unsigned short int yytype_uint16;
1427#endif
1428
1429#ifdef YYTYPE_INT16
1430typedef YYTYPE_INT16 yytype_int16;
1431#else
1432typedef short int yytype_int16;
1433#endif
1434
1435#ifndef YYSIZE_T
1436# ifdef __SIZE_TYPE__
1437# define YYSIZE_T __SIZE_TYPE__
1438# elif defined size_t
1439# define YYSIZE_T size_t
1440# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1441 || defined __cplusplus || defined _MSC_VER)
1442# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1443# define YYSIZE_T size_t
1444# else
1445# define YYSIZE_T unsigned int
1446# endif
1447#endif
1448
1449#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1450
1451#ifndef YY_
1452# if defined YYENABLE_NLS && YYENABLE_NLS
1453# if ENABLE_NLS
1454# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1455# define YY_(msgid) dgettext ("bison-runtime", msgid)
1456# endif
1457# endif
1458# ifndef YY_
1459# define YY_(msgid) msgid
1460# endif
1461#endif
1462
1463/* Suppress unused-variable warnings by "using" E. */
1464#if ! defined lint || defined __GNUC__
1465# define YYUSE(e) ((void) (e))
1466#else
1467# define YYUSE(e) /* empty */
1468#endif
1469
1470/* Identity function, used to suppress warnings about constant conditions. */
1471#ifndef lint
1472# define YYID(n) (n)
1473#else
1474#if (defined __STDC__ || defined __C99__FUNC__ \
1475 || defined __cplusplus || defined _MSC_VER)
1476static int
1477YYID (int i)
1478#else
1479static int
1480YYID (i)
1481 int i;
1482#endif
1483{
1484 return i;
1485}
1486#endif
1487
1488#if ! defined yyoverflow || YYERROR_VERBOSE
1489
1490/* The parser invokes alloca or malloc; define the necessary symbols. */
1491
1492# ifdef YYSTACK_USE_ALLOCA
1493# if YYSTACK_USE_ALLOCA
1494# ifdef __GNUC__
1495# define YYSTACK_ALLOC __builtin_alloca
1496# elif defined __BUILTIN_VA_ARG_INCR
1497# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1498# elif defined _AIX
1499# define YYSTACK_ALLOC __alloca
1500# elif defined _MSC_VER
1501# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1502# define alloca _alloca
1503# else
1504# define YYSTACK_ALLOC alloca
1505# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1506 || defined __cplusplus || defined _MSC_VER)
1507# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1508# ifndef _STDLIB_H
1509# define _STDLIB_H 1
1510# endif
1511# endif
1512# endif
1513# endif
1514# endif
1515
1516# ifdef YYSTACK_ALLOC
1517 /* Pacify GCC's `empty if-body' warning. */
1518# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1519# ifndef YYSTACK_ALLOC_MAXIMUM
1520 /* The OS might guarantee only one guard page at the bottom of the stack,
1521 and a page size can be as small as 4096 bytes. So we cannot safely
1522 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1523 to allow for a few compiler-allocated temporary stack slots. */
1524# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1525# endif
1526# else
1527# define YYSTACK_ALLOC YYMALLOC
1528# define YYSTACK_FREE YYFREE
1529# ifndef YYSTACK_ALLOC_MAXIMUM
1530# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1531# endif
1532# if (defined __cplusplus && ! defined _STDLIB_H \
1533 && ! ((defined YYMALLOC || defined malloc) \
1534 && (defined YYFREE || defined free)))
1535# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1536# ifndef _STDLIB_H
1537# define _STDLIB_H 1
1538# endif
1539# endif
1540# ifndef YYMALLOC
1541# define YYMALLOC malloc
1542# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1543 || defined __cplusplus || defined _MSC_VER)
1544void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1545# endif
1546# endif
1547# ifndef YYFREE
1548# define YYFREE free
1549# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1550 || defined __cplusplus || defined _MSC_VER)
1551void free (void *); /* INFRINGES ON USER NAME SPACE */
1552# endif
1553# endif
1554# endif
1555#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1556
1557
1558#if (! defined yyoverflow \
1559 && (! defined __cplusplus \
1560 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1561
1562/* A type that is properly aligned for any stack member. */
1563union yyalloc
1564{
1565 yytype_int16 yyss;
1566 YYSTYPE yyvs;
1567 };
1568
1569/* The size of the maximum gap between one aligned stack and the next. */
1570# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1571
1572/* The size of an array large to enough to hold all stacks, each with
1573 N elements. */
1574# define YYSTACK_BYTES(N) \
1575 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1576 + YYSTACK_GAP_MAXIMUM)
1577
1578/* Copy COUNT objects from FROM to TO. The source and destination do
1579 not overlap. */
1580# ifndef YYCOPY
1581# if defined __GNUC__ && 1 < __GNUC__
1582# define YYCOPY(To, From, Count) \
1583 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1584# else
1585# define YYCOPY(To, From, Count) \
1586 do \
1587 { \
1588 YYSIZE_T yyi; \
1589 for (yyi = 0; yyi < (Count); yyi++) \
1590 (To)[yyi] = (From)[yyi]; \
1591 } \
1592 while (YYID (0))
1593# endif
1594# endif
1595
1596/* Relocate STACK from its old location to the new one. The
1597 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1598 elements in the stack, and YYPTR gives the new location of the
1599 stack. Advance YYPTR to a properly aligned location for the next
1600 stack. */
1601# define YYSTACK_RELOCATE(Stack) \
1602 do \
1603 { \
1604 YYSIZE_T yynewbytes; \
1605 YYCOPY (&yyptr->Stack, Stack, yysize); \
1606 Stack = &yyptr->Stack; \
1607 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1608 yyptr += yynewbytes / sizeof (*yyptr); \
1609 } \
1610 while (YYID (0))
1611
1612#endif
1613
1614/* YYFINAL -- State number of the termination state. */
1615#define YYFINAL 43
1616/* YYLAST -- Last index in YYTABLE. */
Nate Begemanac80ade2008-05-12 19:01:56 +00001617#define YYLAST 2035
Dan Gohmanf4423b12008-04-19 00:24:39 +00001618
1619/* YYNTOKENS -- Number of terminals. */
Nate Begemanac80ade2008-05-12 19:01:56 +00001620#define YYNTOKENS 167
Dan Gohmanf4423b12008-04-19 00:24:39 +00001621/* YYNNTS -- Number of nonterminals. */
1622#define YYNNTS 85
1623/* YYNRULES -- Number of rules. */
Nate Begemanac80ade2008-05-12 19:01:56 +00001624#define YYNRULES 326
Dan Gohmanf4423b12008-04-19 00:24:39 +00001625/* YYNRULES -- Number of states. */
Nate Begemanac80ade2008-05-12 19:01:56 +00001626#define YYNSTATES 655
Dan Gohmanf4423b12008-04-19 00:24:39 +00001627
1628/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1629#define YYUNDEFTOK 2
Nate Begemanac80ade2008-05-12 19:01:56 +00001630#define YYMAXUTOK 407
Dan Gohmanf4423b12008-04-19 00:24:39 +00001631
1632#define YYTRANSLATE(YYX) \
1633 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1634
1635/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1636static const yytype_uint8 yytranslate[] =
1637{
1638 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1639 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1640 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1641 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Nate Begemanac80ade2008-05-12 19:01:56 +00001642 153, 154, 157, 2, 156, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001643 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Nate Begemanac80ade2008-05-12 19:01:56 +00001644 162, 155, 163, 2, 2, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1646 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Nate Begemanac80ade2008-05-12 19:01:56 +00001647 2, 159, 158, 161, 2, 2, 2, 2, 2, 166,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Nate Begemanac80ade2008-05-12 19:01:56 +00001650 160, 2, 2, 164, 2, 165, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001651 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1653 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1656 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1659 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1660 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1661 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1662 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1663 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1664 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1665 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1666 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1667 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1668 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1669 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1670 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1671 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1672 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1673 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1674 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1675 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1676 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1677 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Nate Begemanac80ade2008-05-12 19:01:56 +00001678 145, 146, 147, 148, 149, 150, 151, 152
Dan Gohmanf4423b12008-04-19 00:24:39 +00001679};
1680
1681#if YYDEBUG
1682/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1683 YYRHS. */
1684static const yytype_uint16 yyprhs[] =
1685{
1686 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1687 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1688 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1689 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1690 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1691 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1692 119, 121, 123, 125, 127, 129, 130, 135, 136, 139,
1693 140, 142, 144, 146, 147, 150, 152, 154, 156, 158,
1694 160, 162, 164, 166, 167, 169, 171, 173, 174, 176,
1695 178, 179, 181, 183, 185, 187, 188, 190, 192, 193,
1696 195, 197, 199, 201, 203, 206, 208, 210, 212, 214,
1697 216, 218, 220, 222, 224, 227, 228, 231, 233, 235,
1698 237, 239, 241, 243, 244, 247, 248, 251, 252, 255,
1699 256, 260, 263, 264, 266, 267, 271, 273, 276, 278,
1700 280, 282, 284, 286, 288, 290, 292, 294, 298, 300,
1701 303, 309, 315, 321, 327, 331, 334, 340, 345, 348,
1702 350, 352, 354, 358, 360, 364, 366, 367, 369, 373,
1703 378, 382, 386, 391, 396, 400, 407, 413, 416, 419,
1704 422, 425, 428, 431, 434, 437, 440, 443, 446, 449,
Nate Begemanac80ade2008-05-12 19:01:56 +00001705 456, 462, 471, 478, 485, 493, 501, 509, 517, 524,
1706 533, 542, 546, 548, 550, 552, 554, 555, 558, 565,
1707 567, 568, 570, 573, 574, 578, 579, 583, 587, 591,
1708 595, 596, 605, 606, 616, 617, 627, 633, 636, 640,
1709 642, 646, 650, 654, 658, 660, 661, 667, 671, 673,
1710 677, 679, 680, 691, 693, 695, 700, 702, 704, 707,
1711 711, 712, 714, 716, 718, 720, 722, 724, 726, 728,
1712 730, 734, 736, 742, 744, 746, 748, 750, 752, 754,
1713 757, 759, 763, 766, 769, 773, 776, 777, 779, 782,
1714 785, 789, 799, 809, 818, 833, 835, 837, 844, 850,
1715 853, 860, 868, 873, 878, 885, 892, 893, 894, 898,
1716 901, 903, 909, 915, 922, 929, 936, 943, 948, 955,
1717 960, 965, 972, 979, 982, 991, 993, 995, 996, 1000,
1718 1007, 1011, 1018, 1021, 1027, 1035, 1041
Dan Gohmanf4423b12008-04-19 00:24:39 +00001719};
1720
1721/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1722static const yytype_int16 yyrhs[] =
1723{
Nate Begemanac80ade2008-05-12 19:01:56 +00001724 213, 0, -1, 74, -1, 75, -1, 76, -1, 77,
Chris Lattnercc81d152008-05-04 17:18:47 +00001725 -1, 78, -1, 79, -1, 80, -1, 81, -1, 82,
1726 -1, 86, -1, 87, -1, 88, -1, 83, -1, 84,
Nate Begemanac80ade2008-05-12 19:01:56 +00001727 -1, 85, -1, 119, -1, 120, -1, 121, -1, 122,
1728 -1, 123, -1, 124, -1, 125, -1, 126, -1, 127,
1729 -1, 128, -1, 129, -1, 130, -1, 93, -1, 94,
1730 -1, 95, -1, 96, -1, 97, -1, 98, -1, 99,
1731 -1, 100, -1, 101, -1, 102, -1, 103, -1, 104,
1732 -1, 105, -1, 106, -1, 107, -1, 108, -1, 109,
1733 -1, 110, -1, 111, -1, 112, -1, 99, -1, 100,
1734 -1, 101, -1, 102, -1, 26, -1, 27, -1, 11,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001735 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
Nate Begemanac80ade2008-05-12 19:01:56 +00001736 -1, 19, -1, 22, -1, 24, -1, 175, -1, -1,
1737 54, 153, 4, 154, -1, -1, 175, 155, -1, -1,
1738 20, -1, 23, -1, 181, -1, -1, 179, 155, -1,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001739 42, -1, 44, -1, 43, -1, 45, -1, 47, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00001740 46, -1, 48, -1, 50, -1, -1, 150, -1, 151,
1741 -1, 152, -1, -1, 46, -1, 48, -1, -1, 42,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001742 -1, 43, -1, 44, -1, 47, -1, -1, 44, -1,
1743 42, -1, -1, 62, -1, 63, -1, 64, -1, 65,
Nate Begemanac80ade2008-05-12 19:01:56 +00001744 -1, 66, -1, 61, 4, -1, 139, -1, 120, -1,
1745 138, -1, 121, -1, 141, -1, 142, -1, 144, -1,
1746 145, -1, 146, -1, 53, 4, -1, -1, 190, 189,
1747 -1, 140, -1, 143, -1, 139, -1, 138, -1, 147,
1748 -1, 148, -1, -1, 192, 191, -1, -1, 149, 22,
1749 -1, -1, 53, 4, -1, -1, 156, 53, 4, -1,
1750 34, 22, -1, -1, 196, -1, -1, 156, 199, 198,
1751 -1, 196, -1, 53, 4, -1, 11, -1, 12, -1,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001752 13, -1, 16, -1, 15, -1, 14, -1, 17, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00001753 49, -1, 200, -1, 201, 177, 157, -1, 235, -1,
1754 158, 4, -1, 201, 153, 205, 154, 192, -1, 10,
1755 153, 205, 154, 192, -1, 159, 4, 160, 201, 161,
1756 -1, 162, 4, 160, 201, 163, -1, 164, 206, 165,
1757 -1, 164, 165, -1, 162, 164, 206, 165, 163, -1,
1758 162, 164, 165, 163, -1, 201, 190, -1, 201, -1,
1759 10, -1, 202, -1, 204, 156, 202, -1, 204, -1,
1760 204, 156, 39, -1, 39, -1, -1, 201, -1, 206,
1761 156, 201, -1, 201, 159, 209, 161, -1, 201, 159,
1762 161, -1, 201, 166, 22, -1, 201, 162, 209, 163,
1763 -1, 201, 164, 209, 165, -1, 201, 164, 165, -1,
1764 201, 162, 164, 209, 165, 163, -1, 201, 162, 164,
1765 165, 163, -1, 201, 40, -1, 201, 41, -1, 201,
1766 235, -1, 201, 208, -1, 201, 25, -1, 173, 3,
1767 -1, 173, 5, -1, 173, 4, -1, 173, 6, -1,
1768 11, 26, -1, 11, 27, -1, 174, 9, -1, 170,
1769 153, 207, 38, 201, 154, -1, 118, 153, 207, 247,
1770 154, -1, 132, 153, 207, 156, 207, 156, 207, 154,
1771 -1, 168, 153, 207, 156, 207, 154, -1, 169, 153,
1772 207, 156, 207, 154, -1, 89, 171, 153, 207, 156,
1773 207, 154, -1, 90, 172, 153, 207, 156, 207, 154,
1774 -1, 91, 171, 153, 207, 156, 207, 154, -1, 92,
1775 172, 153, 207, 156, 207, 154, -1, 134, 153, 207,
1776 156, 207, 154, -1, 135, 153, 207, 156, 207, 156,
1777 207, 154, -1, 136, 153, 207, 156, 207, 156, 207,
1778 154, -1, 209, 156, 207, -1, 207, -1, 32, -1,
1779 33, -1, 37, -1, -1, 203, 235, -1, 124, 153,
1780 212, 38, 201, 154, -1, 214, -1, -1, 215, -1,
1781 214, 215, -1, -1, 31, 216, 231, -1, -1, 30,
1782 217, 232, -1, 59, 58, 221, -1, 178, 18, 201,
1783 -1, 178, 18, 10, -1, -1, 180, 184, 211, 210,
1784 207, 177, 218, 198, -1, -1, 180, 182, 184, 211,
1785 210, 207, 177, 219, 198, -1, -1, 180, 183, 184,
1786 211, 210, 201, 177, 220, 198, -1, 180, 184, 35,
1787 187, 212, -1, 51, 222, -1, 55, 155, 223, -1,
1788 22, -1, 52, 155, 22, -1, 67, 155, 22, -1,
1789 159, 224, 161, -1, 224, 156, 22, -1, 22, -1,
1790 -1, 225, 156, 201, 190, 176, -1, 201, 190, 176,
1791 -1, 225, -1, 225, 156, 39, -1, 39, -1, -1,
1792 188, 203, 179, 153, 226, 154, 192, 197, 194, 193,
1793 -1, 28, -1, 164, -1, 186, 184, 227, 228, -1,
1794 29, -1, 165, -1, 239, 230, -1, 185, 184, 227,
1795 -1, -1, 60, -1, 3, -1, 4, -1, 9, -1,
1796 26, -1, 27, -1, 40, -1, 41, -1, 25, -1,
1797 162, 209, 163, -1, 208, -1, 58, 233, 22, 156,
1798 22, -1, 7, -1, 8, -1, 175, -1, 179, -1,
1799 235, -1, 234, -1, 201, 236, -1, 237, -1, 238,
1800 156, 237, -1, 239, 240, -1, 229, 240, -1, 241,
1801 178, 242, -1, 241, 244, -1, -1, 21, -1, 68,
1802 238, -1, 68, 10, -1, 69, 17, 236, -1, 69,
1803 11, 236, 156, 17, 236, 156, 17, 236, -1, 70,
1804 173, 236, 156, 17, 236, 159, 243, 161, -1, 70,
1805 173, 236, 156, 17, 236, 159, 161, -1, 71, 188,
1806 203, 236, 153, 246, 154, 192, 38, 17, 236, 72,
1807 17, 236, -1, 72, -1, 73, -1, 243, 173, 234,
1808 156, 17, 236, -1, 173, 234, 156, 17, 236, -1,
1809 178, 249, -1, 201, 159, 236, 156, 236, 161, -1,
1810 245, 156, 159, 236, 156, 236, 161, -1, 201, 190,
1811 236, 190, -1, 17, 190, 236, 190, -1, 246, 156,
1812 201, 190, 236, 190, -1, 246, 156, 17, 190, 236,
1813 190, -1, -1, -1, 247, 156, 237, -1, 57, 56,
1814 -1, 56, -1, 168, 201, 236, 156, 236, -1, 169,
1815 201, 236, 156, 236, -1, 89, 171, 201, 236, 156,
1816 236, -1, 90, 172, 201, 236, 156, 236, -1, 91,
1817 171, 201, 236, 156, 236, -1, 92, 172, 201, 236,
1818 156, 236, -1, 170, 237, 38, 201, -1, 132, 237,
1819 156, 237, 156, 237, -1, 133, 237, 156, 201, -1,
1820 134, 237, 156, 237, -1, 135, 237, 156, 237, 156,
1821 237, -1, 136, 237, 156, 237, 156, 237, -1, 131,
1822 245, -1, 248, 188, 203, 236, 153, 246, 154, 192,
1823 -1, 251, -1, 36, -1, -1, 113, 201, 195, -1,
1824 113, 201, 156, 11, 236, 195, -1, 114, 201, 195,
1825 -1, 114, 201, 156, 11, 236, 195, -1, 115, 237,
1826 -1, 250, 116, 201, 236, 195, -1, 250, 117, 237,
1827 156, 201, 236, 195, -1, 137, 201, 236, 156, 4,
1828 -1, 118, 201, 236, 247, -1
Dan Gohmanf4423b12008-04-19 00:24:39 +00001829};
1830
1831/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1832static const yytype_uint16 yyrline[] =
1833{
Chris Lattnercc81d152008-05-04 17:18:47 +00001834 0, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111,
1835 1111, 1112, 1112, 1112, 1112, 1112, 1112, 1113, 1113, 1113,
1836 1113, 1113, 1113, 1114, 1114, 1114, 1114, 1114, 1114, 1117,
1837 1117, 1118, 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1125,
1838 1125, 1126, 1126, 1127, 1127, 1128, 1128, 1129, 1129, 1130,
1839 1130, 1131, 1131, 1132, 1133, 1138, 1139, 1139, 1139, 1139,
1840 1139, 1141, 1141, 1141, 1142, 1142, 1144, 1145, 1149, 1153,
1841 1158, 1158, 1160, 1161, 1166, 1172, 1173, 1174, 1175, 1176,
1842 1180, 1181, 1182, 1186, 1187, 1188, 1189, 1193, 1194, 1195,
1843 1199, 1200, 1201, 1202, 1203, 1207, 1208, 1209, 1212, 1213,
1844 1214, 1215, 1216, 1217, 1218, 1225, 1226, 1227, 1228, 1229,
1845 1230, 1231, 1232, 1233, 1234, 1238, 1239, 1244, 1245, 1246,
1846 1247, 1248, 1249, 1252, 1253, 1258, 1259, 1266, 1267, 1273,
1847 1274, 1283, 1291, 1292, 1297, 1298, 1299, 1304, 1317, 1317,
1848 1317, 1317, 1317, 1317, 1317, 1320, 1324, 1328, 1335, 1340,
1849 1348, 1377, 1402, 1407, 1417, 1427, 1431, 1441, 1448, 1457,
1850 1464, 1469, 1474, 1481, 1482, 1489, 1496, 1504, 1510, 1522,
1851 1550, 1566, 1593, 1621, 1647, 1667, 1693, 1713, 1725, 1732,
1852 1798, 1808, 1818, 1824, 1834, 1840, 1850, 1855, 1860, 1873,
Nate Begemanac80ade2008-05-12 19:01:56 +00001853 1885, 1907, 1915, 1921, 1932, 1937, 1942, 1947, 1952, 1958,
1854 1964, 1973, 1977, 1985, 1985, 1988, 1988, 1991, 2003, 2024,
1855 2029, 2037, 2038, 2042, 2042, 2046, 2046, 2049, 2052, 2076,
1856 2088, 2087, 2099, 2098, 2108, 2107, 2118, 2158, 2161, 2167,
1857 2177, 2181, 2186, 2188, 2193, 2198, 2207, 2217, 2228, 2232,
1858 2241, 2250, 2255, 2384, 2384, 2386, 2395, 2395, 2397, 2402,
1859 2414, 2418, 2423, 2427, 2431, 2435, 2439, 2443, 2447, 2451,
1860 2455, 2480, 2484, 2494, 2498, 2502, 2507, 2514, 2514, 2520,
1861 2529, 2534, 2539, 2543, 2552, 2561, 2570, 2574, 2582, 2589,
1862 2593, 2598, 2608, 2627, 2636, 2721, 2725, 2732, 2743, 2756,
1863 2766, 2777, 2787, 2798, 2806, 2816, 2823, 2826, 2827, 2834,
1864 2838, 2843, 2859, 2876, 2890, 2904, 2918, 2932, 2944, 2952,
1865 2959, 2965, 2971, 2977, 2992, 3082, 3087, 3091, 3098, 3105,
1866 3113, 3120, 3128, 3136, 3150, 3167, 3175
Dan Gohmanf4423b12008-04-19 00:24:39 +00001867};
1868#endif
1869
1870#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1871/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1872 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1873static const char *const yytname[] =
1874{
1875 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1876 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1877 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1878 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1879 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1880 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1881 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1882 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1883 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1884 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1885 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1886 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Chris Lattnercc81d152008-05-04 17:18:47 +00001887 "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
1888 "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
Nate Begemanac80ade2008-05-12 19:01:56 +00001889 "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "VICMP",
1890 "VFCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1891 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1892 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1893 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1894 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1895 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1896 "GETRESULT", "SIGNEXT", "ZEROEXT", "NORETURN", "INREG", "SRET",
1897 "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "READNONE", "READONLY", "GC",
1898 "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'",
1899 "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'",
1900 "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates",
1901 "FPredicates", "IntType", "FPType", "LocalName", "OptLocalName",
1902 "OptAddrSpace", "OptLocalAssign", "GlobalName", "OptGlobalAssign",
1903 "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1904 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1905 "AliasLinkage", "OptCallingConv", "ParamAttr", "OptParamAttrs",
1906 "FuncAttr", "OptFuncAttrs", "OptGC", "OptAlign", "OptCAlign",
1907 "SectionString", "OptSection", "GlobalVarAttributes",
Dan Gohmanf4423b12008-04-19 00:24:39 +00001908 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1909 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1910 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1911 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1912 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1913 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1914 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1915 "SymbolicValueRef", "ValueRef", "ResolvedVal", "ReturnedVal",
1916 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1917 "JumpTable", "Inst", "PHIList", "ParamList", "IndexList", "OptTailCall",
1918 "InstVal", "OptVolatile", "MemoryInst", 0
1919};
1920#endif
1921
1922# ifdef YYPRINT
1923/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1924 token YYLEX-NUM. */
1925static const yytype_uint16 yytoknum[] =
1926{
1927 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1928 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1929 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1930 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1931 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1932 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1933 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1934 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1935 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1936 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1937 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1938 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1939 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1940 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1941 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Nate Begemanac80ade2008-05-12 19:01:56 +00001942 405, 406, 407, 40, 41, 61, 44, 42, 92, 91,
1943 120, 93, 60, 62, 123, 125, 99
Dan Gohmanf4423b12008-04-19 00:24:39 +00001944};
1945# endif
1946
1947/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1948static const yytype_uint8 yyr1[] =
1949{
Nate Begemanac80ade2008-05-12 19:01:56 +00001950 0, 167, 168, 168, 168, 168, 168, 168, 168, 168,
1951 168, 169, 169, 169, 169, 169, 169, 170, 170, 170,
1952 170, 170, 170, 170, 170, 170, 170, 170, 170, 171,
1953 171, 171, 171, 171, 171, 171, 171, 171, 171, 172,
1954 172, 172, 172, 172, 172, 172, 172, 172, 172, 172,
1955 172, 172, 172, 172, 172, 173, 174, 174, 174, 174,
1956 174, 175, 175, 175, 176, 176, 177, 177, 178, 178,
1957 179, 179, 180, 180, 181, 182, 182, 182, 182, 182,
1958 183, 183, 183, 184, 184, 184, 184, 185, 185, 185,
1959 186, 186, 186, 186, 186, 187, 187, 187, 188, 188,
1960 188, 188, 188, 188, 188, 189, 189, 189, 189, 189,
1961 189, 189, 189, 189, 189, 190, 190, 191, 191, 191,
1962 191, 191, 191, 192, 192, 193, 193, 194, 194, 195,
1963 195, 196, 197, 197, 198, 198, 199, 199, 200, 200,
1964 200, 200, 200, 200, 200, 201, 201, 201, 201, 201,
1965 201, 201, 201, 201, 201, 201, 201, 201, 202, 203,
1966 203, 204, 204, 205, 205, 205, 205, 206, 206, 207,
1967 207, 207, 207, 207, 207, 207, 207, 207, 207, 207,
1968 207, 207, 207, 207, 207, 207, 207, 207, 207, 208,
1969 208, 208, 208, 208, 208, 208, 208, 208, 208, 208,
1970 208, 209, 209, 210, 210, 211, 211, 212, 212, 213,
1971 213, 214, 214, 216, 215, 217, 215, 215, 215, 215,
1972 218, 215, 219, 215, 220, 215, 215, 215, 215, 221,
1973 222, 222, 223, 224, 224, 224, 225, 225, 226, 226,
1974 226, 226, 227, 228, 228, 229, 230, 230, 231, 232,
1975 233, 233, 234, 234, 234, 234, 234, 234, 234, 234,
1976 234, 234, 234, 235, 235, 235, 235, 236, 236, 237,
1977 238, 238, 239, 239, 240, 241, 241, 241, 242, 242,
1978 242, 242, 242, 242, 242, 242, 242, 243, 243, 244,
1979 245, 245, 246, 246, 246, 246, 246, 247, 247, 248,
1980 248, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1981 249, 249, 249, 249, 249, 249, 250, 250, 251, 251,
1982 251, 251, 251, 251, 251, 251, 251
Dan Gohmanf4423b12008-04-19 00:24:39 +00001983};
1984
1985/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1986static const yytype_uint8 yyr2[] =
1987{
1988 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1989 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1990 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1991 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1992 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1993 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1994 1, 1, 1, 1, 1, 0, 4, 0, 2, 0,
1995 1, 1, 1, 0, 2, 1, 1, 1, 1, 1,
1996 1, 1, 1, 0, 1, 1, 1, 0, 1, 1,
1997 0, 1, 1, 1, 1, 0, 1, 1, 0, 1,
1998 1, 1, 1, 1, 2, 1, 1, 1, 1, 1,
1999 1, 1, 1, 1, 2, 0, 2, 1, 1, 1,
2000 1, 1, 1, 0, 2, 0, 2, 0, 2, 0,
2001 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
2002 1, 1, 1, 1, 1, 1, 1, 3, 1, 2,
2003 5, 5, 5, 5, 3, 2, 5, 4, 2, 1,
2004 1, 1, 3, 1, 3, 1, 0, 1, 3, 4,
2005 3, 3, 4, 4, 3, 6, 5, 2, 2, 2,
2006 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
Nate Begemanac80ade2008-05-12 19:01:56 +00002007 5, 8, 6, 6, 7, 7, 7, 7, 6, 8,
2008 8, 3, 1, 1, 1, 1, 0, 2, 6, 1,
2009 0, 1, 2, 0, 3, 0, 3, 3, 3, 3,
2010 0, 8, 0, 9, 0, 9, 5, 2, 3, 1,
2011 3, 3, 3, 3, 1, 0, 5, 3, 1, 3,
2012 1, 0, 10, 1, 1, 4, 1, 1, 2, 3,
2013 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2014 3, 1, 5, 1, 1, 1, 1, 1, 1, 2,
2015 1, 3, 2, 2, 3, 2, 0, 1, 2, 2,
2016 3, 9, 9, 8, 14, 1, 1, 6, 5, 2,
2017 6, 7, 4, 4, 6, 6, 0, 0, 3, 2,
2018 1, 5, 5, 6, 6, 6, 6, 4, 6, 4,
2019 4, 6, 6, 2, 8, 1, 1, 0, 3, 6,
2020 3, 6, 2, 5, 7, 5, 4
Dan Gohmanf4423b12008-04-19 00:24:39 +00002021};
2022
2023/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2024 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2025 means the default is an error. */
2026static const yytype_uint16 yydefact[] =
2027{
Nate Begemanac80ade2008-05-12 19:01:56 +00002028 73, 61, 70, 62, 71, 63, 215, 213, 0, 0,
2029 0, 0, 0, 0, 83, 72, 0, 73, 211, 87,
2030 90, 0, 0, 227, 0, 0, 68, 0, 74, 75,
Dan Gohmanf4423b12008-04-19 00:24:39 +00002031 77, 76, 78, 80, 79, 81, 82, 84, 85, 86,
Nate Begemanac80ade2008-05-12 19:01:56 +00002032 83, 83, 206, 1, 212, 88, 89, 83, 216, 91,
2033 92, 93, 94, 83, 276, 214, 276, 0, 0, 235,
2034 228, 229, 217, 263, 264, 219, 138, 139, 140, 143,
2035 142, 141, 144, 145, 0, 0, 0, 0, 265, 266,
2036 146, 218, 148, 206, 206, 95, 205, 0, 98, 98,
2037 277, 273, 69, 246, 247, 248, 272, 230, 231, 234,
Chris Lattnercc81d152008-05-04 17:18:47 +00002038 0, 166, 149, 0, 0, 0, 0, 155, 167, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002039 0, 166, 0, 0, 0, 97, 96, 0, 203, 204,
2040 0, 0, 99, 100, 101, 102, 103, 0, 249, 0,
2041 317, 275, 0, 232, 165, 115, 161, 163, 0, 0,
Chris Lattnercc81d152008-05-04 17:18:47 +00002042 0, 0, 0, 0, 154, 0, 0, 147, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002043 160, 0, 159, 0, 226, 138, 139, 140, 143, 142,
2044 141, 0, 0, 67, 67, 104, 0, 243, 244, 245,
2045 316, 300, 0, 0, 0, 0, 98, 285, 286, 2,
Chris Lattnercc81d152008-05-04 17:18:47 +00002046 3, 4, 5, 6, 7, 8, 9, 10, 14, 15,
2047 16, 11, 12, 13, 0, 0, 0, 0, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002048 0, 0, 17, 18, 19, 20, 21, 22, 23, 24,
2049 25, 26, 27, 28, 0, 0, 0, 0, 0, 0,
2050 0, 0, 0, 0, 274, 98, 289, 0, 315, 233,
2051 158, 0, 123, 67, 67, 157, 0, 168, 0, 123,
2052 67, 67, 0, 207, 186, 187, 182, 184, 183, 185,
2053 188, 181, 177, 178, 0, 0, 0, 0, 0, 0,
2054 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2055 180, 179, 220, 0, 299, 279, 67, 270, 278, 0,
2056 0, 55, 0, 0, 29, 30, 31, 32, 33, 34,
2057 35, 36, 37, 38, 0, 53, 54, 49, 50, 51,
2058 52, 39, 40, 41, 42, 43, 44, 45, 46, 47,
2059 48, 0, 0, 0, 129, 129, 322, 67, 67, 313,
2060 0, 0, 0, 0, 0, 67, 67, 67, 0, 0,
2061 0, 0, 0, 106, 108, 107, 105, 109, 110, 111,
2062 112, 113, 116, 164, 162, 151, 152, 153, 156, 66,
2063 150, 222, 224, 0, 0, 0, 0, 0, 0, 0,
2064 0, 0, 0, 170, 202, 0, 0, 0, 174, 0,
2065 171, 0, 0, 0, 134, 241, 252, 253, 254, 259,
2066 255, 256, 257, 258, 250, 0, 261, 268, 267, 269,
2067 0, 0, 280, 0, 0, 67, 67, 67, 67, 0,
2068 318, 0, 320, 297, 0, 0, 0, 0, 0, 0,
Chris Lattnercc81d152008-05-04 17:18:47 +00002069 0, 0, 0, 0, 0, 0, 67, 0, 114, 120,
2070 119, 117, 118, 121, 122, 124, 134, 134, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002071 0, 0, 0, 297, 0, 0, 0, 0, 0, 169,
2072 155, 167, 0, 172, 173, 0, 0, 0, 0, 221,
2073 240, 115, 238, 0, 251, 0, 0, 271, 0, 0,
2074 0, 0, 0, 0, 0, 0, 0, 0, 326, 0,
2075 0, 0, 309, 310, 0, 0, 0, 0, 0, 307,
2076 0, 129, 0, 223, 225, 67, 0, 0, 0, 0,
2077 0, 0, 0, 0, 0, 201, 176, 0, 0, 0,
2078 0, 0, 0, 136, 134, 65, 0, 123, 0, 260,
2079 0, 0, 296, 0, 0, 0, 0, 129, 130, 129,
2080 0, 0, 0, 0, 0, 0, 325, 301, 302, 296,
2081 0, 323, 67, 208, 0, 0, 0, 0, 190, 0,
Chris Lattnercc81d152008-05-04 17:18:47 +00002082 0, 0, 0, 175, 0, 0, 67, 131, 137, 135,
Nate Begemanac80ade2008-05-12 19:01:56 +00002083 64, 237, 239, 115, 132, 0, 0, 0, 115, 115,
2084 0, 303, 304, 305, 306, 319, 321, 298, 0, 0,
2085 308, 311, 312, 0, 129, 0, 0, 0, 0, 0,
2086 198, 0, 0, 192, 193, 189, 65, 133, 127, 262,
2087 0, 0, 0, 0, 123, 0, 290, 0, 123, 324,
2088 194, 195, 196, 197, 0, 0, 0, 236, 0, 125,
2089 0, 283, 0, 0, 106, 108, 115, 115, 0, 115,
2090 115, 291, 314, 191, 199, 200, 128, 0, 242, 281,
2091 0, 282, 0, 293, 292, 0, 0, 0, 126, 0,
2092 0, 0, 115, 115, 0, 0, 0, 295, 294, 288,
2093 0, 0, 287, 0, 284
Dan Gohmanf4423b12008-04-19 00:24:39 +00002094};
2095
2096/* YYDEFGOTO[NTERM-NUM]. */
2097static const yytype_int16 yydefgoto[] =
2098{
Nate Begemanac80ade2008-05-12 19:01:56 +00002099 -1, 267, 268, 269, 294, 311, 161, 162, 78, 551,
Chris Lattnercc81d152008-05-04 17:18:47 +00002100 112, 12, 79, 14, 15, 40, 41, 42, 47, 53,
Nate Begemanac80ade2008-05-12 19:01:56 +00002101 117, 127, 342, 230, 425, 345, 628, 609, 400, 503,
2102 588, 449, 504, 80, 163, 136, 153, 137, 138, 109,
2103 364, 386, 365, 120, 87, 154, 16, 17, 18, 20,
2104 19, 374, 426, 427, 62, 23, 60, 100, 452, 453,
2105 128, 169, 54, 95, 55, 48, 455, 387, 82, 389,
2106 277, 278, 56, 91, 92, 224, 613, 131, 319, 560,
2107 468, 225, 226, 227, 228
Dan Gohmanf4423b12008-04-19 00:24:39 +00002108};
2109
2110/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2111 STATE-NUM. */
Nate Begemanac80ade2008-05-12 19:01:56 +00002112#define YYPACT_NINF -572
Dan Gohmanf4423b12008-04-19 00:24:39 +00002113static const yytype_int16 yypact[] =
2114{
Nate Begemanac80ade2008-05-12 19:01:56 +00002115 445, -572, -572, -572, -572, -572, -572, -572, -2, -122,
2116 19, -58, 90, -40, 26, -572, 112, 855, -572, 52,
2117 217, -28, 4, -572, 12, 146, -572, 1594, -572, -572,
2118 -572, -572, -572, -572, -572, -572, -572, -572, -572, -572,
2119 70, 70, 125, -572, -572, -572, -572, 70, -572, -572,
2120 -572, -572, -572, 70, 166, -572, -8, 176, 185, 201,
2121 -572, -572, -572, -572, -572, 80, -572, -572, -572, -572,
2122 -572, -572, -572, -572, 232, 241, 2, 227, -572, -572,
2123 -572, -1, -572, 211, 211, 137, -572, 118, 258, 258,
2124 -572, -572, 87, -572, -572, -572, -572, -572, -572, -572,
2125 -57, 1357, -572, 105, 139, 1020, 80, -572, -1, -107,
2126 109, 1357, 145, 118, 118, -572, -572, 1400, -572, -572,
2127 1634, 302, -572, -572, -572, -572, -572, 1677, -572, -16,
2128 1856, -572, 290, -572, -572, -1, -572, 159, 177, 1695,
2129 1695, 179, -102, 1695, -572, 331, 189, -572, 1634, 1695,
2130 80, 186, -1, 247, -572, 226, 335, 338, 339, 342,
2131 344, 269, 345, 1123, 303, -572, 24, -572, -572, -572,
2132 -572, -572, 300, 1752, 76, 347, 258, -572, -572, -572,
2133 -572, -572, -572, -572, -572, -572, -572, -572, -572, -572,
2134 -572, -572, -572, -572, 314, 845, 314, 845, 1695, 1695,
2135 1695, 1695, -572, -572, -572, -572, -572, -572, -572, -572,
2136 -572, -572, -572, -572, 1695, 1695, 1695, 1695, 1695, 1695,
2137 1695, 1695, 1695, 1695, -572, 258, -572, 97, -572, -572,
2138 172, 1418, -572, -43, -31, -572, 196, -1, 206, -572,
2139 303, -12, 1400, -572, -572, -572, -572, -572, -572, -572,
2140 -572, -572, -572, -572, 314, 845, 314, 845, 208, 216,
2141 219, 220, 223, 1473, 1795, 1063, 348, 224, 225, 234,
2142 -572, -572, -572, 237, -572, 80, 843, -572, 238, 524,
2143 524, -572, 524, 1677, -572, -572, -572, -572, -572, -572,
2144 -572, -572, -572, -572, 1695, -572, -572, -572, -572, -572,
2145 -572, -572, -572, -572, -572, -572, -572, -572, -572, -572,
2146 -572, 1695, 1695, 1695, 27, 29, -572, 843, -23, 248,
2147 249, 263, 264, 265, 266, 843, 843, 843, 341, 1677,
2148 1695, 1695, 389, -572, -572, -572, -572, -572, -572, -572,
2149 -572, -572, -572, -572, -572, 198, -572, -572, -572, -572,
2150 198, -572, 145, 359, 250, 270, 271, 272, 1634, 1634,
2151 1634, 1634, 1634, -572, -572, -30, 1314, -104, -572, -101,
2152 -572, 1634, 1634, 1634, 275, 1518, -572, -572, -572, -572,
2153 -572, -572, -572, -572, 366, 1634, -572, -572, -572, -572,
2154 1695, 276, -572, 277, 524, 843, 843, 843, 843, 25,
2155 -572, 35, -572, -572, 524, 278, 1695, 1695, 1695, 1695,
2156 1695, 280, 282, 283, 1695, 524, 843, 287, -572, -572,
2157 -572, -572, -572, -572, -572, -572, 275, 275, 1695, 1634,
2158 1634, 1634, 1634, -572, 291, 292, 293, 294, 1634, -572,
2159 288, 975, -99, -572, -572, 296, 297, 408, 9, -572,
2160 -572, -1, 299, 304, -572, 435, -96, -572, 442, 443,
2161 308, 306, 310, 325, 326, 524, 479, 524, 328, 329,
2162 524, 334, -1, -572, 336, 337, 487, 524, 524, -1,
2163 349, 350, 1695, -572, -572, -20, 351, 352, 353, 354,
2164 102, 1634, 1634, 1634, 1634, -572, -572, 356, 1634, 1634,
2165 1695, 489, 497, -572, 275, 571, 1576, -572, 357, -572,
2166 524, 524, 1853, 524, 524, 524, 524, 350, -572, 350,
2167 1695, 524, 358, 1695, 1695, 1695, -572, -572, -572, 1853,
2168 459, -572, 843, -572, 1634, 1634, 1634, 1634, -572, 360,
2169 369, 364, 368, -572, 371, 376, -15, -572, -572, -572,
2170 -572, -572, -572, -1, 6, 512, 380, 378, 71, -1,
2171 171, -572, -572, -572, -572, -572, -572, -572, 379, 524,
2172 -572, -572, -572, 174, 350, 385, 387, 388, 391, 1634,
2173 -572, 1634, 1634, -572, -572, -572, 571, -572, 499, -572,
2174 536, -6, 699, 699, -572, 1871, -572, 393, -572, -572,
2175 -572, -572, -572, -572, 401, 407, 409, -572, 558, 418,
2176 524, -572, 1265, -3, 415, 417, -572, -572, -19, 71,
2177 -1, -572, 198, -572, -572, -572, -572, 549, -572, -572,
2178 416, -572, 1265, 172, 172, 556, 699, 699, -572, 557,
2179 419, 524, -572, -572, 524, 559, 507, 172, 172, -572,
2180 524, 563, -572, 524, -572
Dan Gohmanf4423b12008-04-19 00:24:39 +00002181};
2182
2183/* YYPGOTO[NTERM-NUM]. */
2184static const yytype_int16 yypgoto[] =
2185{
Nate Begemanac80ade2008-05-12 19:01:56 +00002186 -572, 451, 453, 454, -174, -152, -173, -572, 0, 1,
2187 -146, 493, 3, -572, -572, -572, -572, 49, -572, -572,
2188 -572, -139, -572, -416, -572, -223, -572, -572, -311, 34,
2189 -572, -397, -572, -572, -26, 361, -120, -572, 478, 486,
2190 -64, -153, -250, 164, 207, 355, -572, -572, 577, -572,
2191 -572, -572, -572, -572, -572, -572, -572, -572, -572, -572,
2192 528, -572, -572, -572, -572, -572, -572, -571, -115, 162,
2193 -191, -572, -572, 540, -572, -572, -572, -572, -572, 89,
2194 187, -572, -572, -572, -572
Dan Gohmanf4423b12008-04-19 00:24:39 +00002195};
2196
2197/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2198 positive, shift that token. If negative, reduce the rule which
2199 number is the opposite. If zero, do what YYDEFACT says.
2200 If YYTABLE_NINF, syntax error. */
Nate Begemanac80ade2008-05-12 19:01:56 +00002201#define YYTABLE_NINF -211
Dan Gohmanf4423b12008-04-19 00:24:39 +00002202static const yytype_int16 yytable[] =
2203{
Nate Begemanac80ade2008-05-12 19:01:56 +00002204 11, 81, 282, 13, 402, 281, 104, 166, 281, 316,
2205 270, 110, 167, 90, 367, 369, 350, 11, 272, 635,
2206 13, 93, 312, 110, 320, 321, 322, 323, 324, 483,
2207 484, 110, 328, 24, 110, 505, 465, 283, 243, 110,
2208 501, 630, 110, 501, 2, 313, 467, 4, 271, 143,
2209 21, 108, 438, 110, 143, 438, 164, 438, 144, 443,
2210 438, 640, 502, 236, 444, 22, 497, 509, 29, 30,
2211 31, 32, 33, 34, 35, 135, 36, 25, 466, 108,
2212 354, 110, 356, 110, 240, 135, 329, 279, 466, 83,
2213 84, 152, 11, 280, 351, 352, 88, 26, 45, 132,
2214 46, 152, 89, 355, 133, 357, 1, 549, 27, 3,
2215 111, 5, 43, 233, 234, 28, 442, 237, 346, 419,
2216 420, 421, 111, 241, 422, -144, 438, 57, 423, 424,
2217 111, 439, 347, 111, 533, 456, 404, 586, 111, 585,
2218 417, 111, 592, 593, 419, 420, 421, 276, 168, 422,
2219 118, 119, 111, 423, 424, 611, -67, 94, 631, 58,
2220 85, 388, 86, 394, 388, 388, 105, 388, 61, 273,
2221 531, 59, 314, 315, 276, 317, 37, 38, 39, 115,
2222 111, 116, 111, 399, -67, 401, -67, 90, 318, 276,
2223 276, 276, 276, 276, 325, 326, 327, 276, 97, 457,
2224 633, 634, 388, 636, 637, 135, 565, 98, 566, 415,
2225 388, 388, 388, 330, 331, 471, 152, 473, 474, 475,
2226 37, 38, 39, 99, -144, 332, 647, 648, -144, -55,
2227 -55, -55, -55, 101, 63, 64, 102, 106, 66, 67,
2228 68, 69, 70, 71, 72, 103, 1, 2, 86, 3,
2229 4, 5, 244, 245, 63, 64, 538, 152, 520, 49,
2230 50, 51, 145, 599, 52, 139, 1, 2, 395, 3,
2231 4, 5, 246, 247, 248, 249, 73, 148, 149, 388,
2232 388, 388, 388, 388, 554, 396, 397, 398, 270, 388,
2233 113, 114, 333, 334, 433, 434, 435, 436, 437, 140,
2234 388, 388, 147, 152, 416, 276, 165, 445, 446, 447,
2235 335, 336, 229, 337, 338, 231, 339, 340, 341, 121,
2236 122, 123, 124, 125, 126, 594, 271, 595, 598, 567,
2237 595, 232, 570, 571, 572, 238, 419, 420, 421, 242,
2238 441, 422, 235, 239, -56, 423, 424, -57, -60, 451,
2239 388, -59, 388, -58, 250, 388, 274, 110, 281, 348,
2240 349, 358, 388, 388, 276, 486, 487, 488, 489, 359,
2241 370, 618, 360, 361, 495, 622, 362, 371, 372, 414,
2242 276, 472, 276, 276, 276, 74, 75, 373, 479, 76,
2243 375, 77, 107, 418, 390, 388, 388, 428, 388, 388,
2244 388, 388, 485, 429, 405, 406, 388, 284, 285, 286,
2245 287, 288, 289, 290, 291, 292, 293, 388, 612, 407,
2246 408, 409, 410, 430, 431, 432, 454, 539, 540, 541,
2247 542, 448, 458, 459, 544, 545, 476, 470, 477, 478,
2248 632, 391, 392, 482, 393, -210, 500, 491, 492, 493,
2249 494, 496, 498, 499, 388, 506, 532, 508, 507, 510,
2250 511, 512, 513, -69, 1, 2, 514, 3, 4, 5,
2251 575, 576, 577, 578, 546, 6, 7, 388, 388, 403,
2252 553, 515, 516, 518, 520, 521, 559, 411, 412, 413,
2253 523, 526, 524, 525, 276, 388, 8, 276, 276, 276,
2254 9, 548, 529, 559, 10, 550, 530, 534, 535, 536,
2255 537, 547, 466, 555, 569, 604, 579, 605, 606, 543,
2256 581, 388, 388, 580, 582, 583, 388, 376, 377, 388,
2257 584, 63, 64, 378, 589, 388, 590, 591, 388, 600,
2258 596, 601, 602, 1, 2, 603, 3, 4, 5, 379,
2259 380, 381, 608, 610, 621, 623, 460, 461, 462, 463,
2260 464, 624, 626, 625, 382, 383, 469, 627, -18, 620,
2261 -19, 638, 639, 641, 644, 645, 650, 480, 481, 651,
2262 653, 221, 384, 222, 223, 130, 550, 607, 587, 146,
2263 1, 142, 344, 3, 44, 5, 96, 353, 179, 180,
2264 181, 182, 183, 184, 185, 186, 187, 188, 189, 190,
2265 191, 192, 193, 254, 255, 256, 257, 129, 573, 0,
2266 490, 0, 0, 0, 332, 0, 0, 517, 0, 519,
2267 0, 0, 522, 0, 0, 0, 0, 0, 0, 527,
2268 528, 0, 258, 202, 203, 204, 205, 206, 207, 208,
2269 209, 210, 211, 212, 213, 0, 259, 0, 260, 261,
2270 262, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2271 0, 0, 556, 557, 0, 561, 562, 563, 564, 0,
2272 0, 0, 0, 568, 0, 0, 385, 0, 0, 0,
2273 0, 333, 334, 0, 574, 0, 0, 0, 0, 0,
2274 0, 0, 376, 377, 0, 0, 63, 64, 378, 335,
2275 336, 0, 337, 338, 0, 339, 340, 341, 1, 2,
2276 0, 3, 4, 5, 379, 380, 381, 0, 0, 0,
2277 0, 597, 0, 0, 0, 0, 0, 0, 0, 382,
2278 383, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2279 0, 0, 332, 0, 616, 617, 0, 384, 0, 0,
Dan Gohmanf4423b12008-04-19 00:24:39 +00002280 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002281 0, 0, 629, 179, 180, 181, 182, 183, 184, 185,
2282 186, 187, 188, 189, 190, 191, 192, 193, 254, 255,
2283 256, 257, 0, 0, 0, 0, 0, 0, 642, 643,
2284 0, 0, 0, 646, 0, 0, 649, 0, 0, 0,
2285 0, 0, 652, 0, 0, 654, 0, 258, 202, 614,
2286 615, 205, 206, 207, 208, 209, 210, 211, 212, 213,
2287 0, 259, 0, 260, 261, 262, 0, 335, 336, 0,
2288 337, 338, 0, 339, 340, 341, 376, 377, 0, 0,
2289 63, 64, 378, 0, 0, -209, 0, 0, 0, 0,
2290 0, 385, 1, 2, 0, 3, 4, 5, 379, 380,
2291 381, 295, 296, -69, 1, 2, 0, 3, 4, 5,
2292 0, 0, 0, 382, 383, 6, 7, 0, 0, 0,
2293 0, 0, 0, 0, 0, 0, 0, 110, 0, 0,
2294 0, 384, 0, 0, 0, 0, 8, 0, 0, 0,
2295 9, 0, 0, 0, 10, 0, 0, 179, 180, 181,
2296 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
2297 192, 193, 254, 255, 256, 257, 0, 0, 0, 0,
2298 0, 0, 0, 0, 297, 298, 299, 300, 301, 302,
2299 303, 304, 305, 306, 307, 308, 309, 310, 0, 0,
2300 0, 258, 202, 203, 204, 205, 206, 207, 208, 209,
2301 210, 211, 212, 213, 0, 259, 0, 260, 261, 262,
2302 0, 0, 63, 64, 0, 0, 0, 0, 0, 0,
2303 0, 0, 0, 0, 1, 2, 111, 3, 4, 5,
2304 251, 0, 0, 0, 0, 385, 0, 0, 0, 0,
2305 0, 0, 0, 0, 0, 252, 253, 0, 0, 0,
2306 0, 0, 0, 0, 0, 0, 0, 63, 64, 110,
2307 106, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2308 2, 0, 3, 4, 5, 0, 0, 0, 0, 179,
Chris Lattnercc81d152008-05-04 17:18:47 +00002309 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
Nate Begemanac80ade2008-05-12 19:01:56 +00002310 190, 191, 192, 193, 254, 255, 256, 257, 0, 73,
2311 63, 64, 0, 106, 155, 156, 157, 158, 159, 160,
2312 72, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2313 0, 0, 0, 258, 202, 203, 204, 205, 206, 207,
2314 208, 209, 210, 211, 212, 213, 0, 259, 0, 260,
2315 261, 262, 73, 0, 0, 0, 0, 0, 0, 0,
2316 0, 0, 0, 0, 0, 0, 0, 0, 111, 0,
2317 63, 64, -67, 0, 263, 0, 0, 264, 0, 265,
2318 0, 266, 1, 2, 0, 3, 4, 5, 251, 0,
2319 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2320 0, 0, 0, 252, 253, 0, 0, 0, 0, 0,
2321 0, 0, 0, 0, 0, 0, 0, 110, 74, 75,
2322 0, 0, 76, 0, 77, 141, 0, 0, 0, 0,
2323 0, 0, 0, 0, 0, 0, 0, 179, 180, 181,
2324 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
2325 192, 193, 254, 255, 256, 257, 0, 0, 0, 0,
2326 0, 74, 75, 0, 0, 76, 0, 77, 368, 0,
2327 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2328 0, 258, 202, 203, 204, 205, 206, 207, 208, 209,
2329 210, 211, 212, 213, 0, 259, 0, 260, 261, 262,
2330 0, 0, 0, 0, 0, 0, 0, 0, 376, 377,
2331 0, 0, 0, 0, 378, 0, 111, 0, 0, 0,
2332 0, 0, 263, 0, 0, 264, 0, 265, 0, 266,
2333 379, 380, 381, 0, 0, 0, 0, 0, 0, 0,
2334 0, 0, 0, 0, 0, 382, 383, 0, 0, 0,
2335 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2336 0, 63, 64, 384, 106, 155, 156, 157, 158, 159,
2337 160, 72, 0, 1, 2, 0, 3, 4, 5, 179,
2338 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
2339 190, 191, 192, 193, 254, 255, 256, 257, 0, 0,
2340 0, 0, 0, 73, 63, 64, 0, 106, 66, 67,
2341 68, 69, 70, 71, 72, 0, 1, 2, 0, 3,
2342 4, 5, 0, 258, 202, 203, 204, 205, 206, 207,
2343 208, 209, 210, 211, 212, 213, 134, 259, 0, 260,
2344 261, 262, 0, 0, 0, 0, 73, 63, 64, 0,
2345 150, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2346 2, 0, 3, 4, 5, 63, 64, 385, 106, 66,
2347 67, 68, 69, 70, 71, 72, 0, 1, 2, 0,
2348 3, 4, 5, 0, 0, 0, 0, 0, 0, 73,
2349 0, 0, 0, 0, 0, 0, 0, 343, 0, 0,
2350 0, 0, 0, 0, 0, 0, 0, 73, 0, 0,
2351 0, 0, 74, 75, 0, 0, 76, 0, 77, 440,
2352 63, 64, 0, 106, 155, 156, 157, 158, 159, 160,
2353 72, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2354 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnercc81d152008-05-04 17:18:47 +00002355 0, 0, 0, 0, 0, 74, 75, 0, 0, 76,
Nate Begemanac80ade2008-05-12 19:01:56 +00002356 0, 77, 73, 0, 151, 63, 64, 0, 106, 66,
2357 67, 68, 69, 70, 71, 72, 0, 1, 2, 0,
2358 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2359 0, 0, 0, 0, 0, 0, 0, 450, 74, 75,
2360 0, 0, 76, 0, 77, 0, 0, 73, 0, 0,
2361 0, 0, 0, 0, 0, 0, 74, 75, 0, 0,
2362 76, 0, 77, 63, 64, 0, 106, 66, 67, 68,
Chris Lattnercc81d152008-05-04 17:18:47 +00002363 69, 70, 71, 72, 0, 1, 2, 0, 3, 4,
2364 5, 63, 64, 0, 65, 66, 67, 68, 69, 70,
Nate Begemanac80ade2008-05-12 19:01:56 +00002365 71, 72, 0, 1, 2, 552, 3, 4, 5, 0,
Chris Lattnercc81d152008-05-04 17:18:47 +00002366 0, 0, 0, 0, 0, 73, 0, 0, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002367 0, 74, 75, 0, 363, 76, 0, 77, 0, 0,
Chris Lattnercc81d152008-05-04 17:18:47 +00002368 0, 63, 64, 73, 106, 155, 156, 157, 158, 159,
2369 160, 72, 0, 1, 2, 0, 3, 4, 5, 0,
2370 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002371 0, 0, 0, 0, 0, 0, 74, 75, 0, 0,
2372 76, 0, 77, 73, 63, 64, 0, 150, 66, 67,
2373 68, 69, 70, 71, 72, 0, 1, 2, 0, 3,
2374 4, 5, 63, 64, 0, 106, 66, 67, 68, 69,
2375 70, 71, 72, 0, 1, 2, 0, 3, 4, 5,
2376 0, 0, 0, 0, 0, 0, 73, 0, 0, 0,
2377 0, 0, 0, 0, 74, 75, 0, 0, 76, 0,
2378 77, 0, 0, 0, 73, 0, 0, 0, 0, 0,
Chris Lattnercc81d152008-05-04 17:18:47 +00002379 0, 0, 74, 75, 0, 0, 76, 0, 77, 63,
Nate Begemanac80ade2008-05-12 19:01:56 +00002380 64, 0, 275, 66, 67, 68, 69, 70, 71, 72,
Chris Lattnercc81d152008-05-04 17:18:47 +00002381 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2382 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2383 0, 0, 74, 75, 0, 0, 76, 0, 77, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002384 0, 73, 63, 64, 0, 106, 155, 156, 157, 158,
2385 159, 160, 72, 0, 1, 2, 0, 3, 4, 5,
Chris Lattnercc81d152008-05-04 17:18:47 +00002386 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002387 0, 0, 0, 0, 0, 74, 75, 0, 0, 76,
2388 0, 77, 0, 0, 73, 0, 0, 0, 0, 0,
2389 0, 0, 0, 74, 75, 0, 0, 76, 0, 77,
2390 63, 64, 0, 106, 66, 67, 68, 69, 70, 71,
2391 558, 0, 1, 2, 0, 3, 4, 5, 63, 64,
2392 0, 106, 66, 67, 68, 69, 70, 71, 619, 0,
2393 1, 2, 170, 3, 4, 5, 0, 0, 0, 0,
2394 0, 0, 73, 0, 0, 0, 0, 0, 0, 0,
2395 74, 75, 171, 172, 76, 0, 77, 0, 0, 0,
2396 73, 0, 0, 0, 173, 174, 175, 176, 177, 178,
2397 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
2398 189, 190, 191, 192, 193, 194, 195, 196, 197, 0,
2399 0, 0, 0, 74, 75, 0, 0, 76, 0, 366,
2400 0, 0, 0, 0, 0, 0, 0, 0, 0, 198,
2401 199, 200, 0, 0, 201, 202, 203, 204, 205, 206,
2402 207, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2403 217, 218, 219, 220, 0, 0, 0, 0, 0, 0,
Chris Lattnercc81d152008-05-04 17:18:47 +00002404 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002405 0, 74, 75, 0, 0, 76, 0, 77, 0, 0,
2406 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2407 75, 0, 0, 76, 0, 77
Dan Gohmanf4423b12008-04-19 00:24:39 +00002408};
2409
2410static const yytype_int16 yycheck[] =
2411{
Nate Begemanac80ade2008-05-12 19:01:56 +00002412 0, 27, 175, 0, 315, 11, 4, 127, 11, 200,
2413 163, 54, 28, 21, 264, 265, 239, 17, 164, 38,
2414 17, 29, 196, 54, 215, 216, 217, 218, 219, 426,
2415 427, 54, 223, 155, 54, 451, 11, 176, 153, 54,
2416 34, 612, 54, 34, 20, 197, 11, 23, 163, 156,
2417 52, 77, 156, 54, 156, 156, 120, 156, 165, 163,
2418 156, 632, 53, 165, 165, 67, 165, 163, 42, 43,
2419 44, 45, 46, 47, 48, 101, 50, 58, 53, 105,
2420 254, 54, 256, 54, 148, 111, 225, 11, 53, 40,
2421 41, 117, 92, 17, 240, 241, 47, 155, 46, 156,
2422 48, 127, 53, 255, 161, 257, 19, 504, 18, 22,
2423 153, 24, 0, 139, 140, 155, 366, 143, 161, 138,
2424 139, 140, 153, 149, 143, 54, 156, 155, 147, 148,
2425 153, 161, 163, 153, 154, 385, 159, 553, 153, 154,
2426 331, 153, 558, 559, 138, 139, 140, 173, 164, 143,
2427 32, 33, 153, 147, 148, 161, 157, 165, 161, 155,
2428 35, 276, 37, 283, 279, 280, 164, 282, 22, 166,
2429 481, 159, 198, 199, 200, 201, 150, 151, 152, 42,
2430 153, 44, 153, 156, 157, 156, 157, 21, 214, 215,
2431 216, 217, 218, 219, 220, 221, 222, 223, 22, 390,
2432 616, 617, 317, 619, 620, 231, 517, 22, 519, 329,
2433 325, 326, 327, 116, 117, 406, 242, 408, 409, 410,
2434 150, 151, 152, 22, 153, 53, 642, 643, 157, 3,
2435 4, 5, 6, 153, 7, 8, 4, 10, 11, 12,
2436 13, 14, 15, 16, 17, 4, 19, 20, 37, 22,
2437 23, 24, 26, 27, 7, 8, 154, 283, 156, 42,
2438 43, 44, 153, 574, 47, 160, 19, 20, 294, 22,
2439 23, 24, 3, 4, 5, 6, 49, 113, 114, 394,
2440 395, 396, 397, 398, 507, 311, 312, 313, 441, 404,
2441 83, 84, 120, 121, 358, 359, 360, 361, 362, 160,
2442 415, 416, 157, 329, 330, 331, 4, 371, 372, 373,
2443 138, 139, 22, 141, 142, 156, 144, 145, 146, 61,
2444 62, 63, 64, 65, 66, 154, 441, 156, 154, 520,
2445 156, 154, 523, 524, 525, 4, 138, 139, 140, 153,
2446 366, 143, 163, 154, 9, 147, 148, 9, 9, 375,
2447 465, 9, 467, 9, 9, 470, 56, 54, 11, 163,
2448 154, 153, 477, 478, 390, 429, 430, 431, 432, 153,
2449 22, 594, 153, 153, 438, 598, 153, 153, 153, 38,
2450 406, 407, 408, 409, 410, 158, 159, 153, 414, 162,
2451 153, 164, 165, 4, 156, 510, 511, 38, 513, 514,
2452 515, 516, 428, 153, 156, 156, 521, 93, 94, 95,
2453 96, 97, 98, 99, 100, 101, 102, 532, 591, 156,
2454 156, 156, 156, 153, 153, 153, 60, 491, 492, 493,
2455 494, 156, 156, 156, 498, 499, 156, 159, 156, 156,
2456 613, 279, 280, 156, 282, 0, 38, 156, 156, 156,
2457 156, 163, 156, 156, 569, 156, 482, 22, 154, 17,
2458 17, 153, 156, 18, 19, 20, 156, 22, 23, 24,
2459 534, 535, 536, 537, 500, 30, 31, 592, 593, 317,
2460 506, 156, 156, 4, 156, 156, 512, 325, 326, 327,
2461 156, 4, 156, 156, 520, 610, 51, 523, 524, 525,
2462 55, 4, 153, 529, 59, 505, 156, 156, 156, 156,
2463 156, 22, 53, 156, 156, 579, 156, 581, 582, 163,
2464 156, 636, 637, 154, 156, 154, 641, 3, 4, 644,
2465 154, 7, 8, 9, 22, 650, 156, 159, 653, 154,
2466 161, 154, 154, 19, 20, 154, 22, 23, 24, 25,
2467 26, 27, 53, 17, 161, 154, 394, 395, 396, 397,
2468 398, 154, 4, 154, 40, 41, 404, 149, 153, 595,
2469 153, 22, 156, 17, 17, 156, 17, 415, 416, 72,
2470 17, 130, 58, 130, 130, 92, 586, 586, 554, 111,
2471 19, 105, 231, 22, 17, 24, 56, 242, 74, 75,
2472 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2473 86, 87, 88, 89, 90, 91, 92, 89, 529, -1,
2474 433, -1, -1, -1, 53, -1, -1, 465, -1, 467,
2475 -1, -1, 470, -1, -1, -1, -1, -1, -1, 477,
2476 478, -1, 118, 119, 120, 121, 122, 123, 124, 125,
2477 126, 127, 128, 129, 130, -1, 132, -1, 134, 135,
2478 136, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2479 -1, -1, 510, 511, -1, 513, 514, 515, 516, -1,
2480 -1, -1, -1, 521, -1, -1, 162, -1, -1, -1,
2481 -1, 120, 121, -1, 532, -1, -1, -1, -1, -1,
2482 -1, -1, 3, 4, -1, -1, 7, 8, 9, 138,
2483 139, -1, 141, 142, -1, 144, 145, 146, 19, 20,
2484 -1, 22, 23, 24, 25, 26, 27, -1, -1, -1,
2485 -1, 569, -1, -1, -1, -1, -1, -1, -1, 40,
Chris Lattnercc81d152008-05-04 17:18:47 +00002486 41, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00002487 -1, -1, 53, -1, 592, 593, -1, 58, -1, -1,
Chris Lattnercc81d152008-05-04 17:18:47 +00002488 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00002489 -1, -1, 610, 74, 75, 76, 77, 78, 79, 80,
2490 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2491 91, 92, -1, -1, -1, -1, -1, -1, 636, 637,
2492 -1, -1, -1, 641, -1, -1, 644, -1, -1, -1,
2493 -1, -1, 650, -1, -1, 653, -1, 118, 119, 120,
2494 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
2495 -1, 132, -1, 134, 135, 136, -1, 138, 139, -1,
2496 141, 142, -1, 144, 145, 146, 3, 4, -1, -1,
2497 7, 8, 9, -1, -1, 0, -1, -1, -1, -1,
2498 -1, 162, 19, 20, -1, 22, 23, 24, 25, 26,
2499 27, 26, 27, 18, 19, 20, -1, 22, 23, 24,
2500 -1, -1, -1, 40, 41, 30, 31, -1, -1, -1,
2501 -1, -1, -1, -1, -1, -1, -1, 54, -1, -1,
2502 -1, 58, -1, -1, -1, -1, 51, -1, -1, -1,
2503 55, -1, -1, -1, 59, -1, -1, 74, 75, 76,
2504 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2505 87, 88, 89, 90, 91, 92, -1, -1, -1, -1,
2506 -1, -1, -1, -1, 99, 100, 101, 102, 103, 104,
2507 105, 106, 107, 108, 109, 110, 111, 112, -1, -1,
2508 -1, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2509 127, 128, 129, 130, -1, 132, -1, 134, 135, 136,
2510 -1, -1, 7, 8, -1, -1, -1, -1, -1, -1,
2511 -1, -1, -1, -1, 19, 20, 153, 22, 23, 24,
2512 25, -1, -1, -1, -1, 162, -1, -1, -1, -1,
Chris Lattnercc81d152008-05-04 17:18:47 +00002513 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00002514 -1, -1, -1, -1, -1, -1, -1, 7, 8, 54,
2515 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2516 20, -1, 22, 23, 24, -1, -1, -1, -1, 74,
Chris Lattnercc81d152008-05-04 17:18:47 +00002517 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
Nate Begemanac80ade2008-05-12 19:01:56 +00002518 85, 86, 87, 88, 89, 90, 91, 92, -1, 49,
2519 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
2520 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2521 -1, -1, -1, 118, 119, 120, 121, 122, 123, 124,
2522 125, 126, 127, 128, 129, 130, -1, 132, -1, 134,
2523 135, 136, 49, -1, -1, -1, -1, -1, -1, -1,
2524 -1, -1, -1, -1, -1, -1, -1, -1, 153, -1,
2525 7, 8, 157, -1, 159, -1, -1, 162, -1, 164,
2526 -1, 166, 19, 20, -1, 22, 23, 24, 25, -1,
2527 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2528 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
2529 -1, -1, -1, -1, -1, -1, -1, 54, 158, 159,
2530 -1, -1, 162, -1, 164, 165, -1, -1, -1, -1,
2531 -1, -1, -1, -1, -1, -1, -1, 74, 75, 76,
2532 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2533 87, 88, 89, 90, 91, 92, -1, -1, -1, -1,
2534 -1, 158, 159, -1, -1, 162, -1, 164, 165, -1,
2535 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2536 -1, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2537 127, 128, 129, 130, -1, 132, -1, 134, 135, 136,
Chris Lattnercc81d152008-05-04 17:18:47 +00002538 -1, -1, -1, -1, -1, -1, -1, -1, 3, 4,
Nate Begemanac80ade2008-05-12 19:01:56 +00002539 -1, -1, -1, -1, 9, -1, 153, -1, -1, -1,
2540 -1, -1, 159, -1, -1, 162, -1, 164, -1, 166,
Chris Lattnercc81d152008-05-04 17:18:47 +00002541 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
2542 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2543 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00002544 -1, 7, 8, 58, 10, 11, 12, 13, 14, 15,
2545 16, 17, -1, 19, 20, -1, 22, 23, 24, 74,
Chris Lattnercc81d152008-05-04 17:18:47 +00002546 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
Nate Begemanac80ade2008-05-12 19:01:56 +00002547 85, 86, 87, 88, 89, 90, 91, 92, -1, -1,
2548 -1, -1, -1, 49, 7, 8, -1, 10, 11, 12,
2549 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2550 23, 24, -1, 118, 119, 120, 121, 122, 123, 124,
2551 125, 126, 127, 128, 129, 130, 39, 132, -1, 134,
2552 135, 136, -1, -1, -1, -1, 49, 7, 8, -1,
2553 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2554 20, -1, 22, 23, 24, 7, 8, 162, 10, 11,
2555 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2556 22, 23, 24, -1, -1, -1, -1, -1, -1, 49,
2557 -1, -1, -1, -1, -1, -1, -1, 39, -1, -1,
2558 -1, -1, -1, -1, -1, -1, -1, 49, -1, -1,
2559 -1, -1, 158, 159, -1, -1, 162, -1, 164, 165,
2560 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
2561 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2562 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2563 -1, -1, -1, -1, -1, 158, 159, -1, -1, 162,
2564 -1, 164, 49, -1, 124, 7, 8, -1, 10, 11,
2565 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2566 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2567 -1, -1, -1, -1, -1, -1, -1, 39, 158, 159,
2568 -1, -1, 162, -1, 164, -1, -1, 49, -1, -1,
2569 -1, -1, -1, -1, -1, -1, 158, 159, -1, -1,
2570 162, -1, 164, 7, 8, -1, 10, 11, 12, 13,
Chris Lattnercc81d152008-05-04 17:18:47 +00002571 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2572 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2573 16, 17, -1, 19, 20, 39, 22, 23, 24, -1,
2574 -1, -1, -1, -1, -1, 49, -1, -1, -1, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00002575 -1, 158, 159, -1, 161, 162, -1, 164, -1, -1,
Chris Lattnercc81d152008-05-04 17:18:47 +00002576 -1, 7, 8, 49, 10, 11, 12, 13, 14, 15,
2577 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2578 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00002579 -1, -1, -1, -1, -1, -1, 158, 159, -1, -1,
2580 162, -1, 164, 49, 7, 8, -1, 10, 11, 12,
2581 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2582 23, 24, 7, 8, -1, 10, 11, 12, 13, 14,
2583 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2584 -1, -1, -1, -1, -1, -1, 49, -1, -1, -1,
2585 -1, -1, -1, -1, 158, 159, -1, -1, 162, -1,
2586 164, -1, -1, -1, 49, -1, -1, -1, -1, -1,
2587 -1, -1, 158, 159, -1, -1, 162, -1, 164, 7,
Chris Lattnercc81d152008-05-04 17:18:47 +00002588 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2589 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2590 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00002591 -1, -1, 158, 159, -1, -1, 162, -1, 164, -1,
2592 -1, 49, 7, 8, -1, 10, 11, 12, 13, 14,
2593 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
Chris Lattnercc81d152008-05-04 17:18:47 +00002594 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00002595 -1, -1, -1, -1, -1, 158, 159, -1, -1, 162,
2596 -1, 164, -1, -1, 49, -1, -1, -1, -1, -1,
2597 -1, -1, -1, 158, 159, -1, -1, 162, -1, 164,
2598 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
2599 17, -1, 19, 20, -1, 22, 23, 24, 7, 8,
2600 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2601 19, 20, 36, 22, 23, 24, -1, -1, -1, -1,
2602 -1, -1, 49, -1, -1, -1, -1, -1, -1, -1,
2603 158, 159, 56, 57, 162, -1, 164, -1, -1, -1,
2604 49, -1, -1, -1, 68, 69, 70, 71, 72, 73,
2605 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2606 84, 85, 86, 87, 88, 89, 90, 91, 92, -1,
2607 -1, -1, -1, 158, 159, -1, -1, 162, -1, 164,
2608 -1, -1, -1, -1, -1, -1, -1, -1, -1, 113,
2609 114, 115, -1, -1, 118, 119, 120, 121, 122, 123,
2610 124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
2611 134, 135, 136, 137, -1, -1, -1, -1, -1, -1,
Chris Lattnercc81d152008-05-04 17:18:47 +00002612 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Nate Begemanac80ade2008-05-12 19:01:56 +00002613 -1, 158, 159, -1, -1, 162, -1, 164, -1, -1,
2614 -1, -1, -1, -1, -1, -1, -1, -1, -1, 158,
2615 159, -1, -1, 162, -1, 164
Dan Gohmanf4423b12008-04-19 00:24:39 +00002616};
2617
2618/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2619 symbol of state STATE-NUM. */
2620static const yytype_uint8 yystos[] =
2621{
2622 0, 19, 20, 22, 23, 24, 30, 31, 51, 55,
Nate Begemanac80ade2008-05-12 19:01:56 +00002623 59, 175, 178, 179, 180, 181, 213, 214, 215, 217,
2624 216, 52, 67, 222, 155, 58, 155, 18, 155, 42,
2625 43, 44, 45, 46, 47, 48, 50, 150, 151, 152,
2626 182, 183, 184, 0, 215, 46, 48, 185, 232, 42,
2627 43, 44, 47, 186, 229, 231, 239, 155, 155, 159,
2628 223, 22, 221, 7, 8, 10, 11, 12, 13, 14,
2629 15, 16, 17, 49, 158, 159, 162, 164, 175, 179,
2630 200, 201, 235, 184, 184, 35, 37, 211, 184, 184,
2631 21, 240, 241, 29, 165, 230, 240, 22, 22, 22,
2632 224, 153, 4, 4, 4, 164, 10, 165, 201, 206,
2633 54, 153, 177, 211, 211, 42, 44, 187, 32, 33,
2634 210, 61, 62, 63, 64, 65, 66, 188, 227, 227,
2635 178, 244, 156, 161, 39, 201, 202, 204, 205, 160,
2636 160, 165, 206, 156, 165, 153, 205, 157, 210, 210,
2637 10, 124, 201, 203, 212, 11, 12, 13, 14, 15,
2638 16, 173, 174, 201, 207, 4, 203, 28, 164, 228,
Chris Lattnercc81d152008-05-04 17:18:47 +00002639 36, 56, 57, 68, 69, 70, 71, 72, 73, 74,
2640 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
Nate Begemanac80ade2008-05-12 19:01:56 +00002641 85, 86, 87, 88, 89, 90, 91, 92, 113, 114,
2642 115, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2643 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
2644 137, 168, 169, 170, 242, 248, 249, 250, 251, 22,
2645 190, 156, 154, 201, 201, 163, 165, 201, 4, 154,
2646 207, 201, 153, 235, 26, 27, 3, 4, 5, 6,
2647 9, 25, 40, 41, 89, 90, 91, 92, 118, 132,
2648 134, 135, 136, 159, 162, 164, 166, 168, 169, 170,
2649 208, 235, 177, 179, 56, 10, 201, 237, 238, 11,
2650 17, 11, 173, 188, 93, 94, 95, 96, 97, 98,
2651 99, 100, 101, 102, 171, 26, 27, 99, 100, 101,
2652 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
2653 112, 172, 171, 172, 201, 201, 237, 201, 201, 245,
2654 237, 237, 237, 237, 237, 201, 201, 201, 237, 188,
2655 116, 117, 53, 120, 121, 138, 139, 141, 142, 144,
2656 145, 146, 189, 39, 202, 192, 161, 163, 163, 154,
2657 192, 177, 177, 212, 171, 172, 171, 172, 153, 153,
2658 153, 153, 153, 161, 207, 209, 164, 209, 165, 209,
2659 22, 153, 153, 153, 218, 153, 3, 4, 9, 25,
2660 26, 27, 40, 41, 58, 162, 208, 234, 235, 236,
2661 156, 236, 236, 236, 203, 201, 201, 201, 201, 156,
2662 195, 156, 195, 236, 159, 156, 156, 156, 156, 156,
2663 156, 236, 236, 236, 38, 203, 201, 237, 4, 138,
2664 139, 140, 143, 147, 148, 191, 219, 220, 38, 153,
2665 153, 153, 153, 207, 207, 207, 207, 207, 156, 161,
2666 165, 201, 209, 163, 165, 207, 207, 207, 156, 198,
2667 39, 201, 225, 226, 60, 233, 209, 237, 156, 156,
2668 236, 236, 236, 236, 236, 11, 53, 11, 247, 236,
2669 159, 237, 201, 237, 237, 237, 156, 156, 156, 201,
2670 236, 236, 156, 198, 198, 201, 207, 207, 207, 207,
2671 247, 156, 156, 156, 156, 207, 163, 165, 156, 156,
2672 38, 34, 53, 196, 199, 190, 156, 154, 22, 163,
2673 17, 17, 153, 156, 156, 156, 156, 236, 4, 236,
2674 156, 156, 236, 156, 156, 156, 4, 236, 236, 153,
2675 156, 195, 201, 154, 156, 156, 156, 156, 154, 207,
2676 207, 207, 207, 163, 207, 207, 201, 22, 4, 198,
2677 175, 176, 39, 201, 192, 156, 236, 236, 17, 201,
2678 246, 236, 236, 236, 236, 195, 195, 237, 236, 156,
2679 237, 237, 237, 246, 236, 207, 207, 207, 207, 156,
2680 154, 156, 156, 154, 154, 154, 190, 196, 197, 22,
2681 156, 159, 190, 190, 154, 156, 161, 236, 154, 195,
2682 154, 154, 154, 154, 207, 207, 207, 176, 53, 194,
2683 17, 161, 173, 243, 120, 121, 236, 236, 192, 17,
2684 201, 161, 192, 154, 154, 154, 4, 149, 193, 236,
2685 234, 161, 173, 190, 190, 38, 190, 190, 22, 156,
2686 234, 17, 236, 236, 17, 156, 236, 190, 190, 236,
2687 17, 72, 236, 17, 236
Dan Gohmanf4423b12008-04-19 00:24:39 +00002688};
David Greene718fda32007-08-01 03:59:32 +00002689
Reid Spencer68a24bd2005-08-27 18:50:39 +00002690#define yyerrok (yyerrstatus = 0)
2691#define yyclearin (yychar = YYEMPTY)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002692#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002693#define YYEOF 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00002694
Reid Spencer68a24bd2005-08-27 18:50:39 +00002695#define YYACCEPT goto yyacceptlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002696#define YYABORT goto yyabortlab
2697#define YYERROR goto yyerrorlab
2698
2699
2700/* Like YYERROR except do call yyerror. This remains here temporarily
2701 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002702 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00002703
Reid Spencer68a24bd2005-08-27 18:50:39 +00002704#define YYFAIL goto yyerrlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002705
Reid Spencer68a24bd2005-08-27 18:50:39 +00002706#define YYRECOVERING() (!!yyerrstatus)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002707
2708#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002709do \
2710 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002711 { \
2712 yychar = (Token); \
2713 yylval = (Value); \
2714 yytoken = YYTRANSLATE (yychar); \
2715 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002716 goto yybackup; \
2717 } \
2718 else \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002719 { \
2720 yyerror (YY_("syntax error: cannot back up")); \
2721 YYERROR; \
2722 } \
2723while (YYID (0))
2724
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002725
Reid Spencer68a24bd2005-08-27 18:50:39 +00002726#define YYTERROR 1
2727#define YYERRCODE 256
2728
Dan Gohmanf4423b12008-04-19 00:24:39 +00002729
2730/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2731 If N is 0, then set CURRENT to the empty location which ends
2732 the previous symbol: RHS[0] (always defined). */
2733
2734#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2735#ifndef YYLLOC_DEFAULT
2736# define YYLLOC_DEFAULT(Current, Rhs, N) \
2737 do \
2738 if (YYID (N)) \
2739 { \
2740 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2741 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2742 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2743 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2744 } \
2745 else \
2746 { \
2747 (Current).first_line = (Current).last_line = \
2748 YYRHSLOC (Rhs, 0).last_line; \
2749 (Current).first_column = (Current).last_column = \
2750 YYRHSLOC (Rhs, 0).last_column; \
2751 } \
2752 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002753#endif
2754
Dan Gohmanf4423b12008-04-19 00:24:39 +00002755
2756/* YY_LOCATION_PRINT -- Print the location on the stream.
2757 This macro was not mandated originally: define only if we know
2758 we won't break user code: when these are the locations we know. */
2759
2760#ifndef YY_LOCATION_PRINT
2761# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
2762# define YY_LOCATION_PRINT(File, Loc) \
2763 fprintf (File, "%d.%d-%d.%d", \
2764 (Loc).first_line, (Loc).first_column, \
2765 (Loc).last_line, (Loc).last_column)
2766# else
2767# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2768# endif
2769#endif
2770
2771
2772/* YYLEX -- calling `yylex' with the right arguments. */
2773
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002774#ifdef YYLEX_PARAM
Dan Gohmanf4423b12008-04-19 00:24:39 +00002775# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002776#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002777# define YYLEX yylex ()
Gabor Greife64d2482008-04-06 23:07:54 +00002778#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002779
2780/* Enable debugging if requested. */
2781#if YYDEBUG
2782
2783# ifndef YYFPRINTF
2784# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2785# define YYFPRINTF fprintf
2786# endif
2787
2788# define YYDPRINTF(Args) \
2789do { \
2790 if (yydebug) \
2791 YYFPRINTF Args; \
2792} while (YYID (0))
2793
2794# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2795do { \
2796 if (yydebug) \
2797 { \
2798 YYFPRINTF (stderr, "%s ", Title); \
2799 yy_symbol_print (stderr, \
2800 Type, Value); \
2801 YYFPRINTF (stderr, "\n"); \
2802 } \
2803} while (YYID (0))
2804
2805
2806/*--------------------------------.
2807| Print this symbol on YYOUTPUT. |
2808`--------------------------------*/
2809
2810/*ARGSUSED*/
2811#if (defined __STDC__ || defined __C99__FUNC__ \
2812 || defined __cplusplus || defined _MSC_VER)
2813static void
2814yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greife64d2482008-04-06 23:07:54 +00002815#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002816static void
2817yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2818 FILE *yyoutput;
2819 int yytype;
2820 YYSTYPE const * const yyvaluep;
Gabor Greife64d2482008-04-06 23:07:54 +00002821#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002822{
2823 if (!yyvaluep)
2824 return;
2825# ifdef YYPRINT
2826 if (yytype < YYNTOKENS)
2827 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2828# else
2829 YYUSE (yyoutput);
2830# endif
2831 switch (yytype)
2832 {
2833 default:
2834 break;
2835 }
2836}
2837
2838
2839/*--------------------------------.
2840| Print this symbol on YYOUTPUT. |
2841`--------------------------------*/
2842
2843#if (defined __STDC__ || defined __C99__FUNC__ \
2844 || defined __cplusplus || defined _MSC_VER)
2845static void
2846yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2847#else
2848static void
2849yy_symbol_print (yyoutput, yytype, yyvaluep)
2850 FILE *yyoutput;
2851 int yytype;
2852 YYSTYPE const * const yyvaluep;
Scott Michel15dcd8e2008-01-30 03:10:00 +00002853#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002854{
2855 if (yytype < YYNTOKENS)
2856 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2857 else
2858 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner38905612008-02-19 04:36:25 +00002859
Dan Gohmanf4423b12008-04-19 00:24:39 +00002860 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2861 YYFPRINTF (yyoutput, ")");
2862}
Chris Lattner38905612008-02-19 04:36:25 +00002863
Dan Gohmanf4423b12008-04-19 00:24:39 +00002864/*------------------------------------------------------------------.
2865| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2866| TOP (included). |
2867`------------------------------------------------------------------*/
Chris Lattner38905612008-02-19 04:36:25 +00002868
Dan Gohmanf4423b12008-04-19 00:24:39 +00002869#if (defined __STDC__ || defined __C99__FUNC__ \
2870 || defined __cplusplus || defined _MSC_VER)
2871static void
2872yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2873#else
2874static void
2875yy_stack_print (bottom, top)
2876 yytype_int16 *bottom;
2877 yytype_int16 *top;
Scott Michel15dcd8e2008-01-30 03:10:00 +00002878#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002879{
2880 YYFPRINTF (stderr, "Stack now");
2881 for (; bottom <= top; ++bottom)
2882 YYFPRINTF (stderr, " %d", *bottom);
2883 YYFPRINTF (stderr, "\n");
2884}
Chris Lattner38905612008-02-19 04:36:25 +00002885
Dan Gohmanf4423b12008-04-19 00:24:39 +00002886# define YY_STACK_PRINT(Bottom, Top) \
2887do { \
2888 if (yydebug) \
2889 yy_stack_print ((Bottom), (Top)); \
2890} while (YYID (0))
Chris Lattner38905612008-02-19 04:36:25 +00002891
Dan Gohmanf4423b12008-04-19 00:24:39 +00002892
2893/*------------------------------------------------.
2894| Report that the YYRULE is going to be reduced. |
2895`------------------------------------------------*/
2896
2897#if (defined __STDC__ || defined __C99__FUNC__ \
2898 || defined __cplusplus || defined _MSC_VER)
2899static void
2900yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2901#else
2902static void
2903yy_reduce_print (yyvsp, yyrule)
2904 YYSTYPE *yyvsp;
2905 int yyrule;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002906#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002907{
2908 int yynrhs = yyr2[yyrule];
2909 int yyi;
2910 unsigned long int yylno = yyrline[yyrule];
2911 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2912 yyrule - 1, yylno);
2913 /* The symbols being reduced. */
2914 for (yyi = 0; yyi < yynrhs; yyi++)
2915 {
2916 fprintf (stderr, " $%d = ", yyi + 1);
2917 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2918 &(yyvsp[(yyi + 1) - (yynrhs)])
2919 );
2920 fprintf (stderr, "\n");
2921 }
2922}
Scott Michel7f9ba9b2008-01-30 02:55:46 +00002923
Dan Gohmanf4423b12008-04-19 00:24:39 +00002924# define YY_REDUCE_PRINT(Rule) \
2925do { \
2926 if (yydebug) \
2927 yy_reduce_print (yyvsp, Rule); \
2928} while (YYID (0))
Scott Michel7f9ba9b2008-01-30 02:55:46 +00002929
Dan Gohmanf4423b12008-04-19 00:24:39 +00002930/* Nonzero means print parse trace. It is left uninitialized so that
2931 multiple parsers can coexist. */
2932int yydebug;
2933#else /* !YYDEBUG */
2934# define YYDPRINTF(Args)
2935# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2936# define YY_STACK_PRINT(Bottom, Top)
2937# define YY_REDUCE_PRINT(Rule)
2938#endif /* !YYDEBUG */
2939
2940
2941/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002942#ifndef YYINITDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00002943# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002944#endif
2945
Dan Gohmanf4423b12008-04-19 00:24:39 +00002946/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2947 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002948
Dan Gohmanf4423b12008-04-19 00:24:39 +00002949 Do not make this value too large; the results are undefined if
2950 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2951 evaluated with infinite-precision integer arithmetic. */
David Greene718fda32007-08-01 03:59:32 +00002952
Reid Spencer68a24bd2005-08-27 18:50:39 +00002953#ifndef YYMAXDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00002954# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002955#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002956
Reid Spencer68a24bd2005-08-27 18:50:39 +00002957
2958
Dan Gohmanf4423b12008-04-19 00:24:39 +00002959#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002960
Dan Gohmanf4423b12008-04-19 00:24:39 +00002961# ifndef yystrlen
2962# if defined __GLIBC__ && defined _STRING_H
2963# define yystrlen strlen
2964# else
2965/* Return the length of YYSTR. */
2966#if (defined __STDC__ || defined __C99__FUNC__ \
2967 || defined __cplusplus || defined _MSC_VER)
2968static YYSIZE_T
2969yystrlen (const char *yystr)
Chris Lattner38905612008-02-19 04:36:25 +00002970#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002971static YYSIZE_T
2972yystrlen (yystr)
2973 const char *yystr;
2974#endif
2975{
2976 YYSIZE_T yylen;
2977 for (yylen = 0; yystr[yylen]; yylen++)
2978 continue;
2979 return yylen;
2980}
2981# endif
2982# endif
2983
2984# ifndef yystpcpy
2985# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2986# define yystpcpy stpcpy
2987# else
2988/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2989 YYDEST. */
2990#if (defined __STDC__ || defined __C99__FUNC__ \
2991 || defined __cplusplus || defined _MSC_VER)
2992static char *
2993yystpcpy (char *yydest, const char *yysrc)
2994#else
2995static char *
2996yystpcpy (yydest, yysrc)
2997 char *yydest;
2998 const char *yysrc;
2999#endif
3000{
3001 char *yyd = yydest;
3002 const char *yys = yysrc;
3003
3004 while ((*yyd++ = *yys++) != '\0')
3005 continue;
3006
3007 return yyd - 1;
3008}
3009# endif
3010# endif
3011
3012# ifndef yytnamerr
3013/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3014 quotes and backslashes, so that it's suitable for yyerror. The
3015 heuristic is that double-quoting is unnecessary unless the string
3016 contains an apostrophe, a comma, or backslash (other than
3017 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3018 null, do not copy; instead, return the length of what the result
3019 would have been. */
3020static YYSIZE_T
3021yytnamerr (char *yyres, const char *yystr)
3022{
3023 if (*yystr == '"')
3024 {
3025 YYSIZE_T yyn = 0;
3026 char const *yyp = yystr;
3027
3028 for (;;)
3029 switch (*++yyp)
3030 {
3031 case '\'':
3032 case ',':
3033 goto do_not_strip_quotes;
3034
3035 case '\\':
3036 if (*++yyp != '\\')
3037 goto do_not_strip_quotes;
3038 /* Fall through. */
3039 default:
3040 if (yyres)
3041 yyres[yyn] = *yyp;
3042 yyn++;
3043 break;
3044
3045 case '"':
3046 if (yyres)
3047 yyres[yyn] = '\0';
3048 return yyn;
3049 }
3050 do_not_strip_quotes: ;
3051 }
3052
3053 if (! yyres)
3054 return yystrlen (yystr);
3055
3056 return yystpcpy (yyres, yystr) - yyres;
3057}
3058# endif
3059
3060/* Copy into YYRESULT an error message about the unexpected token
3061 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3062 including the terminating null byte. If YYRESULT is null, do not
3063 copy anything; just return the number of bytes that would be
3064 copied. As a special case, return 0 if an ordinary "syntax error"
3065 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3066 size calculation. */
3067static YYSIZE_T
3068yysyntax_error (char *yyresult, int yystate, int yychar)
3069{
3070 int yyn = yypact[yystate];
3071
3072 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3073 return 0;
3074 else
3075 {
3076 int yytype = YYTRANSLATE (yychar);
3077 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3078 YYSIZE_T yysize = yysize0;
3079 YYSIZE_T yysize1;
3080 int yysize_overflow = 0;
3081 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3082 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3083 int yyx;
3084
3085# if 0
3086 /* This is so xgettext sees the translatable formats that are
3087 constructed on the fly. */
3088 YY_("syntax error, unexpected %s");
3089 YY_("syntax error, unexpected %s, expecting %s");
3090 YY_("syntax error, unexpected %s, expecting %s or %s");
3091 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3092 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3093# endif
3094 char *yyfmt;
3095 char const *yyf;
3096 static char const yyunexpected[] = "syntax error, unexpected %s";
3097 static char const yyexpecting[] = ", expecting %s";
3098 static char const yyor[] = " or %s";
3099 char yyformat[sizeof yyunexpected
3100 + sizeof yyexpecting - 1
3101 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3102 * (sizeof yyor - 1))];
3103 char const *yyprefix = yyexpecting;
3104
3105 /* Start YYX at -YYN if negative to avoid negative indexes in
3106 YYCHECK. */
3107 int yyxbegin = yyn < 0 ? -yyn : 0;
3108
3109 /* Stay within bounds of both yycheck and yytname. */
3110 int yychecklim = YYLAST - yyn + 1;
3111 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3112 int yycount = 1;
3113
3114 yyarg[0] = yytname[yytype];
3115 yyfmt = yystpcpy (yyformat, yyunexpected);
3116
3117 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3118 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3119 {
3120 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3121 {
3122 yycount = 1;
3123 yysize = yysize0;
3124 yyformat[sizeof yyunexpected - 1] = '\0';
3125 break;
3126 }
3127 yyarg[yycount++] = yytname[yyx];
3128 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3129 yysize_overflow |= (yysize1 < yysize);
3130 yysize = yysize1;
3131 yyfmt = yystpcpy (yyfmt, yyprefix);
3132 yyprefix = yyor;
3133 }
3134
3135 yyf = YY_(yyformat);
3136 yysize1 = yysize + yystrlen (yyf);
3137 yysize_overflow |= (yysize1 < yysize);
3138 yysize = yysize1;
3139
3140 if (yysize_overflow)
3141 return YYSIZE_MAXIMUM;
3142
3143 if (yyresult)
3144 {
3145 /* Avoid sprintf, as that infringes on the user's name space.
3146 Don't have undefined behavior even if the translation
3147 produced a string with the wrong number of "%s"s. */
3148 char *yyp = yyresult;
3149 int yyi = 0;
3150 while ((*yyp = *yyf) != '\0')
3151 {
3152 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3153 {
3154 yyp += yytnamerr (yyp, yyarg[yyi++]);
3155 yyf += 2;
3156 }
3157 else
3158 {
3159 yyp++;
3160 yyf++;
3161 }
3162 }
3163 }
3164 return yysize;
3165 }
3166}
3167#endif /* YYERROR_VERBOSE */
3168
3169
3170/*-----------------------------------------------.
3171| Release the memory associated to this symbol. |
3172`-----------------------------------------------*/
3173
3174/*ARGSUSED*/
3175#if (defined __STDC__ || defined __C99__FUNC__ \
3176 || defined __cplusplus || defined _MSC_VER)
3177static void
3178yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3179#else
3180static void
3181yydestruct (yymsg, yytype, yyvaluep)
3182 const char *yymsg;
3183 int yytype;
3184 YYSTYPE *yyvaluep;
3185#endif
3186{
3187 YYUSE (yyvaluep);
3188
3189 if (!yymsg)
3190 yymsg = "Deleting";
3191 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3192
3193 switch (yytype)
3194 {
3195
3196 default:
3197 break;
3198 }
3199}
3200
3201
3202/* Prevent warnings from -Wmissing-prototypes. */
3203
3204#ifdef YYPARSE_PARAM
3205#if defined __STDC__ || defined __cplusplus
3206int yyparse (void *YYPARSE_PARAM);
3207#else
3208int yyparse ();
3209#endif
3210#else /* ! YYPARSE_PARAM */
3211#if defined __STDC__ || defined __cplusplus
David Greene5fd22a82007-09-04 18:46:50 +00003212int yyparse (void);
Gabor Greife64d2482008-04-06 23:07:54 +00003213#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003214int yyparse ();
Scott Michel15dcd8e2008-01-30 03:10:00 +00003215#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003216#endif /* ! YYPARSE_PARAM */
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003217
Chris Lattner38905612008-02-19 04:36:25 +00003218
Dan Gohmanf4423b12008-04-19 00:24:39 +00003219
3220/* The look-ahead symbol. */
3221int yychar;
3222
3223/* The semantic value of the look-ahead symbol. */
3224YYSTYPE yylval;
3225
3226/* Number of syntax errors so far. */
3227int yynerrs;
3228
3229
3230
3231/*----------.
3232| yyparse. |
3233`----------*/
3234
3235#ifdef YYPARSE_PARAM
3236#if (defined __STDC__ || defined __C99__FUNC__ \
3237 || defined __cplusplus || defined _MSC_VER)
3238int
3239yyparse (void *YYPARSE_PARAM)
3240#else
3241int
3242yyparse (YYPARSE_PARAM)
3243 void *YYPARSE_PARAM;
3244#endif
3245#else /* ! YYPARSE_PARAM */
3246#if (defined __STDC__ || defined __C99__FUNC__ \
3247 || defined __cplusplus || defined _MSC_VER)
3248int
3249yyparse (void)
3250#else
3251int
3252yyparse ()
3253
Gabor Greife64d2482008-04-06 23:07:54 +00003254#endif
3255#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003256{
3257
3258 int yystate;
3259 int yyn;
3260 int yyresult;
3261 /* Number of tokens to shift before error messages enabled. */
3262 int yyerrstatus;
3263 /* Look-ahead token as an internal (translated) token number. */
3264 int yytoken = 0;
3265#if YYERROR_VERBOSE
3266 /* Buffer for error messages, and its allocated size. */
3267 char yymsgbuf[128];
3268 char *yymsg = yymsgbuf;
3269 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greife64d2482008-04-06 23:07:54 +00003270#endif
Chris Lattner38905612008-02-19 04:36:25 +00003271
Dan Gohmanf4423b12008-04-19 00:24:39 +00003272 /* Three stacks and their tools:
3273 `yyss': related to states,
3274 `yyvs': related to semantic values,
3275 `yyls': related to locations.
3276
3277 Refer to the stacks thru separate pointers, to allow yyoverflow
3278 to reallocate them elsewhere. */
3279
3280 /* The state stack. */
3281 yytype_int16 yyssa[YYINITDEPTH];
3282 yytype_int16 *yyss = yyssa;
3283 yytype_int16 *yyssp;
3284
3285 /* The semantic value stack. */
3286 YYSTYPE yyvsa[YYINITDEPTH];
3287 YYSTYPE *yyvs = yyvsa;
3288 YYSTYPE *yyvsp;
3289
3290
3291
3292#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3293
3294 YYSIZE_T yystacksize = YYINITDEPTH;
3295
3296 /* The variables used to return semantic value and location from the
3297 action routines. */
3298 YYSTYPE yyval;
3299
3300
3301 /* The number of symbols on the RHS of the reduced rule.
3302 Keep to zero when no symbol should be popped. */
3303 int yylen = 0;
3304
3305 YYDPRINTF ((stderr, "Starting parse\n"));
3306
Reid Spencer68a24bd2005-08-27 18:50:39 +00003307 yystate = 0;
3308 yyerrstatus = 0;
3309 yynerrs = 0;
3310 yychar = YYEMPTY; /* Cause a token to be read. */
3311
3312 /* Initialize stack pointers.
3313 Waste one element of value and location stack
3314 so that they stay on the same level as the state stack.
3315 The wasted elements are never initialized. */
3316
Dan Gohmanf4423b12008-04-19 00:24:39 +00003317 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003318 yyvsp = yyvs;
3319
Dan Gohmanf4423b12008-04-19 00:24:39 +00003320 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003321
Dan Gohmanf4423b12008-04-19 00:24:39 +00003322/*------------------------------------------------------------.
3323| yynewstate -- Push a new state, which is found in yystate. |
3324`------------------------------------------------------------*/
3325 yynewstate:
3326 /* In all cases, when you get here, the value and location stacks
3327 have just been pushed. So pushing a state here evens the stacks. */
3328 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003329
Dan Gohmanf4423b12008-04-19 00:24:39 +00003330 yysetstate:
3331 *yyssp = yystate;
3332
3333 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003334 {
3335 /* Get the current used size of the three stacks, in elements. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003336 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003337
3338#ifdef yyoverflow
Dan Gohmanf4423b12008-04-19 00:24:39 +00003339 {
3340 /* Give user a chance to reallocate the stack. Use copies of
3341 these so that the &'s don't force the real ones into
3342 memory. */
3343 YYSTYPE *yyvs1 = yyvs;
3344 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003345
Dan Gohmanf4423b12008-04-19 00:24:39 +00003346
3347 /* Each stack pointer address is followed by the size of the
3348 data in use in that stack, in bytes. This used to be a
3349 conditional around just the two extra args, but that might
3350 be undefined if yyoverflow is a macro. */
3351 yyoverflow (YY_("memory exhausted"),
3352 &yyss1, yysize * sizeof (*yyssp),
3353 &yyvs1, yysize * sizeof (*yyvsp),
3354
3355 &yystacksize);
3356
3357 yyss = yyss1;
3358 yyvs = yyvs1;
3359 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003360#else /* no yyoverflow */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003361# ifndef YYSTACK_RELOCATE
3362 goto yyexhaustedlab;
3363# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003364 /* Extend the stack our own way. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003365 if (YYMAXDEPTH <= yystacksize)
3366 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003367 yystacksize *= 2;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003368 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003369 yystacksize = YYMAXDEPTH;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003370
3371 {
3372 yytype_int16 *yyss1 = yyss;
3373 union yyalloc *yyptr =
3374 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3375 if (! yyptr)
3376 goto yyexhaustedlab;
3377 YYSTACK_RELOCATE (yyss);
3378 YYSTACK_RELOCATE (yyvs);
3379
3380# undef YYSTACK_RELOCATE
3381 if (yyss1 != yyssa)
3382 YYSTACK_FREE (yyss1);
3383 }
3384# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003385#endif /* no yyoverflow */
3386
Dan Gohmanf4423b12008-04-19 00:24:39 +00003387 yyssp = yyss + yysize - 1;
3388 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003389
3390
Dan Gohmanf4423b12008-04-19 00:24:39 +00003391 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3392 (unsigned long int) yystacksize));
3393
3394 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003395 YYABORT;
3396 }
3397
Dan Gohmanf4423b12008-04-19 00:24:39 +00003398 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003399
3400 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003401
Dan Gohmanf4423b12008-04-19 00:24:39 +00003402/*-----------.
3403| yybackup. |
3404`-----------*/
3405yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003406
Dan Gohmanf4423b12008-04-19 00:24:39 +00003407 /* Do appropriate processing given the current state. Read a
3408 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003409
Dan Gohmanf4423b12008-04-19 00:24:39 +00003410 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003411 yyn = yypact[yystate];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003412 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003413 goto yydefault;
3414
Dan Gohmanf4423b12008-04-19 00:24:39 +00003415 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003416
Dan Gohmanf4423b12008-04-19 00:24:39 +00003417 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003418 if (yychar == YYEMPTY)
3419 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003420 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003421 yychar = YYLEX;
3422 }
3423
Dan Gohmanf4423b12008-04-19 00:24:39 +00003424 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003425 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003426 yychar = yytoken = YYEOF;
3427 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003428 }
3429 else
3430 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003431 yytoken = YYTRANSLATE (yychar);
3432 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003433 }
3434
Dan Gohmanf4423b12008-04-19 00:24:39 +00003435 /* If the proper action on seeing token YYTOKEN is to reduce or to
3436 detect an error, take that action. */
3437 yyn += yytoken;
3438 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003439 goto yydefault;
3440 yyn = yytable[yyn];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003441 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003442 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003443 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003444 goto yyerrlab;
3445 yyn = -yyn;
3446 goto yyreduce;
3447 }
3448
3449 if (yyn == YYFINAL)
3450 YYACCEPT;
3451
Dan Gohmanf4423b12008-04-19 00:24:39 +00003452 /* Count tokens shifted since error; after three, turn off error
3453 status. */
3454 if (yyerrstatus)
3455 yyerrstatus--;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003456
Dan Gohmanf4423b12008-04-19 00:24:39 +00003457 /* Shift the look-ahead token. */
3458 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003459
Dan Gohmanf4423b12008-04-19 00:24:39 +00003460 /* Discard the shifted token unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003461 if (yychar != YYEOF)
3462 yychar = YYEMPTY;
3463
Gabor Greife64d2482008-04-06 23:07:54 +00003464 yystate = yyn;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003465 *++yyvsp = yylval;
3466
Reid Spencer68a24bd2005-08-27 18:50:39 +00003467 goto yynewstate;
3468
Gabor Greife64d2482008-04-06 23:07:54 +00003469
Dan Gohmanf4423b12008-04-19 00:24:39 +00003470/*-----------------------------------------------------------.
3471| yydefault -- do the default action for the current state. |
3472`-----------------------------------------------------------*/
3473yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003474 yyn = yydefact[yystate];
3475 if (yyn == 0)
3476 goto yyerrlab;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003477 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003478
Dan Gohmanf4423b12008-04-19 00:24:39 +00003479
3480/*-----------------------------.
3481| yyreduce -- Do a reduction. |
3482`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003483yyreduce:
Dan Gohmanf4423b12008-04-19 00:24:39 +00003484 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003485 yylen = yyr2[yyn];
3486
Dan Gohmanf4423b12008-04-19 00:24:39 +00003487 /* If YYLEN is nonzero, implement the default value of the action:
3488 `$$ = $1'.
3489
3490 Otherwise, the following line sets YYVAL to garbage.
3491 This behavior is undocumented and Bison
3492 users should not rely upon it. Assigning to YYVAL
3493 unconditionally makes the parser a bit smaller, and it avoids a
3494 GCC warning that YYVAL may be used uninitialized. */
3495 yyval = yyvsp[1-yylen];
3496
3497
3498 YY_REDUCE_PRINT (yyn);
3499 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003500 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003501 case 29:
Nate Begemanac80ade2008-05-12 19:01:56 +00003502#line 1117 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003503 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3504 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003505
Dan Gohmanf4423b12008-04-19 00:24:39 +00003506 case 30:
Nate Begemanac80ade2008-05-12 19:01:56 +00003507#line 1117 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003508 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3509 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003510
Dan Gohmanf4423b12008-04-19 00:24:39 +00003511 case 31:
Nate Begemanac80ade2008-05-12 19:01:56 +00003512#line 1118 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003513 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3514 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003515
Dan Gohmanf4423b12008-04-19 00:24:39 +00003516 case 32:
Nate Begemanac80ade2008-05-12 19:01:56 +00003517#line 1118 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003518 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3519 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003520
Dan Gohmanf4423b12008-04-19 00:24:39 +00003521 case 33:
Nate Begemanac80ade2008-05-12 19:01:56 +00003522#line 1119 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003523 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3524 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003525
Dan Gohmanf4423b12008-04-19 00:24:39 +00003526 case 34:
Nate Begemanac80ade2008-05-12 19:01:56 +00003527#line 1119 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003528 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3529 break;
3530
3531 case 35:
Nate Begemanac80ade2008-05-12 19:01:56 +00003532#line 1120 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003533 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3534 break;
3535
3536 case 36:
Nate Begemanac80ade2008-05-12 19:01:56 +00003537#line 1120 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003538 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3539 break;
3540
3541 case 37:
Nate Begemanac80ade2008-05-12 19:01:56 +00003542#line 1121 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003543 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3544 break;
3545
3546 case 38:
Nate Begemanac80ade2008-05-12 19:01:56 +00003547#line 1121 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003548 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3549 break;
3550
3551 case 39:
Nate Begemanac80ade2008-05-12 19:01:56 +00003552#line 1125 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003553 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3554 break;
3555
3556 case 40:
Nate Begemanac80ade2008-05-12 19:01:56 +00003557#line 1125 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003558 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3559 break;
3560
3561 case 41:
Nate Begemanac80ade2008-05-12 19:01:56 +00003562#line 1126 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003563 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3564 break;
3565
3566 case 42:
Nate Begemanac80ade2008-05-12 19:01:56 +00003567#line 1126 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003568 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3569 break;
3570
3571 case 43:
Nate Begemanac80ade2008-05-12 19:01:56 +00003572#line 1127 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003573 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3574 break;
3575
3576 case 44:
Nate Begemanac80ade2008-05-12 19:01:56 +00003577#line 1127 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003578 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3579 break;
3580
3581 case 45:
Nate Begemanac80ade2008-05-12 19:01:56 +00003582#line 1128 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003583 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3584 break;
3585
3586 case 46:
Nate Begemanac80ade2008-05-12 19:01:56 +00003587#line 1128 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003588 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3589 break;
3590
3591 case 47:
Nate Begemanac80ade2008-05-12 19:01:56 +00003592#line 1129 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003593 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3594 break;
3595
3596 case 48:
Nate Begemanac80ade2008-05-12 19:01:56 +00003597#line 1129 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003598 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3599 break;
3600
3601 case 49:
Nate Begemanac80ade2008-05-12 19:01:56 +00003602#line 1130 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003603 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3604 break;
3605
3606 case 50:
Nate Begemanac80ade2008-05-12 19:01:56 +00003607#line 1130 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003608 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3609 break;
3610
3611 case 51:
Nate Begemanac80ade2008-05-12 19:01:56 +00003612#line 1131 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003613 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3614 break;
3615
3616 case 52:
Nate Begemanac80ade2008-05-12 19:01:56 +00003617#line 1131 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003618 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3619 break;
3620
3621 case 53:
Nate Begemanac80ade2008-05-12 19:01:56 +00003622#line 1132 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003623 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3624 break;
3625
3626 case 54:
Nate Begemanac80ade2008-05-12 19:01:56 +00003627#line 1133 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003628 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3629 break;
3630
3631 case 65:
Nate Begemanac80ade2008-05-12 19:01:56 +00003632#line 1142 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003633 { (yyval.StrVal) = 0; ;}
3634 break;
3635
3636 case 66:
Nate Begemanac80ade2008-05-12 19:01:56 +00003637#line 1144 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003638 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3639 break;
3640
3641 case 67:
Nate Begemanac80ade2008-05-12 19:01:56 +00003642#line 1145 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003643 { (yyval.UIntVal)=0; ;}
3644 break;
3645
3646 case 68:
Nate Begemanac80ade2008-05-12 19:01:56 +00003647#line 1149 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003648 {
3649 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003650 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003651 ;}
3652 break;
3653
3654 case 69:
Nate Begemanac80ade2008-05-12 19:01:56 +00003655#line 1153 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003656 {
3657 (yyval.StrVal) = 0;
Christopher Lambbf3348d2007-12-12 08:45:45 +00003658 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003659 ;}
3660 break;
3661
3662 case 73:
Nate Begemanac80ade2008-05-12 19:01:56 +00003663#line 1161 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003664 {
3665 (yyval.StrVal) = 0;
Christopher Lambbf3348d2007-12-12 08:45:45 +00003666 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003667 ;}
3668 break;
3669
3670 case 74:
Nate Begemanac80ade2008-05-12 19:01:56 +00003671#line 1166 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003672 {
3673 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00003674 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003675 ;}
3676 break;
3677
3678 case 75:
Nate Begemanac80ade2008-05-12 19:01:56 +00003679#line 1172 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003680 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3681 break;
3682
3683 case 76:
Nate Begemanac80ade2008-05-12 19:01:56 +00003684#line 1173 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003685 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3686 break;
3687
3688 case 77:
Nate Begemanac80ade2008-05-12 19:01:56 +00003689#line 1174 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003690 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3691 break;
3692
3693 case 78:
Nate Begemanac80ade2008-05-12 19:01:56 +00003694#line 1175 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003695 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3696 break;
3697
3698 case 79:
Nate Begemanac80ade2008-05-12 19:01:56 +00003699#line 1176 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003700 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3701 break;
3702
3703 case 80:
Nate Begemanac80ade2008-05-12 19:01:56 +00003704#line 1180 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003705 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3706 break;
3707
3708 case 81:
Nate Begemanac80ade2008-05-12 19:01:56 +00003709#line 1181 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003710 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3711 break;
3712
3713 case 82:
Nate Begemanac80ade2008-05-12 19:01:56 +00003714#line 1182 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003715 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3716 break;
3717
3718 case 83:
Nate Begemanac80ade2008-05-12 19:01:56 +00003719#line 1186 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003720 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3721 break;
3722
3723 case 84:
Nate Begemanac80ade2008-05-12 19:01:56 +00003724#line 1187 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003725 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3726 break;
3727
3728 case 85:
Nate Begemanac80ade2008-05-12 19:01:56 +00003729#line 1188 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003730 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3731 break;
3732
3733 case 86:
Nate Begemanac80ade2008-05-12 19:01:56 +00003734#line 1189 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003735 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3736 break;
3737
3738 case 87:
Nate Begemanac80ade2008-05-12 19:01:56 +00003739#line 1193 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003740 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3741 break;
3742
3743 case 88:
Nate Begemanac80ade2008-05-12 19:01:56 +00003744#line 1194 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003745 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3746 break;
3747
3748 case 89:
Nate Begemanac80ade2008-05-12 19:01:56 +00003749#line 1195 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003750 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3751 break;
3752
3753 case 90:
Nate Begemanac80ade2008-05-12 19:01:56 +00003754#line 1199 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003755 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3756 break;
3757
3758 case 91:
Nate Begemanac80ade2008-05-12 19:01:56 +00003759#line 1200 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003760 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3761 break;
3762
3763 case 92:
Nate Begemanac80ade2008-05-12 19:01:56 +00003764#line 1201 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003765 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3766 break;
3767
3768 case 93:
Nate Begemanac80ade2008-05-12 19:01:56 +00003769#line 1202 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003770 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3771 break;
3772
3773 case 94:
Nate Begemanac80ade2008-05-12 19:01:56 +00003774#line 1203 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003775 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3776 break;
3777
3778 case 95:
Nate Begemanac80ade2008-05-12 19:01:56 +00003779#line 1207 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003780 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3781 break;
3782
3783 case 96:
Nate Begemanac80ade2008-05-12 19:01:56 +00003784#line 1208 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003785 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3786 break;
3787
3788 case 97:
Nate Begemanac80ade2008-05-12 19:01:56 +00003789#line 1209 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003790 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3791 break;
3792
3793 case 98:
Nate Begemanac80ade2008-05-12 19:01:56 +00003794#line 1212 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003795 { (yyval.UIntVal) = CallingConv::C; ;}
3796 break;
3797
3798 case 99:
Nate Begemanac80ade2008-05-12 19:01:56 +00003799#line 1213 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003800 { (yyval.UIntVal) = CallingConv::C; ;}
3801 break;
3802
3803 case 100:
Nate Begemanac80ade2008-05-12 19:01:56 +00003804#line 1214 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003805 { (yyval.UIntVal) = CallingConv::Fast; ;}
3806 break;
3807
3808 case 101:
Nate Begemanac80ade2008-05-12 19:01:56 +00003809#line 1215 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003810 { (yyval.UIntVal) = CallingConv::Cold; ;}
3811 break;
3812
3813 case 102:
Nate Begemanac80ade2008-05-12 19:01:56 +00003814#line 1216 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003815 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3816 break;
3817
3818 case 103:
Nate Begemanac80ade2008-05-12 19:01:56 +00003819#line 1217 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003820 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3821 break;
3822
3823 case 104:
Nate Begemanac80ade2008-05-12 19:01:56 +00003824#line 1218 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003825 {
3826 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003827 GEN_ERROR("Calling conv too large");
Dan Gohmanf4423b12008-04-19 00:24:39 +00003828 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003829 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003830 ;}
3831 break;
3832
3833 case 105:
Nate Begemanac80ade2008-05-12 19:01:56 +00003834#line 1225 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003835 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3836 break;
3837
3838 case 106:
Nate Begemanac80ade2008-05-12 19:01:56 +00003839#line 1226 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003840 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3841 break;
3842
3843 case 107:
Nate Begemanac80ade2008-05-12 19:01:56 +00003844#line 1227 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003845 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3846 break;
3847
3848 case 108:
Nate Begemanac80ade2008-05-12 19:01:56 +00003849#line 1228 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003850 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3851 break;
3852
3853 case 109:
Nate Begemanac80ade2008-05-12 19:01:56 +00003854#line 1229 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003855 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3856 break;
3857
3858 case 110:
Nate Begemanac80ade2008-05-12 19:01:56 +00003859#line 1230 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003860 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3861 break;
3862
3863 case 111:
Nate Begemanac80ade2008-05-12 19:01:56 +00003864#line 1231 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003865 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3866 break;
3867
3868 case 112:
Nate Begemanac80ade2008-05-12 19:01:56 +00003869#line 1232 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003870 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3871 break;
3872
3873 case 113:
Nate Begemanac80ade2008-05-12 19:01:56 +00003874#line 1233 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003875 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3876 break;
3877
3878 case 114:
Nate Begemanac80ade2008-05-12 19:01:56 +00003879#line 1234 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003880 { (yyval.ParamAttrs) =
3881 ParamAttr::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
3882 break;
3883
3884 case 115:
Nate Begemanac80ade2008-05-12 19:01:56 +00003885#line 1238 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003886 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3887 break;
3888
3889 case 116:
Nate Begemanac80ade2008-05-12 19:01:56 +00003890#line 1239 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003891 {
3892 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3893 ;}
3894 break;
3895
3896 case 117:
Nate Begemanac80ade2008-05-12 19:01:56 +00003897#line 1244 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003898 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3899 break;
3900
3901 case 118:
Nate Begemanac80ade2008-05-12 19:01:56 +00003902#line 1245 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003903 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3904 break;
3905
3906 case 119:
Nate Begemanac80ade2008-05-12 19:01:56 +00003907#line 1246 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003908 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3909 break;
3910
3911 case 120:
Nate Begemanac80ade2008-05-12 19:01:56 +00003912#line 1247 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003913 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3914 break;
3915
3916 case 121:
Nate Begemanac80ade2008-05-12 19:01:56 +00003917#line 1248 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003918 { (yyval.ParamAttrs) = ParamAttr::ReadNone; ;}
3919 break;
3920
3921 case 122:
Nate Begemanac80ade2008-05-12 19:01:56 +00003922#line 1249 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003923 { (yyval.ParamAttrs) = ParamAttr::ReadOnly; ;}
3924 break;
3925
3926 case 123:
Nate Begemanac80ade2008-05-12 19:01:56 +00003927#line 1252 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003928 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3929 break;
3930
3931 case 124:
Nate Begemanac80ade2008-05-12 19:01:56 +00003932#line 1253 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003933 {
3934 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3935 ;}
3936 break;
3937
3938 case 125:
Nate Begemanac80ade2008-05-12 19:01:56 +00003939#line 1258 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003940 { (yyval.StrVal) = 0; ;}
3941 break;
3942
3943 case 126:
Nate Begemanac80ade2008-05-12 19:01:56 +00003944#line 1259 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003945 {
3946 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
3947 ;}
3948 break;
3949
3950 case 127:
Nate Begemanac80ade2008-05-12 19:01:56 +00003951#line 1266 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003952 { (yyval.UIntVal) = 0; ;}
3953 break;
3954
3955 case 128:
Nate Begemanac80ade2008-05-12 19:01:56 +00003956#line 1267 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003957 {
3958 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3959 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003960 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003961 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003962;}
3963 break;
3964
3965 case 129:
Nate Begemanac80ade2008-05-12 19:01:56 +00003966#line 1273 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003967 { (yyval.UIntVal) = 0; ;}
3968 break;
3969
3970 case 130:
Nate Begemanac80ade2008-05-12 19:01:56 +00003971#line 1274 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003972 {
3973 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3974 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lambbf3348d2007-12-12 08:45:45 +00003975 GEN_ERROR("Alignment must be a power of two");
3976 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003977;}
3978 break;
3979
3980 case 131:
Nate Begemanac80ade2008-05-12 19:01:56 +00003981#line 1283 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003982 {
3983 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
3984 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003985 GEN_ERROR("Invalid character in section name");
Dan Gohmanf4423b12008-04-19 00:24:39 +00003986 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003987 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003988;}
3989 break;
3990
3991 case 132:
Nate Begemanac80ade2008-05-12 19:01:56 +00003992#line 1291 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003993 { (yyval.StrVal) = 0; ;}
3994 break;
3995
3996 case 133:
Nate Begemanac80ade2008-05-12 19:01:56 +00003997#line 1292 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003998 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3999 break;
4000
4001 case 134:
Nate Begemanac80ade2008-05-12 19:01:56 +00004002#line 1297 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004003 {;}
4004 break;
4005
4006 case 135:
Nate Begemanac80ade2008-05-12 19:01:56 +00004007#line 1298 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004008 {;}
4009 break;
4010
4011 case 136:
Nate Begemanac80ade2008-05-12 19:01:56 +00004012#line 1299 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004013 {
4014 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4015 delete (yyvsp[(1) - (1)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004016 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004017 ;}
4018 break;
4019
4020 case 137:
Nate Begemanac80ade2008-05-12 19:01:56 +00004021#line 1304 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004022 {
4023 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004024 GEN_ERROR("Alignment must be a power of two");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004025 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004026 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004027 ;}
4028 break;
4029
4030 case 145:
Nate Begemanac80ade2008-05-12 19:01:56 +00004031#line 1320 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004032 {
4033 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004034 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004035 ;}
4036 break;
4037
4038 case 146:
Nate Begemanac80ade2008-05-12 19:01:56 +00004039#line 1324 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004040 {
4041 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004042 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004043 ;}
4044 break;
4045
4046 case 147:
Nate Begemanac80ade2008-05-12 19:01:56 +00004047#line 1328 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004048 { // Pointer type?
4049 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lambbf3348d2007-12-12 08:45:45 +00004050 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004051 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4052 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00004053 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004054 ;}
4055 break;
4056
4057 case 148:
Nate Begemanac80ade2008-05-12 19:01:56 +00004058#line 1335 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004059 { // Named types are also simple types...
4060 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004061 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004062 (yyval.TypeVal) = new PATypeHolder(tmp);
4063 ;}
4064 break;
4065
4066 case 149:
Nate Begemanac80ade2008-05-12 19:01:56 +00004067#line 1340 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004068 { // Type UpReference
4069 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004070 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohmanf4423b12008-04-19 00:24:39 +00004071 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4072 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004073 UR_OUT("New Upreference!\n");
4074 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004075 ;}
4076 break;
4077
4078 case 150:
Nate Begemanac80ade2008-05-12 19:01:56 +00004079#line 1348 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004080 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004081 // Allow but ignore attributes on function types; this permits auto-upgrade.
4082 // FIXME: remove in LLVM 3.0.
Chris Lattnera925a142008-04-23 05:37:08 +00004083 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4084 if (!FunctionType::isValidReturnType(RetTy))
4085 GEN_ERROR("Invalid result type for LLVM function");
4086
Reid Spencer41dff5e2007-01-26 08:05:27 +00004087 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004088 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004089 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004090 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004091 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004092 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004093
Reid Spencer41dff5e2007-01-26 08:05:27 +00004094 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4095 if (isVarArg) Params.pop_back();
4096
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004097 for (unsigned i = 0; i != Params.size(); ++i)
4098 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4099 GEN_ERROR("Function arguments must be value types!");
4100
4101 CHECK_FOR_ERROR
4102
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004103 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004104 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4105 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
4106 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004107 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004108 ;}
4109 break;
4110
4111 case 151:
Nate Begemanac80ade2008-05-12 19:01:56 +00004112#line 1377 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004113 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004114 // Allow but ignore attributes on function types; this permits auto-upgrade.
4115 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004116 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004117 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004118 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004119 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004120 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004121 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004122
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004123 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4124 if (isVarArg) Params.pop_back();
4125
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004126 for (unsigned i = 0; i != Params.size(); ++i)
4127 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4128 GEN_ERROR("Function arguments must be value types!");
4129
4130 CHECK_FOR_ERROR
4131
Dan Gohmanf4423b12008-04-19 00:24:39 +00004132 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
4133 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4134 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004135 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004136 ;}
4137 break;
4138
4139 case 152:
Nate Begemanac80ade2008-05-12 19:01:56 +00004140#line 1402 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004141 { // Sized array type?
4142 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4143 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004144 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004145 ;}
4146 break;
4147
4148 case 153:
Nate Begemanac80ade2008-05-12 19:01:56 +00004149#line 1407 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004150 { // Vector type?
4151 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4152 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004153 GEN_ERROR("Unsigned result not equal to signed result");
4154 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4155 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004156 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4157 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004158 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004159 ;}
4160 break;
4161
4162 case 154:
Nate Begemanac80ade2008-05-12 19:01:56 +00004163#line 1417 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004164 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004165 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004166 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4167 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004168 Elements.push_back(*I);
4169
Dan Gohmanf4423b12008-04-19 00:24:39 +00004170 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4171 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004172 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004173 ;}
4174 break;
4175
4176 case 155:
Nate Begemanac80ade2008-05-12 19:01:56 +00004177#line 1427 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004178 { // Empty structure type?
4179 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004180 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004181 ;}
4182 break;
4183
4184 case 156:
Nate Begemanac80ade2008-05-12 19:01:56 +00004185#line 1431 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004186 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004187 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004188 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4189 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004190 Elements.push_back(*I);
4191
Dan Gohmanf4423b12008-04-19 00:24:39 +00004192 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4193 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004194 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004195 ;}
4196 break;
4197
4198 case 157:
Nate Begemanac80ade2008-05-12 19:01:56 +00004199#line 1441 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004200 { // Empty structure type?
4201 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004202 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004203 ;}
4204 break;
4205
4206 case 158:
Nate Begemanac80ade2008-05-12 19:01:56 +00004207#line 1448 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004208 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004209 // Allow but ignore attributes on function types; this permits auto-upgrade.
4210 // FIXME: remove in LLVM 3.0.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004211 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
4212 (yyval.TypeWithAttrs).Attrs = ParamAttr::None;
4213 ;}
4214 break;
4215
4216 case 159:
Nate Begemanac80ade2008-05-12 19:01:56 +00004217#line 1457 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004218 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004219 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004220 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4221 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004222 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004223 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4224 ;}
4225 break;
4226
4227 case 160:
Nate Begemanac80ade2008-05-12 19:01:56 +00004228#line 1464 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004229 {
4230 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4231 ;}
4232 break;
4233
4234 case 161:
Nate Begemanac80ade2008-05-12 19:01:56 +00004235#line 1469 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004236 {
4237 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4238 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004239 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004240 ;}
4241 break;
4242
4243 case 162:
Nate Begemanac80ade2008-05-12 19:01:56 +00004244#line 1474 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004245 {
4246 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004247 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004248 ;}
4249 break;
4250
4251 case 164:
Nate Begemanac80ade2008-05-12 19:01:56 +00004252#line 1482 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004253 {
4254 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00004255 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004256 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004257 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004258 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004259 ;}
4260 break;
4261
4262 case 165:
Nate Begemanac80ade2008-05-12 19:01:56 +00004263#line 1489 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004264 {
4265 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004266 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4267 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004268 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004269 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004270 ;}
4271 break;
4272
4273 case 166:
Nate Begemanac80ade2008-05-12 19:01:56 +00004274#line 1496 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004275 {
4276 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004277 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004278 ;}
4279 break;
4280
4281 case 167:
Nate Begemanac80ade2008-05-12 19:01:56 +00004282#line 1504 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004283 {
4284 (yyval.TypeList) = new std::list<PATypeHolder>();
4285 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4286 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004287 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004288 ;}
4289 break;
4290
4291 case 168:
Nate Begemanac80ade2008-05-12 19:01:56 +00004292#line 1510 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004293 {
4294 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4295 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004296 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004297 ;}
4298 break;
4299
4300 case 169:
Nate Begemanac80ade2008-05-12 19:01:56 +00004301#line 1522 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004302 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004303 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004304 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4305 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004306 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004307 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004308 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004309 const Type *ETy = ATy->getElementType();
4310 int NumElements = ATy->getNumElements();
4311
4312 // Verify that we have the correct size...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004313 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004314 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004315 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004316 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004317
4318 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004319 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4320 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004321 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4322 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004323 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004324 }
4325
Dan Gohmanf4423b12008-04-19 00:24:39 +00004326 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4327 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004328 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004329 ;}
4330 break;
4331
4332 case 170:
Nate Begemanac80ade2008-05-12 19:01:56 +00004333#line 1550 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004334 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004335 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004336 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4337 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004338 if (ATy == 0)
4339 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004340 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004341
Andrew Lenharth6353e052006-12-08 18:07:09 +00004342 int NumElements = ATy->getNumElements();
4343 if (NumElements != -1 && NumElements != 0)
4344 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00004345 " arguments, but has size of " + itostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004346 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4347 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004348 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004349 ;}
4350 break;
4351
4352 case 171:
Nate Begemanac80ade2008-05-12 19:01:56 +00004353#line 1566 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004354 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004355 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004356 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4357 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004358 if (ATy == 0)
4359 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004360 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004361
4362 int NumElements = ATy->getNumElements();
4363 const Type *ETy = ATy->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00004364 if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004365 GEN_ERROR("Can't build string constant of size " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004366 itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004367 " when array has size " + itostr(NumElements) + "");
4368 std::vector<Constant*> Vals;
4369 if (ETy == Type::Int8Ty) {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004370 for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
4371 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004372 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004373 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004374 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4375 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004376 delete (yyvsp[(3) - (3)].StrVal);
4377 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4378 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004379 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004380 ;}
4381 break;
4382
4383 case 172:
Nate Begemanac80ade2008-05-12 19:01:56 +00004384#line 1593 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004385 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004386 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004387 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4388 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004389 if (PTy == 0)
4390 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004391 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004392 const Type *ETy = PTy->getElementType();
4393 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004394
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004395 // Verify that we have the correct size...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004396 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004397 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004398 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004399 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004400
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004401 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004402 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4403 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004404 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4405 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004406 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004407 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004408
Dan Gohmanf4423b12008-04-19 00:24:39 +00004409 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4410 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004411 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004412 ;}
4413 break;
4414
4415 case 173:
Nate Begemanac80ade2008-05-12 19:01:56 +00004416#line 1621 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004417 {
4418 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004419 if (STy == 0)
4420 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004421 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004422
Dan Gohmanf4423b12008-04-19 00:24:39 +00004423 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004424 GEN_ERROR("Illegal number of initializers for structure type");
4425
4426 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004427 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4428 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004429 GEN_ERROR("Expected type '" +
4430 STy->getElementType(i)->getDescription() +
4431 "' for element #" + utostr(i) +
4432 " of structure initializer");
4433
4434 // Check to ensure that Type is not packed
4435 if (STy->isPacked())
4436 GEN_ERROR("Unpacked Initializer to vector type '" +
4437 STy->getDescription() + "'");
4438
Dan Gohmanf4423b12008-04-19 00:24:39 +00004439 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4440 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004441 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004442 ;}
4443 break;
4444
4445 case 174:
Nate Begemanac80ade2008-05-12 19:01:56 +00004446#line 1647 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004447 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004448 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004449 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4450 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004451 if (STy == 0)
4452 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004453 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004454
4455 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004456 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004457
4458 // Check to ensure that Type is not packed
4459 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004460 GEN_ERROR("Unpacked Initializer to vector type '" +
4461 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004462
Dan Gohmanf4423b12008-04-19 00:24:39 +00004463 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4464 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004465 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004466 ;}
4467 break;
4468
4469 case 175:
Nate Begemanac80ade2008-05-12 19:01:56 +00004470#line 1667 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004471 {
4472 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004473 if (STy == 0)
4474 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004475 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004476
Dan Gohmanf4423b12008-04-19 00:24:39 +00004477 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004478 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004479
4480 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004481 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4482 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004483 GEN_ERROR("Expected type '" +
4484 STy->getElementType(i)->getDescription() +
4485 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004486 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004487
4488 // Check to ensure that Type is packed
4489 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004490 GEN_ERROR("Vector initializer to non-vector type '" +
4491 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004492
Dan Gohmanf4423b12008-04-19 00:24:39 +00004493 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4494 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004495 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004496 ;}
4497 break;
4498
4499 case 176:
Nate Begemanac80ade2008-05-12 19:01:56 +00004500#line 1693 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004501 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004502 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004503 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4504 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004505 if (STy == 0)
4506 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004507 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004508
4509 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004510 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004511
4512 // Check to ensure that Type is packed
4513 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004514 GEN_ERROR("Vector initializer to non-vector type '" +
4515 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004516
Dan Gohmanf4423b12008-04-19 00:24:39 +00004517 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4518 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004519 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004520 ;}
4521 break;
4522
4523 case 177:
Nate Begemanac80ade2008-05-12 19:01:56 +00004524#line 1713 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004525 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004526 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004527 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4528 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004529 if (PTy == 0)
4530 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004531 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004532
Dan Gohmanf4423b12008-04-19 00:24:39 +00004533 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4534 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004535 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004536 ;}
4537 break;
4538
4539 case 178:
Nate Begemanac80ade2008-05-12 19:01:56 +00004540#line 1725 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004541 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004542 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004543 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4544 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4545 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004546 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004547 ;}
4548 break;
4549
4550 case 179:
Nate Begemanac80ade2008-05-12 19:01:56 +00004551#line 1732 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004552 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004553 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004554 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4555 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004556 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004557 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004558
4559 // ConstExprs can exist in the body of a function, thus creating
4560 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004561 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004562 // symbol table instead of the module symbol table for the global symbol,
4563 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004564 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004565 //
4566 Function *SavedCurFn = CurFun.CurrentFunction;
4567 CurFun.CurrentFunction = 0;
4568
Dan Gohmanf4423b12008-04-19 00:24:39 +00004569 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004570 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004571
4572 CurFun.CurrentFunction = SavedCurFn;
4573
4574 // If this is an initializer for a constant pointer, which is referencing a
4575 // (currently) undefined variable, create a stub now that shall be replaced
4576 // in the future with the right type of variable.
4577 //
4578 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004579 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004580 const PointerType *PT = cast<PointerType>(Ty);
4581
4582 // First check to see if the forward references value is already created!
4583 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004584 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004585
4586 if (I != CurModule.GlobalRefs.end()) {
4587 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004588 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004589 } else {
4590 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004591 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4592 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4593 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004594 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004595
4596 // Create the forward referenced global.
4597 GlobalValue *GV;
4598 if (const FunctionType *FTy =
4599 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004600 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4601 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004602 } else {
4603 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004604 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004605 Name, CurModule.CurrentModule);
4606 }
4607
4608 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004609 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004610 V = GV;
4611 }
4612 }
4613
Dan Gohmanf4423b12008-04-19 00:24:39 +00004614 (yyval.ConstVal) = cast<GlobalValue>(V);
4615 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004616 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004617 ;}
4618 break;
4619
4620 case 180:
Nate Begemanac80ade2008-05-12 19:01:56 +00004621#line 1798 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004622 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004623 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004624 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4625 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004626 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004627 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4628 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4629 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004630 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004631 ;}
4632 break;
4633
4634 case 181:
Nate Begemanac80ade2008-05-12 19:01:56 +00004635#line 1808 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004636 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004637 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004638 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4639 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004640 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4641 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004642 (yyval.ConstVal) = Constant::getNullValue(Ty);
4643 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004644 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004645 ;}
4646 break;
4647
4648 case 182:
Nate Begemanac80ade2008-05-12 19:01:56 +00004649#line 1818 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004650 { // integral constants
4651 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004652 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004653 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004654 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004655 ;}
4656 break;
4657
4658 case 183:
Nate Begemanac80ade2008-05-12 19:01:56 +00004659#line 1824 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004660 { // arbitrary precision integer constants
4661 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4662 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004663 GEN_ERROR("Constant value does not fit in type");
4664 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004665 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4666 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4667 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004668 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004669 ;}
4670 break;
4671
4672 case 184:
Nate Begemanac80ade2008-05-12 19:01:56 +00004673#line 1834 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004674 { // integral constants
4675 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004676 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004677 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004678 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004679 ;}
4680 break;
4681
4682 case 185:
Nate Begemanac80ade2008-05-12 19:01:56 +00004683#line 1840 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004684 { // arbitrary precision integer constants
4685 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4686 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004687 GEN_ERROR("Constant value does not fit in type");
4688 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004689 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4690 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4691 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004692 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004693 ;}
4694 break;
4695
4696 case 186:
Nate Begemanac80ade2008-05-12 19:01:56 +00004697#line 1850 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004698 { // Boolean constants
4699 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4700 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004701 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004702 ;}
4703 break;
4704
4705 case 187:
Nate Begemanac80ade2008-05-12 19:01:56 +00004706#line 1855 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004707 { // Boolean constants
4708 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4709 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004710 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004711 ;}
4712 break;
4713
4714 case 188:
Nate Begemanac80ade2008-05-12 19:01:56 +00004715#line 1860 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004716 { // Floating point constants
4717 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004718 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004719 // Lexer has no type info, so builds all float and double FP constants
4720 // as double. Fix this here. Long double is done right.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004721 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4722 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004723 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004724 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004725 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004726 ;}
4727 break;
4728
4729 case 189:
Nate Begemanac80ade2008-05-12 19:01:56 +00004730#line 1873 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004731 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004732 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004733 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4734 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4735 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4736 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004737 GEN_ERROR("invalid cast opcode for cast from '" +
4738 Val->getType()->getDescription() + "' to '" +
4739 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004740 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4741 delete (yyvsp[(5) - (6)].TypeVal);
4742 ;}
4743 break;
4744
4745 case 190:
Nate Begemanac80ade2008-05-12 19:01:56 +00004746#line 1885 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004747 {
4748 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004749 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004750
4751 const Type *IdxTy =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004752 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004753 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004754 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004755 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004756
Chris Lattnerf7469af2007-01-31 04:44:08 +00004757 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004758 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4759 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004760 IdxVec.push_back(C);
4761 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004762 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004763
Dan Gohmanf4423b12008-04-19 00:24:39 +00004764 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004765
Dan Gohmanf4423b12008-04-19 00:24:39 +00004766 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004767 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004768 ;}
4769 break;
4770
4771 case 191:
Nate Begemanac80ade2008-05-12 19:01:56 +00004772#line 1907 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004773 {
4774 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004775 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004776 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004777 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004778 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004779 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004780 ;}
4781 break;
4782
4783 case 192:
Nate Begemanac80ade2008-05-12 19:01:56 +00004784#line 1915 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004785 {
4786 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004787 GEN_ERROR("Binary operator types must match");
4788 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004789 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4790 ;}
4791 break;
4792
4793 case 193:
Nate Begemanac80ade2008-05-12 19:01:56 +00004794#line 1921 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004795 {
4796 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004797 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004798 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4799 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4800 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004801 GEN_ERROR("Logical operator requires integral operands");
4802 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004803 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004804 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004805 ;}
4806 break;
4807
4808 case 194:
Nate Begemanac80ade2008-05-12 19:01:56 +00004809#line 1932 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004810 {
4811 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004812 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004813 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4814 ;}
4815 break;
4816
4817 case 195:
Nate Begemanac80ade2008-05-12 19:01:56 +00004818#line 1937 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004819 {
4820 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004821 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004822 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4823 ;}
4824 break;
4825
4826 case 196:
Nate Begemanac80ade2008-05-12 19:01:56 +00004827#line 1942 "/llvm/lib/AsmParser/llvmAsmParser.y"
4828 {
4829 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
4830 GEN_ERROR("vicmp operand types must match");
4831 (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4832 ;}
4833 break;
4834
4835 case 197:
4836#line 1947 "/llvm/lib/AsmParser/llvmAsmParser.y"
4837 {
4838 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
4839 GEN_ERROR("vfcmp operand types must match");
4840 (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4841 ;}
4842 break;
4843
4844 case 198:
4845#line 1952 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004846 {
4847 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004848 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004849 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004850 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004851 ;}
4852 break;
4853
Nate Begemanac80ade2008-05-12 19:01:56 +00004854 case 199:
4855#line 1958 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004856 {
4857 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004858 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004859 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004860 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004861 ;}
4862 break;
4863
Nate Begemanac80ade2008-05-12 19:01:56 +00004864 case 200:
4865#line 1964 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004866 {
4867 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004868 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004869 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004870 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004871 ;}
4872 break;
4873
Nate Begemanac80ade2008-05-12 19:01:56 +00004874 case 201:
4875#line 1973 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004876 {
4877 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004878 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004879 ;}
4880 break;
4881
Nate Begemanac80ade2008-05-12 19:01:56 +00004882 case 202:
4883#line 1977 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004884 {
4885 (yyval.ConstVector) = new std::vector<Constant*>();
4886 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004887 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004888 ;}
4889 break;
4890
Dan Gohmanf4423b12008-04-19 00:24:39 +00004891 case 203:
Nate Begemanac80ade2008-05-12 19:01:56 +00004892#line 1985 "/llvm/lib/AsmParser/llvmAsmParser.y"
4893 { (yyval.BoolVal) = false; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004894 break;
4895
4896 case 204:
Nate Begemanac80ade2008-05-12 19:01:56 +00004897#line 1985 "/llvm/lib/AsmParser/llvmAsmParser.y"
4898 { (yyval.BoolVal) = true; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004899 break;
4900
4901 case 205:
Nate Begemanac80ade2008-05-12 19:01:56 +00004902#line 1988 "/llvm/lib/AsmParser/llvmAsmParser.y"
4903 { (yyval.BoolVal) = true; ;}
4904 break;
4905
4906 case 206:
4907#line 1988 "/llvm/lib/AsmParser/llvmAsmParser.y"
4908 { (yyval.BoolVal) = false; ;}
4909 break;
4910
4911 case 207:
4912#line 1991 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004913 {
4914 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4915 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00004916 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004917 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4918 if (!Aliasee)
4919 GEN_ERROR("Aliases can be created only to global values");
4920
Dan Gohmanf4423b12008-04-19 00:24:39 +00004921 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004922 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004923 delete (yyvsp[(1) - (2)].TypeVal);
4924 ;}
4925 break;
4926
Nate Begemanac80ade2008-05-12 19:01:56 +00004927 case 208:
4928#line 2003 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004929 {
4930 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4931 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4932 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004933 GEN_ERROR("invalid cast opcode for cast from '" +
4934 Val->getType()->getDescription() + "' to '" +
4935 DestTy->getDescription() + "'");
4936
Dan Gohmanf4423b12008-04-19 00:24:39 +00004937 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004938 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004939 delete (yyvsp[(5) - (6)].TypeVal);
4940 ;}
4941 break;
4942
Nate Begemanac80ade2008-05-12 19:01:56 +00004943 case 209:
4944#line 2024 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004945 {
4946 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Christopher Lambbf3348d2007-12-12 08:45:45 +00004947 CurModule.ModuleDone();
4948 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004949 ;}
4950 break;
4951
Nate Begemanac80ade2008-05-12 19:01:56 +00004952 case 210:
4953#line 2029 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004954 {
4955 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Dale Johannesen172f3112008-02-20 21:15:43 +00004956 CurModule.ModuleDone();
4957 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004958 ;}
4959 break;
4960
Nate Begemanac80ade2008-05-12 19:01:56 +00004961 case 213:
4962#line 2042 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004963 { CurFun.isDeclare = false; ;}
4964 break;
4965
Nate Begemanac80ade2008-05-12 19:01:56 +00004966 case 214:
4967#line 2042 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004968 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004969 CurFun.FunctionDone();
4970 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004971 ;}
4972 break;
4973
Nate Begemanac80ade2008-05-12 19:01:56 +00004974 case 215:
4975#line 2046 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004976 { CurFun.isDeclare = true; ;}
4977 break;
4978
Dan Gohmanf4423b12008-04-19 00:24:39 +00004979 case 216:
Nate Begemanac80ade2008-05-12 19:01:56 +00004980#line 2046 "/llvm/lib/AsmParser/llvmAsmParser.y"
4981 {
4982 CHECK_FOR_ERROR
4983 ;}
4984 break;
4985
4986 case 217:
4987#line 2049 "/llvm/lib/AsmParser/llvmAsmParser.y"
4988 {
4989 CHECK_FOR_ERROR
4990 ;}
4991 break;
4992
4993 case 218:
4994#line 2052 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004995 {
Reid Spencer14310612006-12-31 05:40:51 +00004996 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004997 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004998 // Eagerly resolve types. This is not an optimization, this is a
4999 // requirement that is due to the fact that we could have this:
5000 //
5001 // %list = type { %list * }
5002 // %list = type { %list * } ; repeated type decl
5003 //
5004 // If types are not resolved eagerly, then the two types will not be
5005 // determined to be the same type!
5006 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00005007 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005008
Dan Gohmanf4423b12008-04-19 00:24:39 +00005009 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00005010 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005011 // If this is a named type that is not a redefinition, add it to the slot
5012 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005013 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005014 }
Reid Spencera132e042006-12-03 05:46:11 +00005015
Dan Gohmanf4423b12008-04-19 00:24:39 +00005016 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005017 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005018 ;}
5019 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00005020
Nate Begemanac80ade2008-05-12 19:01:56 +00005021 case 219:
5022#line 2076 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005023 {
5024 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
5025
5026 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005027 CHECK_FOR_ERROR
5028 // If this is a named type that is not a redefinition, add it to the slot
5029 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005030 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005031 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005032 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005033 ;}
5034 break;
5035
Nate Begemanac80ade2008-05-12 19:01:56 +00005036 case 220:
5037#line 2088 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005038 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005039 /* "Externally Visible" Linkage */
Dan Gohmanf4423b12008-04-19 00:24:39 +00005040 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005041 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005042 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5043 (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));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005044 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005045 ;}
5046 break;
5047
Nate Begemanac80ade2008-05-12 19:01:56 +00005048 case 221:
5049#line 2095 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005050 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005051 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005052 ;}
5053 break;
5054
Nate Begemanac80ade2008-05-12 19:01:56 +00005055 case 222:
5056#line 2099 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005057 {
5058 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005059 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005060 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 Lambbf3348d2007-12-12 08:45:45 +00005061 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005062 ;}
5063 break;
5064
Nate Begemanac80ade2008-05-12 19:01:56 +00005065 case 223:
5066#line 2104 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005067 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005068 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005069 ;}
5070 break;
5071
Nate Begemanac80ade2008-05-12 19:01:56 +00005072 case 224:
5073#line 2108 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005074 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005075 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005076 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5077 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 Lambbf3348d2007-12-12 08:45:45 +00005078 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005079 delete (yyvsp[(6) - (7)].TypeVal);
5080 ;}
5081 break;
5082
Nate Begemanac80ade2008-05-12 19:01:56 +00005083 case 225:
5084#line 2114 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005085 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005086 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005087 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005088 ;}
5089 break;
5090
Nate Begemanac80ade2008-05-12 19:01:56 +00005091 case 226:
5092#line 2118 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005093 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005094 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005095 if ((yyvsp[(1) - (5)].StrVal)) {
5096 Name = *(yyvsp[(1) - (5)].StrVal);
5097 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005098 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005099 if (Name.empty())
5100 GEN_ERROR("Alias name cannot be empty");
5101
Dan Gohmanf4423b12008-04-19 00:24:39 +00005102 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005103 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005104 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005105
Dan Gohmanf4423b12008-04-19 00:24:39 +00005106 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005107 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005108 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005109 InsertValue(GA, CurModule.Values);
Chris Lattner569f7372007-09-10 23:24:14 +00005110
5111
5112 // If there was a forward reference of this alias, resolve it now.
5113
5114 ValID ID;
5115 if (!Name.empty())
5116 ID = ValID::createGlobalName(Name);
5117 else
5118 ID = ValID::createGlobalID(CurModule.Values.size()-1);
5119
5120 if (GlobalValue *FWGV =
5121 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5122 // Replace uses of the fwdref with the actual alias.
5123 FWGV->replaceAllUsesWith(GA);
5124 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5125 GV->eraseFromParent();
5126 else
5127 cast<Function>(FWGV)->eraseFromParent();
5128 }
5129 ID.destroy();
5130
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005131 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005132 ;}
5133 break;
5134
Nate Begemanac80ade2008-05-12 19:01:56 +00005135 case 227:
5136#line 2158 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005137 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005138 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005139 ;}
5140 break;
5141
Nate Begemanac80ade2008-05-12 19:01:56 +00005142 case 228:
5143#line 2161 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005144 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005145 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005146 ;}
5147 break;
5148
Nate Begemanac80ade2008-05-12 19:01:56 +00005149 case 229:
5150#line 2167 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005151 {
Chris Lattner66316012006-01-24 04:14:29 +00005152 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005153 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005154 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005155 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005156 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5157 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005158 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005159;}
5160 break;
5161
Nate Begemanac80ade2008-05-12 19:01:56 +00005162 case 230:
5163#line 2177 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005164 {
5165 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5166 delete (yyvsp[(3) - (3)].StrVal);
5167 ;}
5168 break;
5169
Nate Begemanac80ade2008-05-12 19:01:56 +00005170 case 231:
5171#line 2181 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005172 {
5173 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5174 delete (yyvsp[(3) - (3)].StrVal);
5175 ;}
5176 break;
5177
Nate Begemanac80ade2008-05-12 19:01:56 +00005178 case 233:
5179#line 2188 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005180 {
5181 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5182 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005183 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005184 ;}
5185 break;
5186
Nate Begemanac80ade2008-05-12 19:01:56 +00005187 case 234:
5188#line 2193 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005189 {
5190 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5191 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005192 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005193 ;}
5194 break;
5195
Nate Begemanac80ade2008-05-12 19:01:56 +00005196 case 235:
5197#line 2198 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005198 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005199 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005200 ;}
5201 break;
5202
Nate Begemanac80ade2008-05-12 19:01:56 +00005203 case 236:
5204#line 2207 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005205 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005206 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005207 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5208 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005209 GEN_ERROR("void typed arguments are invalid");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005210 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5211 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5212 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005213 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005214 ;}
5215 break;
5216
Nate Begemanac80ade2008-05-12 19:01:56 +00005217 case 237:
5218#line 2217 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005219 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005220 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005221 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5222 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005223 GEN_ERROR("void typed arguments are invalid");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005224 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5225 (yyval.ArgList) = new ArgListType;
5226 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005227 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005228 ;}
5229 break;
5230
Nate Begemanac80ade2008-05-12 19:01:56 +00005231 case 238:
5232#line 2228 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005233 {
5234 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005235 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005236 ;}
5237 break;
5238
Nate Begemanac80ade2008-05-12 19:01:56 +00005239 case 239:
5240#line 2232 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005241 {
5242 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005243 struct ArgListEntry E;
5244 E.Ty = new PATypeHolder(Type::VoidTy);
5245 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00005246 E.Attrs = ParamAttr::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005247 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005248 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005249 ;}
5250 break;
5251
Nate Begemanac80ade2008-05-12 19:01:56 +00005252 case 240:
5253#line 2241 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005254 {
5255 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005256 struct ArgListEntry E;
5257 E.Ty = new PATypeHolder(Type::VoidTy);
5258 E.Name = 0;
5259 E.Attrs = ParamAttr::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005260 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005261 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005262 ;}
5263 break;
5264
Nate Begemanac80ade2008-05-12 19:01:56 +00005265 case 241:
5266#line 2250 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005267 {
5268 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005269 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005270 ;}
5271 break;
5272
Nate Begemanac80ade2008-05-12 19:01:56 +00005273 case 242:
5274#line 2256 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005275 {
5276 std::string FunctionName(*(yyvsp[(3) - (10)].StrVal));
5277 delete (yyvsp[(3) - (10)].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005278
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005279 // Check the function result for abstractness if this is a define. We should
5280 // have no abstract types at this point
Dan Gohmanf4423b12008-04-19 00:24:39 +00005281 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (10)].TypeVal)))
5282 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (10)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005283
Chris Lattnera925a142008-04-23 05:37:08 +00005284 if (!FunctionType::isValidReturnType(*(yyvsp[(2) - (10)].TypeVal)))
5285 GEN_ERROR("Invalid result type for LLVM function");
5286
Reid Spencer68a24bd2005-08-27 18:50:39 +00005287 std::vector<const Type*> ParamTypeList;
Chris Lattner58d74912008-03-12 17:45:29 +00005288 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005289 if ((yyvsp[(7) - (10)].ParamAttrs) != ParamAttr::None)
5290 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(7) - (10)].ParamAttrs)));
5291 if ((yyvsp[(5) - (10)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005292 unsigned index = 1;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005293 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin(); I != (yyvsp[(5) - (10)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005294 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005295 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5296 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005297 ParamTypeList.push_back(Ty);
Chris Lattner58d74912008-03-12 17:45:29 +00005298 if (Ty != Type::VoidTy && I->Attrs != ParamAttr::None)
5299 Attrs.push_back(ParamAttrsWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005300 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005301 }
5302
5303 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5304 if (isVarArg) ParamTypeList.pop_back();
5305
Chris Lattner58d74912008-03-12 17:45:29 +00005306 PAListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005307 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00005308 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005309
Dan Gohmanf4423b12008-04-19 00:24:39 +00005310 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (10)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005311 const PointerType *PFT = PointerType::getUnqual(FT);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005312 delete (yyvsp[(2) - (10)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005313
5314 ValID ID;
5315 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005316 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005317 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005318 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005319 }
5320
5321 Function *Fn = 0;
5322 // See if this function was forward referenced. If so, recycle the object.
5323 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5324 // Move the function to the end of the list, from whereever it was
5325 // previously inserted.
5326 Fn = cast<Function>(FWRef);
Chris Lattner58d74912008-03-12 17:45:29 +00005327 assert(Fn->getParamAttrs().isEmpty() &&
5328 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005329 CurModule.CurrentModule->getFunctionList().remove(Fn);
5330 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5331 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005332 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005333 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005334 // The existing function doesn't have the same type. This is an overload
5335 // error.
5336 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsdc024672007-11-27 13:23:08 +00005337 } else if (Fn->getParamAttrs() != PAL) {
5338 // The existing function doesn't have the same parameter attributes.
5339 // This is an overload error.
5340 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005341 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005342 // Neither the existing or the current function is a declaration and they
5343 // have the same name and same type. Clearly this is a redefinition.
5344 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005345 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005346 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005347 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5348 AI != AE; ++AI)
5349 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005350 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005351 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005352 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5353 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005354 InsertValue(Fn, CurModule.Values);
5355 }
5356
5357 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005358
5359 if (CurFun.isDeclare) {
5360 // If we have declaration, always overwrite linkage. This will allow us to
5361 // correctly handle cases, when pointer to function is passed as argument to
5362 // another function.
5363 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005364 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005365 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005366 Fn->setCallingConv((yyvsp[(1) - (10)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00005367 Fn->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005368 Fn->setAlignment((yyvsp[(9) - (10)].UIntVal));
5369 if ((yyvsp[(8) - (10)].StrVal)) {
5370 Fn->setSection(*(yyvsp[(8) - (10)].StrVal));
5371 delete (yyvsp[(8) - (10)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005372 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005373 if ((yyvsp[(10) - (10)].StrVal)) {
5374 Fn->setCollector((yyvsp[(10) - (10)].StrVal)->c_str());
5375 delete (yyvsp[(10) - (10)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005376 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005377
5378 // Add all of the arguments we parsed to the function...
Dan Gohmanf4423b12008-04-19 00:24:39 +00005379 if ((yyvsp[(5) - (10)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005380 if (isVarArg) { // Nuke the last entry
Dan Gohmanf4423b12008-04-19 00:24:39 +00005381 assert((yyvsp[(5) - (10)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (10)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005382 "Not a varargs marker!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005383 delete (yyvsp[(5) - (10)].ArgList)->back().Ty;
5384 (yyvsp[(5) - (10)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005385 }
5386 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005387 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005388 unsigned Idx = 1;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005389 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin();
5390 I != (yyvsp[(5) - (10)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005391 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005392 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005393 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005394 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005395 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005396 }
Reid Spencera132e042006-12-03 05:46:11 +00005397
Dan Gohmanf4423b12008-04-19 00:24:39 +00005398 delete (yyvsp[(5) - (10)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005399 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005400 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005401;}
5402 break;
5403
Nate Begemanac80ade2008-05-12 19:01:56 +00005404 case 245:
5405#line 2386 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005406 {
5407 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005408
5409 // Make sure that we keep track of the linkage type even if there was a
5410 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005411 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5412 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5413;}
5414 break;
5415
Nate Begemanac80ade2008-05-12 19:01:56 +00005416 case 248:
5417#line 2397 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005418 {
5419 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005420 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005421;}
5422 break;
5423
Nate Begemanac80ade2008-05-12 19:01:56 +00005424 case 249:
5425#line 2402 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005426 {
5427 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5428 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5429 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005430 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005431 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005432 ;}
5433 break;
5434
Nate Begemanac80ade2008-05-12 19:01:56 +00005435 case 250:
5436#line 2414 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005437 {
5438 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005439 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005440 ;}
5441 break;
5442
Nate Begemanac80ade2008-05-12 19:01:56 +00005443 case 251:
5444#line 2418 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005445 {
5446 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005447 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005448 ;}
5449 break;
5450
Nate Begemanac80ade2008-05-12 19:01:56 +00005451 case 252:
5452#line 2423 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005453 { // A reference to a direct constant
5454 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005455 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005456 ;}
5457 break;
5458
Nate Begemanac80ade2008-05-12 19:01:56 +00005459 case 253:
5460#line 2427 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005461 {
5462 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005463 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005464 ;}
5465 break;
5466
Nate Begemanac80ade2008-05-12 19:01:56 +00005467 case 254:
5468#line 2431 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005469 { // Perhaps it's an FP constant?
5470 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005471 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005472 ;}
5473 break;
5474
Nate Begemanac80ade2008-05-12 19:01:56 +00005475 case 255:
5476#line 2435 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005477 {
5478 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005479 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005480 ;}
5481 break;
5482
Nate Begemanac80ade2008-05-12 19:01:56 +00005483 case 256:
5484#line 2439 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005485 {
5486 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005487 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005488 ;}
5489 break;
5490
Nate Begemanac80ade2008-05-12 19:01:56 +00005491 case 257:
5492#line 2443 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005493 {
5494 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005495 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005496 ;}
5497 break;
5498
Nate Begemanac80ade2008-05-12 19:01:56 +00005499 case 258:
5500#line 2447 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005501 {
5502 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005503 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005504 ;}
5505 break;
5506
Nate Begemanac80ade2008-05-12 19:01:56 +00005507 case 259:
5508#line 2451 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005509 { // A vector zero constant.
5510 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005511 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005512 ;}
5513 break;
5514
Nate Begemanac80ade2008-05-12 19:01:56 +00005515 case 260:
5516#line 2455 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005517 { // Nonempty unsized packed vector
5518 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5519 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005520
Reid Spencer9d6565a2007-02-15 02:26:10 +00005521 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005522 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005523 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005524 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005525 ETy,
5526 NumElements)
5527 )
5528 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005529
5530 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005531 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5532 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005533 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005534 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005535 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005536 }
5537
Dan Gohmanf4423b12008-04-19 00:24:39 +00005538 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5539 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005540 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005541 ;}
5542 break;
5543
Nate Begemanac80ade2008-05-12 19:01:56 +00005544 case 261:
5545#line 2480 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005546 {
5547 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005548 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005549 ;}
5550 break;
5551
Nate Begemanac80ade2008-05-12 19:01:56 +00005552 case 262:
5553#line 2484 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005554 {
5555 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5556 delete (yyvsp[(3) - (5)].StrVal);
5557 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005558 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005559 ;}
5560 break;
5561
Nate Begemanac80ade2008-05-12 19:01:56 +00005562 case 263:
5563#line 2494 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005564 { // Is it an integer reference...?
5565 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005566 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005567 ;}
5568 break;
5569
Nate Begemanac80ade2008-05-12 19:01:56 +00005570 case 264:
5571#line 2498 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005572 {
5573 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005574 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005575 ;}
5576 break;
5577
Nate Begemanac80ade2008-05-12 19:01:56 +00005578 case 265:
5579#line 2502 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005580 { // Is it a named reference...?
5581 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5582 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005583 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005584 ;}
5585 break;
5586
Nate Begemanac80ade2008-05-12 19:01:56 +00005587 case 266:
5588#line 2507 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005589 { // Is it a named reference...?
5590 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5591 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005592 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005593 ;}
5594 break;
5595
Nate Begemanac80ade2008-05-12 19:01:56 +00005596 case 269:
5597#line 2520 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005598 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005599 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005600 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5601 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5602 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005603 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005604 ;}
5605 break;
5606
Nate Begemanac80ade2008-05-12 19:01:56 +00005607 case 270:
5608#line 2529 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005609 {
5610 (yyval.ValueList) = new std::vector<Value *>();
5611 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005612 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005613 ;}
5614 break;
5615
Nate Begemanac80ade2008-05-12 19:01:56 +00005616 case 271:
5617#line 2534 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005618 {
5619 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005620 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005621 ;}
5622 break;
5623
Nate Begemanac80ade2008-05-12 19:01:56 +00005624 case 272:
5625#line 2539 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005626 {
5627 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005628 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005629 ;}
5630 break;
5631
Nate Begemanac80ade2008-05-12 19:01:56 +00005632 case 273:
5633#line 2543 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005634 { // Do not allow functions with 0 basic blocks
5635 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005636 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005637 ;}
5638 break;
5639
Nate Begemanac80ade2008-05-12 19:01:56 +00005640 case 274:
5641#line 2552 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005642 {
5643 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005644 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005645 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5646 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5647 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005648 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005649 ;}
5650 break;
5651
Nate Begemanac80ade2008-05-12 19:01:56 +00005652 case 275:
5653#line 2561 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005654 {
5655 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005656 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5657 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00005658 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5659 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5660 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005661 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005662 ;}
5663 break;
Chris Lattner38905612008-02-19 04:36:25 +00005664
Nate Begemanac80ade2008-05-12 19:01:56 +00005665 case 276:
5666#line 2570 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005667 { // Empty space between instruction lists
Chris Lattnercc81d152008-05-04 17:18:47 +00005668 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf4423b12008-04-19 00:24:39 +00005669 CHECK_FOR_ERROR
5670 ;}
5671 break;
5672
Nate Begemanac80ade2008-05-12 19:01:56 +00005673 case 277:
5674#line 2574 "/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnercc81d152008-05-04 17:18:47 +00005675 { // Labelled (named) basic block
5676 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
5677 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005678 CHECK_FOR_ERROR
Chris Lattnercc81d152008-05-04 17:18:47 +00005679
Dan Gohmanf4423b12008-04-19 00:24:39 +00005680 ;}
5681 break;
5682
Nate Begemanac80ade2008-05-12 19:01:56 +00005683 case 278:
5684#line 2582 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005685 { // Return with a result...
5686 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
5687 assert(!VL.empty() && "Invalid ret operands!");
5688 (yyval.TermInstVal) = ReturnInst::Create(&VL[0], VL.size());
5689 delete (yyvsp[(2) - (2)].ValueList);
5690 CHECK_FOR_ERROR
5691 ;}
5692 break;
5693
Nate Begemanac80ade2008-05-12 19:01:56 +00005694 case 279:
5695#line 2589 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005696 { // Return with no result...
5697 (yyval.TermInstVal) = ReturnInst::Create();
5698 CHECK_FOR_ERROR
5699 ;}
5700 break;
5701
Nate Begemanac80ade2008-05-12 19:01:56 +00005702 case 280:
5703#line 2593 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005704 { // Unconditional Branch...
5705 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5706 CHECK_FOR_ERROR
5707 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
5708 ;}
5709 break;
5710
Nate Begemanac80ade2008-05-12 19:01:56 +00005711 case 281:
5712#line 2598 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005713 {
5714 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5715 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5716 CHECK_FOR_ERROR
5717 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5718 CHECK_FOR_ERROR
5719 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5720 CHECK_FOR_ERROR
5721 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
5722 ;}
5723 break;
5724
Nate Begemanac80ade2008-05-12 19:01:56 +00005725 case 282:
5726#line 2608 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005727 {
5728 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5729 CHECK_FOR_ERROR
5730 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5731 CHECK_FOR_ERROR
5732 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5733 (yyval.TermInstVal) = S;
5734
5735 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5736 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005737 for (; I != E; ++I) {
5738 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5739 S->addCase(CI, I->second);
5740 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005741 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005742 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005743 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005744 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005745 ;}
5746 break;
5747
Nate Begemanac80ade2008-05-12 19:01:56 +00005748 case 283:
5749#line 2627 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005750 {
5751 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005752 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005753 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005754 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00005755 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005756 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005757 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005758 ;}
5759 break;
5760
Nate Begemanac80ade2008-05-12 19:01:56 +00005761 case 284:
5762#line 2637 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005763 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005764
Reid Spencer14310612006-12-31 05:40:51 +00005765 // Handle the short syntax
5766 const PointerType *PFTy = 0;
5767 const FunctionType *Ty = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005768 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005769 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5770 // Pull out the types of all of the arguments...
5771 std::vector<const Type*> ParamTypes;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005772 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00005773 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005774 const Type *Ty = I->Val->getType();
5775 if (Ty == Type::VoidTy)
5776 GEN_ERROR("Short call syntax cannot be used with varargs");
5777 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005778 }
Chris Lattnera925a142008-04-23 05:37:08 +00005779
5780 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (14)].TypeVal)))
5781 GEN_ERROR("Invalid result type for LLVM function");
5782
Dan Gohmanf4423b12008-04-19 00:24:39 +00005783 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005784 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005785 }
5786
Dan Gohmanf4423b12008-04-19 00:24:39 +00005787 delete (yyvsp[(3) - (14)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005788
Dan Gohmanf4423b12008-04-19 00:24:39 +00005789 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005790 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005791 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005792 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005793 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005794 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005795
Chris Lattner58d74912008-03-12 17:45:29 +00005796 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005797 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None)
5798 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(8) - (14)].ParamAttrs)));
Duncan Sandsdc024672007-11-27 13:23:08 +00005799
Reid Spencer14310612006-12-31 05:40:51 +00005800 // Check the arguments
5801 ValueList Args;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005802 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005803 // Make sure no arguments is a good thing!
5804 if (Ty->getNumParams() != 0)
5805 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005806 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005807 } else { // Has arguments?
5808 // Loop through FunctionType's arguments and ensure they are specified
5809 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005810 FunctionType::param_iterator I = Ty->param_begin();
5811 FunctionType::param_iterator E = Ty->param_end();
Dan Gohmanf4423b12008-04-19 00:24:39 +00005812 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00005813 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005814
Duncan Sandsdc024672007-11-27 13:23:08 +00005815 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005816 if (ArgI->Val->getType() != *I)
5817 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005818 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005819 Args.push_back(ArgI->Val);
Chris Lattner58d74912008-03-12 17:45:29 +00005820 if (ArgI->Attrs != ParamAttr::None)
5821 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005822 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005823
Reid Spencer14310612006-12-31 05:40:51 +00005824 if (Ty->isVarArg()) {
5825 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00005826 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005827 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner58d74912008-03-12 17:45:29 +00005828 if (ArgI->Attrs != ParamAttr::None)
5829 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00005830 }
Reid Spencer14310612006-12-31 05:40:51 +00005831 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005832 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005833 }
Reid Spencer14310612006-12-31 05:40:51 +00005834
Chris Lattner58d74912008-03-12 17:45:29 +00005835 PAListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00005836 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00005837 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00005838
Reid Spencer14310612006-12-31 05:40:51 +00005839 // Create the InvokeInst
Gabor Greife64d2482008-04-06 23:07:54 +00005840 InvokeInst *II = InvokeInst::Create(V, Normal, Except, Args.begin(),Args.end());
Dan Gohmanf4423b12008-04-19 00:24:39 +00005841 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00005842 II->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005843 (yyval.TermInstVal) = II;
5844 delete (yyvsp[(6) - (14)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005845 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005846 ;}
5847 break;
5848
Nate Begemanac80ade2008-05-12 19:01:56 +00005849 case 285:
5850#line 2721 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005851 {
5852 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005853 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005854 ;}
5855 break;
5856
Nate Begemanac80ade2008-05-12 19:01:56 +00005857 case 286:
5858#line 2725 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005859 {
5860 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005861 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005862 ;}
5863 break;
5864
Nate Begemanac80ade2008-05-12 19:01:56 +00005865 case 287:
5866#line 2732 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005867 {
5868 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5869 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005870 CHECK_FOR_ERROR
5871 if (V == 0)
5872 GEN_ERROR("May only switch on a constant pool value");
5873
Dan Gohmanf4423b12008-04-19 00:24:39 +00005874 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005875 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005876 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5877 ;}
5878 break;
5879
Nate Begemanac80ade2008-05-12 19:01:56 +00005880 case 288:
5881#line 2743 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005882 {
5883 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5884 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005885 CHECK_FOR_ERROR
5886
5887 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005888 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005889
Dan Gohmanf4423b12008-04-19 00:24:39 +00005890 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005891 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005892 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5893 ;}
5894 break;
5895
Nate Begemanac80ade2008-05-12 19:01:56 +00005896 case 289:
5897#line 2756 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005898 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005899 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00005900 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005901 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005902 InsertValue((yyvsp[(2) - (2)].InstVal));
5903 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005904 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005905 ;}
5906 break;
5907
Nate Begemanac80ade2008-05-12 19:01:56 +00005908 case 290:
5909#line 2766 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005910 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005911 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005912 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5913 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5914 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005915 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005916 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005917 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005918 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5919 delete (yyvsp[(1) - (6)].TypeVal);
5920 ;}
5921 break;
5922
Nate Begemanac80ade2008-05-12 19:01:56 +00005923 case 291:
5924#line 2777 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005925 {
5926 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5927 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005928 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005929 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005930 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005931 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5932 ;}
5933 break;
5934
Nate Begemanac80ade2008-05-12 19:01:56 +00005935 case 292:
5936#line 2787 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005937 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005938 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005939 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005940 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005941 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00005942 (yyval.ParamList) = new ParamList();
5943 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal));
5944 (yyval.ParamList)->push_back(E);
5945 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00005946 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005947 ;}
5948 break;
5949
Nate Begemanac80ade2008-05-12 19:01:56 +00005950 case 293:
5951#line 2798 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005952 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005953 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00005954 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00005955 (yyval.ParamList) = new ParamList();
5956 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal));
5957 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00005958 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005959 ;}
5960 break;
5961
Nate Begemanac80ade2008-05-12 19:01:56 +00005962 case 294:
5963#line 2806 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005964 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005965 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005966 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005967 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5968 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5969 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
5970 (yyval.ParamList)->push_back(E);
5971 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005972 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005973 ;}
5974 break;
5975
Nate Begemanac80ade2008-05-12 19:01:56 +00005976 case 295:
5977#line 2816 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005978 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005979 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00005980 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5981 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal));
5982 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00005983 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005984 ;}
5985 break;
5986
Nate Begemanac80ade2008-05-12 19:01:56 +00005987 case 296:
5988#line 2823 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005989 { (yyval.ParamList) = new ParamList(); ;}
5990 break;
5991
Nate Begemanac80ade2008-05-12 19:01:56 +00005992 case 297:
5993#line 2826 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005994 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5995 break;
5996
Nate Begemanac80ade2008-05-12 19:01:56 +00005997 case 298:
5998#line 2827 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005999 {
6000 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6001 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00006002 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006003 ;}
6004 break;
6005
Nate Begemanac80ade2008-05-12 19:01:56 +00006006 case 299:
6007#line 2834 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006008 {
6009 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006010 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006011 ;}
6012 break;
6013
Nate Begemanac80ade2008-05-12 19:01:56 +00006014 case 300:
6015#line 2838 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006016 {
6017 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006018 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006019 ;}
6020 break;
6021
Nate Begemanac80ade2008-05-12 19:01:56 +00006022 case 301:
6023#line 2843 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006024 {
Reid Spencer14310612006-12-31 05:40:51 +00006025 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006026 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6027 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
6028 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006029 GEN_ERROR(
6030 "Arithmetic operator requires integer, FP, or packed operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006031 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006032 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006033 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006034 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006035 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
6036 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006037 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006038 delete (yyvsp[(2) - (5)].TypeVal);
6039 ;}
6040 break;
6041
Nate Begemanac80ade2008-05-12 19:01:56 +00006042 case 302:
6043#line 2859 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006044 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006045 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006046 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6047 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
6048 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
6049 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006050 GEN_ERROR("Logical operator requires integral operands");
6051 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006052 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006053 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006054 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006055 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006056 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
6057 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006058 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006059 delete (yyvsp[(2) - (5)].TypeVal);
6060 ;}
6061 break;
6062
Nate Begemanac80ade2008-05-12 19:01:56 +00006063 case 303:
6064#line 2876 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006065 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006066 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006067 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6068 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006069 GEN_ERROR("Vector types not supported by icmp instruction");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006070 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006071 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006072 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006073 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006074 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
6075 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006076 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006077 delete (yyvsp[(3) - (6)].TypeVal);
6078 ;}
6079 break;
6080
Nate Begemanac80ade2008-05-12 19:01:56 +00006081 case 304:
6082#line 2890 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006083 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006084 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006085 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6086 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006087 GEN_ERROR("Vector types not supported by fcmp instruction");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006088 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006089 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006090 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006091 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006092 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
6093 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006094 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006095 delete (yyvsp[(3) - (6)].TypeVal);
6096 ;}
6097 break;
6098
Nate Begemanac80ade2008-05-12 19:01:56 +00006099 case 305:
6100#line 2904 "/llvm/lib/AsmParser/llvmAsmParser.y"
6101 {
6102 if (!UpRefs.empty())
6103 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6104 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6105 GEN_ERROR("Scalar types not supported by vicmp instruction");
6106 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6107 CHECK_FOR_ERROR
6108 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6109 CHECK_FOR_ERROR
6110 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
6111 if ((yyval.InstVal) == 0)
6112 GEN_ERROR("icmp operator returned null");
6113 delete (yyvsp[(3) - (6)].TypeVal);
6114 ;}
6115 break;
6116
6117 case 306:
6118#line 2918 "/llvm/lib/AsmParser/llvmAsmParser.y"
6119 {
6120 if (!UpRefs.empty())
6121 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6122 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6123 GEN_ERROR("Scalar types not supported by vfcmp instruction");
6124 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6125 CHECK_FOR_ERROR
6126 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6127 CHECK_FOR_ERROR
6128 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
6129 if ((yyval.InstVal) == 0)
6130 GEN_ERROR("fcmp operator returned null");
6131 delete (yyvsp[(3) - (6)].TypeVal);
6132 ;}
6133 break;
6134
6135 case 307:
6136#line 2932 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006137 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006138 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006139 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6140 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6141 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6142 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006143 GEN_ERROR("invalid cast opcode for cast from '" +
6144 Val->getType()->getDescription() + "' to '" +
6145 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006146 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
6147 delete (yyvsp[(4) - (4)].TypeVal);
6148 ;}
6149 break;
6150
Nate Begemanac80ade2008-05-12 19:01:56 +00006151 case 308:
6152#line 2944 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006153 {
6154 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006155 GEN_ERROR("select condition must be boolean");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006156 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006157 GEN_ERROR("select value types should match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006158 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006159 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006160 ;}
6161 break;
6162
Nate Begemanac80ade2008-05-12 19:01:56 +00006163 case 309:
6164#line 2952 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006165 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006166 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006167 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6168 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6169 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006170 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006171 ;}
6172 break;
6173
Nate Begemanac80ade2008-05-12 19:01:56 +00006174 case 310:
6175#line 2959 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006176 {
6177 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006178 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006179 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006180 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006181 ;}
6182 break;
6183
Nate Begemanac80ade2008-05-12 19:01:56 +00006184 case 311:
6185#line 2965 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006186 {
6187 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006188 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006189 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006190 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006191 ;}
6192 break;
6193
Nate Begemanac80ade2008-05-12 19:01:56 +00006194 case 312:
6195#line 2971 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006196 {
6197 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006198 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006199 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006200 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006201 ;}
6202 break;
6203
Nate Begemanac80ade2008-05-12 19:01:56 +00006204 case 313:
6205#line 2977 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006206 {
6207 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006208 if (!Ty->isFirstClassType())
6209 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006210 (yyval.InstVal) = PHINode::Create(Ty);
6211 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6212 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
6213 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006214 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006215 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6216 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006217 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006218 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006219 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006220 ;}
6221 break;
6222
Nate Begemanac80ade2008-05-12 19:01:56 +00006223 case 314:
6224#line 2993 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006225 {
Reid Spencer14310612006-12-31 05:40:51 +00006226
6227 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006228 const PointerType *PFTy = 0;
6229 const FunctionType *Ty = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006230 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006231 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6232 // Pull out the types of all of the arguments...
6233 std::vector<const Type*> ParamTypes;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006234 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006235 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006236 const Type *Ty = I->Val->getType();
6237 if (Ty == Type::VoidTy)
6238 GEN_ERROR("Short call syntax cannot be used with varargs");
6239 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006240 }
Chris Lattnera925a142008-04-23 05:37:08 +00006241
6242 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (8)].TypeVal)))
6243 GEN_ERROR("Invalid result type for LLVM function");
6244
Dan Gohmanf4423b12008-04-19 00:24:39 +00006245 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006246 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006247 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006248
Dan Gohmanf4423b12008-04-19 00:24:39 +00006249 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006250 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006251
Reid Spencer7780acb2007-04-16 06:56:07 +00006252 // Check for call to invalid intrinsic to avoid crashing later.
6253 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006254 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006255 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6256 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006257 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6258 theF->getName() + "'");
6259 }
6260
Duncan Sandsdc024672007-11-27 13:23:08 +00006261 // Set up the ParamAttrs for the function
Chris Lattner58d74912008-03-12 17:45:29 +00006262 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006263 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None)
6264 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(8) - (8)].ParamAttrs)));
Reid Spencer14310612006-12-31 05:40:51 +00006265 // Check the arguments
6266 ValueList Args;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006267 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006268 // Make sure no arguments is a good thing!
6269 if (Ty->getNumParams() != 0)
6270 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006271 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006272 } else { // Has arguments?
6273 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006274 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006275 FunctionType::param_iterator I = Ty->param_begin();
6276 FunctionType::param_iterator E = Ty->param_end();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006277 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006278 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006279
Duncan Sandsdc024672007-11-27 13:23:08 +00006280 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006281 if (ArgI->Val->getType() != *I)
6282 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006283 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006284 Args.push_back(ArgI->Val);
Chris Lattner58d74912008-03-12 17:45:29 +00006285 if (ArgI->Attrs != ParamAttr::None)
6286 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006287 }
6288 if (Ty->isVarArg()) {
6289 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006290 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006291 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner58d74912008-03-12 17:45:29 +00006292 if (ArgI->Attrs != ParamAttr::None)
6293 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006294 }
Reid Spencer14310612006-12-31 05:40:51 +00006295 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006296 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006297 }
Duncan Sandsdc024672007-11-27 13:23:08 +00006298
6299 // Finish off the ParamAttrs and check them
Chris Lattner58d74912008-03-12 17:45:29 +00006300 PAListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006301 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00006302 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006303
Reid Spencer14310612006-12-31 05:40:51 +00006304 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006305 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006306 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6307 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00006308 CI->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006309 (yyval.InstVal) = CI;
6310 delete (yyvsp[(6) - (8)].ParamList);
6311 delete (yyvsp[(3) - (8)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006312 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006313 ;}
6314 break;
6315
Nate Begemanac80ade2008-05-12 19:01:56 +00006316 case 315:
6317#line 3082 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006318 {
6319 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006320 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006321 ;}
6322 break;
6323
Nate Begemanac80ade2008-05-12 19:01:56 +00006324 case 316:
6325#line 3087 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006326 {
6327 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006328 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006329 ;}
6330 break;
6331
Nate Begemanac80ade2008-05-12 19:01:56 +00006332 case 317:
6333#line 3091 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006334 {
6335 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006336 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006337 ;}
6338 break;
6339
Nate Begemanac80ade2008-05-12 19:01:56 +00006340 case 318:
6341#line 3098 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006342 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006343 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006344 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6345 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6346 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006347 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006348 ;}
6349 break;
6350
Nate Begemanac80ade2008-05-12 19:01:56 +00006351 case 319:
6352#line 3105 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006353 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006354 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006355 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6356 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006357 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006358 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6359 delete (yyvsp[(2) - (6)].TypeVal);
6360 ;}
6361 break;
6362
Nate Begemanac80ade2008-05-12 19:01:56 +00006363 case 320:
6364#line 3113 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006365 {
Reid Spencer14310612006-12-31 05:40:51 +00006366 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006367 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6368 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6369 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006370 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006371 ;}
6372 break;
6373
Nate Begemanac80ade2008-05-12 19:01:56 +00006374 case 321:
6375#line 3120 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006376 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006377 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006378 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6379 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006380 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006381 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6382 delete (yyvsp[(2) - (6)].TypeVal);
6383 ;}
6384 break;
6385
Nate Begemanac80ade2008-05-12 19:01:56 +00006386 case 322:
6387#line 3128 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006388 {
6389 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006390 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006391 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6392 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006393 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006394 ;}
6395 break;
6396
Nate Begemanac80ade2008-05-12 19:01:56 +00006397 case 323:
6398#line 3136 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006399 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006400 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006401 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6402 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006403 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006404 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6405 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006406 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006407 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6408 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006409 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006410 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6411 delete (yyvsp[(3) - (5)].TypeVal);
6412 ;}
6413 break;
6414
Nate Begemanac80ade2008-05-12 19:01:56 +00006415 case 324:
6416#line 3150 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006417 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006418 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006419 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6420 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006421 if (!PT)
6422 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006423 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006424 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006425 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6426 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006427 "' into space of type '" + ElTy->getDescription() + "'");
6428
Dan Gohmanf4423b12008-04-19 00:24:39 +00006429 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006430 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006431 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6432 delete (yyvsp[(5) - (7)].TypeVal);
6433 ;}
6434 break;
6435
Nate Begemanac80ade2008-05-12 19:01:56 +00006436 case 325:
6437#line 3167 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006438 {
6439 Value *TmpVal = getVal((yyvsp[(2) - (5)].TypeVal)->get(), (yyvsp[(3) - (5)].ValIDVal));
6440 if (!GetResultInst::isValidOperands(TmpVal, (yyvsp[(5) - (5)].UInt64Val)))
Devang Patel5a970972008-02-19 22:27:01 +00006441 GEN_ERROR("Invalid getresult operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006442 (yyval.InstVal) = new GetResultInst(TmpVal, (yyvsp[(5) - (5)].UInt64Val));
6443 delete (yyvsp[(2) - (5)].TypeVal);
Devang Patel5a970972008-02-19 22:27:01 +00006444 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006445 ;}
6446 break;
6447
Nate Begemanac80ade2008-05-12 19:01:56 +00006448 case 326:
6449#line 3175 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006450 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006451 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006452 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6453 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006454 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006455
Dan Gohmanf4423b12008-04-19 00:24:39 +00006456 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00006457 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006458 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6459 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006460 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006461 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
6462 delete (yyvsp[(2) - (4)].TypeVal);
6463 delete (yyvsp[(4) - (4)].ValueList);
6464 ;}
6465 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006466
Dan Gohmanf4423b12008-04-19 00:24:39 +00006467
6468/* Line 1267 of yacc.c. */
Nate Begemanac80ade2008-05-12 19:01:56 +00006469#line 6470 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006470 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00006471 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006472 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6473
6474 YYPOPSTACK (yylen);
6475 yylen = 0;
6476 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006477
6478 *++yyvsp = yyval;
6479
6480
Dan Gohmanf4423b12008-04-19 00:24:39 +00006481 /* Now `shift' the result of the reduction. Determine what state
6482 that goes to, based on the state we popped back to and the rule
6483 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006484
6485 yyn = yyr1[yyn];
6486
Dan Gohmanf4423b12008-04-19 00:24:39 +00006487 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6488 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006489 yystate = yytable[yystate];
6490 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00006491 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00006492
6493 goto yynewstate;
6494
6495
Dan Gohmanf4423b12008-04-19 00:24:39 +00006496/*------------------------------------.
6497| yyerrlab -- here on detecting error |
6498`------------------------------------*/
6499yyerrlab:
6500 /* If not already recovering from an error, report this error. */
6501 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006502 {
6503 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006504#if ! YYERROR_VERBOSE
6505 yyerror (YY_("syntax error"));
6506#else
6507 {
6508 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6509 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6510 {
6511 YYSIZE_T yyalloc = 2 * yysize;
6512 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6513 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6514 if (yymsg != yymsgbuf)
6515 YYSTACK_FREE (yymsg);
6516 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6517 if (yymsg)
6518 yymsg_alloc = yyalloc;
6519 else
6520 {
6521 yymsg = yymsgbuf;
6522 yymsg_alloc = sizeof yymsgbuf;
6523 }
6524 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00006525
Dan Gohmanf4423b12008-04-19 00:24:39 +00006526 if (0 < yysize && yysize <= yymsg_alloc)
6527 {
6528 (void) yysyntax_error (yymsg, yystate, yychar);
6529 yyerror (yymsg);
6530 }
6531 else
6532 {
6533 yyerror (YY_("syntax error"));
6534 if (yysize != 0)
6535 goto yyexhaustedlab;
6536 }
6537 }
6538#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006539 }
6540
Dan Gohmanf4423b12008-04-19 00:24:39 +00006541
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006542
6543 if (yyerrstatus == 3)
6544 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00006545 /* If just tried and failed to reuse look-ahead token after an
6546 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006547
Dan Gohmanf4423b12008-04-19 00:24:39 +00006548 if (yychar <= YYEOF)
6549 {
6550 /* Return failure if at end of input. */
6551 if (yychar == YYEOF)
6552 YYABORT;
6553 }
6554 else
6555 {
6556 yydestruct ("Error: discarding",
6557 yytoken, &yylval);
6558 yychar = YYEMPTY;
6559 }
6560 }
6561
6562 /* Else will try to reuse look-ahead token after shifting the error
6563 token. */
6564 goto yyerrlab1;
6565
6566
6567/*---------------------------------------------------.
6568| yyerrorlab -- error raised explicitly by YYERROR. |
6569`---------------------------------------------------*/
6570yyerrorlab:
6571
6572 /* Pacify compilers like GCC when the user code never invokes
6573 YYERROR and the label yyerrorlab therefore never appears in user
6574 code. */
6575 if (/*CONSTCOND*/ 0)
6576 goto yyerrorlab;
6577
6578 /* Do not reclaim the symbols of the rule which action triggered
6579 this YYERROR. */
6580 YYPOPSTACK (yylen);
6581 yylen = 0;
6582 YY_STACK_PRINT (yyss, yyssp);
6583 yystate = *yyssp;
6584 goto yyerrlab1;
6585
6586
6587/*-------------------------------------------------------------.
6588| yyerrlab1 -- common code for both syntax error and YYERROR. |
6589`-------------------------------------------------------------*/
6590yyerrlab1:
6591 yyerrstatus = 3; /* Each real token shifted decrements this. */
6592
6593 for (;;)
6594 {
6595 yyn = yypact[yystate];
6596 if (yyn != YYPACT_NINF)
6597 {
6598 yyn += YYTERROR;
6599 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6600 {
6601 yyn = yytable[yyn];
6602 if (0 < yyn)
6603 break;
6604 }
6605 }
6606
6607 /* Pop the current state because it cannot handle the error token. */
6608 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006609 YYABORT;
6610
Dale Johannesencdd509a2007-09-07 21:07:57 +00006611
Dan Gohmanf4423b12008-04-19 00:24:39 +00006612 yydestruct ("Error: popping",
6613 yystos[yystate], yyvsp);
6614 YYPOPSTACK (1);
6615 yystate = *yyssp;
6616 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006617 }
6618
6619 if (yyn == YYFINAL)
6620 YYACCEPT;
6621
Reid Spencer68a24bd2005-08-27 18:50:39 +00006622 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006623
6624
6625 /* Shift the error token. */
6626 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00006627
Reid Spencer68a24bd2005-08-27 18:50:39 +00006628 yystate = yyn;
6629 goto yynewstate;
6630
Gabor Greife64d2482008-04-06 23:07:54 +00006631
Dan Gohmanf4423b12008-04-19 00:24:39 +00006632/*-------------------------------------.
6633| yyacceptlab -- YYACCEPT comes here. |
6634`-------------------------------------*/
6635yyacceptlab:
6636 yyresult = 0;
6637 goto yyreturn;
6638
6639/*-----------------------------------.
6640| yyabortlab -- YYABORT comes here. |
6641`-----------------------------------*/
6642yyabortlab:
6643 yyresult = 1;
6644 goto yyreturn;
6645
6646#ifndef yyoverflow
6647/*-------------------------------------------------.
6648| yyexhaustedlab -- memory exhaustion comes here. |
6649`-------------------------------------------------*/
6650yyexhaustedlab:
6651 yyerror (YY_("memory exhausted"));
6652 yyresult = 2;
6653 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00006654#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00006655
6656yyreturn:
6657 if (yychar != YYEOF && yychar != YYEMPTY)
6658 yydestruct ("Cleanup: discarding lookahead",
6659 yytoken, &yylval);
6660 /* Do not reclaim the symbols of the rule which action triggered
6661 this YYABORT or YYACCEPT. */
6662 YYPOPSTACK (yylen);
6663 YY_STACK_PRINT (yyss, yyssp);
6664 while (yyssp != yyss)
6665 {
6666 yydestruct ("Cleanup: popping",
6667 yystos[*yyssp], yyvsp);
6668 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00006669 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006670#ifndef yyoverflow
6671 if (yyss != yyssa)
6672 YYSTACK_FREE (yyss);
6673#endif
6674#if YYERROR_VERBOSE
6675 if (yymsg != yymsgbuf)
6676 YYSTACK_FREE (yymsg);
6677#endif
6678 /* Make sure YYID is used. */
6679 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006680}
Dan Gohmanf4423b12008-04-19 00:24:39 +00006681
6682
Nate Begemanac80ade2008-05-12 19:01:56 +00006683#line 3192 "/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006684
6685
Reid Spencer14310612006-12-31 05:40:51 +00006686// common code from the two 'RunVMAsmParser' functions
6687static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00006688 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00006689 // Check to make sure the parser succeeded
6690 if (yyparse()) {
6691 if (ParserResult)
6692 delete ParserResult;
6693 return 0;
6694 }
6695
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006696 // Emit an error if there are any unresolved types left.
6697 if (!CurModule.LateResolveTypes.empty()) {
6698 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6699 if (DID.Type == ValID::LocalName) {
6700 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6701 } else {
6702 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6703 }
6704 if (ParserResult)
6705 delete ParserResult;
6706 return 0;
6707 }
6708
6709 // Emit an error if there are any unresolved values left.
6710 if (!CurModule.LateResolveValues.empty()) {
6711 Value *V = CurModule.LateResolveValues.back();
6712 std::map<Value*, std::pair<ValID, int> >::iterator I =
6713 CurModule.PlaceHolderInfo.find(V);
6714
6715 if (I != CurModule.PlaceHolderInfo.end()) {
6716 ValID &DID = I->second.first;
6717 if (DID.Type == ValID::LocalName) {
6718 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6719 } else {
6720 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6721 }
6722 if (ParserResult)
6723 delete ParserResult;
6724 return 0;
6725 }
6726 }
6727
Reid Spencer14310612006-12-31 05:40:51 +00006728 // Check to make sure that parsing produced a result
6729 if (!ParserResult)
6730 return 0;
6731
6732 // Reset ParserResult variable while saving its value for the result.
6733 Module *Result = ParserResult;
6734 ParserResult = 0;
6735
6736 return Result;
6737}
6738
Reid Spencer61c83e02006-08-18 08:43:06 +00006739void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00006740 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00006741 // TODO: column number in exception
6742 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00006743 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00006744 TriggerError = 1;
6745}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006746
6747int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00006748 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006749 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00006750 if (yychar != YYEMPTY && yychar != 0) {
6751 errMsg += " while reading token: '";
6752 errMsg += std::string(LLLgetTokenStart(),
6753 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
6754 }
Reid Spencer61c83e02006-08-18 08:43:06 +00006755 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006756 return 0;
6757}
Dan Gohmanf4423b12008-04-19 00:24:39 +00006758