blob: a17e8ee52c72895fd12552be68b644fdc3e8b56d [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,
142 UNWINDS = 323,
143 RET = 324,
144 BR = 325,
145 SWITCH = 326,
146 INVOKE = 327,
147 UNWIND = 328,
148 UNREACHABLE = 329,
149 ADD = 330,
150 SUB = 331,
151 MUL = 332,
152 UDIV = 333,
153 SDIV = 334,
154 FDIV = 335,
155 UREM = 336,
156 SREM = 337,
157 FREM = 338,
158 AND = 339,
159 OR = 340,
160 XOR = 341,
161 SHL = 342,
162 LSHR = 343,
163 ASHR = 344,
164 ICMP = 345,
165 FCMP = 346,
166 EQ = 347,
167 NE = 348,
168 SLT = 349,
169 SGT = 350,
170 SLE = 351,
171 SGE = 352,
172 ULT = 353,
173 UGT = 354,
174 ULE = 355,
175 UGE = 356,
176 OEQ = 357,
177 ONE = 358,
178 OLT = 359,
179 OGT = 360,
180 OLE = 361,
181 OGE = 362,
182 ORD = 363,
183 UNO = 364,
184 UEQ = 365,
185 UNE = 366,
186 MALLOC = 367,
187 ALLOCA = 368,
188 FREE = 369,
189 LOAD = 370,
190 STORE = 371,
191 GETELEMENTPTR = 372,
192 TRUNC = 373,
193 ZEXT = 374,
194 SEXT = 375,
195 FPTRUNC = 376,
196 FPEXT = 377,
197 BITCAST = 378,
198 UITOFP = 379,
199 SITOFP = 380,
200 FPTOUI = 381,
201 FPTOSI = 382,
202 INTTOPTR = 383,
203 PTRTOINT = 384,
204 PHI_TOK = 385,
205 SELECT = 386,
206 VAARG = 387,
207 EXTRACTELEMENT = 388,
208 INSERTELEMENT = 389,
209 SHUFFLEVECTOR = 390,
210 GETRESULT = 391,
211 SIGNEXT = 392,
212 ZEROEXT = 393,
213 NORETURN = 394,
214 INREG = 395,
215 SRET = 396,
216 NOUNWIND = 397,
217 NOALIAS = 398,
218 BYVAL = 399,
219 NEST = 400,
220 READNONE = 401,
221 READONLY = 402,
222 GC = 403,
223 DEFAULT = 404,
224 HIDDEN = 405,
225 PROTECTED = 406
226 };
227#endif
228/* Tokens. */
229#define ESINT64VAL 258
230#define EUINT64VAL 259
231#define ESAPINTVAL 260
232#define EUAPINTVAL 261
233#define LOCALVAL_ID 262
234#define GLOBALVAL_ID 263
235#define FPVAL 264
236#define VOID 265
237#define INTTYPE 266
238#define FLOAT 267
239#define DOUBLE 268
240#define X86_FP80 269
241#define FP128 270
242#define PPC_FP128 271
243#define LABEL 272
244#define TYPE 273
245#define LOCALVAR 274
246#define GLOBALVAR 275
247#define LABELSTR 276
248#define STRINGCONSTANT 277
249#define ATSTRINGCONSTANT 278
250#define PCTSTRINGCONSTANT 279
251#define ZEROINITIALIZER 280
252#define TRUETOK 281
253#define FALSETOK 282
254#define BEGINTOK 283
255#define ENDTOK 284
256#define DECLARE 285
257#define DEFINE 286
258#define GLOBAL 287
259#define CONSTANT 288
260#define SECTION 289
261#define ALIAS 290
262#define VOLATILE 291
263#define THREAD_LOCAL 292
264#define TO 293
265#define DOTDOTDOT 294
266#define NULL_TOK 295
267#define UNDEF 296
268#define INTERNAL 297
269#define LINKONCE 298
270#define WEAK 299
271#define APPENDING 300
272#define DLLIMPORT 301
273#define DLLEXPORT 302
274#define EXTERN_WEAK 303
275#define OPAQUE 304
276#define EXTERNAL 305
277#define TARGET 306
278#define TRIPLE 307
279#define ALIGN 308
280#define ADDRSPACE 309
281#define DEPLIBS 310
282#define CALL 311
283#define TAIL 312
284#define ASM_TOK 313
285#define MODULE 314
286#define SIDEEFFECT 315
287#define CC_TOK 316
288#define CCC_TOK 317
289#define FASTCC_TOK 318
290#define COLDCC_TOK 319
291#define X86_STDCALLCC_TOK 320
292#define X86_FASTCALLCC_TOK 321
293#define DATALAYOUT 322
294#define UNWINDS 323
295#define RET 324
296#define BR 325
297#define SWITCH 326
298#define INVOKE 327
299#define UNWIND 328
300#define UNREACHABLE 329
301#define ADD 330
302#define SUB 331
303#define MUL 332
304#define UDIV 333
305#define SDIV 334
306#define FDIV 335
307#define UREM 336
308#define SREM 337
309#define FREM 338
310#define AND 339
311#define OR 340
312#define XOR 341
313#define SHL 342
314#define LSHR 343
315#define ASHR 344
316#define ICMP 345
317#define FCMP 346
318#define EQ 347
319#define NE 348
320#define SLT 349
321#define SGT 350
322#define SLE 351
323#define SGE 352
324#define ULT 353
325#define UGT 354
326#define ULE 355
327#define UGE 356
328#define OEQ 357
329#define ONE 358
330#define OLT 359
331#define OGT 360
332#define OLE 361
333#define OGE 362
334#define ORD 363
335#define UNO 364
336#define UEQ 365
337#define UNE 366
338#define MALLOC 367
339#define ALLOCA 368
340#define FREE 369
341#define LOAD 370
342#define STORE 371
343#define GETELEMENTPTR 372
344#define TRUNC 373
345#define ZEXT 374
346#define SEXT 375
347#define FPTRUNC 376
348#define FPEXT 377
349#define BITCAST 378
350#define UITOFP 379
351#define SITOFP 380
352#define FPTOUI 381
353#define FPTOSI 382
354#define INTTOPTR 383
355#define PTRTOINT 384
356#define PHI_TOK 385
357#define SELECT 386
358#define VAARG 387
359#define EXTRACTELEMENT 388
360#define INSERTELEMENT 389
361#define SHUFFLEVECTOR 390
362#define GETRESULT 391
363#define SIGNEXT 392
364#define ZEROEXT 393
365#define NORETURN 394
366#define INREG 395
367#define SRET 396
368#define NOUNWIND 397
369#define NOALIAS 398
370#define BYVAL 399
371#define NEST 400
372#define READNONE 401
373#define READONLY 402
374#define GC 403
375#define DEFAULT 404
376#define HIDDEN 405
377#define PROTECTED 406
378
379
380
381
382/* Copy the first part of user declarations. */
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000383#line 14 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000384
385#include "ParserInternals.h"
386#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000387#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000388#include "llvm/Instructions.h"
389#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000390#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000391#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000392#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000393#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000394#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000395#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000396#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000397#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000398#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000399#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000400#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000401#include <utility>
402
Reid Spencere4f47592006-08-18 17:32:55 +0000403// The following is a gross hack. In order to rid the libAsmParser library of
404// exceptions, we have to have a way of getting the yyparse function to go into
405// an error situation. So, whenever we want an error to occur, the GenerateError
406// function (see bottom of file) sets TriggerError. Then, at the end of each
407// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
408// (a goto) to put YACC in error state. Furthermore, several calls to
409// GenerateError are made from inside productions and they must simulate the
410// previous exception behavior by exiting the production immediately. We have
411// replaced these with the GEN_ERROR macro which calls GeneratError and then
412// immediately invokes YYERROR. This would be so much cleaner if it was a
413// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000414static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000415#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000416#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
417
Reid Spencer68a24bd2005-08-27 18:50:39 +0000418int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
419int yylex(); // declaration" of xxx warnings.
420int yyparse();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000421using namespace llvm;
422
423static Module *ParserResult;
424
425// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
426// relating to upreferences in the input stream.
427//
428//#define DEBUG_UPREFS 1
429#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000430#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000431#else
432#define UR_OUT(X)
433#endif
434
435#define YYERROR_VERBOSE 1
436
Chris Lattnerb475c422005-11-12 18:22:38 +0000437static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000438
439
440// This contains info used when building the body of a function. It is
441// destroyed when the function is completed.
442//
443typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000444
Reid Spencer68a24bd2005-08-27 18:50:39 +0000445static void
Reid Spencer93c40032007-03-19 18:40:50 +0000446ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000447
448static struct PerModuleInfo {
449 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000450 ValueList Values; // Module level numbered definitions
451 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000452 std::vector<PATypeHolder> Types;
453 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000454
455 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000456 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000457 /// that we can resolve them later and print error messages as appropriate.
458 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
459
460 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
461 // references to global values. Global values may be referenced before they
462 // are defined, and if so, the temporary object that they represent is held
463 // here. This is used for forward references of GlobalValues.
464 //
465 typedef std::map<std::pair<const PointerType *,
466 ValID>, GlobalValue*> GlobalRefsType;
467 GlobalRefsType GlobalRefs;
468
469 void ModuleDone() {
470 // If we could not resolve some functions at function compilation time
471 // (calls to functions before they are defined), resolve them now... Types
472 // are resolved when the constant pool has been completely parsed.
473 //
474 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000475 if (TriggerError)
476 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000477
478 // Check to make sure that all global value forward references have been
479 // resolved!
480 //
481 if (!GlobalRefs.empty()) {
482 std::string UndefinedReferences = "Unresolved global references exist:\n";
483
484 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
485 I != E; ++I) {
486 UndefinedReferences += " " + I->first.first->getDescription() + " " +
487 I->first.second.getName() + "\n";
488 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000489 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000490 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000491 }
492
Chandler Carruth02202192007-08-04 01:56:21 +0000493 // Look for intrinsic functions and CallInst that need to be upgraded
494 for (Module::iterator FI = CurrentModule->begin(),
495 FE = CurrentModule->end(); FI != FE; )
496 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
497
Reid Spencer68a24bd2005-08-27 18:50:39 +0000498 Values.clear(); // Clear out function local definitions
499 Types.clear();
500 CurrentModule = 0;
501 }
502
Reid Spencer68a24bd2005-08-27 18:50:39 +0000503 // GetForwardRefForGlobal - Check to see if there is a forward reference
504 // for this global. If so, remove it from the GlobalRefs map and return it.
505 // If not, just return null.
506 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
507 // Check to see if there is a forward reference to this global variable...
508 // if there is, eliminate it and patch the reference to use the new def'n.
509 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
510 GlobalValue *Ret = 0;
511 if (I != GlobalRefs.end()) {
512 Ret = I->second;
513 GlobalRefs.erase(I);
514 }
515 return Ret;
516 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000517
518 bool TypeIsUnresolved(PATypeHolder* PATy) {
519 // If it isn't abstract, its resolved
520 const Type* Ty = PATy->get();
521 if (!Ty->isAbstract())
522 return false;
523 // Traverse the type looking for abstract types. If it isn't abstract then
524 // we don't need to traverse that leg of the type.
525 std::vector<const Type*> WorkList, SeenList;
526 WorkList.push_back(Ty);
527 while (!WorkList.empty()) {
528 const Type* Ty = WorkList.back();
529 SeenList.push_back(Ty);
530 WorkList.pop_back();
531 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
532 // Check to see if this is an unresolved type
533 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
534 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
535 for ( ; I != E; ++I) {
536 if (I->second.get() == OpTy)
537 return true;
538 }
539 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
540 const Type* TheTy = SeqTy->getElementType();
541 if (TheTy->isAbstract() && TheTy != Ty) {
542 std::vector<const Type*>::iterator I = SeenList.begin(),
543 E = SeenList.end();
544 for ( ; I != E; ++I)
545 if (*I == TheTy)
546 break;
547 if (I == E)
548 WorkList.push_back(TheTy);
549 }
550 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
551 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
552 const Type* TheTy = StrTy->getElementType(i);
553 if (TheTy->isAbstract() && TheTy != Ty) {
554 std::vector<const Type*>::iterator I = SeenList.begin(),
555 E = SeenList.end();
556 for ( ; I != E; ++I)
557 if (*I == TheTy)
558 break;
559 if (I == E)
560 WorkList.push_back(TheTy);
561 }
562 }
563 }
564 }
565 return false;
566 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000567} CurModule;
568
569static struct PerFunctionInfo {
570 Function *CurrentFunction; // Pointer to current function being created
571
Reid Spencer93c40032007-03-19 18:40:50 +0000572 ValueList Values; // Keep track of #'d definitions
573 unsigned NextValNum;
574 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000575 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000576 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000577 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000578
579 /// BBForwardRefs - When we see forward references to basic blocks, keep
580 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000581 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000582
583 inline PerFunctionInfo() {
584 CurrentFunction = 0;
585 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000586 Linkage = GlobalValue::ExternalLinkage;
587 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000588 }
589
590 inline void FunctionStart(Function *M) {
591 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000592 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000593 }
594
595 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000596 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000597 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000598 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000599 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000600 return;
601 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000602
603 // Resolve all forward references now.
604 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
605
606 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000607 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000608 CurrentFunction = 0;
609 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000610 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000611 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000612 }
613} CurFun; // Info for the current function...
614
615static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
616
617
618//===----------------------------------------------------------------------===//
619// Code to handle definitions of all the types
620//===----------------------------------------------------------------------===//
621
Reid Spencer93c40032007-03-19 18:40:50 +0000622static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
623 // Things that have names or are void typed don't get slot numbers
624 if (V->hasName() || (V->getType() == Type::VoidTy))
625 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626
Reid Spencer93c40032007-03-19 18:40:50 +0000627 // In the case of function values, we have to allow for the forward reference
628 // of basic blocks, which are included in the numbering. Consequently, we keep
629 // track of the next insertion location with NextValNum. When a BB gets
630 // inserted, it could change the size of the CurFun.Values vector.
631 if (&ValueTab == &CurFun.Values) {
632 if (ValueTab.size() <= CurFun.NextValNum)
633 ValueTab.resize(CurFun.NextValNum+1);
634 ValueTab[CurFun.NextValNum++] = V;
635 return;
636 }
637 // For all other lists, its okay to just tack it on the back of the vector.
638 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000639}
640
641static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
642 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000643 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000644 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000645 if (D.Num < CurModule.Types.size())
646 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000647 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000648 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000649 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000650 D.destroy(); // Free old strdup'd memory...
651 return N;
652 }
653 break;
654 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000655 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000656 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657 }
658
659 // If we reached here, we referenced either a symbol that we don't know about
660 // or an id number that hasn't been read yet. We may be referencing something
661 // forward, so just create an entry to be resolved later and get to it...
662 //
663 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
664
665
666 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000667 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000668 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000669 return 0;
670 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000671 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000672 return 0;
673 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000674 }
675
Reid Spencer861d9d62006-11-28 07:29:44 +0000676 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000677 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000678 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000679
Reid Spencer861d9d62006-11-28 07:29:44 +0000680 Type *Typ = OpaqueType::get();
681 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
682 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000683 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000684
Reid Spencer93c40032007-03-19 18:40:50 +0000685// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000686// the provided ValID. If the value exists and has already been defined, return
687// it. Otherwise return null.
688//
Reid Spencer93c40032007-03-19 18:40:50 +0000689static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000690 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000691 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000692 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000693 return 0;
694 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000695
696 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000697 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000698 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000699 if (D.Num >= CurFun.Values.size())
700 return 0;
701 Value *Result = CurFun.Values[D.Num];
702 if (Ty != Result->getType()) {
703 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
704 Result->getType()->getDescription() + "' does not match "
705 "expected type, '" + Ty->getDescription() + "'");
706 return 0;
707 }
708 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000709 }
710 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000711 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000712 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000713 Value *Result = CurModule.Values[D.Num];
714 if (Ty != Result->getType()) {
715 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
716 Result->getType()->getDescription() + "' does not match "
717 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000718 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000719 }
720 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000721 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000722
723 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000724 if (!inFunctionScope())
725 return 0;
726 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000727 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000728 if (N == 0)
729 return 0;
730 if (N->getType() != Ty)
731 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000732
733 D.destroy(); // Free old strdup'd memory...
734 return N;
735 }
736 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000737 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000738 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000739 if (N == 0)
740 return 0;
741 if (N->getType() != Ty)
742 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000743
744 D.destroy(); // Free old strdup'd memory...
745 return N;
746 }
747
748 // Check to make sure that "Ty" is an integral type, and that our
749 // value will fit into the specified type...
750 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner38905612008-02-19 04:36:25 +0000751 if (!isa<IntegerType>(Ty) ||
752 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000753 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000754 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000755 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000756 return 0;
757 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000758 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000759
760 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000761 if (isa<IntegerType>(Ty) &&
762 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Reid Spencerb83eb642006-10-20 07:07:24 +0000763 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner38905612008-02-19 04:36:25 +0000764
765 if (!isa<IntegerType>(Ty) ||
766 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
767 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
768 "' is invalid or out of range for type '" +
769 Ty->getDescription() + "'");
770 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000771 }
Chris Lattner38905612008-02-19 04:36:25 +0000772 // This is really a signed reference. Transmogrify.
773 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000774
775 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000776 if (!Ty->isFloatingPoint() ||
777 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000778 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000779 return 0;
780 }
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000781 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +0000782 // as double. Fix this here. Long double does not need this.
783 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
784 Ty==Type::FloatTy)
Dale Johannesencdd509a2007-09-07 21:07:57 +0000785 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000786 return ConstantFP::get(*D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000787
788 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000789 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000790 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000791 return 0;
792 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000793 return ConstantPointerNull::get(cast<PointerType>(Ty));
794
795 case ValID::ConstUndefVal: // Is it an undef value?
796 return UndefValue::get(Ty);
797
Chris Lattner7aa61892005-12-21 17:53:23 +0000798 case ValID::ConstZeroVal: // Is it a zero value?
799 return Constant::getNullValue(Ty);
800
Reid Spencer68a24bd2005-08-27 18:50:39 +0000801 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000803 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000804 return 0;
805 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000806 return D.ConstantValue;
807
Chris Lattner0e9c3762006-01-25 22:27:16 +0000808 case ValID::InlineAsmVal: { // Inline asm expression
809 const PointerType *PTy = dyn_cast<PointerType>(Ty);
810 const FunctionType *FTy =
811 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000812 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000813 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000814 return 0;
815 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000816 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
817 D.IAD->HasSideEffects);
818 D.destroy(); // Free InlineAsmDescriptor.
819 return IA;
820 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000821 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000822 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000823 return 0;
824 } // End of switch
825
Reid Spencera9720f52007-02-05 17:04:00 +0000826 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000827 return 0;
828}
829
Reid Spencer93c40032007-03-19 18:40:50 +0000830// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000831// value is not already defined, it "improvises" by creating a placeholder var
832// that looks and acts just like the requested variable. When the value is
833// defined later, all uses of the placeholder variable are replaced with the
834// real thing.
835//
836static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000837 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000838 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000839 return 0;
840 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000841
842 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000843 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000844 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000845 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000846
Reid Spencer5b7e7532006-09-28 19:28:24 +0000847 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000848 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000849 return 0;
850 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000851
852 // If we reached here, we referenced either a symbol that we don't know about
853 // or an id number that hasn't been read yet. We may be referencing something
854 // forward, so just create an entry to be resolved later and get to it...
855 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000856 switch (ID.Type) {
857 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000858 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000859 const PointerType *PTy = dyn_cast<PointerType>(Ty);
860 if (!PTy) {
861 GenerateError("Invalid type for reference to global" );
862 return 0;
863 }
864 const Type* ElTy = PTy->getElementType();
865 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greife64d2482008-04-06 23:07:54 +0000866 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000867 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000868 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
869 (Module*)0, false, PTy->getAddressSpace());
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000870 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000871 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000872 default:
873 V = new Argument(Ty);
874 }
875
Reid Spencer68a24bd2005-08-27 18:50:39 +0000876 // Remember where this forward reference came from. FIXME, shouldn't we try
877 // to recycle these things??
878 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsdc024672007-11-27 13:23:08 +0000879 LLLgetLineNo())));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000880
881 if (inFunctionScope())
882 InsertValue(V, CurFun.LateResolveValues);
883 else
884 InsertValue(V, CurModule.LateResolveValues);
885 return V;
886}
887
Reid Spencer93c40032007-03-19 18:40:50 +0000888/// defineBBVal - This is a definition of a new basic block with the specified
889/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Devang Patel67909432008-03-03 18:58:47 +0000890static BasicBlock *defineBBVal(const ValID &ID, BasicBlock *unwindDest) {
Reid Spencera9720f52007-02-05 17:04:00 +0000891 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000892
Reid Spencer68a24bd2005-08-27 18:50:39 +0000893 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000894
Reid Spencer93c40032007-03-19 18:40:50 +0000895 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000896
Reid Spencer93c40032007-03-19 18:40:50 +0000897 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
898 if (BBI != CurFun.BBForwardRefs.end()) {
899 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000900 // The forward declaration could have been inserted anywhere in the
901 // function: insert it into the correct place now.
902 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
903 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000904
Reid Spencer66728ef2007-03-20 01:13:36 +0000905 // We're about to erase the entry, save the key so we can clean it up.
906 ValID Tmp = BBI->first;
907
Reid Spencer93c40032007-03-19 18:40:50 +0000908 // Erase the forward ref from the map as its no longer "forward"
909 CurFun.BBForwardRefs.erase(ID);
910
Reid Spencer66728ef2007-03-20 01:13:36 +0000911 // The key has been removed from the map but so we don't want to leave
912 // strdup'd memory around so destroy it too.
913 Tmp.destroy();
914
Reid Spencer93c40032007-03-19 18:40:50 +0000915 // If its a numbered definition, bump the number and set the BB value.
916 if (ID.Type == ValID::LocalID) {
917 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
918 InsertValue(BB);
919 }
Devang Patel67909432008-03-03 18:58:47 +0000920 } else {
921 // We haven't seen this BB before and its first mention is a definition.
922 // Just create it and return it.
923 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greife64d2482008-04-06 23:07:54 +0000924 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel67909432008-03-03 18:58:47 +0000925 if (ID.Type == ValID::LocalID) {
926 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
927 InsertValue(BB);
928 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000929 }
Reid Spencer93c40032007-03-19 18:40:50 +0000930
Devang Patel67909432008-03-03 18:58:47 +0000931 ID.destroy();
932 BB->setUnwindDest(unwindDest);
Reid Spencer93c40032007-03-19 18:40:50 +0000933 return BB;
934}
935
936/// getBBVal - get an existing BB value or create a forward reference for it.
937///
938static BasicBlock *getBBVal(const ValID &ID) {
939 assert(inFunctionScope() && "Can't get basic block at global scope!");
940
941 BasicBlock *BB = 0;
942
943 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
944 if (BBI != CurFun.BBForwardRefs.end()) {
945 BB = BBI->second;
946 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000947 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000948 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000949 if (N) {
Reid Spencer93c40032007-03-19 18:40:50 +0000950 if (N->getType()->getTypeID() == Type::LabelTyID)
951 BB = cast<BasicBlock>(N);
952 else
953 GenerateError("Reference to label '" + Name + "' is actually of type '"+
954 N->getType()->getDescription() + "'");
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000955 }
Reid Spencer93c40032007-03-19 18:40:50 +0000956 } else if (ID.Type == ValID::LocalID) {
957 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
958 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
959 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
960 else
961 GenerateError("Reference to label '%" + utostr(ID.Num) +
962 "' is actually of type '"+
963 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
964 }
965 } else {
966 GenerateError("Illegal label reference " + ID.getName());
967 return 0;
968 }
969
970 // If its already been defined, return it now.
971 if (BB) {
972 ID.destroy(); // Free strdup'd memory.
973 return BB;
974 }
975
976 // Otherwise, this block has not been seen before, create it.
977 std::string Name;
978 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000979 Name = ID.getName();
Gabor Greife64d2482008-04-06 23:07:54 +0000980 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Reid Spencer93c40032007-03-19 18:40:50 +0000981
982 // Insert it in the forward refs map.
983 CurFun.BBForwardRefs[ID] = BB;
984
Reid Spencer68a24bd2005-08-27 18:50:39 +0000985 return BB;
986}
987
988
989//===----------------------------------------------------------------------===//
990// Code to handle forward references in instructions
991//===----------------------------------------------------------------------===//
992//
993// This code handles the late binding needed with statements that reference
994// values not defined yet... for example, a forward branch, or the PHI node for
995// a loop body.
996//
997// This keeps a table (CurFun.LateResolveValues) of all such forward references
998// and back patchs after we are done.
999//
1000
1001// ResolveDefinitions - If we could not resolve some defs at parsing
1002// time (forward branches, phi functions for loops, etc...) resolve the
1003// defs now...
1004//
1005static void
Reid Spencer93c40032007-03-19 18:40:50 +00001006ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001007 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +00001008 while (!LateResolvers.empty()) {
1009 Value *V = LateResolvers.back();
1010 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001011
Reid Spencer93c40032007-03-19 18:40:50 +00001012 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1013 CurModule.PlaceHolderInfo.find(V);
1014 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001015
Reid Spencer93c40032007-03-19 18:40:50 +00001016 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001017
Reid Spencer93c40032007-03-19 18:40:50 +00001018 Value *TheRealValue = getExistingVal(V->getType(), DID);
1019 if (TriggerError)
1020 return;
1021 if (TheRealValue) {
1022 V->replaceAllUsesWith(TheRealValue);
1023 delete V;
1024 CurModule.PlaceHolderInfo.erase(PHI);
1025 } else if (FutureLateResolvers) {
1026 // Functions have their unresolved items forwarded to the module late
1027 // resolver table
1028 InsertValue(V, *FutureLateResolvers);
1029 } else {
1030 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1031 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1032 "' of type '" + V->getType()->getDescription() + "'",
1033 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001034 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001035 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001036 GenerateError("Reference to an invalid definition: #" +
1037 itostr(DID.Num) + " of type '" +
1038 V->getType()->getDescription() + "'",
1039 PHI->second.second);
1040 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001041 }
1042 }
1043 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001044 LateResolvers.clear();
1045}
1046
1047// ResolveTypeTo - A brand new type was just declared. This means that (if
1048// name is not null) things referencing Name can be resolved. Otherwise, things
1049// refering to the number can be resolved. Do this now.
1050//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001051static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001052 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001053 if (Name)
1054 D = ValID::createLocalName(*Name);
1055 else
1056 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001057
Reid Spencer861d9d62006-11-28 07:29:44 +00001058 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001059 CurModule.LateResolveTypes.find(D);
1060 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001061 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001062 CurModule.LateResolveTypes.erase(I);
1063 }
1064}
1065
1066// setValueName - Set the specified value to the name given. The name may be
1067// null potentially, in which case this is a noop. The string passed in is
1068// assumed to be a malloc'd string buffer, and is free'd by this function.
1069//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001070static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001071 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001072 std::string Name(*NameStr); // Copy string
1073 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001074
Reid Spencer41dff5e2007-01-26 08:05:27 +00001075 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001076 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001077 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001078 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001079
Reid Spencera9720f52007-02-05 17:04:00 +00001080 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001081 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1082 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001083 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001084 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001085 return;
1086 }
1087
1088 // Set the name.
1089 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001090}
1091
1092/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1093/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001094static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001095ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001096 GlobalValue::LinkageTypes Linkage,
1097 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001098 bool isConstantGlobal, const Type *Ty,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001099 Constant *Initializer, bool IsThreadLocal,
1100 unsigned AddressSpace = 0) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001101 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001102 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001103 return 0;
1104 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001105
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001106 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001107
1108 std::string Name;
1109 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001110 Name = *NameStr; // Copy string
1111 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001112 }
1113
1114 // See if this global value was forward referenced. If so, recycle the
1115 // object.
1116 ValID ID;
1117 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001118 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001119 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001120 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001121 }
1122
1123 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1124 // Move the global to the end of the list, from whereever it was
1125 // previously inserted.
1126 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1127 CurModule.CurrentModule->getGlobalList().remove(GV);
1128 CurModule.CurrentModule->getGlobalList().push_back(GV);
1129 GV->setInitializer(Initializer);
1130 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001131 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001132 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001133 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001134 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001135 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001136 }
1137
Reid Spenceref9b9a72007-02-05 20:47:22 +00001138 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001139 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001140 // if the global we're parsing has an initializer (is a definition) and
1141 // has external linkage.
1142 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1143 // If there is already a global with external linkage with this name
1144 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1145 // If we allow this GVar to get created, it will be renamed in the
1146 // symbol table because it conflicts with an existing GVar. We can't
1147 // allow redefinition of GVars whose linking indicates that their name
1148 // must stay the same. Issue the error.
1149 GenerateError("Redefinition of global variable named '" + Name +
1150 "' of type '" + Ty->getDescription() + "'");
1151 return 0;
1152 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001153 }
1154
1155 // Otherwise there is no existing GV to use, create one now.
1156 GlobalVariable *GV =
1157 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001158 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001159 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001160 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001161 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001162}
1163
1164// setTypeName - Set the specified type to the name given. The name may be
1165// null potentially, in which case this is a noop. The string passed in is
1166// assumed to be a malloc'd string buffer, and is freed by this function.
1167//
1168// This function returns true if the type has already been defined, but is
1169// allowed to be redefined in the specified context. If the name is a new name
1170// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001171static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001172 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001173 if (NameStr == 0) return false;
1174
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001175 std::string Name(*NameStr); // Copy string
1176 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001177
1178 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001179 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001180 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001181 return false;
1182 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001183
1184 // Set the type name, checking for conflicts as we do so.
1185 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1186
1187 if (AlreadyExists) { // Inserting a name that is already defined???
1188 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001189 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001190
1191 // There is only one case where this is allowed: when we are refining an
1192 // opaque type. In this case, Existing will be an opaque type.
1193 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1194 // We ARE replacing an opaque type!
1195 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1196 return true;
1197 }
1198
1199 // Otherwise, this is an attempt to redefine a type. That's okay if
1200 // the redefinition is identical to the original. This will be so if
1201 // Existing and T point to the same Type object. In this one case we
1202 // allow the equivalent redefinition.
1203 if (Existing == T) return true; // Yes, it's equal.
1204
1205 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001206 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001207 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001208 }
1209
1210 return false;
1211}
1212
1213//===----------------------------------------------------------------------===//
1214// Code for handling upreferences in type names...
1215//
1216
1217// TypeContains - Returns true if Ty directly contains E in it.
1218//
1219static bool TypeContains(const Type *Ty, const Type *E) {
1220 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1221 E) != Ty->subtype_end();
1222}
1223
1224namespace {
1225 struct UpRefRecord {
1226 // NestingLevel - The number of nesting levels that need to be popped before
1227 // this type is resolved.
1228 unsigned NestingLevel;
1229
1230 // LastContainedTy - This is the type at the current binding level for the
1231 // type. Every time we reduce the nesting level, this gets updated.
1232 const Type *LastContainedTy;
1233
1234 // UpRefTy - This is the actual opaque type that the upreference is
1235 // represented with.
1236 OpaqueType *UpRefTy;
1237
1238 UpRefRecord(unsigned NL, OpaqueType *URTy)
1239 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1240 };
1241}
1242
1243// UpRefs - A list of the outstanding upreferences that need to be resolved.
1244static std::vector<UpRefRecord> UpRefs;
1245
1246/// HandleUpRefs - Every time we finish a new layer of types, this function is
1247/// called. It loops through the UpRefs vector, which is a list of the
1248/// currently active types. For each type, if the up reference is contained in
1249/// the newly completed type, we decrement the level count. When the level
1250/// count reaches zero, the upreferenced type is the type that is passed in:
1251/// thus we can complete the cycle.
1252///
1253static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001254 // If Ty isn't abstract, or if there are no up-references in it, then there is
1255 // nothing to resolve here.
1256 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1257
Reid Spencer68a24bd2005-08-27 18:50:39 +00001258 PATypeHolder Ty(ty);
1259 UR_OUT("Type '" << Ty->getDescription() <<
1260 "' newly formed. Resolving upreferences.\n" <<
1261 UpRefs.size() << " upreferences active!\n");
1262
1263 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1264 // to zero), we resolve them all together before we resolve them to Ty. At
1265 // the end of the loop, if there is anything to resolve to Ty, it will be in
1266 // this variable.
1267 OpaqueType *TypeToResolve = 0;
1268
1269 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1270 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1271 << UpRefs[i].second->getDescription() << ") = "
1272 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1273 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1274 // Decrement level of upreference
1275 unsigned Level = --UpRefs[i].NestingLevel;
1276 UpRefs[i].LastContainedTy = Ty;
1277 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1278 if (Level == 0) { // Upreference should be resolved!
1279 if (!TypeToResolve) {
1280 TypeToResolve = UpRefs[i].UpRefTy;
1281 } else {
1282 UR_OUT(" * Resolving upreference for "
1283 << UpRefs[i].second->getDescription() << "\n";
1284 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1285 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1286 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1287 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1288 }
1289 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1290 --i; // Do not skip the next element...
1291 }
1292 }
1293 }
1294
1295 if (TypeToResolve) {
1296 UR_OUT(" * Resolving upreference for "
1297 << UpRefs[i].second->getDescription() << "\n";
1298 std::string OldName = TypeToResolve->getDescription());
1299 TypeToResolve->refineAbstractTypeTo(Ty);
1300 }
1301
1302 return Ty;
1303}
1304
Reid Spencer68a24bd2005-08-27 18:50:39 +00001305//===----------------------------------------------------------------------===//
1306// RunVMAsmParser - Define an interface to this parser
1307//===----------------------------------------------------------------------===//
1308//
Reid Spencer14310612006-12-31 05:40:51 +00001309static Module* RunParser(Module * M);
1310
Duncan Sandsdc024672007-11-27 13:23:08 +00001311Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1312 InitLLLexer(MB);
1313 Module *M = RunParser(new Module(LLLgetFilename()));
1314 FreeLexer();
1315 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001316}
1317
1318
Dan Gohmanf4423b12008-04-19 00:24:39 +00001319
1320/* Enabling traces. */
1321#ifndef YYDEBUG
1322# define YYDEBUG 0
1323#endif
1324
1325/* Enabling verbose error messages. */
1326#ifdef YYERROR_VERBOSE
1327# undef YYERROR_VERBOSE
1328# define YYERROR_VERBOSE 1
1329#else
1330# define YYERROR_VERBOSE 0
1331#endif
1332
1333/* Enabling the token table. */
1334#ifndef YYTOKEN_TABLE
1335# define YYTOKEN_TABLE 0
1336#endif
1337
1338#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1339typedef union YYSTYPE
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00001340#line 950 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001341{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001342 llvm::Module *ModuleVal;
1343 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001344 llvm::BasicBlock *BasicBlockVal;
1345 llvm::TerminatorInst *TermInstVal;
1346 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001347 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001348
Reid Spencera132e042006-12-03 05:46:11 +00001349 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001350 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001351 llvm::PATypeHolder *TypeVal;
1352 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001353 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001354 llvm::ArgListType *ArgList;
1355 llvm::TypeWithAttrs TypeWithAttrs;
1356 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001357 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001358
Reid Spencer68a24bd2005-08-27 18:50:39 +00001359 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001360 std::list<std::pair<llvm::Value*,
1361 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001362 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001363 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001364
1365 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001366 llvm::GlobalValue::VisibilityTypes Visibility;
Dale Johannesen222ebf72008-02-19 21:40:51 +00001367 llvm::ParameterAttributes ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001368 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001369 int64_t SInt64Val;
1370 uint64_t UInt64Val;
1371 int SIntVal;
1372 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001373 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001374 bool BoolVal;
1375
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001376 std::string *StrVal; // This memory must be deleted
1377 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001378
Reid Spencera132e042006-12-03 05:46:11 +00001379 llvm::Instruction::BinaryOps BinaryOpVal;
1380 llvm::Instruction::TermOps TermOpVal;
1381 llvm::Instruction::MemoryOps MemOpVal;
1382 llvm::Instruction::CastOps CastOpVal;
1383 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001384 llvm::ICmpInst::Predicate IPredicate;
1385 llvm::FCmpInst::Predicate FPredicate;
Dan Gohmanf4423b12008-04-19 00:24:39 +00001386}
1387/* Line 193 of yacc.c. */
1388#line 1389 "llvmAsmParser.tab.c"
1389 YYSTYPE;
1390# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1391# define YYSTYPE_IS_DECLARED 1
1392# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001393#endif
1394
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001395
Reid Spencer68a24bd2005-08-27 18:50:39 +00001396
Dan Gohmanf4423b12008-04-19 00:24:39 +00001397/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001398
1399
Dan Gohmanf4423b12008-04-19 00:24:39 +00001400/* Line 216 of yacc.c. */
1401#line 1402 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001402
Dan Gohmanf4423b12008-04-19 00:24:39 +00001403#ifdef short
1404# undef short
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001405#endif
1406
Dan Gohmanf4423b12008-04-19 00:24:39 +00001407#ifdef YYTYPE_UINT8
1408typedef YYTYPE_UINT8 yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001409#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00001410typedef unsigned char yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001411#endif
1412
Dan Gohmanf4423b12008-04-19 00:24:39 +00001413#ifdef YYTYPE_INT8
1414typedef YYTYPE_INT8 yytype_int8;
1415#elif (defined __STDC__ || defined __C99__FUNC__ \
1416 || defined __cplusplus || defined _MSC_VER)
1417typedef signed char yytype_int8;
1418#else
1419typedef short int yytype_int8;
1420#endif
1421
1422#ifdef YYTYPE_UINT16
1423typedef YYTYPE_UINT16 yytype_uint16;
1424#else
1425typedef unsigned short int yytype_uint16;
1426#endif
1427
1428#ifdef YYTYPE_INT16
1429typedef YYTYPE_INT16 yytype_int16;
1430#else
1431typedef short int yytype_int16;
1432#endif
1433
1434#ifndef YYSIZE_T
1435# ifdef __SIZE_TYPE__
1436# define YYSIZE_T __SIZE_TYPE__
1437# elif defined size_t
1438# define YYSIZE_T size_t
1439# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1440 || defined __cplusplus || defined _MSC_VER)
1441# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1442# define YYSIZE_T size_t
1443# else
1444# define YYSIZE_T unsigned int
1445# endif
1446#endif
1447
1448#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1449
1450#ifndef YY_
1451# if defined YYENABLE_NLS && YYENABLE_NLS
1452# if ENABLE_NLS
1453# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1454# define YY_(msgid) dgettext ("bison-runtime", msgid)
1455# endif
1456# endif
1457# ifndef YY_
1458# define YY_(msgid) msgid
1459# endif
1460#endif
1461
1462/* Suppress unused-variable warnings by "using" E. */
1463#if ! defined lint || defined __GNUC__
1464# define YYUSE(e) ((void) (e))
1465#else
1466# define YYUSE(e) /* empty */
1467#endif
1468
1469/* Identity function, used to suppress warnings about constant conditions. */
1470#ifndef lint
1471# define YYID(n) (n)
1472#else
1473#if (defined __STDC__ || defined __C99__FUNC__ \
1474 || defined __cplusplus || defined _MSC_VER)
1475static int
1476YYID (int i)
1477#else
1478static int
1479YYID (i)
1480 int i;
1481#endif
1482{
1483 return i;
1484}
1485#endif
1486
1487#if ! defined yyoverflow || YYERROR_VERBOSE
1488
1489/* The parser invokes alloca or malloc; define the necessary symbols. */
1490
1491# ifdef YYSTACK_USE_ALLOCA
1492# if YYSTACK_USE_ALLOCA
1493# ifdef __GNUC__
1494# define YYSTACK_ALLOC __builtin_alloca
1495# elif defined __BUILTIN_VA_ARG_INCR
1496# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1497# elif defined _AIX
1498# define YYSTACK_ALLOC __alloca
1499# elif defined _MSC_VER
1500# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1501# define alloca _alloca
1502# else
1503# define YYSTACK_ALLOC alloca
1504# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1505 || defined __cplusplus || defined _MSC_VER)
1506# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1507# ifndef _STDLIB_H
1508# define _STDLIB_H 1
1509# endif
1510# endif
1511# endif
1512# endif
1513# endif
1514
1515# ifdef YYSTACK_ALLOC
1516 /* Pacify GCC's `empty if-body' warning. */
1517# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1518# ifndef YYSTACK_ALLOC_MAXIMUM
1519 /* The OS might guarantee only one guard page at the bottom of the stack,
1520 and a page size can be as small as 4096 bytes. So we cannot safely
1521 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1522 to allow for a few compiler-allocated temporary stack slots. */
1523# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1524# endif
1525# else
1526# define YYSTACK_ALLOC YYMALLOC
1527# define YYSTACK_FREE YYFREE
1528# ifndef YYSTACK_ALLOC_MAXIMUM
1529# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1530# endif
1531# if (defined __cplusplus && ! defined _STDLIB_H \
1532 && ! ((defined YYMALLOC || defined malloc) \
1533 && (defined YYFREE || defined free)))
1534# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1535# ifndef _STDLIB_H
1536# define _STDLIB_H 1
1537# endif
1538# endif
1539# ifndef YYMALLOC
1540# define YYMALLOC malloc
1541# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1542 || defined __cplusplus || defined _MSC_VER)
1543void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1544# endif
1545# endif
1546# ifndef YYFREE
1547# define YYFREE free
1548# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1549 || defined __cplusplus || defined _MSC_VER)
1550void free (void *); /* INFRINGES ON USER NAME SPACE */
1551# endif
1552# endif
1553# endif
1554#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1555
1556
1557#if (! defined yyoverflow \
1558 && (! defined __cplusplus \
1559 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1560
1561/* A type that is properly aligned for any stack member. */
1562union yyalloc
1563{
1564 yytype_int16 yyss;
1565 YYSTYPE yyvs;
1566 };
1567
1568/* The size of the maximum gap between one aligned stack and the next. */
1569# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1570
1571/* The size of an array large to enough to hold all stacks, each with
1572 N elements. */
1573# define YYSTACK_BYTES(N) \
1574 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1575 + YYSTACK_GAP_MAXIMUM)
1576
1577/* Copy COUNT objects from FROM to TO. The source and destination do
1578 not overlap. */
1579# ifndef YYCOPY
1580# if defined __GNUC__ && 1 < __GNUC__
1581# define YYCOPY(To, From, Count) \
1582 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1583# else
1584# define YYCOPY(To, From, Count) \
1585 do \
1586 { \
1587 YYSIZE_T yyi; \
1588 for (yyi = 0; yyi < (Count); yyi++) \
1589 (To)[yyi] = (From)[yyi]; \
1590 } \
1591 while (YYID (0))
1592# endif
1593# endif
1594
1595/* Relocate STACK from its old location to the new one. The
1596 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1597 elements in the stack, and YYPTR gives the new location of the
1598 stack. Advance YYPTR to a properly aligned location for the next
1599 stack. */
1600# define YYSTACK_RELOCATE(Stack) \
1601 do \
1602 { \
1603 YYSIZE_T yynewbytes; \
1604 YYCOPY (&yyptr->Stack, Stack, yysize); \
1605 Stack = &yyptr->Stack; \
1606 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1607 yyptr += yynewbytes / sizeof (*yyptr); \
1608 } \
1609 while (YYID (0))
1610
1611#endif
1612
1613/* YYFINAL -- State number of the termination state. */
1614#define YYFINAL 43
1615/* YYLAST -- Last index in YYTABLE. */
1616#define YYLAST 2015
1617
1618/* YYNTOKENS -- Number of terminals. */
1619#define YYNTOKENS 166
1620/* YYNNTS -- Number of nonterminals. */
1621#define YYNNTS 85
1622/* YYNRULES -- Number of rules. */
1623#define YYNRULES 324
1624/* YYNRULES -- Number of states. */
1625#define YYNSTATES 635
1626
1627/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1628#define YYUNDEFTOK 2
1629#define YYMAXUTOK 406
1630
1631#define YYTRANSLATE(YYX) \
1632 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1633
1634/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1635static const yytype_uint8 yytranslate[] =
1636{
1637 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1638 2, 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 152, 153, 156, 2, 155, 2, 2, 2, 2, 2,
1642 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1643 161, 154, 162, 2, 2, 2, 2, 2, 2, 2,
1644 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1646 2, 158, 157, 160, 2, 2, 2, 2, 2, 165,
1647 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1649 159, 2, 2, 163, 2, 164, 2, 2, 2, 2,
1650 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1651 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1653 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1656 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1659 2, 2, 2, 2, 2, 2, 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, 1, 2, 3, 4,
1663 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1664 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1665 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1666 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1667 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1668 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1669 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1670 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1671 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1672 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1673 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1674 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1675 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1676 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1677 145, 146, 147, 148, 149, 150, 151
1678};
1679
1680#if YYDEBUG
1681/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1682 YYRHS. */
1683static const yytype_uint16 yyprhs[] =
1684{
1685 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1686 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1687 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1688 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1689 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1690 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1691 119, 121, 123, 125, 127, 129, 130, 135, 136, 139,
1692 140, 142, 144, 146, 147, 150, 152, 154, 156, 158,
1693 160, 162, 164, 166, 167, 169, 171, 173, 174, 176,
1694 178, 179, 181, 183, 185, 187, 188, 190, 192, 193,
1695 195, 197, 199, 201, 203, 206, 208, 210, 212, 214,
1696 216, 218, 220, 222, 224, 227, 228, 231, 233, 235,
1697 237, 239, 241, 243, 244, 247, 248, 251, 252, 255,
1698 256, 260, 263, 264, 266, 267, 271, 273, 276, 278,
1699 280, 282, 284, 286, 288, 290, 292, 294, 298, 300,
1700 303, 309, 315, 321, 327, 331, 334, 340, 345, 348,
1701 350, 352, 354, 358, 360, 364, 366, 367, 369, 373,
1702 378, 382, 386, 391, 396, 400, 407, 413, 416, 419,
1703 422, 425, 428, 431, 434, 437, 440, 443, 446, 449,
1704 456, 462, 471, 478, 485, 493, 501, 508, 517, 526,
1705 530, 532, 534, 536, 538, 539, 542, 549, 551, 552,
1706 554, 557, 558, 562, 563, 567, 571, 575, 579, 580,
1707 589, 590, 600, 601, 611, 617, 620, 624, 626, 630,
1708 634, 638, 642, 644, 645, 651, 655, 657, 661, 663,
1709 664, 675, 677, 679, 684, 686, 688, 691, 695, 696,
1710 698, 700, 702, 704, 706, 708, 710, 712, 714, 718,
1711 720, 726, 728, 730, 732, 734, 736, 738, 741, 743,
1712 747, 750, 753, 757, 760, 761, 765, 767, 772, 775,
1713 778, 782, 792, 802, 811, 826, 828, 830, 837, 843,
1714 846, 853, 861, 866, 871, 878, 885, 886, 887, 891,
1715 894, 896, 902, 908, 915, 922, 927, 934, 939, 944,
1716 951, 958, 961, 970, 972, 974, 975, 979, 986, 990,
1717 997, 1000, 1006, 1014, 1020
1718};
1719
1720/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1721static const yytype_int16 yyrhs[] =
1722{
1723 212, 0, -1, 75, -1, 76, -1, 77, -1, 78,
1724 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
1725 -1, 87, -1, 88, -1, 89, -1, 84, -1, 85,
1726 -1, 86, -1, 118, -1, 119, -1, 120, -1, 121,
1727 -1, 122, -1, 123, -1, 124, -1, 125, -1, 126,
1728 -1, 127, -1, 128, -1, 129, -1, 92, -1, 93,
1729 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
1730 -1, 99, -1, 100, -1, 101, -1, 102, -1, 103,
1731 -1, 104, -1, 105, -1, 106, -1, 107, -1, 108,
1732 -1, 109, -1, 110, -1, 111, -1, 98, -1, 99,
1733 -1, 100, -1, 101, -1, 26, -1, 27, -1, 11,
1734 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1735 -1, 19, -1, 22, -1, 24, -1, 174, -1, -1,
1736 54, 152, 4, 153, -1, -1, 174, 154, -1, -1,
1737 20, -1, 23, -1, 180, -1, -1, 178, 154, -1,
1738 42, -1, 44, -1, 43, -1, 45, -1, 47, -1,
1739 46, -1, 48, -1, 50, -1, -1, 149, -1, 150,
1740 -1, 151, -1, -1, 46, -1, 48, -1, -1, 42,
1741 -1, 43, -1, 44, -1, 47, -1, -1, 44, -1,
1742 42, -1, -1, 62, -1, 63, -1, 64, -1, 65,
1743 -1, 66, -1, 61, 4, -1, 138, -1, 119, -1,
1744 137, -1, 120, -1, 140, -1, 141, -1, 143, -1,
1745 144, -1, 145, -1, 53, 4, -1, -1, 189, 188,
1746 -1, 139, -1, 142, -1, 138, -1, 137, -1, 146,
1747 -1, 147, -1, -1, 191, 190, -1, -1, 148, 22,
1748 -1, -1, 53, 4, -1, -1, 155, 53, 4, -1,
1749 34, 22, -1, -1, 195, -1, -1, 155, 198, 197,
1750 -1, 195, -1, 53, 4, -1, 11, -1, 12, -1,
1751 13, -1, 16, -1, 15, -1, 14, -1, 17, -1,
1752 49, -1, 199, -1, 200, 176, 156, -1, 234, -1,
1753 157, 4, -1, 200, 152, 204, 153, 191, -1, 10,
1754 152, 204, 153, 191, -1, 158, 4, 159, 200, 160,
1755 -1, 161, 4, 159, 200, 162, -1, 163, 205, 164,
1756 -1, 163, 164, -1, 161, 163, 205, 164, 162, -1,
1757 161, 163, 164, 162, -1, 200, 189, -1, 200, -1,
1758 10, -1, 201, -1, 203, 155, 201, -1, 203, -1,
1759 203, 155, 39, -1, 39, -1, -1, 200, -1, 205,
1760 155, 200, -1, 200, 158, 208, 160, -1, 200, 158,
1761 160, -1, 200, 165, 22, -1, 200, 161, 208, 162,
1762 -1, 200, 163, 208, 164, -1, 200, 163, 164, -1,
1763 200, 161, 163, 208, 164, 162, -1, 200, 161, 163,
1764 164, 162, -1, 200, 40, -1, 200, 41, -1, 200,
1765 234, -1, 200, 207, -1, 200, 25, -1, 172, 3,
1766 -1, 172, 5, -1, 172, 4, -1, 172, 6, -1,
1767 11, 26, -1, 11, 27, -1, 173, 9, -1, 169,
1768 152, 206, 38, 200, 153, -1, 117, 152, 206, 246,
1769 153, -1, 131, 152, 206, 155, 206, 155, 206, 153,
1770 -1, 167, 152, 206, 155, 206, 153, -1, 168, 152,
1771 206, 155, 206, 153, -1, 90, 170, 152, 206, 155,
1772 206, 153, -1, 91, 171, 152, 206, 155, 206, 153,
1773 -1, 133, 152, 206, 155, 206, 153, -1, 134, 152,
1774 206, 155, 206, 155, 206, 153, -1, 135, 152, 206,
1775 155, 206, 155, 206, 153, -1, 208, 155, 206, -1,
1776 206, -1, 32, -1, 33, -1, 37, -1, -1, 202,
1777 234, -1, 123, 152, 211, 38, 200, 153, -1, 213,
1778 -1, -1, 214, -1, 213, 214, -1, -1, 31, 215,
1779 230, -1, -1, 30, 216, 231, -1, 59, 58, 220,
1780 -1, 177, 18, 200, -1, 177, 18, 10, -1, -1,
1781 179, 183, 210, 209, 206, 176, 217, 197, -1, -1,
1782 179, 181, 183, 210, 209, 206, 176, 218, 197, -1,
1783 -1, 179, 182, 183, 210, 209, 200, 176, 219, 197,
1784 -1, 179, 183, 35, 186, 211, -1, 51, 221, -1,
1785 55, 154, 222, -1, 22, -1, 52, 154, 22, -1,
1786 67, 154, 22, -1, 158, 223, 160, -1, 223, 155,
1787 22, -1, 22, -1, -1, 224, 155, 200, 189, 175,
1788 -1, 200, 189, 175, -1, 224, -1, 224, 155, 39,
1789 -1, 39, -1, -1, 187, 202, 178, 152, 225, 153,
1790 191, 196, 193, 192, -1, 28, -1, 163, -1, 185,
1791 183, 226, 227, -1, 29, -1, 164, -1, 238, 229,
1792 -1, 184, 183, 226, -1, -1, 60, -1, 3, -1,
1793 4, -1, 9, -1, 26, -1, 27, -1, 40, -1,
1794 41, -1, 25, -1, 161, 208, 162, -1, 207, -1,
1795 58, 232, 22, 155, 22, -1, 7, -1, 8, -1,
1796 174, -1, 178, -1, 234, -1, 233, -1, 200, 235,
1797 -1, 236, -1, 237, 155, 236, -1, 238, 239, -1,
1798 228, 239, -1, 240, 177, 241, -1, 240, 243, -1,
1799 -1, 68, 38, 235, -1, 21, -1, 21, 68, 38,
1800 235, -1, 69, 237, -1, 69, 10, -1, 70, 17,
1801 235, -1, 70, 11, 235, 155, 17, 235, 155, 17,
1802 235, -1, 71, 172, 235, 155, 17, 235, 158, 242,
1803 160, -1, 71, 172, 235, 155, 17, 235, 158, 160,
1804 -1, 72, 187, 202, 235, 152, 245, 153, 191, 38,
1805 17, 235, 73, 17, 235, -1, 73, -1, 74, -1,
1806 242, 172, 233, 155, 17, 235, -1, 172, 233, 155,
1807 17, 235, -1, 177, 248, -1, 200, 158, 235, 155,
1808 235, 160, -1, 244, 155, 158, 235, 155, 235, 160,
1809 -1, 200, 189, 235, 189, -1, 17, 189, 235, 189,
1810 -1, 245, 155, 200, 189, 235, 189, -1, 245, 155,
1811 17, 189, 235, 189, -1, -1, -1, 246, 155, 236,
1812 -1, 57, 56, -1, 56, -1, 167, 200, 235, 155,
1813 235, -1, 168, 200, 235, 155, 235, -1, 90, 170,
1814 200, 235, 155, 235, -1, 91, 171, 200, 235, 155,
1815 235, -1, 169, 236, 38, 200, -1, 131, 236, 155,
1816 236, 155, 236, -1, 132, 236, 155, 200, -1, 133,
1817 236, 155, 236, -1, 134, 236, 155, 236, 155, 236,
1818 -1, 135, 236, 155, 236, 155, 236, -1, 130, 244,
1819 -1, 247, 187, 202, 235, 152, 245, 153, 191, -1,
1820 250, -1, 36, -1, -1, 112, 200, 194, -1, 112,
1821 200, 155, 11, 235, 194, -1, 113, 200, 194, -1,
1822 113, 200, 155, 11, 235, 194, -1, 114, 236, -1,
1823 249, 115, 200, 235, 194, -1, 249, 116, 236, 155,
1824 200, 235, 194, -1, 136, 200, 234, 155, 4, -1,
1825 117, 200, 235, 246, -1
1826};
1827
1828/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1829static const yytype_uint16 yyrline[] =
1830{
1831 0, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112,
1832 1112, 1113, 1113, 1113, 1113, 1113, 1113, 1114, 1114, 1114,
1833 1114, 1114, 1114, 1115, 1115, 1115, 1115, 1115, 1115, 1118,
1834 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1122, 1122, 1126,
1835 1126, 1127, 1127, 1128, 1128, 1129, 1129, 1130, 1130, 1131,
1836 1131, 1132, 1132, 1133, 1134, 1139, 1140, 1140, 1140, 1140,
1837 1140, 1142, 1142, 1142, 1143, 1143, 1145, 1146, 1150, 1154,
1838 1159, 1159, 1161, 1162, 1167, 1173, 1174, 1175, 1176, 1177,
1839 1181, 1182, 1183, 1187, 1188, 1189, 1190, 1194, 1195, 1196,
1840 1200, 1201, 1202, 1203, 1204, 1208, 1209, 1210, 1213, 1214,
1841 1215, 1216, 1217, 1218, 1219, 1226, 1227, 1228, 1229, 1230,
1842 1231, 1232, 1233, 1234, 1235, 1239, 1240, 1245, 1246, 1247,
1843 1248, 1249, 1250, 1253, 1254, 1259, 1260, 1267, 1268, 1274,
1844 1275, 1284, 1292, 1293, 1298, 1299, 1300, 1305, 1318, 1318,
1845 1318, 1318, 1318, 1318, 1318, 1321, 1325, 1329, 1336, 1341,
1846 1349, 1380, 1405, 1410, 1420, 1430, 1434, 1444, 1451, 1460,
1847 1467, 1472, 1477, 1484, 1485, 1492, 1499, 1507, 1513, 1525,
1848 1553, 1569, 1596, 1624, 1650, 1670, 1696, 1716, 1728, 1735,
1849 1801, 1811, 1821, 1827, 1837, 1843, 1853, 1858, 1863, 1876,
1850 1888, 1910, 1918, 1924, 1935, 1940, 1945, 1951, 1957, 1966,
1851 1970, 1978, 1978, 1981, 1981, 1984, 1996, 2017, 2022, 2030,
1852 2031, 2035, 2035, 2039, 2039, 2042, 2045, 2069, 2081, 2080,
1853 2092, 2091, 2101, 2100, 2111, 2151, 2154, 2160, 2170, 2174,
1854 2179, 2181, 2186, 2191, 2200, 2210, 2221, 2225, 2234, 2243,
1855 2248, 2374, 2374, 2376, 2385, 2385, 2387, 2392, 2404, 2408,
1856 2413, 2417, 2421, 2425, 2429, 2433, 2437, 2441, 2445, 2470,
1857 2474, 2484, 2488, 2492, 2497, 2504, 2504, 2510, 2519, 2524,
1858 2529, 2533, 2542, 2551, 2560, 2564, 2568, 2573, 2580, 2587,
1859 2591, 2596, 2606, 2625, 2634, 2715, 2719, 2726, 2737, 2750,
1860 2760, 2771, 2781, 2792, 2800, 2810, 2817, 2820, 2821, 2828,
1861 2832, 2837, 2853, 2870, 2884, 2898, 2910, 2918, 2925, 2931,
1862 2937, 2943, 2958, 3044, 3049, 3053, 3060, 3067, 3075, 3082,
1863 3090, 3098, 3112, 3129, 3137
1864};
1865#endif
1866
1867#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1868/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1869 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1870static const char *const yytname[] =
1871{
1872 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1873 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1874 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1875 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1876 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1877 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1878 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1879 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1880 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1881 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1882 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1883 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
1884 "DATALAYOUT", "UNWINDS", "RET", "BR", "SWITCH", "INVOKE", "UNWIND",
1885 "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM",
1886 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP",
1887 "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1888 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1889 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1890 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1891 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1892 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1893 "GETRESULT", "SIGNEXT", "ZEROEXT", "NORETURN", "INREG", "SRET",
1894 "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "READNONE", "READONLY", "GC",
1895 "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'",
1896 "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'",
1897 "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates",
1898 "FPredicates", "IntType", "FPType", "LocalName", "OptLocalName",
1899 "OptAddrSpace", "OptLocalAssign", "GlobalName", "OptGlobalAssign",
1900 "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1901 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1902 "AliasLinkage", "OptCallingConv", "ParamAttr", "OptParamAttrs",
1903 "FuncAttr", "OptFuncAttrs", "OptGC", "OptAlign", "OptCAlign",
1904 "SectionString", "OptSection", "GlobalVarAttributes",
1905 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1906 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1907 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1908 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1909 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1910 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1911 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1912 "SymbolicValueRef", "ValueRef", "ResolvedVal", "ReturnedVal",
1913 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1914 "JumpTable", "Inst", "PHIList", "ParamList", "IndexList", "OptTailCall",
1915 "InstVal", "OptVolatile", "MemoryInst", 0
1916};
1917#endif
1918
1919# ifdef YYPRINT
1920/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1921 token YYLEX-NUM. */
1922static const yytype_uint16 yytoknum[] =
1923{
1924 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1925 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1926 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1927 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1928 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1929 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1930 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1931 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1932 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1933 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1934 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1935 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1936 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1937 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1938 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
1939 405, 406, 40, 41, 61, 44, 42, 92, 91, 120,
1940 93, 60, 62, 123, 125, 99
1941};
1942# endif
1943
1944/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1945static const yytype_uint8 yyr1[] =
1946{
1947 0, 166, 167, 167, 167, 167, 167, 167, 167, 167,
1948 167, 168, 168, 168, 168, 168, 168, 169, 169, 169,
1949 169, 169, 169, 169, 169, 169, 169, 169, 169, 170,
1950 170, 170, 170, 170, 170, 170, 170, 170, 170, 171,
1951 171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
1952 171, 171, 171, 171, 171, 172, 173, 173, 173, 173,
1953 173, 174, 174, 174, 175, 175, 176, 176, 177, 177,
1954 178, 178, 179, 179, 180, 181, 181, 181, 181, 181,
1955 182, 182, 182, 183, 183, 183, 183, 184, 184, 184,
1956 185, 185, 185, 185, 185, 186, 186, 186, 187, 187,
1957 187, 187, 187, 187, 187, 188, 188, 188, 188, 188,
1958 188, 188, 188, 188, 188, 189, 189, 190, 190, 190,
1959 190, 190, 190, 191, 191, 192, 192, 193, 193, 194,
1960 194, 195, 196, 196, 197, 197, 198, 198, 199, 199,
1961 199, 199, 199, 199, 199, 200, 200, 200, 200, 200,
1962 200, 200, 200, 200, 200, 200, 200, 200, 201, 202,
1963 202, 203, 203, 204, 204, 204, 204, 205, 205, 206,
1964 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
1965 206, 206, 206, 206, 206, 206, 206, 206, 206, 207,
1966 207, 207, 207, 207, 207, 207, 207, 207, 207, 208,
1967 208, 209, 209, 210, 210, 211, 211, 212, 212, 213,
1968 213, 215, 214, 216, 214, 214, 214, 214, 217, 214,
1969 218, 214, 219, 214, 214, 214, 214, 220, 221, 221,
1970 222, 223, 223, 223, 224, 224, 225, 225, 225, 225,
1971 226, 227, 227, 228, 229, 229, 230, 231, 232, 232,
1972 233, 233, 233, 233, 233, 233, 233, 233, 233, 233,
1973 233, 234, 234, 234, 234, 235, 235, 236, 237, 237,
1974 238, 238, 239, 240, 240, 240, 240, 240, 241, 241,
1975 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
1976 244, 244, 245, 245, 245, 245, 245, 246, 246, 247,
1977 247, 248, 248, 248, 248, 248, 248, 248, 248, 248,
1978 248, 248, 248, 248, 249, 249, 250, 250, 250, 250,
1979 250, 250, 250, 250, 250
1980};
1981
1982/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1983static const yytype_uint8 yyr2[] =
1984{
1985 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1986 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1987 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1988 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1989 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1990 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1991 1, 1, 1, 1, 1, 0, 4, 0, 2, 0,
1992 1, 1, 1, 0, 2, 1, 1, 1, 1, 1,
1993 1, 1, 1, 0, 1, 1, 1, 0, 1, 1,
1994 0, 1, 1, 1, 1, 0, 1, 1, 0, 1,
1995 1, 1, 1, 1, 2, 1, 1, 1, 1, 1,
1996 1, 1, 1, 1, 2, 0, 2, 1, 1, 1,
1997 1, 1, 1, 0, 2, 0, 2, 0, 2, 0,
1998 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
1999 1, 1, 1, 1, 1, 1, 1, 3, 1, 2,
2000 5, 5, 5, 5, 3, 2, 5, 4, 2, 1,
2001 1, 1, 3, 1, 3, 1, 0, 1, 3, 4,
2002 3, 3, 4, 4, 3, 6, 5, 2, 2, 2,
2003 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
2004 5, 8, 6, 6, 7, 7, 6, 8, 8, 3,
2005 1, 1, 1, 1, 0, 2, 6, 1, 0, 1,
2006 2, 0, 3, 0, 3, 3, 3, 3, 0, 8,
2007 0, 9, 0, 9, 5, 2, 3, 1, 3, 3,
2008 3, 3, 1, 0, 5, 3, 1, 3, 1, 0,
2009 10, 1, 1, 4, 1, 1, 2, 3, 0, 1,
2010 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
2011 5, 1, 1, 1, 1, 1, 1, 2, 1, 3,
2012 2, 2, 3, 2, 0, 3, 1, 4, 2, 2,
2013 3, 9, 9, 8, 14, 1, 1, 6, 5, 2,
2014 6, 7, 4, 4, 6, 6, 0, 0, 3, 2,
2015 1, 5, 5, 6, 6, 4, 6, 4, 4, 6,
2016 6, 2, 8, 1, 1, 0, 3, 6, 3, 6,
2017 2, 5, 7, 5, 4
2018};
2019
2020/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2021 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2022 means the default is an error. */
2023static const yytype_uint16 yydefact[] =
2024{
2025 73, 61, 70, 62, 71, 63, 213, 211, 0, 0,
2026 0, 0, 0, 0, 83, 72, 0, 73, 209, 87,
2027 90, 0, 0, 225, 0, 0, 68, 0, 74, 75,
2028 77, 76, 78, 80, 79, 81, 82, 84, 85, 86,
2029 83, 83, 204, 1, 210, 88, 89, 83, 214, 91,
2030 92, 93, 94, 83, 274, 212, 274, 0, 0, 233,
2031 226, 227, 215, 261, 262, 217, 138, 139, 140, 143,
2032 142, 141, 144, 145, 0, 0, 0, 0, 263, 264,
2033 146, 216, 148, 204, 204, 95, 203, 0, 98, 98,
2034 276, 0, 271, 69, 244, 245, 246, 270, 228, 229,
2035 232, 0, 166, 149, 0, 0, 0, 0, 155, 167,
2036 0, 0, 166, 0, 0, 0, 97, 96, 0, 201,
2037 202, 0, 0, 99, 100, 101, 102, 103, 0, 247,
2038 0, 0, 0, 315, 273, 0, 230, 165, 115, 161,
2039 163, 0, 0, 0, 0, 0, 0, 154, 0, 0,
2040 147, 0, 0, 160, 0, 159, 0, 224, 138, 139,
2041 140, 143, 142, 141, 0, 0, 67, 67, 104, 0,
2042 241, 242, 243, 0, 250, 251, 252, 257, 253, 254,
2043 255, 256, 248, 2, 3, 4, 5, 6, 7, 8,
2044 9, 10, 14, 15, 16, 11, 12, 13, 0, 0,
2045 0, 17, 18, 19, 20, 21, 22, 23, 24, 25,
2046 26, 27, 28, 0, 0, 0, 0, 0, 0, 0,
2047 0, 259, 266, 265, 275, 314, 300, 0, 0, 0,
2048 0, 98, 285, 286, 0, 0, 0, 0, 0, 0,
2049 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2050 272, 98, 289, 0, 313, 231, 158, 0, 123, 67,
2051 67, 157, 0, 168, 0, 123, 67, 67, 0, 205,
2052 186, 187, 182, 184, 183, 185, 188, 181, 177, 178,
2053 0, 0, 0, 0, 180, 179, 218, 0, 277, 249,
2054 0, 29, 30, 31, 32, 33, 34, 35, 36, 37,
2055 38, 0, 53, 54, 49, 50, 51, 52, 39, 40,
2056 41, 42, 43, 44, 45, 46, 47, 48, 0, 0,
2057 0, 0, 0, 0, 200, 0, 0, 0, 0, 299,
2058 279, 67, 268, 278, 0, 0, 55, 0, 0, 0,
2059 0, 129, 129, 320, 67, 67, 311, 0, 0, 0,
2060 0, 0, 67, 67, 67, 0, 0, 0, 0, 0,
2061 106, 108, 107, 105, 109, 110, 111, 112, 113, 116,
2062 164, 162, 151, 152, 153, 156, 66, 150, 220, 222,
2063 0, 170, 0, 0, 0, 174, 0, 171, 134, 239,
2064 0, 0, 0, 297, 0, 0, 0, 0, 0, 258,
2065 0, 0, 0, 267, 0, 0, 280, 0, 0, 67,
2066 67, 0, 316, 0, 318, 297, 0, 0, 0, 0,
2067 0, 0, 0, 0, 0, 0, 0, 0, 67, 0,
2068 114, 120, 119, 117, 118, 121, 122, 124, 134, 134,
2069 0, 169, 155, 167, 0, 172, 173, 0, 219, 238,
2070 115, 236, 0, 0, 0, 0, 0, 0, 0, 0,
2071 0, 199, 0, 0, 0, 269, 0, 0, 0, 0,
2072 0, 0, 0, 0, 324, 0, 0, 0, 307, 308,
2073 0, 0, 0, 0, 0, 305, 0, 129, 0, 221,
2074 223, 67, 176, 0, 0, 0, 136, 134, 65, 0,
2075 123, 260, 0, 0, 190, 0, 0, 0, 0, 0,
2076 0, 0, 67, 0, 0, 296, 0, 0, 129, 130,
2077 129, 0, 0, 0, 0, 0, 323, 301, 302, 296,
2078 0, 321, 67, 206, 175, 131, 137, 135, 64, 235,
2079 237, 115, 132, 0, 0, 298, 0, 196, 0, 0,
2080 192, 193, 189, 0, 0, 115, 115, 0, 303, 304,
2081 317, 319, 0, 0, 306, 309, 310, 0, 129, 65,
2082 133, 127, 194, 195, 0, 0, 0, 0, 0, 0,
2083 0, 123, 0, 290, 0, 123, 322, 234, 0, 125,
2084 191, 197, 198, 0, 283, 0, 0, 106, 108, 115,
2085 115, 0, 115, 115, 291, 312, 128, 0, 240, 281,
2086 0, 282, 0, 293, 292, 0, 0, 0, 126, 0,
2087 0, 0, 115, 115, 0, 0, 0, 295, 294, 288,
2088 0, 0, 287, 0, 284
2089};
2090
2091/* YYDEFGOTO[NTERM-NUM]. */
2092static const yytype_int16 yydefgoto[] =
2093{
2094 -1, 218, 219, 220, 301, 318, 164, 165, 78, 539,
2095 113, 12, 79, 14, 15, 40, 41, 42, 47, 53,
2096 118, 128, 369, 256, 437, 372, 608, 589, 412, 496,
2097 571, 448, 497, 80, 166, 139, 156, 140, 141, 110,
2098 324, 221, 325, 121, 87, 157, 16, 17, 18, 20,
2099 19, 388, 438, 439, 62, 23, 60, 101, 451, 452,
2100 129, 172, 54, 96, 55, 48, 290, 222, 82, 224,
2101 332, 333, 56, 92, 93, 250, 596, 134, 346, 557,
2102 456, 251, 252, 253, 254
2103};
2104
2105/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2106 STATE-NUM. */
2107#define YYPACT_NINF -524
2108static const yytype_int16 yypact[] =
2109{
2110 369, -524, -524, -524, -524, -524, -524, -524, 46, -130,
2111 11, -89, 62, -59, 258, -524, 135, 506, -524, 227,
2112 130, -12, 26, -524, -1, 180, -524, 1572, -524, -524,
2113 -524, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2114 119, 119, 250, -524, -524, -524, -524, 119, -524, -524,
2115 -524, -524, -524, 119, 39, -524, -2, 214, 221, 229,
2116 -524, -524, -524, -524, -524, 59, -524, -524, -524, -524,
2117 -524, -524, -524, -524, 262, 268, 8, 35, -524, -524,
2118 -524, 9, -524, 195, 195, 244, -524, 162, 233, 233,
2119 186, 238, -524, 127, -524, -524, -524, -524, -524, -524,
2120 -524, 50, 1126, -524, 133, 161, 815, 59, -524, 9,
2121 -88, 172, 1126, 181, 162, 162, -524, -524, 1372, -524,
2122 -524, 1612, 337, -524, -524, -524, -524, -524, 1652, -524,
2123 -3, 314, 906, 1867, -524, 334, -524, -524, 9, -524,
2124 205, 208, 1692, 1692, 200, -64, 1692, -524, 359, 211,
2125 -524, 1612, 1692, 59, 216, 9, 410, -524, 223, 357,
2126 361, 362, 363, 365, 275, 366, 1182, 329, -524, 97,
2127 -524, -524, -524, 906, -524, -524, -524, -524, -524, -524,
2128 -524, -524, 324, -524, -524, -524, -524, -524, -524, -524,
2129 -524, -524, -524, -524, -524, -524, -524, -524, 511, 491,
2130 234, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2131 -524, -524, -524, 252, 253, 259, 260, 1612, 263, 267,
2132 271, -524, -524, -524, -524, -524, -524, 354, 1732, 68,
2133 374, 233, -524, -524, 511, 491, 1692, 1692, 1692, 1692,
2134 1692, 1692, 1692, 1692, 1692, 1692, 1692, 1692, 1692, 1692,
2135 -524, 233, -524, 197, -524, -524, 210, 1452, -524, -31,
2136 2, -524, 264, 9, 237, -524, 329, -25, 1372, -524,
2137 -524, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2138 1412, 1772, 855, 403, -524, -524, -524, 279, -524, -524,
2139 405, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2140 -524, 284, -524, -524, -524, -524, -524, -524, -524, -524,
2141 -524, -524, -524, -524, -524, -524, -524, -524, 285, 1612,
2142 1612, 1612, 1612, 1612, -524, -46, 1612, 1612, 1612, -524,
2143 59, 766, -524, 287, 906, 906, -524, 906, 1652, 1692,
2144 1692, 45, 51, -524, 766, 17, 290, 294, 295, 297,
2145 298, 299, 14, 766, 766, 417, 1652, 1692, 1692, 452,
2146 -524, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2147 -524, -524, 189, -524, -524, -524, -524, 189, -524, 181,
2148 421, -524, 102, 1080, -32, -524, -49, -524, 305, 1492,
2149 306, 1612, 1612, -524, 308, 311, 315, 316, 1612, -524,
2150 317, 318, 431, -524, 1692, 319, -524, 321, 906, 766,
2151 766, 24, -524, 28, -524, -524, 906, 320, 1692, 1692,
2152 1692, 1692, 1692, 322, 325, 327, 1692, 906, 766, 328,
2153 -524, -524, -524, -524, -524, -524, -524, -524, 305, 305,
2154 1692, -524, 323, 1035, -17, -524, -524, 30, -524, -524,
2155 9, 331, 326, 462, 332, 333, 154, 1612, 1612, 1612,
2156 1612, -524, 1612, 1612, 1692, -524, 472, 473, 340, 339,
2157 341, 906, 493, 906, 347, 348, 906, 349, 9, -524,
2158 352, 353, 507, 906, 906, 9, 343, 360, 1692, -524,
2159 -524, 38, -524, 371, 494, 515, -524, 305, 115, 1532,
2160 -524, -524, 1612, 1612, -524, 1692, 367, 368, 372, 379,
2161 382, 385, 56, 906, 906, 1812, 906, 906, 360, -524,
2162 360, 906, 384, 1692, 1692, 1692, -524, -524, -524, 1812,
2163 487, -524, 766, -524, -524, -524, -524, -524, -524, -524,
2164 -524, 9, -6, 388, 389, -524, 1612, -524, 1612, 1612,
2165 -524, -524, -524, 390, 386, 33, 9, 166, -524, -524,
2166 -524, -524, 383, 906, -524, -524, -524, 170, 360, 115,
2167 -524, 495, -524, -524, 396, 397, 399, 536, 3, 623,
2168 623, -524, 1852, -524, 395, -524, -524, -524, 552, 411,
2169 -524, -524, -524, 906, -524, 1323, 7, 412, 414, -524,
2170 -524, 6, 33, 9, -524, 189, -524, 540, -524, -524,
2171 413, -524, 1323, 210, 210, 550, 623, 623, -524, 553,
2172 416, 906, -524, -524, 906, 555, 500, 210, 210, -524,
2173 906, 557, -524, 906, -524
2174};
2175
2176/* YYPGOTO[NTERM-NUM]. */
2177static const yytype_int16 yypgoto[] =
2178{
2179 -524, 443, 445, 446, 350, 346, -229, -524, 0, 16,
2180 -141, 489, 13, -524, -524, -524, -524, 61, -524, -524,
2181 -524, -190, -524, -444, -524, -263, -524, -524, -337, 41,
2182 -524, -407, -524, -524, -24, 356, -108, -524, 474, 508,
2183 -81, -150, -207, 228, 261, 351, -524, -524, 598, -524,
2184 -524, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2185 527, -524, -524, -524, -524, -524, -524, -523, -70, 104,
2186 -234, -524, -524, 566, -524, -524, -524, -524, -524, 94,
2187 209, -524, -524, -524, -524
2188};
2189
2190/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2191 positive, shift that token. If negative, reduce the rule which
2192 number is the opposite. If zero, do what YYDEFACT says.
2193 If YYTABLE_NINF, syntax error. */
2194#define YYTABLE_NINF -209
2195static const yytype_int16 yytable[] =
2196{
2197 11, 337, 377, 81, 343, 414, 498, 347, 348, 349,
2198 350, 351, 105, 13, 336, 355, 284, 11, 336, 90,
2199 169, 63, 64, 111, 24, 170, 286, 94, 494, 111,
2200 13, 489, 490, 1, 2, 471, 3, 4, 5, 473,
2201 167, 338, 63, 64, 615, 107, 66, 67, 68, 69,
2202 70, 71, 72, 109, 1, 2, 111, 3, 4, 5,
2203 90, 356, 223, 111, 494, 26, 91, 146, 111, 25,
2204 266, 111, 610, 382, 384, 386, 147, 472, 138, 334,
2205 27, 472, 109, 495, 73, 335, 269, -144, 138, 620,
2206 537, 146, 111, 11, 155, 28, 285, 569, 21, 111,
2207 262, 83, 84, 223, 155, 111, 398, 91, 88, 398,
2208 111, 579, 580, 22, 89, 446, 399, 2, 259, 260,
2209 4, 112, 263, 398, 429, 378, 379, 112, 267, 373,
2210 445, 431, 432, 433, 1, 43, 434, 3, 398, 5,
2211 435, 436, 57, 431, 432, 433, 1, 493, 434, 3,
2212 531, 5, 435, 436, 112, 613, 614, 59, 616, 617,
2213 171, 112, 95, 594, 374, -67, 112, 611, 359, 112,
2214 465, 106, 49, 50, 51, 416, 444, 52, 627, 628,
2215 58, 560, 287, 561, 477, -144, 479, 480, 481, -144,
2216 112, 533, 74, 75, 119, 120, 76, 112, 77, 108,
2217 411, -67, 61, 112, 331, 135, 413, -67, 112, 552,
2218 136, 102, 341, 342, 331, 344, 345, 331, 331, 331,
2219 331, 331, 352, 353, 354, 331, -55, -55, -55, -55,
2220 408, 586, 86, 138, 360, 361, 98, 542, 393, 394,
2221 395, 396, 397, 99, 155, 400, 401, 402, 427, 270,
2222 271, 100, 362, 363, 131, 364, 365, 398, 366, 367,
2223 368, 223, 441, 359, 223, 223, 103, 223, 37, 38,
2224 39, 545, 104, 45, 223, 46, 132, 288, 272, 273,
2225 274, 275, 423, 223, 223, 85, 116, 86, 117, 564,
2226 565, 566, 142, 284, 122, 123, 124, 125, 126, 127,
2227 29, 30, 31, 32, 33, 34, 35, 504, 36, 505,
2228 454, 455, 357, 358, 155, 409, 410, 461, 601, 581,
2229 143, 582, 605, 585, 148, 582, 431, 432, 433, 360,
2230 361, 434, 155, 428, 331, 435, 436, 150, 223, 223,
2231 223, 168, 151, 152, 114, 115, 223, 362, 363, 595,
2232 364, 365, 173, 366, 367, 368, 255, 223, 223, 443,
2233 257, 258, 261, 264, 265, 450, -56, 612, 268, -208,
2234 -57, -60, -59, 285, -58, 276, 506, 507, 508, 509,
2235 331, 510, 511, 111, 289, 336, 319, -69, 1, 2,
2236 376, 3, 4, 5, 331, 478, 331, 331, 331, 6,
2237 7, 223, 485, 223, 320, 321, 223, 37, 38, 39,
2238 329, 322, 323, 223, 223, 326, 491, 63, 64, 327,
2239 8, 543, 544, 328, 9, 387, 375, 390, 10, 1,
2240 2, 389, 3, 4, 5, 403, 391, 392, 405, 406,
2241 512, 407, 404, 223, 223, 417, 223, 223, 415, 418,
2242 419, 223, 420, 421, 422, 426, 430, 424, 425, 440,
2243 447, 453, 223, 457, 532, 574, 458, 575, 576, 464,
2244 459, 460, 462, 463, 466, 541, 467, 482, 476, 500,
2245 483, 331, 484, 488, 501, 492, 499, 502, 503, 513,
2246 514, 556, 515, 223, 516, 529, 517, 519, 538, 331,
2247 331, 331, 505, 521, 523, 556, -207, 524, 525, 223,
2248 223, 526, 468, 469, 470, 530, 535, 302, 303, 536,
2249 475, 547, 546, 223, -69, 1, 2, 548, 3, 4,
2250 5, 486, 487, 534, 549, 550, 6, 7, 551, 563,
2251 472, 572, 573, 583, 578, 577, 223, 223, 588, 590,
2252 591, 223, 592, 593, 223, 604, 606, 8, 603, 607,
2253 223, 9, 618, 223, -18, 10, -19, 621, 619, 538,
2254 624, 625, 630, 631, 633, 518, 247, 520, 248, 249,
2255 522, 340, 133, 570, 339, 587, 149, 527, 528, 304,
2256 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2257 315, 316, 317, 291, 292, 293, 294, 295, 296, 297,
2258 298, 299, 300, 371, 145, 44, 130, 553, 554, 380,
2259 558, 559, 97, 567, 474, 562, 174, 175, 0, 0,
2260 63, 64, 176, 0, 0, 0, 568, 0, 0, 0,
2261 0, 0, 1, 2, 0, 3, 4, 5, 177, 178,
2262 179, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2263 0, 0, 0, 180, 181, 0, 0, 584, 0, 0,
2264 0, 0, 0, 0, 0, 0, 359, 0, 0, 0,
2265 0, 182, 0, 599, 600, 0, 0, 0, 0, 0,
2266 0, 0, 0, 0, 0, 0, 0, 609, 183, 184,
2267 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
2268 195, 196, 197, 198, 199, 0, 0, 0, 0, 0,
2269 622, 623, 0, 0, 0, 626, 0, 0, 629, 0,
2270 0, 0, 0, 0, 632, 0, 0, 634, 0, 0,
2271 200, 201, 597, 598, 204, 205, 206, 207, 208, 209,
2272 210, 211, 212, 0, 213, 0, 214, 215, 216, 0,
2273 362, 363, 0, 364, 365, 0, 366, 367, 368, 174,
2274 175, 0, 0, 63, 64, 176, 0, 0, 0, 0,
2275 0, 0, 0, 0, 217, 1, 2, 0, 3, 4,
2276 5, 177, 178, 179, 0, 0, 0, 0, 0, 0,
2277 0, 0, 0, 0, 0, 0, 180, 181, 0, 0,
2278 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2279 111, 0, 63, 64, 182, 107, 66, 67, 68, 69,
2280 70, 71, 72, 0, 1, 2, 0, 3, 4, 5,
2281 0, 183, 184, 185, 186, 187, 188, 189, 190, 191,
2282 192, 193, 194, 195, 196, 197, 198, 199, 0, 0,
2283 0, 0, 63, 64, 73, 107, 158, 159, 160, 161,
2284 162, 163, 72, 0, 1, 2, 0, 3, 4, 5,
2285 0, 0, 0, 200, 201, 202, 203, 204, 205, 206,
2286 207, 208, 209, 210, 211, 212, 0, 213, 0, 214,
2287 215, 216, 0, 0, 73, 0, 0, 0, 0, 174,
2288 175, 0, 0, 63, 64, 176, 0, 0, 112, 0,
2289 0, 0, 0, 0, 0, 1, 2, 217, 3, 4,
2290 5, 177, 178, 179, 0, 0, 0, 0, 0, 0,
2291 0, 0, 0, 0, 0, 0, 180, 181, 0, 0,
2292 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2293 0, 0, 0, 0, 182, 0, 0, 0, 0, 0,
2294 0, 0, 74, 75, 0, 0, 76, 0, 77, 144,
2295 0, 183, 184, 185, 186, 187, 188, 189, 190, 191,
2296 192, 193, 194, 195, 196, 197, 198, 199, 0, 0,
2297 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2298 0, 0, 74, 75, 0, 0, 76, 0, 77, 385,
2299 0, 0, 0, 200, 201, 202, 203, 204, 205, 206,
2300 207, 208, 209, 210, 211, 212, 0, 213, 0, 214,
2301 215, 216, 63, 64, 0, 0, 0, 0, 0, 0,
2302 0, 0, 0, 0, 1, 2, 0, 3, 4, 5,
2303 277, 0, 0, 0, 0, 0, 0, 217, 0, 0,
2304 0, 0, 0, 0, 0, 278, 279, 0, 0, 0,
2305 0, 0, 0, 0, 0, 0, 0, 63, 64, 111,
2306 107, 158, 159, 160, 161, 162, 163, 72, 0, 1,
2307 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2308 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
2309 193, 194, 195, 196, 197, 198, 199, 0, 0, 73,
2310 0, 0, 0, 63, 64, 0, 107, 66, 67, 68,
2311 69, 70, 71, 72, 0, 1, 2, 0, 3, 4,
2312 5, 0, 200, 201, 202, 203, 204, 205, 206, 207,
2313 208, 209, 210, 211, 212, 137, 213, 0, 214, 215,
2314 216, 0, 0, 0, 0, 73, 0, 0, 0, 0,
2315 0, 0, 0, 0, 0, 0, 0, 112, 0, 63,
2316 64, -67, 0, 280, 0, 0, 281, 0, 282, 0,
2317 283, 1, 2, 0, 3, 4, 5, 277, 0, 0,
2318 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2319 0, 0, 278, 279, 0, 0, 0, 0, 0, 0,
2320 0, 0, 0, 0, 0, 0, 111, 74, 75, 0,
2321 0, 76, 0, 77, 442, 0, 0, 0, 0, 0,
2322 0, 0, 0, 0, 0, 0, 0, 183, 184, 185,
2323 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
2324 196, 197, 198, 199, 0, 0, 0, 0, 0, 0,
2325 0, 0, 0, 74, 75, 0, 0, 76, 0, 77,
2326 0, 0, 0, 0, 0, 0, 0, 0, 0, 200,
2327 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
2328 211, 212, 0, 213, 0, 214, 215, 216, 0, 0,
2329 0, 0, 0, 0, 0, 0, 174, 175, 0, 0,
2330 0, 0, 176, 0, 112, 0, 0, 0, 0, 0,
2331 280, 0, 0, 281, 0, 282, 0, 283, 177, 178,
2332 179, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2333 0, 0, 0, 180, 181, 0, 0, 0, 0, 0,
2334 0, 0, 0, 0, 0, 0, 0, 0, 0, 63,
2335 64, 182, 153, 66, 67, 68, 69, 70, 71, 72,
2336 0, 1, 2, 0, 3, 4, 5, 0, 183, 184,
2337 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
2338 195, 196, 197, 198, 199, 0, 0, 0, 0, 63,
2339 64, 73, 107, 158, 159, 160, 161, 162, 163, 72,
2340 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2341 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
2342 210, 211, 212, 0, 213, 0, 214, 215, 216, 63,
2343 64, 73, 107, 66, 67, 68, 69, 70, 71, 72,
2344 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2345 0, 0, 0, 0, 217, 0, 0, 0, 0, 0,
2346 0, 370, 0, 0, 0, 154, 0, 0, 0, 63,
2347 64, 73, 107, 66, 67, 68, 69, 70, 71, 72,
2348 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2349 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2350 75, 449, 0, 76, 0, 77, 0, 0, 0, 63,
2351 64, 73, 107, 66, 67, 68, 69, 70, 71, 72,
2352 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2353 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2354 75, 540, 381, 76, 0, 77, 0, 0, 0, 63,
2355 64, 73, 65, 66, 67, 68, 69, 70, 71, 72,
2356 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2357 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2358 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2359 64, 73, 107, 158, 159, 160, 161, 162, 163, 72,
2360 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2361 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2362 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2363 64, 73, 153, 66, 67, 68, 69, 70, 71, 72,
2364 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2365 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2366 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2367 64, 73, 107, 66, 67, 68, 69, 70, 71, 72,
2368 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2369 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2370 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2371 64, 73, 330, 66, 67, 68, 69, 70, 71, 72,
2372 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2373 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2374 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2375 64, 73, 107, 158, 159, 160, 161, 162, 163, 72,
2376 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2377 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2378 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2379 64, 73, 107, 66, 67, 68, 69, 70, 71, 555,
2380 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2381 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2382 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2383 64, 73, 107, 66, 67, 68, 69, 70, 71, 602,
2384 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2385 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2386 75, 0, 0, 76, 0, 77, 0, 0, 0, 0,
2387 0, 73, 0, 225, 0, 0, 0, 0, 0, 0,
2388 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2389 0, 0, 0, 226, 227, 0, 0, 0, 0, 74,
2390 75, 0, 0, 76, 0, 383, 228, 229, 230, 231,
2391 232, 233, 183, 184, 185, 186, 187, 188, 189, 190,
2392 191, 192, 193, 194, 195, 196, 197, 234, 235, 0,
2393 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2394 75, 0, 0, 76, 0, 77, 0, 0, 0, 236,
2395 237, 238, 0, 0, 239, 201, 202, 203, 204, 205,
2396 206, 207, 208, 209, 210, 211, 212, 240, 241, 242,
2397 243, 244, 245, 246, 0, 0, 0, 0, 0, 74,
2398 75, 0, 0, 76, 0, 77
2399};
2400
2401static const yytype_int16 yycheck[] =
2402{
2403 0, 230, 265, 27, 238, 342, 450, 241, 242, 243,
2404 244, 245, 4, 0, 11, 249, 166, 17, 11, 21,
2405 128, 7, 8, 54, 154, 28, 167, 29, 34, 54,
2406 17, 438, 439, 19, 20, 11, 22, 23, 24, 11,
2407 121, 231, 7, 8, 38, 10, 11, 12, 13, 14,
2408 15, 16, 17, 77, 19, 20, 54, 22, 23, 24,
2409 21, 251, 132, 54, 34, 154, 68, 155, 54, 58,
2410 151, 54, 595, 280, 281, 282, 164, 53, 102, 11,
2411 18, 53, 106, 53, 49, 17, 156, 54, 112, 612,
2412 497, 155, 54, 93, 118, 154, 166, 541, 52, 54,
2413 164, 40, 41, 173, 128, 54, 155, 68, 47, 155,
2414 54, 555, 556, 67, 53, 164, 162, 20, 142, 143,
2415 23, 152, 146, 155, 358, 266, 267, 152, 152, 160,
2416 162, 137, 138, 139, 19, 0, 142, 22, 155, 24,
2417 146, 147, 154, 137, 138, 139, 19, 164, 142, 22,
2418 487, 24, 146, 147, 152, 599, 600, 158, 602, 603,
2419 163, 152, 164, 160, 162, 156, 152, 160, 53, 152,
2420 404, 163, 42, 43, 44, 158, 383, 47, 622, 623,
2421 154, 518, 169, 520, 418, 152, 420, 421, 422, 156,
2422 152, 153, 157, 158, 32, 33, 161, 152, 163, 164,
2423 155, 156, 22, 152, 228, 155, 155, 156, 152, 153,
2424 160, 152, 236, 237, 238, 239, 240, 241, 242, 243,
2425 244, 245, 246, 247, 248, 249, 3, 4, 5, 6,
2426 338, 568, 37, 257, 119, 120, 22, 500, 319, 320,
2427 321, 322, 323, 22, 268, 326, 327, 328, 356, 26,
2428 27, 22, 137, 138, 68, 140, 141, 155, 143, 144,
2429 145, 331, 160, 53, 334, 335, 4, 337, 149, 150,
2430 151, 505, 4, 46, 344, 48, 38, 173, 3, 4,
2431 5, 6, 352, 353, 354, 35, 42, 37, 44, 523,
2432 524, 525, 159, 443, 61, 62, 63, 64, 65, 66,
2433 42, 43, 44, 45, 46, 47, 48, 153, 50, 155,
2434 391, 392, 115, 116, 338, 339, 340, 398, 581, 153,
2435 159, 155, 585, 153, 152, 155, 137, 138, 139, 119,
2436 120, 142, 356, 357, 358, 146, 147, 156, 408, 409,
2437 410, 4, 114, 115, 83, 84, 416, 137, 138, 578,
2438 140, 141, 38, 143, 144, 145, 22, 427, 428, 383,
2439 155, 153, 162, 4, 153, 389, 9, 596, 152, 0,
2440 9, 9, 9, 443, 9, 9, 457, 458, 459, 460,
2441 404, 462, 463, 54, 60, 11, 152, 18, 19, 20,
2442 153, 22, 23, 24, 418, 419, 420, 421, 422, 30,
2443 31, 471, 426, 473, 152, 152, 476, 149, 150, 151,
2444 56, 152, 152, 483, 484, 152, 440, 7, 8, 152,
2445 51, 502, 503, 152, 55, 22, 162, 22, 59, 19,
2446 20, 152, 22, 23, 24, 331, 152, 152, 334, 335,
2447 464, 337, 155, 513, 514, 155, 516, 517, 344, 155,
2448 155, 521, 155, 155, 155, 38, 4, 353, 354, 38,
2449 155, 155, 532, 155, 488, 546, 155, 548, 549, 38,
2450 155, 155, 155, 155, 155, 499, 155, 155, 158, 153,
2451 155, 505, 155, 155, 22, 162, 155, 155, 155, 17,
2452 17, 515, 152, 563, 155, 152, 155, 4, 498, 523,
2453 524, 525, 155, 155, 155, 529, 0, 155, 155, 579,
2454 580, 4, 408, 409, 410, 155, 22, 26, 27, 4,
2455 416, 153, 155, 593, 18, 19, 20, 155, 22, 23,
2456 24, 427, 428, 162, 155, 153, 30, 31, 153, 155,
2457 53, 153, 153, 160, 158, 155, 616, 617, 53, 153,
2458 153, 621, 153, 17, 624, 160, 4, 51, 582, 148,
2459 630, 55, 22, 633, 152, 59, 152, 17, 155, 569,
2460 17, 155, 17, 73, 17, 471, 133, 473, 133, 133,
2461 476, 235, 93, 542, 234, 569, 112, 483, 484, 98,
2462 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2463 109, 110, 111, 92, 93, 94, 95, 96, 97, 98,
2464 99, 100, 101, 257, 106, 17, 89, 513, 514, 268,
2465 516, 517, 56, 529, 415, 521, 3, 4, -1, -1,
2466 7, 8, 9, -1, -1, -1, 532, -1, -1, -1,
2467 -1, -1, 19, 20, -1, 22, 23, 24, 25, 26,
2468 27, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2469 -1, -1, -1, 40, 41, -1, -1, 563, -1, -1,
2470 -1, -1, -1, -1, -1, -1, 53, -1, -1, -1,
2471 -1, 58, -1, 579, 580, -1, -1, -1, -1, -1,
2472 -1, -1, -1, -1, -1, -1, -1, 593, 75, 76,
2473 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2474 87, 88, 89, 90, 91, -1, -1, -1, -1, -1,
2475 616, 617, -1, -1, -1, 621, -1, -1, 624, -1,
2476 -1, -1, -1, -1, 630, -1, -1, 633, -1, -1,
2477 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2478 127, 128, 129, -1, 131, -1, 133, 134, 135, -1,
2479 137, 138, -1, 140, 141, -1, 143, 144, 145, 3,
2480 4, -1, -1, 7, 8, 9, -1, -1, -1, -1,
2481 -1, -1, -1, -1, 161, 19, 20, -1, 22, 23,
2482 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2483 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
2484 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2485 54, -1, 7, 8, 58, 10, 11, 12, 13, 14,
2486 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2487 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2488 84, 85, 86, 87, 88, 89, 90, 91, -1, -1,
2489 -1, -1, 7, 8, 49, 10, 11, 12, 13, 14,
2490 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2491 -1, -1, -1, 117, 118, 119, 120, 121, 122, 123,
2492 124, 125, 126, 127, 128, 129, -1, 131, -1, 133,
2493 134, 135, -1, -1, 49, -1, -1, -1, -1, 3,
2494 4, -1, -1, 7, 8, 9, -1, -1, 152, -1,
2495 -1, -1, -1, -1, -1, 19, 20, 161, 22, 23,
2496 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2497 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
2498 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2499 -1, -1, -1, -1, 58, -1, -1, -1, -1, -1,
2500 -1, -1, 157, 158, -1, -1, 161, -1, 163, 164,
2501 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2502 84, 85, 86, 87, 88, 89, 90, 91, -1, -1,
2503 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2504 -1, -1, 157, 158, -1, -1, 161, -1, 163, 164,
2505 -1, -1, -1, 117, 118, 119, 120, 121, 122, 123,
2506 124, 125, 126, 127, 128, 129, -1, 131, -1, 133,
2507 134, 135, 7, 8, -1, -1, -1, -1, -1, -1,
2508 -1, -1, -1, -1, 19, 20, -1, 22, 23, 24,
2509 25, -1, -1, -1, -1, -1, -1, 161, -1, -1,
2510 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2511 -1, -1, -1, -1, -1, -1, -1, 7, 8, 54,
2512 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2513 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2514 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2515 85, 86, 87, 88, 89, 90, 91, -1, -1, 49,
2516 -1, -1, -1, 7, 8, -1, 10, 11, 12, 13,
2517 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2518 24, -1, 117, 118, 119, 120, 121, 122, 123, 124,
2519 125, 126, 127, 128, 129, 39, 131, -1, 133, 134,
2520 135, -1, -1, -1, -1, 49, -1, -1, -1, -1,
2521 -1, -1, -1, -1, -1, -1, -1, 152, -1, 7,
2522 8, 156, -1, 158, -1, -1, 161, -1, 163, -1,
2523 165, 19, 20, -1, 22, 23, 24, 25, -1, -1,
2524 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2525 -1, -1, 40, 41, -1, -1, -1, -1, -1, -1,
2526 -1, -1, -1, -1, -1, -1, 54, 157, 158, -1,
2527 -1, 161, -1, 163, 164, -1, -1, -1, -1, -1,
2528 -1, -1, -1, -1, -1, -1, -1, 75, 76, 77,
2529 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
2530 88, 89, 90, 91, -1, -1, -1, -1, -1, -1,
2531 -1, -1, -1, 157, 158, -1, -1, 161, -1, 163,
2532 -1, -1, -1, -1, -1, -1, -1, -1, -1, 117,
2533 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2534 128, 129, -1, 131, -1, 133, 134, 135, -1, -1,
2535 -1, -1, -1, -1, -1, -1, 3, 4, -1, -1,
2536 -1, -1, 9, -1, 152, -1, -1, -1, -1, -1,
2537 158, -1, -1, 161, -1, 163, -1, 165, 25, 26,
2538 27, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2539 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
2540 -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
2541 8, 58, 10, 11, 12, 13, 14, 15, 16, 17,
2542 -1, 19, 20, -1, 22, 23, 24, -1, 75, 76,
2543 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2544 87, 88, 89, 90, 91, -1, -1, -1, -1, 7,
2545 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2546 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2547 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2548 127, 128, 129, -1, 131, -1, 133, 134, 135, 7,
2549 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2550 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2551 -1, -1, -1, -1, 161, -1, -1, -1, -1, -1,
2552 -1, 39, -1, -1, -1, 123, -1, -1, -1, 7,
2553 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2554 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2555 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2556 158, 39, -1, 161, -1, 163, -1, -1, -1, 7,
2557 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2558 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2559 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2560 158, 39, 160, 161, -1, 163, -1, -1, -1, 7,
2561 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2562 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2563 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2564 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2565 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2566 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2567 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2568 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2569 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2570 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2571 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2572 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2573 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2574 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2575 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2576 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2577 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2578 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2579 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2580 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2581 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2582 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2583 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2584 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2585 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2586 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2587 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2588 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2589 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2590 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2591 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2592 158, -1, -1, 161, -1, 163, -1, -1, -1, -1,
2593 -1, 49, -1, 36, -1, -1, -1, -1, -1, -1,
2594 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2595 -1, -1, -1, 56, 57, -1, -1, -1, -1, 157,
2596 158, -1, -1, 161, -1, 163, 69, 70, 71, 72,
2597 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2598 83, 84, 85, 86, 87, 88, 89, 90, 91, -1,
2599 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2600 158, -1, -1, 161, -1, 163, -1, -1, -1, 112,
2601 113, 114, -1, -1, 117, 118, 119, 120, 121, 122,
2602 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
2603 133, 134, 135, 136, -1, -1, -1, -1, -1, 157,
2604 158, -1, -1, 161, -1, 163
2605};
2606
2607/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2608 symbol of state STATE-NUM. */
2609static const yytype_uint8 yystos[] =
2610{
2611 0, 19, 20, 22, 23, 24, 30, 31, 51, 55,
2612 59, 174, 177, 178, 179, 180, 212, 213, 214, 216,
2613 215, 52, 67, 221, 154, 58, 154, 18, 154, 42,
2614 43, 44, 45, 46, 47, 48, 50, 149, 150, 151,
2615 181, 182, 183, 0, 214, 46, 48, 184, 231, 42,
2616 43, 44, 47, 185, 228, 230, 238, 154, 154, 158,
2617 222, 22, 220, 7, 8, 10, 11, 12, 13, 14,
2618 15, 16, 17, 49, 157, 158, 161, 163, 174, 178,
2619 199, 200, 234, 183, 183, 35, 37, 210, 183, 183,
2620 21, 68, 239, 240, 29, 164, 229, 239, 22, 22,
2621 22, 223, 152, 4, 4, 4, 163, 10, 164, 200,
2622 205, 54, 152, 176, 210, 210, 42, 44, 186, 32,
2623 33, 209, 61, 62, 63, 64, 65, 66, 187, 226,
2624 226, 68, 38, 177, 243, 155, 160, 39, 200, 201,
2625 203, 204, 159, 159, 164, 205, 155, 164, 152, 204,
2626 156, 209, 209, 10, 123, 200, 202, 211, 11, 12,
2627 13, 14, 15, 16, 172, 173, 200, 206, 4, 202,
2628 28, 163, 227, 38, 3, 4, 9, 25, 26, 27,
2629 40, 41, 58, 75, 76, 77, 78, 79, 80, 81,
2630 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2631 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2632 127, 128, 129, 131, 133, 134, 135, 161, 167, 168,
2633 169, 207, 233, 234, 235, 36, 56, 57, 69, 70,
2634 71, 72, 73, 74, 90, 91, 112, 113, 114, 117,
2635 130, 131, 132, 133, 134, 135, 136, 167, 168, 169,
2636 241, 247, 248, 249, 250, 22, 189, 155, 153, 200,
2637 200, 162, 164, 200, 4, 153, 206, 200, 152, 234,
2638 26, 27, 3, 4, 5, 6, 9, 25, 40, 41,
2639 158, 161, 163, 165, 207, 234, 176, 178, 235, 60,
2640 232, 92, 93, 94, 95, 96, 97, 98, 99, 100,
2641 101, 170, 26, 27, 98, 99, 100, 101, 102, 103,
2642 104, 105, 106, 107, 108, 109, 110, 111, 171, 152,
2643 152, 152, 152, 152, 206, 208, 152, 152, 152, 56,
2644 10, 200, 236, 237, 11, 17, 11, 172, 187, 170,
2645 171, 200, 200, 236, 200, 200, 244, 236, 236, 236,
2646 236, 236, 200, 200, 200, 236, 187, 115, 116, 53,
2647 119, 120, 137, 138, 140, 141, 143, 144, 145, 188,
2648 39, 201, 191, 160, 162, 162, 153, 191, 176, 176,
2649 211, 160, 208, 163, 208, 164, 208, 22, 217, 152,
2650 22, 152, 152, 206, 206, 206, 206, 206, 155, 162,
2651 206, 206, 206, 235, 155, 235, 235, 235, 202, 200,
2652 200, 155, 194, 155, 194, 235, 158, 155, 155, 155,
2653 155, 155, 155, 234, 235, 235, 38, 202, 200, 236,
2654 4, 137, 138, 139, 142, 146, 147, 190, 218, 219,
2655 38, 160, 164, 200, 208, 162, 164, 155, 197, 39,
2656 200, 224, 225, 155, 206, 206, 246, 155, 155, 155,
2657 155, 206, 155, 155, 38, 236, 155, 155, 235, 235,
2658 235, 11, 53, 11, 246, 235, 158, 236, 200, 236,
2659 236, 236, 155, 155, 155, 200, 235, 235, 155, 197,
2660 197, 200, 162, 164, 34, 53, 195, 198, 189, 155,
2661 153, 22, 155, 155, 153, 155, 206, 206, 206, 206,
2662 206, 206, 200, 17, 17, 152, 155, 155, 235, 4,
2663 235, 155, 235, 155, 155, 155, 4, 235, 235, 152,
2664 155, 194, 200, 153, 162, 22, 4, 197, 174, 175,
2665 39, 200, 191, 206, 206, 236, 155, 153, 155, 155,
2666 153, 153, 153, 235, 235, 17, 200, 245, 235, 235,
2667 194, 194, 235, 155, 236, 236, 236, 245, 235, 189,
2668 195, 196, 153, 153, 206, 206, 206, 155, 158, 189,
2669 189, 153, 155, 160, 235, 153, 194, 175, 53, 193,
2670 153, 153, 153, 17, 160, 172, 242, 119, 120, 235,
2671 235, 191, 17, 200, 160, 191, 4, 148, 192, 235,
2672 233, 160, 172, 189, 189, 38, 189, 189, 22, 155,
2673 233, 17, 235, 235, 17, 155, 235, 189, 189, 235,
2674 17, 73, 235, 17, 235
2675};
David Greene718fda32007-08-01 03:59:32 +00002676
Reid Spencer68a24bd2005-08-27 18:50:39 +00002677#define yyerrok (yyerrstatus = 0)
2678#define yyclearin (yychar = YYEMPTY)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002679#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002680#define YYEOF 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00002681
Reid Spencer68a24bd2005-08-27 18:50:39 +00002682#define YYACCEPT goto yyacceptlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002683#define YYABORT goto yyabortlab
2684#define YYERROR goto yyerrorlab
2685
2686
2687/* Like YYERROR except do call yyerror. This remains here temporarily
2688 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002689 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00002690
Reid Spencer68a24bd2005-08-27 18:50:39 +00002691#define YYFAIL goto yyerrlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002692
Reid Spencer68a24bd2005-08-27 18:50:39 +00002693#define YYRECOVERING() (!!yyerrstatus)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002694
2695#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002696do \
2697 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002698 { \
2699 yychar = (Token); \
2700 yylval = (Value); \
2701 yytoken = YYTRANSLATE (yychar); \
2702 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002703 goto yybackup; \
2704 } \
2705 else \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002706 { \
2707 yyerror (YY_("syntax error: cannot back up")); \
2708 YYERROR; \
2709 } \
2710while (YYID (0))
2711
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002712
Reid Spencer68a24bd2005-08-27 18:50:39 +00002713#define YYTERROR 1
2714#define YYERRCODE 256
2715
Dan Gohmanf4423b12008-04-19 00:24:39 +00002716
2717/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2718 If N is 0, then set CURRENT to the empty location which ends
2719 the previous symbol: RHS[0] (always defined). */
2720
2721#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2722#ifndef YYLLOC_DEFAULT
2723# define YYLLOC_DEFAULT(Current, Rhs, N) \
2724 do \
2725 if (YYID (N)) \
2726 { \
2727 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2728 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2729 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2730 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2731 } \
2732 else \
2733 { \
2734 (Current).first_line = (Current).last_line = \
2735 YYRHSLOC (Rhs, 0).last_line; \
2736 (Current).first_column = (Current).last_column = \
2737 YYRHSLOC (Rhs, 0).last_column; \
2738 } \
2739 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002740#endif
2741
Dan Gohmanf4423b12008-04-19 00:24:39 +00002742
2743/* YY_LOCATION_PRINT -- Print the location on the stream.
2744 This macro was not mandated originally: define only if we know
2745 we won't break user code: when these are the locations we know. */
2746
2747#ifndef YY_LOCATION_PRINT
2748# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
2749# define YY_LOCATION_PRINT(File, Loc) \
2750 fprintf (File, "%d.%d-%d.%d", \
2751 (Loc).first_line, (Loc).first_column, \
2752 (Loc).last_line, (Loc).last_column)
2753# else
2754# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2755# endif
2756#endif
2757
2758
2759/* YYLEX -- calling `yylex' with the right arguments. */
2760
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002761#ifdef YYLEX_PARAM
Dan Gohmanf4423b12008-04-19 00:24:39 +00002762# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002763#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002764# define YYLEX yylex ()
Gabor Greife64d2482008-04-06 23:07:54 +00002765#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002766
2767/* Enable debugging if requested. */
2768#if YYDEBUG
2769
2770# ifndef YYFPRINTF
2771# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2772# define YYFPRINTF fprintf
2773# endif
2774
2775# define YYDPRINTF(Args) \
2776do { \
2777 if (yydebug) \
2778 YYFPRINTF Args; \
2779} while (YYID (0))
2780
2781# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2782do { \
2783 if (yydebug) \
2784 { \
2785 YYFPRINTF (stderr, "%s ", Title); \
2786 yy_symbol_print (stderr, \
2787 Type, Value); \
2788 YYFPRINTF (stderr, "\n"); \
2789 } \
2790} while (YYID (0))
2791
2792
2793/*--------------------------------.
2794| Print this symbol on YYOUTPUT. |
2795`--------------------------------*/
2796
2797/*ARGSUSED*/
2798#if (defined __STDC__ || defined __C99__FUNC__ \
2799 || defined __cplusplus || defined _MSC_VER)
2800static void
2801yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greife64d2482008-04-06 23:07:54 +00002802#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002803static void
2804yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2805 FILE *yyoutput;
2806 int yytype;
2807 YYSTYPE const * const yyvaluep;
Gabor Greife64d2482008-04-06 23:07:54 +00002808#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002809{
2810 if (!yyvaluep)
2811 return;
2812# ifdef YYPRINT
2813 if (yytype < YYNTOKENS)
2814 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2815# else
2816 YYUSE (yyoutput);
2817# endif
2818 switch (yytype)
2819 {
2820 default:
2821 break;
2822 }
2823}
2824
2825
2826/*--------------------------------.
2827| Print this symbol on YYOUTPUT. |
2828`--------------------------------*/
2829
2830#if (defined __STDC__ || defined __C99__FUNC__ \
2831 || defined __cplusplus || defined _MSC_VER)
2832static void
2833yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2834#else
2835static void
2836yy_symbol_print (yyoutput, yytype, yyvaluep)
2837 FILE *yyoutput;
2838 int yytype;
2839 YYSTYPE const * const yyvaluep;
Scott Michel15dcd8e2008-01-30 03:10:00 +00002840#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002841{
2842 if (yytype < YYNTOKENS)
2843 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2844 else
2845 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner38905612008-02-19 04:36:25 +00002846
Dan Gohmanf4423b12008-04-19 00:24:39 +00002847 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2848 YYFPRINTF (yyoutput, ")");
2849}
Chris Lattner38905612008-02-19 04:36:25 +00002850
Dan Gohmanf4423b12008-04-19 00:24:39 +00002851/*------------------------------------------------------------------.
2852| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2853| TOP (included). |
2854`------------------------------------------------------------------*/
Chris Lattner38905612008-02-19 04:36:25 +00002855
Dan Gohmanf4423b12008-04-19 00:24:39 +00002856#if (defined __STDC__ || defined __C99__FUNC__ \
2857 || defined __cplusplus || defined _MSC_VER)
2858static void
2859yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2860#else
2861static void
2862yy_stack_print (bottom, top)
2863 yytype_int16 *bottom;
2864 yytype_int16 *top;
Scott Michel15dcd8e2008-01-30 03:10:00 +00002865#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002866{
2867 YYFPRINTF (stderr, "Stack now");
2868 for (; bottom <= top; ++bottom)
2869 YYFPRINTF (stderr, " %d", *bottom);
2870 YYFPRINTF (stderr, "\n");
2871}
Chris Lattner38905612008-02-19 04:36:25 +00002872
Dan Gohmanf4423b12008-04-19 00:24:39 +00002873# define YY_STACK_PRINT(Bottom, Top) \
2874do { \
2875 if (yydebug) \
2876 yy_stack_print ((Bottom), (Top)); \
2877} while (YYID (0))
Chris Lattner38905612008-02-19 04:36:25 +00002878
Dan Gohmanf4423b12008-04-19 00:24:39 +00002879
2880/*------------------------------------------------.
2881| Report that the YYRULE is going to be reduced. |
2882`------------------------------------------------*/
2883
2884#if (defined __STDC__ || defined __C99__FUNC__ \
2885 || defined __cplusplus || defined _MSC_VER)
2886static void
2887yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2888#else
2889static void
2890yy_reduce_print (yyvsp, yyrule)
2891 YYSTYPE *yyvsp;
2892 int yyrule;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002893#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002894{
2895 int yynrhs = yyr2[yyrule];
2896 int yyi;
2897 unsigned long int yylno = yyrline[yyrule];
2898 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2899 yyrule - 1, yylno);
2900 /* The symbols being reduced. */
2901 for (yyi = 0; yyi < yynrhs; yyi++)
2902 {
2903 fprintf (stderr, " $%d = ", yyi + 1);
2904 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2905 &(yyvsp[(yyi + 1) - (yynrhs)])
2906 );
2907 fprintf (stderr, "\n");
2908 }
2909}
Scott Michel7f9ba9b2008-01-30 02:55:46 +00002910
Dan Gohmanf4423b12008-04-19 00:24:39 +00002911# define YY_REDUCE_PRINT(Rule) \
2912do { \
2913 if (yydebug) \
2914 yy_reduce_print (yyvsp, Rule); \
2915} while (YYID (0))
Scott Michel7f9ba9b2008-01-30 02:55:46 +00002916
Dan Gohmanf4423b12008-04-19 00:24:39 +00002917/* Nonzero means print parse trace. It is left uninitialized so that
2918 multiple parsers can coexist. */
2919int yydebug;
2920#else /* !YYDEBUG */
2921# define YYDPRINTF(Args)
2922# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2923# define YY_STACK_PRINT(Bottom, Top)
2924# define YY_REDUCE_PRINT(Rule)
2925#endif /* !YYDEBUG */
2926
2927
2928/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002929#ifndef YYINITDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00002930# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002931#endif
2932
Dan Gohmanf4423b12008-04-19 00:24:39 +00002933/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2934 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002935
Dan Gohmanf4423b12008-04-19 00:24:39 +00002936 Do not make this value too large; the results are undefined if
2937 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2938 evaluated with infinite-precision integer arithmetic. */
David Greene718fda32007-08-01 03:59:32 +00002939
Reid Spencer68a24bd2005-08-27 18:50:39 +00002940#ifndef YYMAXDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00002941# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002942#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002943
Reid Spencer68a24bd2005-08-27 18:50:39 +00002944
2945
Dan Gohmanf4423b12008-04-19 00:24:39 +00002946#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002947
Dan Gohmanf4423b12008-04-19 00:24:39 +00002948# ifndef yystrlen
2949# if defined __GLIBC__ && defined _STRING_H
2950# define yystrlen strlen
2951# else
2952/* Return the length of YYSTR. */
2953#if (defined __STDC__ || defined __C99__FUNC__ \
2954 || defined __cplusplus || defined _MSC_VER)
2955static YYSIZE_T
2956yystrlen (const char *yystr)
Chris Lattner38905612008-02-19 04:36:25 +00002957#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002958static YYSIZE_T
2959yystrlen (yystr)
2960 const char *yystr;
2961#endif
2962{
2963 YYSIZE_T yylen;
2964 for (yylen = 0; yystr[yylen]; yylen++)
2965 continue;
2966 return yylen;
2967}
2968# endif
2969# endif
2970
2971# ifndef yystpcpy
2972# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2973# define yystpcpy stpcpy
2974# else
2975/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2976 YYDEST. */
2977#if (defined __STDC__ || defined __C99__FUNC__ \
2978 || defined __cplusplus || defined _MSC_VER)
2979static char *
2980yystpcpy (char *yydest, const char *yysrc)
2981#else
2982static char *
2983yystpcpy (yydest, yysrc)
2984 char *yydest;
2985 const char *yysrc;
2986#endif
2987{
2988 char *yyd = yydest;
2989 const char *yys = yysrc;
2990
2991 while ((*yyd++ = *yys++) != '\0')
2992 continue;
2993
2994 return yyd - 1;
2995}
2996# endif
2997# endif
2998
2999# ifndef yytnamerr
3000/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3001 quotes and backslashes, so that it's suitable for yyerror. The
3002 heuristic is that double-quoting is unnecessary unless the string
3003 contains an apostrophe, a comma, or backslash (other than
3004 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3005 null, do not copy; instead, return the length of what the result
3006 would have been. */
3007static YYSIZE_T
3008yytnamerr (char *yyres, const char *yystr)
3009{
3010 if (*yystr == '"')
3011 {
3012 YYSIZE_T yyn = 0;
3013 char const *yyp = yystr;
3014
3015 for (;;)
3016 switch (*++yyp)
3017 {
3018 case '\'':
3019 case ',':
3020 goto do_not_strip_quotes;
3021
3022 case '\\':
3023 if (*++yyp != '\\')
3024 goto do_not_strip_quotes;
3025 /* Fall through. */
3026 default:
3027 if (yyres)
3028 yyres[yyn] = *yyp;
3029 yyn++;
3030 break;
3031
3032 case '"':
3033 if (yyres)
3034 yyres[yyn] = '\0';
3035 return yyn;
3036 }
3037 do_not_strip_quotes: ;
3038 }
3039
3040 if (! yyres)
3041 return yystrlen (yystr);
3042
3043 return yystpcpy (yyres, yystr) - yyres;
3044}
3045# endif
3046
3047/* Copy into YYRESULT an error message about the unexpected token
3048 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3049 including the terminating null byte. If YYRESULT is null, do not
3050 copy anything; just return the number of bytes that would be
3051 copied. As a special case, return 0 if an ordinary "syntax error"
3052 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3053 size calculation. */
3054static YYSIZE_T
3055yysyntax_error (char *yyresult, int yystate, int yychar)
3056{
3057 int yyn = yypact[yystate];
3058
3059 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3060 return 0;
3061 else
3062 {
3063 int yytype = YYTRANSLATE (yychar);
3064 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3065 YYSIZE_T yysize = yysize0;
3066 YYSIZE_T yysize1;
3067 int yysize_overflow = 0;
3068 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3069 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3070 int yyx;
3071
3072# if 0
3073 /* This is so xgettext sees the translatable formats that are
3074 constructed on the fly. */
3075 YY_("syntax error, unexpected %s");
3076 YY_("syntax error, unexpected %s, expecting %s");
3077 YY_("syntax error, unexpected %s, expecting %s or %s");
3078 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3079 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3080# endif
3081 char *yyfmt;
3082 char const *yyf;
3083 static char const yyunexpected[] = "syntax error, unexpected %s";
3084 static char const yyexpecting[] = ", expecting %s";
3085 static char const yyor[] = " or %s";
3086 char yyformat[sizeof yyunexpected
3087 + sizeof yyexpecting - 1
3088 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3089 * (sizeof yyor - 1))];
3090 char const *yyprefix = yyexpecting;
3091
3092 /* Start YYX at -YYN if negative to avoid negative indexes in
3093 YYCHECK. */
3094 int yyxbegin = yyn < 0 ? -yyn : 0;
3095
3096 /* Stay within bounds of both yycheck and yytname. */
3097 int yychecklim = YYLAST - yyn + 1;
3098 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3099 int yycount = 1;
3100
3101 yyarg[0] = yytname[yytype];
3102 yyfmt = yystpcpy (yyformat, yyunexpected);
3103
3104 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3105 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3106 {
3107 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3108 {
3109 yycount = 1;
3110 yysize = yysize0;
3111 yyformat[sizeof yyunexpected - 1] = '\0';
3112 break;
3113 }
3114 yyarg[yycount++] = yytname[yyx];
3115 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3116 yysize_overflow |= (yysize1 < yysize);
3117 yysize = yysize1;
3118 yyfmt = yystpcpy (yyfmt, yyprefix);
3119 yyprefix = yyor;
3120 }
3121
3122 yyf = YY_(yyformat);
3123 yysize1 = yysize + yystrlen (yyf);
3124 yysize_overflow |= (yysize1 < yysize);
3125 yysize = yysize1;
3126
3127 if (yysize_overflow)
3128 return YYSIZE_MAXIMUM;
3129
3130 if (yyresult)
3131 {
3132 /* Avoid sprintf, as that infringes on the user's name space.
3133 Don't have undefined behavior even if the translation
3134 produced a string with the wrong number of "%s"s. */
3135 char *yyp = yyresult;
3136 int yyi = 0;
3137 while ((*yyp = *yyf) != '\0')
3138 {
3139 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3140 {
3141 yyp += yytnamerr (yyp, yyarg[yyi++]);
3142 yyf += 2;
3143 }
3144 else
3145 {
3146 yyp++;
3147 yyf++;
3148 }
3149 }
3150 }
3151 return yysize;
3152 }
3153}
3154#endif /* YYERROR_VERBOSE */
3155
3156
3157/*-----------------------------------------------.
3158| Release the memory associated to this symbol. |
3159`-----------------------------------------------*/
3160
3161/*ARGSUSED*/
3162#if (defined __STDC__ || defined __C99__FUNC__ \
3163 || defined __cplusplus || defined _MSC_VER)
3164static void
3165yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3166#else
3167static void
3168yydestruct (yymsg, yytype, yyvaluep)
3169 const char *yymsg;
3170 int yytype;
3171 YYSTYPE *yyvaluep;
3172#endif
3173{
3174 YYUSE (yyvaluep);
3175
3176 if (!yymsg)
3177 yymsg = "Deleting";
3178 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3179
3180 switch (yytype)
3181 {
3182
3183 default:
3184 break;
3185 }
3186}
3187
3188
3189/* Prevent warnings from -Wmissing-prototypes. */
3190
3191#ifdef YYPARSE_PARAM
3192#if defined __STDC__ || defined __cplusplus
3193int yyparse (void *YYPARSE_PARAM);
3194#else
3195int yyparse ();
3196#endif
3197#else /* ! YYPARSE_PARAM */
3198#if defined __STDC__ || defined __cplusplus
David Greene5fd22a82007-09-04 18:46:50 +00003199int yyparse (void);
Gabor Greife64d2482008-04-06 23:07:54 +00003200#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003201int yyparse ();
Scott Michel15dcd8e2008-01-30 03:10:00 +00003202#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003203#endif /* ! YYPARSE_PARAM */
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003204
Chris Lattner38905612008-02-19 04:36:25 +00003205
Dan Gohmanf4423b12008-04-19 00:24:39 +00003206
3207/* The look-ahead symbol. */
3208int yychar;
3209
3210/* The semantic value of the look-ahead symbol. */
3211YYSTYPE yylval;
3212
3213/* Number of syntax errors so far. */
3214int yynerrs;
3215
3216
3217
3218/*----------.
3219| yyparse. |
3220`----------*/
3221
3222#ifdef YYPARSE_PARAM
3223#if (defined __STDC__ || defined __C99__FUNC__ \
3224 || defined __cplusplus || defined _MSC_VER)
3225int
3226yyparse (void *YYPARSE_PARAM)
3227#else
3228int
3229yyparse (YYPARSE_PARAM)
3230 void *YYPARSE_PARAM;
3231#endif
3232#else /* ! YYPARSE_PARAM */
3233#if (defined __STDC__ || defined __C99__FUNC__ \
3234 || defined __cplusplus || defined _MSC_VER)
3235int
3236yyparse (void)
3237#else
3238int
3239yyparse ()
3240
Gabor Greife64d2482008-04-06 23:07:54 +00003241#endif
3242#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003243{
3244
3245 int yystate;
3246 int yyn;
3247 int yyresult;
3248 /* Number of tokens to shift before error messages enabled. */
3249 int yyerrstatus;
3250 /* Look-ahead token as an internal (translated) token number. */
3251 int yytoken = 0;
3252#if YYERROR_VERBOSE
3253 /* Buffer for error messages, and its allocated size. */
3254 char yymsgbuf[128];
3255 char *yymsg = yymsgbuf;
3256 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greife64d2482008-04-06 23:07:54 +00003257#endif
Chris Lattner38905612008-02-19 04:36:25 +00003258
Dan Gohmanf4423b12008-04-19 00:24:39 +00003259 /* Three stacks and their tools:
3260 `yyss': related to states,
3261 `yyvs': related to semantic values,
3262 `yyls': related to locations.
3263
3264 Refer to the stacks thru separate pointers, to allow yyoverflow
3265 to reallocate them elsewhere. */
3266
3267 /* The state stack. */
3268 yytype_int16 yyssa[YYINITDEPTH];
3269 yytype_int16 *yyss = yyssa;
3270 yytype_int16 *yyssp;
3271
3272 /* The semantic value stack. */
3273 YYSTYPE yyvsa[YYINITDEPTH];
3274 YYSTYPE *yyvs = yyvsa;
3275 YYSTYPE *yyvsp;
3276
3277
3278
3279#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3280
3281 YYSIZE_T yystacksize = YYINITDEPTH;
3282
3283 /* The variables used to return semantic value and location from the
3284 action routines. */
3285 YYSTYPE yyval;
3286
3287
3288 /* The number of symbols on the RHS of the reduced rule.
3289 Keep to zero when no symbol should be popped. */
3290 int yylen = 0;
3291
3292 YYDPRINTF ((stderr, "Starting parse\n"));
3293
Reid Spencer68a24bd2005-08-27 18:50:39 +00003294 yystate = 0;
3295 yyerrstatus = 0;
3296 yynerrs = 0;
3297 yychar = YYEMPTY; /* Cause a token to be read. */
3298
3299 /* Initialize stack pointers.
3300 Waste one element of value and location stack
3301 so that they stay on the same level as the state stack.
3302 The wasted elements are never initialized. */
3303
Dan Gohmanf4423b12008-04-19 00:24:39 +00003304 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003305 yyvsp = yyvs;
3306
Dan Gohmanf4423b12008-04-19 00:24:39 +00003307 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003308
Dan Gohmanf4423b12008-04-19 00:24:39 +00003309/*------------------------------------------------------------.
3310| yynewstate -- Push a new state, which is found in yystate. |
3311`------------------------------------------------------------*/
3312 yynewstate:
3313 /* In all cases, when you get here, the value and location stacks
3314 have just been pushed. So pushing a state here evens the stacks. */
3315 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003316
Dan Gohmanf4423b12008-04-19 00:24:39 +00003317 yysetstate:
3318 *yyssp = yystate;
3319
3320 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003321 {
3322 /* Get the current used size of the three stacks, in elements. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003323 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003324
3325#ifdef yyoverflow
Dan Gohmanf4423b12008-04-19 00:24:39 +00003326 {
3327 /* Give user a chance to reallocate the stack. Use copies of
3328 these so that the &'s don't force the real ones into
3329 memory. */
3330 YYSTYPE *yyvs1 = yyvs;
3331 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003332
Dan Gohmanf4423b12008-04-19 00:24:39 +00003333
3334 /* Each stack pointer address is followed by the size of the
3335 data in use in that stack, in bytes. This used to be a
3336 conditional around just the two extra args, but that might
3337 be undefined if yyoverflow is a macro. */
3338 yyoverflow (YY_("memory exhausted"),
3339 &yyss1, yysize * sizeof (*yyssp),
3340 &yyvs1, yysize * sizeof (*yyvsp),
3341
3342 &yystacksize);
3343
3344 yyss = yyss1;
3345 yyvs = yyvs1;
3346 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003347#else /* no yyoverflow */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003348# ifndef YYSTACK_RELOCATE
3349 goto yyexhaustedlab;
3350# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003351 /* Extend the stack our own way. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003352 if (YYMAXDEPTH <= yystacksize)
3353 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003354 yystacksize *= 2;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003355 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003356 yystacksize = YYMAXDEPTH;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003357
3358 {
3359 yytype_int16 *yyss1 = yyss;
3360 union yyalloc *yyptr =
3361 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3362 if (! yyptr)
3363 goto yyexhaustedlab;
3364 YYSTACK_RELOCATE (yyss);
3365 YYSTACK_RELOCATE (yyvs);
3366
3367# undef YYSTACK_RELOCATE
3368 if (yyss1 != yyssa)
3369 YYSTACK_FREE (yyss1);
3370 }
3371# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003372#endif /* no yyoverflow */
3373
Dan Gohmanf4423b12008-04-19 00:24:39 +00003374 yyssp = yyss + yysize - 1;
3375 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003376
3377
Dan Gohmanf4423b12008-04-19 00:24:39 +00003378 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3379 (unsigned long int) yystacksize));
3380
3381 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003382 YYABORT;
3383 }
3384
Dan Gohmanf4423b12008-04-19 00:24:39 +00003385 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003386
3387 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003388
Dan Gohmanf4423b12008-04-19 00:24:39 +00003389/*-----------.
3390| yybackup. |
3391`-----------*/
3392yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003393
Dan Gohmanf4423b12008-04-19 00:24:39 +00003394 /* Do appropriate processing given the current state. Read a
3395 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003396
Dan Gohmanf4423b12008-04-19 00:24:39 +00003397 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003398 yyn = yypact[yystate];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003399 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003400 goto yydefault;
3401
Dan Gohmanf4423b12008-04-19 00:24:39 +00003402 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003403
Dan Gohmanf4423b12008-04-19 00:24:39 +00003404 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003405 if (yychar == YYEMPTY)
3406 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003407 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003408 yychar = YYLEX;
3409 }
3410
Dan Gohmanf4423b12008-04-19 00:24:39 +00003411 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003412 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003413 yychar = yytoken = YYEOF;
3414 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003415 }
3416 else
3417 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003418 yytoken = YYTRANSLATE (yychar);
3419 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003420 }
3421
Dan Gohmanf4423b12008-04-19 00:24:39 +00003422 /* If the proper action on seeing token YYTOKEN is to reduce or to
3423 detect an error, take that action. */
3424 yyn += yytoken;
3425 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003426 goto yydefault;
3427 yyn = yytable[yyn];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003428 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003429 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003430 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003431 goto yyerrlab;
3432 yyn = -yyn;
3433 goto yyreduce;
3434 }
3435
3436 if (yyn == YYFINAL)
3437 YYACCEPT;
3438
Dan Gohmanf4423b12008-04-19 00:24:39 +00003439 /* Count tokens shifted since error; after three, turn off error
3440 status. */
3441 if (yyerrstatus)
3442 yyerrstatus--;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003443
Dan Gohmanf4423b12008-04-19 00:24:39 +00003444 /* Shift the look-ahead token. */
3445 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003446
Dan Gohmanf4423b12008-04-19 00:24:39 +00003447 /* Discard the shifted token unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003448 if (yychar != YYEOF)
3449 yychar = YYEMPTY;
3450
Gabor Greife64d2482008-04-06 23:07:54 +00003451 yystate = yyn;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003452 *++yyvsp = yylval;
3453
Reid Spencer68a24bd2005-08-27 18:50:39 +00003454 goto yynewstate;
3455
Gabor Greife64d2482008-04-06 23:07:54 +00003456
Dan Gohmanf4423b12008-04-19 00:24:39 +00003457/*-----------------------------------------------------------.
3458| yydefault -- do the default action for the current state. |
3459`-----------------------------------------------------------*/
3460yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003461 yyn = yydefact[yystate];
3462 if (yyn == 0)
3463 goto yyerrlab;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003464 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003465
Dan Gohmanf4423b12008-04-19 00:24:39 +00003466
3467/*-----------------------------.
3468| yyreduce -- Do a reduction. |
3469`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003470yyreduce:
Dan Gohmanf4423b12008-04-19 00:24:39 +00003471 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003472 yylen = yyr2[yyn];
3473
Dan Gohmanf4423b12008-04-19 00:24:39 +00003474 /* If YYLEN is nonzero, implement the default value of the action:
3475 `$$ = $1'.
3476
3477 Otherwise, the following line sets YYVAL to garbage.
3478 This behavior is undocumented and Bison
3479 users should not rely upon it. Assigning to YYVAL
3480 unconditionally makes the parser a bit smaller, and it avoids a
3481 GCC warning that YYVAL may be used uninitialized. */
3482 yyval = yyvsp[1-yylen];
3483
3484
3485 YY_REDUCE_PRINT (yyn);
3486 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003487 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003488 case 29:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003489#line 1118 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003490 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3491 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003492
Dan Gohmanf4423b12008-04-19 00:24:39 +00003493 case 30:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003494#line 1118 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003495 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3496 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003497
Dan Gohmanf4423b12008-04-19 00:24:39 +00003498 case 31:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003499#line 1119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003500 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3501 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003502
Dan Gohmanf4423b12008-04-19 00:24:39 +00003503 case 32:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003504#line 1119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003505 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3506 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003507
Dan Gohmanf4423b12008-04-19 00:24:39 +00003508 case 33:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003509#line 1120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003510 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3511 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003512
Dan Gohmanf4423b12008-04-19 00:24:39 +00003513 case 34:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003514#line 1120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003515 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3516 break;
3517
3518 case 35:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003519#line 1121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003520 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3521 break;
3522
3523 case 36:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003524#line 1121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003525 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3526 break;
3527
3528 case 37:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003529#line 1122 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003530 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3531 break;
3532
3533 case 38:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003534#line 1122 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003535 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3536 break;
3537
3538 case 39:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003539#line 1126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003540 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3541 break;
3542
3543 case 40:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003544#line 1126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003545 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3546 break;
3547
3548 case 41:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003549#line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003550 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3551 break;
3552
3553 case 42:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003554#line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003555 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3556 break;
3557
3558 case 43:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003559#line 1128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003560 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3561 break;
3562
3563 case 44:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003564#line 1128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003565 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3566 break;
3567
3568 case 45:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003569#line 1129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003570 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3571 break;
3572
3573 case 46:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003574#line 1129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003575 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3576 break;
3577
3578 case 47:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003579#line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003580 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3581 break;
3582
3583 case 48:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003584#line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003585 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3586 break;
3587
3588 case 49:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003589#line 1131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003590 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3591 break;
3592
3593 case 50:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003594#line 1131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003595 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3596 break;
3597
3598 case 51:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003599#line 1132 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003600 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3601 break;
3602
3603 case 52:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003604#line 1132 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003605 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3606 break;
3607
3608 case 53:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003609#line 1133 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003610 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3611 break;
3612
3613 case 54:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003614#line 1134 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003615 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3616 break;
3617
3618 case 65:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003619#line 1143 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003620 { (yyval.StrVal) = 0; ;}
3621 break;
3622
3623 case 66:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003624#line 1145 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003625 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3626 break;
3627
3628 case 67:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003629#line 1146 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003630 { (yyval.UIntVal)=0; ;}
3631 break;
3632
3633 case 68:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003634#line 1150 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003635 {
3636 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003637 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003638 ;}
3639 break;
3640
3641 case 69:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003642#line 1154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003643 {
3644 (yyval.StrVal) = 0;
Christopher Lambbf3348d2007-12-12 08:45:45 +00003645 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003646 ;}
3647 break;
3648
3649 case 73:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003650#line 1162 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003651 {
3652 (yyval.StrVal) = 0;
Christopher Lambbf3348d2007-12-12 08:45:45 +00003653 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003654 ;}
3655 break;
3656
3657 case 74:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003658#line 1167 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003659 {
3660 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00003661 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003662 ;}
3663 break;
3664
3665 case 75:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003666#line 1173 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003667 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3668 break;
3669
3670 case 76:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003671#line 1174 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003672 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3673 break;
3674
3675 case 77:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003676#line 1175 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003677 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3678 break;
3679
3680 case 78:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003681#line 1176 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003682 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3683 break;
3684
3685 case 79:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003686#line 1177 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003687 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3688 break;
3689
3690 case 80:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003691#line 1181 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003692 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3693 break;
3694
3695 case 81:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003696#line 1182 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003697 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3698 break;
3699
3700 case 82:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003701#line 1183 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003702 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3703 break;
3704
3705 case 83:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003706#line 1187 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003707 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3708 break;
3709
3710 case 84:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003711#line 1188 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003712 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3713 break;
3714
3715 case 85:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003716#line 1189 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003717 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3718 break;
3719
3720 case 86:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003721#line 1190 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003722 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3723 break;
3724
3725 case 87:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003726#line 1194 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003727 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3728 break;
3729
3730 case 88:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003731#line 1195 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003732 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3733 break;
3734
3735 case 89:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003736#line 1196 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003737 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3738 break;
3739
3740 case 90:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003741#line 1200 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003742 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3743 break;
3744
3745 case 91:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003746#line 1201 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003747 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3748 break;
3749
3750 case 92:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003751#line 1202 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003752 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3753 break;
3754
3755 case 93:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003756#line 1203 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003757 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3758 break;
3759
3760 case 94:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003761#line 1204 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003762 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3763 break;
3764
3765 case 95:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003766#line 1208 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003767 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3768 break;
3769
3770 case 96:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003771#line 1209 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003772 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3773 break;
3774
3775 case 97:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003776#line 1210 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003777 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3778 break;
3779
3780 case 98:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003781#line 1213 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003782 { (yyval.UIntVal) = CallingConv::C; ;}
3783 break;
3784
3785 case 99:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003786#line 1214 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003787 { (yyval.UIntVal) = CallingConv::C; ;}
3788 break;
3789
3790 case 100:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003791#line 1215 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003792 { (yyval.UIntVal) = CallingConv::Fast; ;}
3793 break;
3794
3795 case 101:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003796#line 1216 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003797 { (yyval.UIntVal) = CallingConv::Cold; ;}
3798 break;
3799
3800 case 102:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003801#line 1217 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003802 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3803 break;
3804
3805 case 103:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003806#line 1218 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003807 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3808 break;
3809
3810 case 104:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003811#line 1219 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003812 {
3813 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003814 GEN_ERROR("Calling conv too large");
Dan Gohmanf4423b12008-04-19 00:24:39 +00003815 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003816 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003817 ;}
3818 break;
3819
3820 case 105:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003821#line 1226 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003822 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3823 break;
3824
3825 case 106:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003826#line 1227 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003827 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3828 break;
3829
3830 case 107:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003831#line 1228 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003832 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3833 break;
3834
3835 case 108:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003836#line 1229 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003837 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3838 break;
3839
3840 case 109:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003841#line 1230 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003842 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3843 break;
3844
3845 case 110:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003846#line 1231 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003847 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3848 break;
3849
3850 case 111:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003851#line 1232 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003852 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3853 break;
3854
3855 case 112:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003856#line 1233 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003857 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3858 break;
3859
3860 case 113:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003861#line 1234 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003862 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3863 break;
3864
3865 case 114:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003866#line 1235 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003867 { (yyval.ParamAttrs) =
3868 ParamAttr::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
3869 break;
3870
3871 case 115:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003872#line 1239 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003873 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3874 break;
3875
3876 case 116:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003877#line 1240 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003878 {
3879 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3880 ;}
3881 break;
3882
3883 case 117:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003884#line 1245 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003885 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3886 break;
3887
3888 case 118:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003889#line 1246 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003890 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3891 break;
3892
3893 case 119:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003894#line 1247 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003895 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3896 break;
3897
3898 case 120:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003899#line 1248 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003900 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3901 break;
3902
3903 case 121:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003904#line 1249 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003905 { (yyval.ParamAttrs) = ParamAttr::ReadNone; ;}
3906 break;
3907
3908 case 122:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003909#line 1250 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003910 { (yyval.ParamAttrs) = ParamAttr::ReadOnly; ;}
3911 break;
3912
3913 case 123:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003914#line 1253 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003915 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3916 break;
3917
3918 case 124:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003919#line 1254 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003920 {
3921 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3922 ;}
3923 break;
3924
3925 case 125:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003926#line 1259 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003927 { (yyval.StrVal) = 0; ;}
3928 break;
3929
3930 case 126:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003931#line 1260 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003932 {
3933 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
3934 ;}
3935 break;
3936
3937 case 127:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003938#line 1267 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003939 { (yyval.UIntVal) = 0; ;}
3940 break;
3941
3942 case 128:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003943#line 1268 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003944 {
3945 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3946 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003947 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003948 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003949;}
3950 break;
3951
3952 case 129:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003953#line 1274 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003954 { (yyval.UIntVal) = 0; ;}
3955 break;
3956
3957 case 130:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003958#line 1275 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003959 {
3960 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3961 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lambbf3348d2007-12-12 08:45:45 +00003962 GEN_ERROR("Alignment must be a power of two");
3963 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003964;}
3965 break;
3966
3967 case 131:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003968#line 1284 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003969 {
3970 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
3971 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003972 GEN_ERROR("Invalid character in section name");
Dan Gohmanf4423b12008-04-19 00:24:39 +00003973 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003974 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003975;}
3976 break;
3977
3978 case 132:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003979#line 1292 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003980 { (yyval.StrVal) = 0; ;}
3981 break;
3982
3983 case 133:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003984#line 1293 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003985 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3986 break;
3987
3988 case 134:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003989#line 1298 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003990 {;}
3991 break;
3992
3993 case 135:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003994#line 1299 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003995 {;}
3996 break;
3997
3998 case 136:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00003999#line 1300 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004000 {
4001 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4002 delete (yyvsp[(1) - (1)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004003 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004004 ;}
4005 break;
4006
4007 case 137:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004008#line 1305 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004009 {
4010 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004011 GEN_ERROR("Alignment must be a power of two");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004012 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004013 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004014 ;}
4015 break;
4016
4017 case 145:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004018#line 1321 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004019 {
4020 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004021 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004022 ;}
4023 break;
4024
4025 case 146:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004026#line 1325 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004027 {
4028 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004029 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004030 ;}
4031 break;
4032
4033 case 147:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004034#line 1329 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004035 { // Pointer type?
4036 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lambbf3348d2007-12-12 08:45:45 +00004037 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004038 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4039 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00004040 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004041 ;}
4042 break;
4043
4044 case 148:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004045#line 1336 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004046 { // Named types are also simple types...
4047 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004048 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004049 (yyval.TypeVal) = new PATypeHolder(tmp);
4050 ;}
4051 break;
4052
4053 case 149:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004054#line 1341 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004055 { // Type UpReference
4056 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004057 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohmanf4423b12008-04-19 00:24:39 +00004058 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4059 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004060 UR_OUT("New Upreference!\n");
4061 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004062 ;}
4063 break;
4064
4065 case 150:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004066#line 1349 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004067 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004068 // Allow but ignore attributes on function types; this permits auto-upgrade.
4069 // FIXME: remove in LLVM 3.0.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004070 const Type* RetTy = *(yyvsp[(1) - (5)].TypeVal);
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004071 if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00004072 isa<StructType>(RetTy) ||
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004073 isa<OpaqueType>(RetTy)))
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004074 GEN_ERROR("LLVM Functions cannot return aggregates");
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004075
Reid Spencer41dff5e2007-01-26 08:05:27 +00004076 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004077 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004078 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004079 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004080 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004081 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004082
Reid Spencer41dff5e2007-01-26 08:05:27 +00004083 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4084 if (isVarArg) Params.pop_back();
4085
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004086 for (unsigned i = 0; i != Params.size(); ++i)
4087 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4088 GEN_ERROR("Function arguments must be value types!");
4089
4090 CHECK_FOR_ERROR
4091
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004092 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004093 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4094 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
4095 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004096 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004097 ;}
4098 break;
4099
4100 case 151:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004101#line 1380 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004102 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004103 // Allow but ignore attributes on function types; this permits auto-upgrade.
4104 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004105 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004106 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004107 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004108 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004109 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004110 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004111
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004112 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4113 if (isVarArg) Params.pop_back();
4114
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004115 for (unsigned i = 0; i != Params.size(); ++i)
4116 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4117 GEN_ERROR("Function arguments must be value types!");
4118
4119 CHECK_FOR_ERROR
4120
Dan Gohmanf4423b12008-04-19 00:24:39 +00004121 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
4122 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4123 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004124 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004125 ;}
4126 break;
4127
4128 case 152:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004129#line 1405 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004130 { // Sized array type?
4131 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4132 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004133 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004134 ;}
4135 break;
4136
4137 case 153:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004138#line 1410 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004139 { // Vector type?
4140 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4141 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004142 GEN_ERROR("Unsigned result not equal to signed result");
4143 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4144 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004145 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4146 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004147 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004148 ;}
4149 break;
4150
4151 case 154:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004152#line 1420 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004153 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004154 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004155 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4156 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004157 Elements.push_back(*I);
4158
Dan Gohmanf4423b12008-04-19 00:24:39 +00004159 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4160 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004161 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004162 ;}
4163 break;
4164
4165 case 155:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004166#line 1430 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004167 { // Empty structure type?
4168 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004169 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004170 ;}
4171 break;
4172
4173 case 156:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004174#line 1434 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004175 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004176 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004177 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4178 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004179 Elements.push_back(*I);
4180
Dan Gohmanf4423b12008-04-19 00:24:39 +00004181 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4182 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004183 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004184 ;}
4185 break;
4186
4187 case 157:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004188#line 1444 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004189 { // Empty structure type?
4190 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004191 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004192 ;}
4193 break;
4194
4195 case 158:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004196#line 1451 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004197 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004198 // Allow but ignore attributes on function types; this permits auto-upgrade.
4199 // FIXME: remove in LLVM 3.0.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004200 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
4201 (yyval.TypeWithAttrs).Attrs = ParamAttr::None;
4202 ;}
4203 break;
4204
4205 case 159:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004206#line 1460 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004207 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004208 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004209 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4210 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004211 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004212 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4213 ;}
4214 break;
4215
4216 case 160:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004217#line 1467 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004218 {
4219 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4220 ;}
4221 break;
4222
4223 case 161:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004224#line 1472 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004225 {
4226 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4227 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004228 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004229 ;}
4230 break;
4231
4232 case 162:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004233#line 1477 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004234 {
4235 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004236 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004237 ;}
4238 break;
4239
4240 case 164:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004241#line 1485 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004242 {
4243 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00004244 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004245 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004246 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004247 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004248 ;}
4249 break;
4250
4251 case 165:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004252#line 1492 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004253 {
4254 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004255 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4256 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 166:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004263#line 1499 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004264 {
4265 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004266 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004267 ;}
4268 break;
4269
4270 case 167:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004271#line 1507 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004272 {
4273 (yyval.TypeList) = new std::list<PATypeHolder>();
4274 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4275 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004276 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004277 ;}
4278 break;
4279
4280 case 168:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004281#line 1513 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004282 {
4283 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4284 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004285 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004286 ;}
4287 break;
4288
4289 case 169:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004290#line 1525 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004291 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004292 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004293 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4294 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004295 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004296 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004297 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004298 const Type *ETy = ATy->getElementType();
4299 int NumElements = ATy->getNumElements();
4300
4301 // Verify that we have the correct size...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004302 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004303 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004304 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004305 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004306
4307 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004308 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4309 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004310 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4311 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004312 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004313 }
4314
Dan Gohmanf4423b12008-04-19 00:24:39 +00004315 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4316 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004317 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004318 ;}
4319 break;
4320
4321 case 170:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004322#line 1553 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004323 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004324 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004325 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4326 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004327 if (ATy == 0)
4328 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004329 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004330
Andrew Lenharth6353e052006-12-08 18:07:09 +00004331 int NumElements = ATy->getNumElements();
4332 if (NumElements != -1 && NumElements != 0)
4333 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00004334 " arguments, but has size of " + itostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004335 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4336 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004337 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004338 ;}
4339 break;
4340
4341 case 171:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004342#line 1569 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004343 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004344 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004345 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4346 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004347 if (ATy == 0)
4348 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004349 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004350
4351 int NumElements = ATy->getNumElements();
4352 const Type *ETy = ATy->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00004353 if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004354 GEN_ERROR("Can't build string constant of size " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004355 itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004356 " when array has size " + itostr(NumElements) + "");
4357 std::vector<Constant*> Vals;
4358 if (ETy == Type::Int8Ty) {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004359 for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
4360 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004361 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004362 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004363 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4364 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004365 delete (yyvsp[(3) - (3)].StrVal);
4366 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4367 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004368 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004369 ;}
4370 break;
4371
4372 case 172:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004373#line 1596 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004374 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004375 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004376 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4377 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004378 if (PTy == 0)
4379 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004380 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004381 const Type *ETy = PTy->getElementType();
4382 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004383
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004384 // Verify that we have the correct size...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004385 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004386 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004387 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004388 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004389
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004390 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004391 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4392 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004393 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4394 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004395 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004396 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004397
Dan Gohmanf4423b12008-04-19 00:24:39 +00004398 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4399 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004400 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004401 ;}
4402 break;
4403
4404 case 173:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004405#line 1624 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004406 {
4407 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004408 if (STy == 0)
4409 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004410 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004411
Dan Gohmanf4423b12008-04-19 00:24:39 +00004412 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004413 GEN_ERROR("Illegal number of initializers for structure type");
4414
4415 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004416 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4417 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004418 GEN_ERROR("Expected type '" +
4419 STy->getElementType(i)->getDescription() +
4420 "' for element #" + utostr(i) +
4421 " of structure initializer");
4422
4423 // Check to ensure that Type is not packed
4424 if (STy->isPacked())
4425 GEN_ERROR("Unpacked Initializer to vector type '" +
4426 STy->getDescription() + "'");
4427
Dan Gohmanf4423b12008-04-19 00:24:39 +00004428 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4429 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004430 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004431 ;}
4432 break;
4433
4434 case 174:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004435#line 1650 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004436 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004437 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004438 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4439 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004440 if (STy == 0)
4441 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004442 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004443
4444 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004445 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004446
4447 // Check to ensure that Type is not packed
4448 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004449 GEN_ERROR("Unpacked Initializer to vector type '" +
4450 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004451
Dan Gohmanf4423b12008-04-19 00:24:39 +00004452 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4453 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004454 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004455 ;}
4456 break;
4457
4458 case 175:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004459#line 1670 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004460 {
4461 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004462 if (STy == 0)
4463 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004464 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004465
Dan Gohmanf4423b12008-04-19 00:24:39 +00004466 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004467 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004468
4469 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004470 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4471 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004472 GEN_ERROR("Expected type '" +
4473 STy->getElementType(i)->getDescription() +
4474 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004475 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004476
4477 // Check to ensure that Type is packed
4478 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004479 GEN_ERROR("Vector initializer to non-vector type '" +
4480 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004481
Dan Gohmanf4423b12008-04-19 00:24:39 +00004482 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4483 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004484 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004485 ;}
4486 break;
4487
4488 case 176:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004489#line 1696 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004490 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004491 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004492 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4493 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004494 if (STy == 0)
4495 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004496 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004497
4498 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004499 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004500
4501 // Check to ensure that Type is packed
4502 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004503 GEN_ERROR("Vector initializer to non-vector type '" +
4504 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004505
Dan Gohmanf4423b12008-04-19 00:24:39 +00004506 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4507 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004508 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004509 ;}
4510 break;
4511
4512 case 177:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004513#line 1716 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004514 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004515 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004516 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4517 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004518 if (PTy == 0)
4519 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004520 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004521
Dan Gohmanf4423b12008-04-19 00:24:39 +00004522 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4523 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004524 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004525 ;}
4526 break;
4527
4528 case 178:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004529#line 1728 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004530 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004531 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004532 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4533 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4534 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004535 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004536 ;}
4537 break;
4538
4539 case 179:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004540#line 1735 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004541 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004542 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004543 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4544 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004545 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004546 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004547
4548 // ConstExprs can exist in the body of a function, thus creating
4549 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004550 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004551 // symbol table instead of the module symbol table for the global symbol,
4552 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004553 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004554 //
4555 Function *SavedCurFn = CurFun.CurrentFunction;
4556 CurFun.CurrentFunction = 0;
4557
Dan Gohmanf4423b12008-04-19 00:24:39 +00004558 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004559 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004560
4561 CurFun.CurrentFunction = SavedCurFn;
4562
4563 // If this is an initializer for a constant pointer, which is referencing a
4564 // (currently) undefined variable, create a stub now that shall be replaced
4565 // in the future with the right type of variable.
4566 //
4567 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004568 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004569 const PointerType *PT = cast<PointerType>(Ty);
4570
4571 // First check to see if the forward references value is already created!
4572 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004573 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004574
4575 if (I != CurModule.GlobalRefs.end()) {
4576 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004577 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004578 } else {
4579 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004580 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4581 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4582 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004583 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004584
4585 // Create the forward referenced global.
4586 GlobalValue *GV;
4587 if (const FunctionType *FTy =
4588 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004589 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4590 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004591 } else {
4592 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004593 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004594 Name, CurModule.CurrentModule);
4595 }
4596
4597 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004598 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004599 V = GV;
4600 }
4601 }
4602
Dan Gohmanf4423b12008-04-19 00:24:39 +00004603 (yyval.ConstVal) = cast<GlobalValue>(V);
4604 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004605 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004606 ;}
4607 break;
4608
4609 case 180:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004610#line 1801 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004611 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004612 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004613 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4614 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004615 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004616 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4617 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4618 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004619 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004620 ;}
4621 break;
4622
4623 case 181:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004624#line 1811 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004625 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004626 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004627 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4628 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004629 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4630 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004631 (yyval.ConstVal) = Constant::getNullValue(Ty);
4632 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004633 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004634 ;}
4635 break;
4636
4637 case 182:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004638#line 1821 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004639 { // integral constants
4640 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004641 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004642 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004643 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004644 ;}
4645 break;
4646
4647 case 183:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004648#line 1827 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004649 { // arbitrary precision integer constants
4650 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4651 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004652 GEN_ERROR("Constant value does not fit in type");
4653 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004654 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4655 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4656 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004657 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004658 ;}
4659 break;
4660
4661 case 184:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004662#line 1837 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004663 { // integral constants
4664 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004665 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004666 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004667 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004668 ;}
4669 break;
4670
4671 case 185:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004672#line 1843 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004673 { // arbitrary precision integer constants
4674 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4675 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004676 GEN_ERROR("Constant value does not fit in type");
4677 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004678 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4679 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4680 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004681 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004682 ;}
4683 break;
4684
4685 case 186:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004686#line 1853 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004687 { // Boolean constants
4688 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4689 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004690 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004691 ;}
4692 break;
4693
4694 case 187:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004695#line 1858 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004696 { // Boolean constants
4697 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4698 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004699 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004700 ;}
4701 break;
4702
4703 case 188:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004704#line 1863 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004705 { // Floating point constants
4706 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004707 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004708 // Lexer has no type info, so builds all float and double FP constants
4709 // as double. Fix this here. Long double is done right.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004710 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4711 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004712 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004713 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004714 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004715 ;}
4716 break;
4717
4718 case 189:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004719#line 1876 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004720 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004721 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004722 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4723 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4724 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4725 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004726 GEN_ERROR("invalid cast opcode for cast from '" +
4727 Val->getType()->getDescription() + "' to '" +
4728 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004729 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4730 delete (yyvsp[(5) - (6)].TypeVal);
4731 ;}
4732 break;
4733
4734 case 190:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004735#line 1888 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004736 {
4737 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004738 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004739
4740 const Type *IdxTy =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004741 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004742 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004743 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004744 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004745
Chris Lattnerf7469af2007-01-31 04:44:08 +00004746 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004747 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4748 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004749 IdxVec.push_back(C);
4750 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004751 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004752
Dan Gohmanf4423b12008-04-19 00:24:39 +00004753 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004754
Dan Gohmanf4423b12008-04-19 00:24:39 +00004755 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004756 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004757 ;}
4758 break;
4759
4760 case 191:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004761#line 1910 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004762 {
4763 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004764 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004765 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004766 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004767 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004768 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004769 ;}
4770 break;
4771
4772 case 192:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004773#line 1918 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004774 {
4775 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004776 GEN_ERROR("Binary operator types must match");
4777 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004778 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4779 ;}
4780 break;
4781
4782 case 193:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004783#line 1924 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004784 {
4785 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004786 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004787 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4788 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4789 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004790 GEN_ERROR("Logical operator requires integral operands");
4791 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004792 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004793 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004794 ;}
4795 break;
4796
4797 case 194:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004798#line 1935 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004799 {
4800 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004801 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004802 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4803 ;}
4804 break;
4805
4806 case 195:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004807#line 1940 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004808 {
4809 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004810 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004811 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4812 ;}
4813 break;
4814
4815 case 196:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004816#line 1945 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004817 {
4818 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004819 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004820 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004821 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004822 ;}
4823 break;
4824
4825 case 197:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004826#line 1951 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004827 {
4828 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004829 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004830 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004831 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004832 ;}
4833 break;
4834
4835 case 198:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004836#line 1957 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004837 {
4838 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004839 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004840 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004841 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004842 ;}
4843 break;
4844
4845 case 199:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004846#line 1966 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004847 {
4848 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004849 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004850 ;}
4851 break;
4852
4853 case 200:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004854#line 1970 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004855 {
4856 (yyval.ConstVector) = new std::vector<Constant*>();
4857 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004858 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004859 ;}
4860 break;
4861
4862 case 201:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004863#line 1978 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004864 { (yyval.BoolVal) = false; ;}
4865 break;
4866
4867 case 202:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004868#line 1978 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004869 { (yyval.BoolVal) = true; ;}
4870 break;
4871
4872 case 203:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004873#line 1981 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004874 { (yyval.BoolVal) = true; ;}
4875 break;
4876
4877 case 204:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004878#line 1981 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004879 { (yyval.BoolVal) = false; ;}
4880 break;
4881
4882 case 205:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004883#line 1984 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004884 {
4885 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4886 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00004887 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004888 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4889 if (!Aliasee)
4890 GEN_ERROR("Aliases can be created only to global values");
4891
Dan Gohmanf4423b12008-04-19 00:24:39 +00004892 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004893 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004894 delete (yyvsp[(1) - (2)].TypeVal);
4895 ;}
4896 break;
4897
4898 case 206:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004899#line 1996 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004900 {
4901 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4902 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4903 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004904 GEN_ERROR("invalid cast opcode for cast from '" +
4905 Val->getType()->getDescription() + "' to '" +
4906 DestTy->getDescription() + "'");
4907
Dan Gohmanf4423b12008-04-19 00:24:39 +00004908 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004909 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004910 delete (yyvsp[(5) - (6)].TypeVal);
4911 ;}
4912 break;
4913
4914 case 207:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004915#line 2017 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004916 {
4917 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Christopher Lambbf3348d2007-12-12 08:45:45 +00004918 CurModule.ModuleDone();
4919 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004920 ;}
4921 break;
4922
4923 case 208:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004924#line 2022 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004925 {
4926 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Dale Johannesen172f3112008-02-20 21:15:43 +00004927 CurModule.ModuleDone();
4928 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004929 ;}
4930 break;
4931
4932 case 211:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004933#line 2035 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004934 { CurFun.isDeclare = false; ;}
4935 break;
4936
4937 case 212:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004938#line 2035 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004939 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004940 CurFun.FunctionDone();
4941 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004942 ;}
4943 break;
4944
4945 case 213:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004946#line 2039 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004947 { CurFun.isDeclare = true; ;}
4948 break;
4949
4950 case 214:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004951#line 2039 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004952 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00004953 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004954 ;}
4955 break;
4956
4957 case 215:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004958#line 2042 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004959 {
Dale Johannesen172f3112008-02-20 21:15:43 +00004960 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004961 ;}
4962 break;
4963
4964 case 216:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004965#line 2045 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004966 {
Reid Spencer14310612006-12-31 05:40:51 +00004967 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004968 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004969 // Eagerly resolve types. This is not an optimization, this is a
4970 // requirement that is due to the fact that we could have this:
4971 //
4972 // %list = type { %list * }
4973 // %list = type { %list * } ; repeated type decl
4974 //
4975 // If types are not resolved eagerly, then the two types will not be
4976 // determined to be the same type!
4977 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00004978 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004979
Dan Gohmanf4423b12008-04-19 00:24:39 +00004980 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004981 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004982 // If this is a named type that is not a redefinition, add it to the slot
4983 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004984 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004985 }
Reid Spencera132e042006-12-03 05:46:11 +00004986
Dan Gohmanf4423b12008-04-19 00:24:39 +00004987 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004988 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004989 ;}
4990 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00004991
Dan Gohmanf4423b12008-04-19 00:24:39 +00004992 case 217:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004993#line 2069 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004994 {
4995 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4996
4997 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004998 CHECK_FOR_ERROR
4999 // If this is a named type that is not a redefinition, add it to the slot
5000 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005001 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005002 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005003 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005004 ;}
5005 break;
5006
5007 case 218:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005008#line 2081 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005009 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005010 /* "Externally Visible" Linkage */
Dan Gohmanf4423b12008-04-19 00:24:39 +00005011 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005012 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005013 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5014 (yyvsp[(2) - (6)].Visibility), (yyvsp[(4) - (6)].BoolVal), (yyvsp[(5) - (6)].ConstVal)->getType(), (yyvsp[(5) - (6)].ConstVal), (yyvsp[(3) - (6)].BoolVal), (yyvsp[(6) - (6)].UIntVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005015 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005016 ;}
5017 break;
5018
5019 case 219:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005020#line 2088 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005021 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005022 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005023 ;}
5024 break;
5025
5026 case 220:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005027#line 2092 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005028 {
5029 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005030 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005031 CurGV = ParseGlobalVariable((yyvsp[(1) - (7)].StrVal), (yyvsp[(2) - (7)].Linkage), (yyvsp[(3) - (7)].Visibility), (yyvsp[(5) - (7)].BoolVal), (yyvsp[(6) - (7)].ConstVal)->getType(), (yyvsp[(6) - (7)].ConstVal), (yyvsp[(4) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
Christopher Lambbf3348d2007-12-12 08:45:45 +00005032 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005033 ;}
5034 break;
5035
5036 case 221:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005037#line 2097 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005038 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005039 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005040 ;}
5041 break;
5042
5043 case 222:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005044#line 2101 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005045 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005046 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005047 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5048 CurGV = ParseGlobalVariable((yyvsp[(1) - (7)].StrVal), (yyvsp[(2) - (7)].Linkage), (yyvsp[(3) - (7)].Visibility), (yyvsp[(5) - (7)].BoolVal), *(yyvsp[(6) - (7)].TypeVal), 0, (yyvsp[(4) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
Christopher Lambbf3348d2007-12-12 08:45:45 +00005049 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005050 delete (yyvsp[(6) - (7)].TypeVal);
5051 ;}
5052 break;
5053
5054 case 223:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005055#line 2107 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005056 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005057 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005058 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005059 ;}
5060 break;
5061
5062 case 224:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005063#line 2111 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005064 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005065 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005066 if ((yyvsp[(1) - (5)].StrVal)) {
5067 Name = *(yyvsp[(1) - (5)].StrVal);
5068 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005069 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005070 if (Name.empty())
5071 GEN_ERROR("Alias name cannot be empty");
5072
Dan Gohmanf4423b12008-04-19 00:24:39 +00005073 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005074 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005075 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005076
Dan Gohmanf4423b12008-04-19 00:24:39 +00005077 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005078 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005079 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005080 InsertValue(GA, CurModule.Values);
Chris Lattner569f7372007-09-10 23:24:14 +00005081
5082
5083 // If there was a forward reference of this alias, resolve it now.
5084
5085 ValID ID;
5086 if (!Name.empty())
5087 ID = ValID::createGlobalName(Name);
5088 else
5089 ID = ValID::createGlobalID(CurModule.Values.size()-1);
5090
5091 if (GlobalValue *FWGV =
5092 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5093 // Replace uses of the fwdref with the actual alias.
5094 FWGV->replaceAllUsesWith(GA);
5095 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5096 GV->eraseFromParent();
5097 else
5098 cast<Function>(FWGV)->eraseFromParent();
5099 }
5100 ID.destroy();
5101
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005102 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005103 ;}
5104 break;
5105
5106 case 225:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005107#line 2151 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005108 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005109 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005110 ;}
5111 break;
5112
5113 case 226:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005114#line 2154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005115 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005116 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005117 ;}
5118 break;
5119
5120 case 227:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005121#line 2160 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005122 {
Chris Lattner66316012006-01-24 04:14:29 +00005123 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005124 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005125 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005126 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005127 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5128 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005129 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005130;}
5131 break;
5132
5133 case 228:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005134#line 2170 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005135 {
5136 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5137 delete (yyvsp[(3) - (3)].StrVal);
5138 ;}
5139 break;
5140
5141 case 229:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005142#line 2174 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005143 {
5144 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5145 delete (yyvsp[(3) - (3)].StrVal);
5146 ;}
5147 break;
5148
5149 case 231:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005150#line 2181 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005151 {
5152 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5153 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005154 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005155 ;}
5156 break;
5157
5158 case 232:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005159#line 2186 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005160 {
5161 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5162 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005163 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005164 ;}
5165 break;
5166
5167 case 233:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005168#line 2191 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005169 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005170 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005171 ;}
5172 break;
5173
5174 case 234:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005175#line 2200 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005176 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005177 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005178 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5179 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005180 GEN_ERROR("void typed arguments are invalid");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005181 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5182 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5183 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005184 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005185 ;}
5186 break;
5187
5188 case 235:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005189#line 2210 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005190 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005191 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005192 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5193 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005194 GEN_ERROR("void typed arguments are invalid");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005195 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5196 (yyval.ArgList) = new ArgListType;
5197 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005198 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005199 ;}
5200 break;
5201
5202 case 236:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005203#line 2221 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005204 {
5205 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005206 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005207 ;}
5208 break;
5209
5210 case 237:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005211#line 2225 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005212 {
5213 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005214 struct ArgListEntry E;
5215 E.Ty = new PATypeHolder(Type::VoidTy);
5216 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00005217 E.Attrs = ParamAttr::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005218 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005219 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005220 ;}
5221 break;
5222
5223 case 238:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005224#line 2234 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005225 {
5226 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005227 struct ArgListEntry E;
5228 E.Ty = new PATypeHolder(Type::VoidTy);
5229 E.Name = 0;
5230 E.Attrs = ParamAttr::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005231 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005232 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005233 ;}
5234 break;
5235
5236 case 239:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005237#line 2243 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005238 {
5239 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005240 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005241 ;}
5242 break;
5243
5244 case 240:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005245#line 2249 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005246 {
5247 std::string FunctionName(*(yyvsp[(3) - (10)].StrVal));
5248 delete (yyvsp[(3) - (10)].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005249
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005250 // Check the function result for abstractness if this is a define. We should
5251 // have no abstract types at this point
Dan Gohmanf4423b12008-04-19 00:24:39 +00005252 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (10)].TypeVal)))
5253 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (10)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005254
Reid Spencer68a24bd2005-08-27 18:50:39 +00005255 std::vector<const Type*> ParamTypeList;
Chris Lattner58d74912008-03-12 17:45:29 +00005256 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005257 if ((yyvsp[(7) - (10)].ParamAttrs) != ParamAttr::None)
5258 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(7) - (10)].ParamAttrs)));
5259 if ((yyvsp[(5) - (10)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005260 unsigned index = 1;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005261 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin(); I != (yyvsp[(5) - (10)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005262 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005263 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5264 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005265 ParamTypeList.push_back(Ty);
Chris Lattner58d74912008-03-12 17:45:29 +00005266 if (Ty != Type::VoidTy && I->Attrs != ParamAttr::None)
5267 Attrs.push_back(ParamAttrsWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005268 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005269 }
5270
5271 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5272 if (isVarArg) ParamTypeList.pop_back();
5273
Chris Lattner58d74912008-03-12 17:45:29 +00005274 PAListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005275 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00005276 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005277
Dan Gohmanf4423b12008-04-19 00:24:39 +00005278 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (10)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005279 const PointerType *PFT = PointerType::getUnqual(FT);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005280 delete (yyvsp[(2) - (10)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005281
5282 ValID ID;
5283 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005284 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005285 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005286 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005287 }
5288
5289 Function *Fn = 0;
5290 // See if this function was forward referenced. If so, recycle the object.
5291 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5292 // Move the function to the end of the list, from whereever it was
5293 // previously inserted.
5294 Fn = cast<Function>(FWRef);
Chris Lattner58d74912008-03-12 17:45:29 +00005295 assert(Fn->getParamAttrs().isEmpty() &&
5296 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005297 CurModule.CurrentModule->getFunctionList().remove(Fn);
5298 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5299 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005300 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005301 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005302 // The existing function doesn't have the same type. This is an overload
5303 // error.
5304 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsdc024672007-11-27 13:23:08 +00005305 } else if (Fn->getParamAttrs() != PAL) {
5306 // The existing function doesn't have the same parameter attributes.
5307 // This is an overload error.
5308 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005309 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005310 // Neither the existing or the current function is a declaration and they
5311 // have the same name and same type. Clearly this is a redefinition.
5312 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005313 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005314 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005315 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5316 AI != AE; ++AI)
5317 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005318 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005319 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005320 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5321 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005322 InsertValue(Fn, CurModule.Values);
5323 }
5324
5325 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005326
5327 if (CurFun.isDeclare) {
5328 // If we have declaration, always overwrite linkage. This will allow us to
5329 // correctly handle cases, when pointer to function is passed as argument to
5330 // another function.
5331 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005332 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005333 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005334 Fn->setCallingConv((yyvsp[(1) - (10)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00005335 Fn->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005336 Fn->setAlignment((yyvsp[(9) - (10)].UIntVal));
5337 if ((yyvsp[(8) - (10)].StrVal)) {
5338 Fn->setSection(*(yyvsp[(8) - (10)].StrVal));
5339 delete (yyvsp[(8) - (10)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005340 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005341 if ((yyvsp[(10) - (10)].StrVal)) {
5342 Fn->setCollector((yyvsp[(10) - (10)].StrVal)->c_str());
5343 delete (yyvsp[(10) - (10)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005344 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005345
5346 // Add all of the arguments we parsed to the function...
Dan Gohmanf4423b12008-04-19 00:24:39 +00005347 if ((yyvsp[(5) - (10)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005348 if (isVarArg) { // Nuke the last entry
Dan Gohmanf4423b12008-04-19 00:24:39 +00005349 assert((yyvsp[(5) - (10)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (10)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005350 "Not a varargs marker!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005351 delete (yyvsp[(5) - (10)].ArgList)->back().Ty;
5352 (yyvsp[(5) - (10)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005353 }
5354 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005355 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005356 unsigned Idx = 1;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005357 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin();
5358 I != (yyvsp[(5) - (10)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005359 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005360 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005361 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005362 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005363 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005364 }
Reid Spencera132e042006-12-03 05:46:11 +00005365
Dan Gohmanf4423b12008-04-19 00:24:39 +00005366 delete (yyvsp[(5) - (10)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005367 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005368 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005369;}
5370 break;
5371
5372 case 243:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005373#line 2376 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005374 {
5375 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005376
5377 // Make sure that we keep track of the linkage type even if there was a
5378 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005379 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5380 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5381;}
5382 break;
5383
5384 case 246:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005385#line 2387 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005386 {
5387 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005388 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005389;}
5390 break;
5391
5392 case 247:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005393#line 2392 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005394 {
5395 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5396 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5397 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005398 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005399 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005400 ;}
5401 break;
5402
5403 case 248:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005404#line 2404 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005405 {
5406 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005407 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005408 ;}
5409 break;
5410
5411 case 249:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005412#line 2408 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005413 {
5414 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005415 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005416 ;}
5417 break;
5418
5419 case 250:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005420#line 2413 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005421 { // A reference to a direct constant
5422 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005423 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005424 ;}
5425 break;
5426
5427 case 251:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005428#line 2417 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005429 {
5430 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005431 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005432 ;}
5433 break;
5434
5435 case 252:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005436#line 2421 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005437 { // Perhaps it's an FP constant?
5438 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005439 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005440 ;}
5441 break;
5442
5443 case 253:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005444#line 2425 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005445 {
5446 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005447 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005448 ;}
5449 break;
5450
5451 case 254:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005452#line 2429 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005453 {
5454 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005455 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005456 ;}
5457 break;
5458
5459 case 255:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005460#line 2433 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005461 {
5462 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005463 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005464 ;}
5465 break;
5466
5467 case 256:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005468#line 2437 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005469 {
5470 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005471 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005472 ;}
5473 break;
5474
5475 case 257:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005476#line 2441 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005477 { // A vector zero constant.
5478 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005479 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005480 ;}
5481 break;
5482
5483 case 258:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005484#line 2445 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005485 { // Nonempty unsized packed vector
5486 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5487 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005488
Reid Spencer9d6565a2007-02-15 02:26:10 +00005489 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005490 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005491 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005492 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005493 ETy,
5494 NumElements)
5495 )
5496 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005497
5498 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005499 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5500 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005501 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005502 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005503 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005504 }
5505
Dan Gohmanf4423b12008-04-19 00:24:39 +00005506 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5507 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005508 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005509 ;}
5510 break;
5511
5512 case 259:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005513#line 2470 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005514 {
5515 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005516 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005517 ;}
5518 break;
5519
5520 case 260:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005521#line 2474 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005522 {
5523 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5524 delete (yyvsp[(3) - (5)].StrVal);
5525 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005526 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005527 ;}
5528 break;
5529
5530 case 261:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005531#line 2484 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005532 { // Is it an integer reference...?
5533 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005534 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005535 ;}
5536 break;
5537
5538 case 262:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005539#line 2488 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005540 {
5541 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005542 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005543 ;}
5544 break;
5545
5546 case 263:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005547#line 2492 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005548 { // Is it a named reference...?
5549 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5550 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005551 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005552 ;}
5553 break;
5554
5555 case 264:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005556#line 2497 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005557 { // Is it a named reference...?
5558 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5559 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005560 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005561 ;}
5562 break;
5563
5564 case 267:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005565#line 2510 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005566 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005567 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005568 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5569 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5570 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005571 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005572 ;}
5573 break;
5574
5575 case 268:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005576#line 2519 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005577 {
5578 (yyval.ValueList) = new std::vector<Value *>();
5579 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005580 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005581 ;}
5582 break;
5583
5584 case 269:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005585#line 2524 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005586 {
5587 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005588 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005589 ;}
5590 break;
5591
5592 case 270:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005593#line 2529 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005594 {
5595 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005596 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005597 ;}
5598 break;
5599
5600 case 271:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005601#line 2533 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005602 { // Do not allow functions with 0 basic blocks
5603 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005604 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005605 ;}
5606 break;
5607
5608 case 272:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005609#line 2542 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005610 {
5611 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005612 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005613 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5614 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5615 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005616 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005617 ;}
5618 break;
5619
5620 case 273:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005621#line 2551 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005622 {
5623 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005624 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5625 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00005626 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5627 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5628 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005629 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005630 ;}
5631 break;
Chris Lattner38905612008-02-19 04:36:25 +00005632
Dan Gohmanf4423b12008-04-19 00:24:39 +00005633 case 274:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005634#line 2560 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005635 { // Empty space between instruction lists
5636 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum), 0);
5637 CHECK_FOR_ERROR
5638 ;}
5639 break;
5640
5641 case 275:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005642#line 2564 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005643 { // Only the unwind to block
5644 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum), getBBVal((yyvsp[(3) - (3)].ValIDVal)));
5645 CHECK_FOR_ERROR
5646 ;}
5647 break;
5648
5649 case 276:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005650#line 2568 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005651 { // Labelled (named) basic block
5652 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)), 0);
5653 delete (yyvsp[(1) - (1)].StrVal);
5654 CHECK_FOR_ERROR
5655 ;}
5656 break;
5657
5658 case 277:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005659#line 2573 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005660 {
5661 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (4)].StrVal)), getBBVal((yyvsp[(4) - (4)].ValIDVal)));
5662 delete (yyvsp[(1) - (4)].StrVal);
5663 CHECK_FOR_ERROR
5664 ;}
5665 break;
5666
5667 case 278:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005668#line 2580 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005669 { // Return with a result...
5670 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
5671 assert(!VL.empty() && "Invalid ret operands!");
5672 (yyval.TermInstVal) = ReturnInst::Create(&VL[0], VL.size());
5673 delete (yyvsp[(2) - (2)].ValueList);
5674 CHECK_FOR_ERROR
5675 ;}
5676 break;
5677
5678 case 279:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005679#line 2587 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005680 { // Return with no result...
5681 (yyval.TermInstVal) = ReturnInst::Create();
5682 CHECK_FOR_ERROR
5683 ;}
5684 break;
5685
5686 case 280:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005687#line 2591 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005688 { // Unconditional Branch...
5689 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5690 CHECK_FOR_ERROR
5691 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
5692 ;}
5693 break;
5694
5695 case 281:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005696#line 2596 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005697 {
5698 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5699 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5700 CHECK_FOR_ERROR
5701 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5702 CHECK_FOR_ERROR
5703 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5704 CHECK_FOR_ERROR
5705 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
5706 ;}
5707 break;
5708
5709 case 282:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005710#line 2606 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005711 {
5712 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5713 CHECK_FOR_ERROR
5714 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5715 CHECK_FOR_ERROR
5716 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5717 (yyval.TermInstVal) = S;
5718
5719 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5720 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005721 for (; I != E; ++I) {
5722 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5723 S->addCase(CI, I->second);
5724 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005725 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005726 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005727 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005728 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005729 ;}
5730 break;
5731
5732 case 283:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005733#line 2625 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005734 {
5735 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005736 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005737 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005738 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00005739 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005740 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005741 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005742 ;}
5743 break;
5744
5745 case 284:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005746#line 2635 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005747 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005748
Reid Spencer14310612006-12-31 05:40:51 +00005749 // Handle the short syntax
5750 const PointerType *PFTy = 0;
5751 const FunctionType *Ty = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005752 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005753 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5754 // Pull out the types of all of the arguments...
5755 std::vector<const Type*> ParamTypes;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005756 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00005757 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005758 const Type *Ty = I->Val->getType();
5759 if (Ty == Type::VoidTy)
5760 GEN_ERROR("Short call syntax cannot be used with varargs");
5761 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005762 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005763 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005764 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005765 }
5766
Dan Gohmanf4423b12008-04-19 00:24:39 +00005767 delete (yyvsp[(3) - (14)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005768
Dan Gohmanf4423b12008-04-19 00:24:39 +00005769 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005770 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005771 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005772 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005773 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005774 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005775
Chris Lattner58d74912008-03-12 17:45:29 +00005776 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005777 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None)
5778 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(8) - (14)].ParamAttrs)));
Duncan Sandsdc024672007-11-27 13:23:08 +00005779
Reid Spencer14310612006-12-31 05:40:51 +00005780 // Check the arguments
5781 ValueList Args;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005782 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005783 // Make sure no arguments is a good thing!
5784 if (Ty->getNumParams() != 0)
5785 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005786 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005787 } else { // Has arguments?
5788 // Loop through FunctionType's arguments and ensure they are specified
5789 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005790 FunctionType::param_iterator I = Ty->param_begin();
5791 FunctionType::param_iterator E = Ty->param_end();
Dan Gohmanf4423b12008-04-19 00:24:39 +00005792 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00005793 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005794
Duncan Sandsdc024672007-11-27 13:23:08 +00005795 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005796 if (ArgI->Val->getType() != *I)
5797 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005798 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005799 Args.push_back(ArgI->Val);
Chris Lattner58d74912008-03-12 17:45:29 +00005800 if (ArgI->Attrs != ParamAttr::None)
5801 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005802 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005803
Reid Spencer14310612006-12-31 05:40:51 +00005804 if (Ty->isVarArg()) {
5805 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00005806 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005807 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner58d74912008-03-12 17:45:29 +00005808 if (ArgI->Attrs != ParamAttr::None)
5809 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00005810 }
Reid Spencer14310612006-12-31 05:40:51 +00005811 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005812 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005813 }
Reid Spencer14310612006-12-31 05:40:51 +00005814
Chris Lattner58d74912008-03-12 17:45:29 +00005815 PAListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00005816 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00005817 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00005818
Reid Spencer14310612006-12-31 05:40:51 +00005819 // Create the InvokeInst
Gabor Greife64d2482008-04-06 23:07:54 +00005820 InvokeInst *II = InvokeInst::Create(V, Normal, Except, Args.begin(),Args.end());
Dan Gohmanf4423b12008-04-19 00:24:39 +00005821 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00005822 II->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005823 (yyval.TermInstVal) = II;
5824 delete (yyvsp[(6) - (14)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005825 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005826 ;}
5827 break;
5828
5829 case 285:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005830#line 2715 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005831 {
5832 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005833 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005834 ;}
5835 break;
5836
5837 case 286:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005838#line 2719 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005839 {
5840 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005841 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005842 ;}
5843 break;
5844
5845 case 287:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005846#line 2726 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005847 {
5848 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5849 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005850 CHECK_FOR_ERROR
5851 if (V == 0)
5852 GEN_ERROR("May only switch on a constant pool value");
5853
Dan Gohmanf4423b12008-04-19 00:24:39 +00005854 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005855 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005856 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5857 ;}
5858 break;
5859
5860 case 288:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005861#line 2737 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005862 {
5863 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5864 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005865 CHECK_FOR_ERROR
5866
5867 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005868 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005869
Dan Gohmanf4423b12008-04-19 00:24:39 +00005870 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005871 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005872 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5873 ;}
5874 break;
5875
5876 case 289:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005877#line 2750 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005878 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005879 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00005880 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005881 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005882 InsertValue((yyvsp[(2) - (2)].InstVal));
5883 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005884 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005885 ;}
5886 break;
5887
5888 case 290:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005889#line 2760 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005890 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005891 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005892 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5893 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5894 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005895 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005896 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005897 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005898 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5899 delete (yyvsp[(1) - (6)].TypeVal);
5900 ;}
5901 break;
5902
5903 case 291:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005904#line 2771 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005905 {
5906 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5907 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005908 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005909 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005910 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005911 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5912 ;}
5913 break;
5914
5915 case 292:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005916#line 2781 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005917 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005918 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005919 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005920 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005921 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00005922 (yyval.ParamList) = new ParamList();
5923 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal));
5924 (yyval.ParamList)->push_back(E);
5925 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00005926 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005927 ;}
5928 break;
5929
5930 case 293:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005931#line 2792 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005932 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005933 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00005934 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00005935 (yyval.ParamList) = new ParamList();
5936 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal));
5937 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00005938 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005939 ;}
5940 break;
5941
5942 case 294:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005943#line 2800 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005944 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005945 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005946 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005947 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5948 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5949 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
5950 (yyval.ParamList)->push_back(E);
5951 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005952 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005953 ;}
5954 break;
5955
5956 case 295:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005957#line 2810 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005958 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005959 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00005960 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5961 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal));
5962 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00005963 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005964 ;}
5965 break;
5966
5967 case 296:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005968#line 2817 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005969 { (yyval.ParamList) = new ParamList(); ;}
5970 break;
5971
5972 case 297:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005973#line 2820 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005974 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5975 break;
5976
5977 case 298:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005978#line 2821 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005979 {
5980 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5981 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005982 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005983 ;}
5984 break;
5985
5986 case 299:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005987#line 2828 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005988 {
5989 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005990 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005991 ;}
5992 break;
5993
5994 case 300:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00005995#line 2832 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005996 {
5997 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005998 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005999 ;}
6000 break;
6001
6002 case 301:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006003#line 2837 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006004 {
Reid Spencer14310612006-12-31 05:40:51 +00006005 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006006 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6007 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
6008 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006009 GEN_ERROR(
6010 "Arithmetic operator requires integer, FP, or packed operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006011 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006012 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006013 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006014 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006015 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
6016 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006017 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006018 delete (yyvsp[(2) - (5)].TypeVal);
6019 ;}
6020 break;
6021
6022 case 302:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006023#line 2853 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006024 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +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()) {
6028 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
6029 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006030 GEN_ERROR("Logical operator requires integral operands");
6031 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006032 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006033 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006034 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006035 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006036 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
6037 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006038 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006039 delete (yyvsp[(2) - (5)].TypeVal);
6040 ;}
6041 break;
6042
6043 case 303:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006044#line 2870 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006045 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006046 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006047 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6048 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006049 GEN_ERROR("Vector types not supported by icmp instruction");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006050 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006051 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006052 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006053 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006054 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
6055 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006056 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006057 delete (yyvsp[(3) - (6)].TypeVal);
6058 ;}
6059 break;
6060
6061 case 304:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006062#line 2884 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006063 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006064 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006065 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6066 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006067 GEN_ERROR("Vector types not supported by fcmp instruction");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006068 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006069 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006070 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006071 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006072 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
6073 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006074 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006075 delete (yyvsp[(3) - (6)].TypeVal);
6076 ;}
6077 break;
6078
6079 case 305:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006080#line 2898 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006081 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006082 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006083 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6084 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6085 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6086 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006087 GEN_ERROR("invalid cast opcode for cast from '" +
6088 Val->getType()->getDescription() + "' to '" +
6089 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006090 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
6091 delete (yyvsp[(4) - (4)].TypeVal);
6092 ;}
6093 break;
6094
6095 case 306:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006096#line 2910 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006097 {
6098 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006099 GEN_ERROR("select condition must be boolean");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006100 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006101 GEN_ERROR("select value types should match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006102 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006103 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006104 ;}
6105 break;
6106
6107 case 307:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006108#line 2918 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006109 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006110 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006111 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6112 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6113 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006114 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006115 ;}
6116 break;
6117
6118 case 308:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006119#line 2925 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006120 {
6121 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006122 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006123 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006124 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006125 ;}
6126 break;
6127
6128 case 309:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006129#line 2931 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006130 {
6131 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006132 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006133 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006134 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006135 ;}
6136 break;
6137
6138 case 310:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006139#line 2937 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006140 {
6141 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006142 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006143 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006144 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006145 ;}
6146 break;
6147
6148 case 311:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006149#line 2943 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006150 {
6151 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006152 if (!Ty->isFirstClassType())
6153 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006154 (yyval.InstVal) = PHINode::Create(Ty);
6155 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6156 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
6157 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006158 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006159 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6160 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006161 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006162 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006163 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006164 ;}
6165 break;
6166
6167 case 312:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006168#line 2959 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006169 {
Reid Spencer14310612006-12-31 05:40:51 +00006170
6171 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006172 const PointerType *PFTy = 0;
6173 const FunctionType *Ty = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006174 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006175 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6176 // Pull out the types of all of the arguments...
6177 std::vector<const Type*> ParamTypes;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006178 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006179 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006180 const Type *Ty = I->Val->getType();
6181 if (Ty == Type::VoidTy)
6182 GEN_ERROR("Short call syntax cannot be used with varargs");
6183 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006184 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006185 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006186 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006187 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006188
Dan Gohmanf4423b12008-04-19 00:24:39 +00006189 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006190 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006191
Reid Spencer7780acb2007-04-16 06:56:07 +00006192 // Check for call to invalid intrinsic to avoid crashing later.
6193 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006194 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006195 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6196 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006197 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6198 theF->getName() + "'");
6199 }
6200
Duncan Sandsdc024672007-11-27 13:23:08 +00006201 // Set up the ParamAttrs for the function
Chris Lattner58d74912008-03-12 17:45:29 +00006202 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006203 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None)
6204 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(8) - (8)].ParamAttrs)));
Reid Spencer14310612006-12-31 05:40:51 +00006205 // Check the arguments
6206 ValueList Args;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006207 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006208 // Make sure no arguments is a good thing!
6209 if (Ty->getNumParams() != 0)
6210 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006211 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006212 } else { // Has arguments?
6213 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006214 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006215 FunctionType::param_iterator I = Ty->param_begin();
6216 FunctionType::param_iterator E = Ty->param_end();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006217 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006218 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006219
Duncan Sandsdc024672007-11-27 13:23:08 +00006220 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006221 if (ArgI->Val->getType() != *I)
6222 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006223 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006224 Args.push_back(ArgI->Val);
Chris Lattner58d74912008-03-12 17:45:29 +00006225 if (ArgI->Attrs != ParamAttr::None)
6226 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006227 }
6228 if (Ty->isVarArg()) {
6229 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006230 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006231 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner58d74912008-03-12 17:45:29 +00006232 if (ArgI->Attrs != ParamAttr::None)
6233 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006234 }
Reid Spencer14310612006-12-31 05:40:51 +00006235 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006236 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006237 }
Duncan Sandsdc024672007-11-27 13:23:08 +00006238
6239 // Finish off the ParamAttrs and check them
Chris Lattner58d74912008-03-12 17:45:29 +00006240 PAListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006241 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00006242 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006243
Reid Spencer14310612006-12-31 05:40:51 +00006244 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006245 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006246 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6247 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00006248 CI->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006249 (yyval.InstVal) = CI;
6250 delete (yyvsp[(6) - (8)].ParamList);
6251 delete (yyvsp[(3) - (8)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006252 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006253 ;}
6254 break;
6255
6256 case 313:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006257#line 3044 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006258 {
6259 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006260 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006261 ;}
6262 break;
6263
6264 case 314:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006265#line 3049 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006266 {
6267 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006268 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006269 ;}
6270 break;
6271
6272 case 315:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006273#line 3053 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006274 {
6275 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006276 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006277 ;}
6278 break;
6279
6280 case 316:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006281#line 3060 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006282 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006283 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006284 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6285 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6286 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006287 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006288 ;}
6289 break;
6290
6291 case 317:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006292#line 3067 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006293 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006294 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006295 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6296 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006297 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006298 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6299 delete (yyvsp[(2) - (6)].TypeVal);
6300 ;}
6301 break;
6302
6303 case 318:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006304#line 3075 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006305 {
Reid Spencer14310612006-12-31 05:40:51 +00006306 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006307 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6308 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6309 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006310 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006311 ;}
6312 break;
6313
6314 case 319:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006315#line 3082 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006316 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006317 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006318 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6319 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006320 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006321 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6322 delete (yyvsp[(2) - (6)].TypeVal);
6323 ;}
6324 break;
6325
6326 case 320:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006327#line 3090 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006328 {
6329 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006330 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006331 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6332 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006333 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006334 ;}
6335 break;
6336
6337 case 321:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006338#line 3098 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006339 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006340 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006341 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6342 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006343 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006344 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6345 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006346 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006347 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6348 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006349 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006350 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6351 delete (yyvsp[(3) - (5)].TypeVal);
6352 ;}
6353 break;
6354
6355 case 322:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006356#line 3112 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006357 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006358 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006359 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6360 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006361 if (!PT)
6362 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006363 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006364 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006365 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6366 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006367 "' into space of type '" + ElTy->getDescription() + "'");
6368
Dan Gohmanf4423b12008-04-19 00:24:39 +00006369 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006370 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006371 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6372 delete (yyvsp[(5) - (7)].TypeVal);
6373 ;}
6374 break;
6375
6376 case 323:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006377#line 3129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006378 {
6379 Value *TmpVal = getVal((yyvsp[(2) - (5)].TypeVal)->get(), (yyvsp[(3) - (5)].ValIDVal));
6380 if (!GetResultInst::isValidOperands(TmpVal, (yyvsp[(5) - (5)].UInt64Val)))
Devang Patel5a970972008-02-19 22:27:01 +00006381 GEN_ERROR("Invalid getresult operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006382 (yyval.InstVal) = new GetResultInst(TmpVal, (yyvsp[(5) - (5)].UInt64Val));
6383 delete (yyvsp[(2) - (5)].TypeVal);
Devang Patel5a970972008-02-19 22:27:01 +00006384 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006385 ;}
6386 break;
6387
6388 case 324:
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006389#line 3137 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006390 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006391 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006392 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6393 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006394 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006395
Dan Gohmanf4423b12008-04-19 00:24:39 +00006396 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 +00006397 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006398 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6399 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006400 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006401 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
6402 delete (yyvsp[(2) - (4)].TypeVal);
6403 delete (yyvsp[(4) - (4)].ValueList);
6404 ;}
6405 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006406
Dan Gohmanf4423b12008-04-19 00:24:39 +00006407
6408/* Line 1267 of yacc.c. */
6409#line 6410 "llvmAsmParser.tab.c"
6410 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00006411 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006412 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6413
6414 YYPOPSTACK (yylen);
6415 yylen = 0;
6416 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006417
6418 *++yyvsp = yyval;
6419
6420
Dan Gohmanf4423b12008-04-19 00:24:39 +00006421 /* Now `shift' the result of the reduction. Determine what state
6422 that goes to, based on the state we popped back to and the rule
6423 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006424
6425 yyn = yyr1[yyn];
6426
Dan Gohmanf4423b12008-04-19 00:24:39 +00006427 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6428 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006429 yystate = yytable[yystate];
6430 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00006431 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00006432
6433 goto yynewstate;
6434
6435
Dan Gohmanf4423b12008-04-19 00:24:39 +00006436/*------------------------------------.
6437| yyerrlab -- here on detecting error |
6438`------------------------------------*/
6439yyerrlab:
6440 /* If not already recovering from an error, report this error. */
6441 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006442 {
6443 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006444#if ! YYERROR_VERBOSE
6445 yyerror (YY_("syntax error"));
6446#else
6447 {
6448 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6449 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6450 {
6451 YYSIZE_T yyalloc = 2 * yysize;
6452 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6453 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6454 if (yymsg != yymsgbuf)
6455 YYSTACK_FREE (yymsg);
6456 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6457 if (yymsg)
6458 yymsg_alloc = yyalloc;
6459 else
6460 {
6461 yymsg = yymsgbuf;
6462 yymsg_alloc = sizeof yymsgbuf;
6463 }
6464 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00006465
Dan Gohmanf4423b12008-04-19 00:24:39 +00006466 if (0 < yysize && yysize <= yymsg_alloc)
6467 {
6468 (void) yysyntax_error (yymsg, yystate, yychar);
6469 yyerror (yymsg);
6470 }
6471 else
6472 {
6473 yyerror (YY_("syntax error"));
6474 if (yysize != 0)
6475 goto yyexhaustedlab;
6476 }
6477 }
6478#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006479 }
6480
Dan Gohmanf4423b12008-04-19 00:24:39 +00006481
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006482
6483 if (yyerrstatus == 3)
6484 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00006485 /* If just tried and failed to reuse look-ahead token after an
6486 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006487
Dan Gohmanf4423b12008-04-19 00:24:39 +00006488 if (yychar <= YYEOF)
6489 {
6490 /* Return failure if at end of input. */
6491 if (yychar == YYEOF)
6492 YYABORT;
6493 }
6494 else
6495 {
6496 yydestruct ("Error: discarding",
6497 yytoken, &yylval);
6498 yychar = YYEMPTY;
6499 }
6500 }
6501
6502 /* Else will try to reuse look-ahead token after shifting the error
6503 token. */
6504 goto yyerrlab1;
6505
6506
6507/*---------------------------------------------------.
6508| yyerrorlab -- error raised explicitly by YYERROR. |
6509`---------------------------------------------------*/
6510yyerrorlab:
6511
6512 /* Pacify compilers like GCC when the user code never invokes
6513 YYERROR and the label yyerrorlab therefore never appears in user
6514 code. */
6515 if (/*CONSTCOND*/ 0)
6516 goto yyerrorlab;
6517
6518 /* Do not reclaim the symbols of the rule which action triggered
6519 this YYERROR. */
6520 YYPOPSTACK (yylen);
6521 yylen = 0;
6522 YY_STACK_PRINT (yyss, yyssp);
6523 yystate = *yyssp;
6524 goto yyerrlab1;
6525
6526
6527/*-------------------------------------------------------------.
6528| yyerrlab1 -- common code for both syntax error and YYERROR. |
6529`-------------------------------------------------------------*/
6530yyerrlab1:
6531 yyerrstatus = 3; /* Each real token shifted decrements this. */
6532
6533 for (;;)
6534 {
6535 yyn = yypact[yystate];
6536 if (yyn != YYPACT_NINF)
6537 {
6538 yyn += YYTERROR;
6539 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6540 {
6541 yyn = yytable[yyn];
6542 if (0 < yyn)
6543 break;
6544 }
6545 }
6546
6547 /* Pop the current state because it cannot handle the error token. */
6548 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006549 YYABORT;
6550
Dale Johannesencdd509a2007-09-07 21:07:57 +00006551
Dan Gohmanf4423b12008-04-19 00:24:39 +00006552 yydestruct ("Error: popping",
6553 yystos[yystate], yyvsp);
6554 YYPOPSTACK (1);
6555 yystate = *yyssp;
6556 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006557 }
6558
6559 if (yyn == YYFINAL)
6560 YYACCEPT;
6561
Reid Spencer68a24bd2005-08-27 18:50:39 +00006562 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006563
6564
6565 /* Shift the error token. */
6566 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00006567
Reid Spencer68a24bd2005-08-27 18:50:39 +00006568 yystate = yyn;
6569 goto yynewstate;
6570
Gabor Greife64d2482008-04-06 23:07:54 +00006571
Dan Gohmanf4423b12008-04-19 00:24:39 +00006572/*-------------------------------------.
6573| yyacceptlab -- YYACCEPT comes here. |
6574`-------------------------------------*/
6575yyacceptlab:
6576 yyresult = 0;
6577 goto yyreturn;
6578
6579/*-----------------------------------.
6580| yyabortlab -- YYABORT comes here. |
6581`-----------------------------------*/
6582yyabortlab:
6583 yyresult = 1;
6584 goto yyreturn;
6585
6586#ifndef yyoverflow
6587/*-------------------------------------------------.
6588| yyexhaustedlab -- memory exhaustion comes here. |
6589`-------------------------------------------------*/
6590yyexhaustedlab:
6591 yyerror (YY_("memory exhausted"));
6592 yyresult = 2;
6593 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00006594#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00006595
6596yyreturn:
6597 if (yychar != YYEOF && yychar != YYEMPTY)
6598 yydestruct ("Cleanup: discarding lookahead",
6599 yytoken, &yylval);
6600 /* Do not reclaim the symbols of the rule which action triggered
6601 this YYABORT or YYACCEPT. */
6602 YYPOPSTACK (yylen);
6603 YY_STACK_PRINT (yyss, yyssp);
6604 while (yyssp != yyss)
6605 {
6606 yydestruct ("Cleanup: popping",
6607 yystos[*yyssp], yyvsp);
6608 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00006609 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006610#ifndef yyoverflow
6611 if (yyss != yyssa)
6612 YYSTACK_FREE (yyss);
6613#endif
6614#if YYERROR_VERBOSE
6615 if (yymsg != yymsgbuf)
6616 YYSTACK_FREE (yymsg);
6617#endif
6618 /* Make sure YYID is used. */
6619 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006620}
Dan Gohmanf4423b12008-04-19 00:24:39 +00006621
6622
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00006623#line 3154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006624
6625
Reid Spencer14310612006-12-31 05:40:51 +00006626// common code from the two 'RunVMAsmParser' functions
6627static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00006628 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00006629 // Check to make sure the parser succeeded
6630 if (yyparse()) {
6631 if (ParserResult)
6632 delete ParserResult;
6633 return 0;
6634 }
6635
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006636 // Emit an error if there are any unresolved types left.
6637 if (!CurModule.LateResolveTypes.empty()) {
6638 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6639 if (DID.Type == ValID::LocalName) {
6640 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6641 } else {
6642 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6643 }
6644 if (ParserResult)
6645 delete ParserResult;
6646 return 0;
6647 }
6648
6649 // Emit an error if there are any unresolved values left.
6650 if (!CurModule.LateResolveValues.empty()) {
6651 Value *V = CurModule.LateResolveValues.back();
6652 std::map<Value*, std::pair<ValID, int> >::iterator I =
6653 CurModule.PlaceHolderInfo.find(V);
6654
6655 if (I != CurModule.PlaceHolderInfo.end()) {
6656 ValID &DID = I->second.first;
6657 if (DID.Type == ValID::LocalName) {
6658 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6659 } else {
6660 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6661 }
6662 if (ParserResult)
6663 delete ParserResult;
6664 return 0;
6665 }
6666 }
6667
Reid Spencer14310612006-12-31 05:40:51 +00006668 // Check to make sure that parsing produced a result
6669 if (!ParserResult)
6670 return 0;
6671
6672 // Reset ParserResult variable while saving its value for the result.
6673 Module *Result = ParserResult;
6674 ParserResult = 0;
6675
6676 return Result;
6677}
6678
Reid Spencer61c83e02006-08-18 08:43:06 +00006679void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00006680 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00006681 // TODO: column number in exception
6682 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00006683 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00006684 TriggerError = 1;
6685}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006686
6687int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00006688 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006689 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00006690 if (yychar != YYEMPTY && yychar != 0) {
6691 errMsg += " while reading token: '";
6692 errMsg += std::string(LLLgetTokenStart(),
6693 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
6694 }
Reid Spencer61c83e02006-08-18 08:43:06 +00006695 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006696 return 0;
6697}
Dan Gohmanf4423b12008-04-19 00:24:39 +00006698