blob: 0af24fcffac86f781d45993ada3eeda46a867c9b [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,
Chris Lattnera925a142008-04-23 05:37:08 +00001846 1349, 1378, 1403, 1408, 1418, 1428, 1432, 1442, 1449, 1458,
1847 1465, 1470, 1475, 1482, 1483, 1490, 1497, 1505, 1511, 1523,
1848 1551, 1567, 1594, 1622, 1648, 1668, 1694, 1714, 1726, 1733,
1849 1799, 1809, 1819, 1825, 1835, 1841, 1851, 1856, 1861, 1874,
1850 1886, 1908, 1916, 1922, 1933, 1938, 1943, 1949, 1955, 1964,
1851 1968, 1976, 1976, 1979, 1979, 1982, 1994, 2015, 2020, 2028,
1852 2029, 2033, 2033, 2037, 2037, 2040, 2043, 2067, 2079, 2078,
1853 2090, 2089, 2099, 2098, 2109, 2149, 2152, 2158, 2168, 2172,
1854 2177, 2179, 2184, 2189, 2198, 2208, 2219, 2223, 2232, 2241,
1855 2246, 2375, 2375, 2377, 2386, 2386, 2388, 2393, 2405, 2409,
1856 2414, 2418, 2422, 2426, 2430, 2434, 2438, 2442, 2446, 2471,
1857 2475, 2485, 2489, 2493, 2498, 2505, 2505, 2511, 2520, 2525,
1858 2530, 2534, 2543, 2552, 2561, 2565, 2569, 2574, 2581, 2588,
1859 2592, 2597, 2607, 2626, 2635, 2720, 2724, 2731, 2742, 2755,
1860 2765, 2776, 2786, 2797, 2805, 2815, 2822, 2825, 2826, 2833,
1861 2837, 2842, 2858, 2875, 2889, 2903, 2915, 2923, 2930, 2936,
1862 2942, 2948, 2963, 3053, 3058, 3062, 3069, 3076, 3084, 3091,
1863 3099, 3107, 3121, 3138, 3146
Dan Gohmanf4423b12008-04-19 00:24:39 +00001864};
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.
Chris Lattnera925a142008-04-23 05:37:08 +00004070 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4071 if (!FunctionType::isValidReturnType(RetTy))
4072 GEN_ERROR("Invalid result type for LLVM function");
4073
Reid Spencer41dff5e2007-01-26 08:05:27 +00004074 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004075 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004076 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004077 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004078 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004079 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004080
Reid Spencer41dff5e2007-01-26 08:05:27 +00004081 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4082 if (isVarArg) Params.pop_back();
4083
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004084 for (unsigned i = 0; i != Params.size(); ++i)
4085 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4086 GEN_ERROR("Function arguments must be value types!");
4087
4088 CHECK_FOR_ERROR
4089
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004090 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004091 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4092 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
4093 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004094 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004095 ;}
4096 break;
4097
4098 case 151:
Chris Lattnera925a142008-04-23 05:37:08 +00004099#line 1378 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004100 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004101 // Allow but ignore attributes on function types; this permits auto-upgrade.
4102 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004103 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004104 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004105 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004106 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004107 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004108 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004109
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004110 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4111 if (isVarArg) Params.pop_back();
4112
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004113 for (unsigned i = 0; i != Params.size(); ++i)
4114 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4115 GEN_ERROR("Function arguments must be value types!");
4116
4117 CHECK_FOR_ERROR
4118
Dan Gohmanf4423b12008-04-19 00:24:39 +00004119 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
4120 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4121 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004122 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004123 ;}
4124 break;
4125
4126 case 152:
Chris Lattnera925a142008-04-23 05:37:08 +00004127#line 1403 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004128 { // Sized array type?
4129 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4130 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004131 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004132 ;}
4133 break;
4134
4135 case 153:
Chris Lattnera925a142008-04-23 05:37:08 +00004136#line 1408 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004137 { // Vector type?
4138 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4139 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004140 GEN_ERROR("Unsigned result not equal to signed result");
4141 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4142 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004143 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4144 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004145 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004146 ;}
4147 break;
4148
4149 case 154:
Chris Lattnera925a142008-04-23 05:37:08 +00004150#line 1418 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004151 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004152 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004153 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4154 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004155 Elements.push_back(*I);
4156
Dan Gohmanf4423b12008-04-19 00:24:39 +00004157 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4158 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004159 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004160 ;}
4161 break;
4162
4163 case 155:
Chris Lattnera925a142008-04-23 05:37:08 +00004164#line 1428 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004165 { // Empty structure type?
4166 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004167 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004168 ;}
4169 break;
4170
4171 case 156:
Chris Lattnera925a142008-04-23 05:37:08 +00004172#line 1432 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004173 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004174 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004175 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4176 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004177 Elements.push_back(*I);
4178
Dan Gohmanf4423b12008-04-19 00:24:39 +00004179 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4180 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004181 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004182 ;}
4183 break;
4184
4185 case 157:
Chris Lattnera925a142008-04-23 05:37:08 +00004186#line 1442 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004187 { // Empty structure type?
4188 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004189 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004190 ;}
4191 break;
4192
4193 case 158:
Chris Lattnera925a142008-04-23 05:37:08 +00004194#line 1449 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004195 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004196 // Allow but ignore attributes on function types; this permits auto-upgrade.
4197 // FIXME: remove in LLVM 3.0.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004198 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
4199 (yyval.TypeWithAttrs).Attrs = ParamAttr::None;
4200 ;}
4201 break;
4202
4203 case 159:
Chris Lattnera925a142008-04-23 05:37:08 +00004204#line 1458 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004205 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004206 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004207 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4208 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004209 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004210 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4211 ;}
4212 break;
4213
4214 case 160:
Chris Lattnera925a142008-04-23 05:37:08 +00004215#line 1465 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004216 {
4217 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4218 ;}
4219 break;
4220
4221 case 161:
Chris Lattnera925a142008-04-23 05:37:08 +00004222#line 1470 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004223 {
4224 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4225 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004226 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004227 ;}
4228 break;
4229
4230 case 162:
Chris Lattnera925a142008-04-23 05:37:08 +00004231#line 1475 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004232 {
4233 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004234 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004235 ;}
4236 break;
4237
4238 case 164:
Chris Lattnera925a142008-04-23 05:37:08 +00004239#line 1483 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004240 {
4241 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00004242 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004243 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004244 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004245 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004246 ;}
4247 break;
4248
4249 case 165:
Chris Lattnera925a142008-04-23 05:37:08 +00004250#line 1490 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004251 {
4252 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004253 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4254 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004255 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004256 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004257 ;}
4258 break;
4259
4260 case 166:
Chris Lattnera925a142008-04-23 05:37:08 +00004261#line 1497 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004262 {
4263 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004264 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004265 ;}
4266 break;
4267
4268 case 167:
Chris Lattnera925a142008-04-23 05:37:08 +00004269#line 1505 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004270 {
4271 (yyval.TypeList) = new std::list<PATypeHolder>();
4272 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4273 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004274 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004275 ;}
4276 break;
4277
4278 case 168:
Chris Lattnera925a142008-04-23 05:37:08 +00004279#line 1511 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004280 {
4281 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4282 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004283 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004284 ;}
4285 break;
4286
4287 case 169:
Chris Lattnera925a142008-04-23 05:37:08 +00004288#line 1523 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004289 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004290 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004291 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4292 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004293 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004294 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004295 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004296 const Type *ETy = ATy->getElementType();
4297 int NumElements = ATy->getNumElements();
4298
4299 // Verify that we have the correct size...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004300 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004301 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004302 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004303 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004304
4305 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004306 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4307 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004308 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4309 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004310 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004311 }
4312
Dan Gohmanf4423b12008-04-19 00:24:39 +00004313 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4314 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004315 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004316 ;}
4317 break;
4318
4319 case 170:
Chris Lattnera925a142008-04-23 05:37:08 +00004320#line 1551 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004321 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004322 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004323 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4324 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004325 if (ATy == 0)
4326 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004327 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004328
Andrew Lenharth6353e052006-12-08 18:07:09 +00004329 int NumElements = ATy->getNumElements();
4330 if (NumElements != -1 && NumElements != 0)
4331 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00004332 " arguments, but has size of " + itostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004333 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4334 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004335 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004336 ;}
4337 break;
4338
4339 case 171:
Chris Lattnera925a142008-04-23 05:37:08 +00004340#line 1567 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004341 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004342 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004343 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4344 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004345 if (ATy == 0)
4346 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004347 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004348
4349 int NumElements = ATy->getNumElements();
4350 const Type *ETy = ATy->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00004351 if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004352 GEN_ERROR("Can't build string constant of size " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004353 itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004354 " when array has size " + itostr(NumElements) + "");
4355 std::vector<Constant*> Vals;
4356 if (ETy == Type::Int8Ty) {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004357 for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
4358 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004359 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004360 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004361 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4362 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004363 delete (yyvsp[(3) - (3)].StrVal);
4364 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4365 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004366 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004367 ;}
4368 break;
4369
4370 case 172:
Chris Lattnera925a142008-04-23 05:37:08 +00004371#line 1594 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004372 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004373 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004374 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4375 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004376 if (PTy == 0)
4377 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004378 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004379 const Type *ETy = PTy->getElementType();
4380 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004381
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004382 // Verify that we have the correct size...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004383 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004384 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004385 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004386 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004387
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004388 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004389 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4390 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004391 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4392 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004393 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004394 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004395
Dan Gohmanf4423b12008-04-19 00:24:39 +00004396 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4397 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004398 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004399 ;}
4400 break;
4401
4402 case 173:
Chris Lattnera925a142008-04-23 05:37:08 +00004403#line 1622 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004404 {
4405 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004406 if (STy == 0)
4407 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004408 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004409
Dan Gohmanf4423b12008-04-19 00:24:39 +00004410 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004411 GEN_ERROR("Illegal number of initializers for structure type");
4412
4413 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004414 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4415 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004416 GEN_ERROR("Expected type '" +
4417 STy->getElementType(i)->getDescription() +
4418 "' for element #" + utostr(i) +
4419 " of structure initializer");
4420
4421 // Check to ensure that Type is not packed
4422 if (STy->isPacked())
4423 GEN_ERROR("Unpacked Initializer to vector type '" +
4424 STy->getDescription() + "'");
4425
Dan Gohmanf4423b12008-04-19 00:24:39 +00004426 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4427 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004428 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004429 ;}
4430 break;
4431
4432 case 174:
Chris Lattnera925a142008-04-23 05:37:08 +00004433#line 1648 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004434 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004435 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004436 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4437 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004438 if (STy == 0)
4439 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004440 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004441
4442 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004443 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004444
4445 // Check to ensure that Type is not packed
4446 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004447 GEN_ERROR("Unpacked Initializer to vector type '" +
4448 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004449
Dan Gohmanf4423b12008-04-19 00:24:39 +00004450 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4451 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004452 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004453 ;}
4454 break;
4455
4456 case 175:
Chris Lattnera925a142008-04-23 05:37:08 +00004457#line 1668 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004458 {
4459 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004460 if (STy == 0)
4461 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004462 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004463
Dan Gohmanf4423b12008-04-19 00:24:39 +00004464 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004465 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004466
4467 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004468 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4469 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004470 GEN_ERROR("Expected type '" +
4471 STy->getElementType(i)->getDescription() +
4472 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004473 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004474
4475 // Check to ensure that Type is packed
4476 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004477 GEN_ERROR("Vector initializer to non-vector type '" +
4478 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004479
Dan Gohmanf4423b12008-04-19 00:24:39 +00004480 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4481 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004482 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004483 ;}
4484 break;
4485
4486 case 176:
Chris Lattnera925a142008-04-23 05:37:08 +00004487#line 1694 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004488 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004489 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004490 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4491 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004492 if (STy == 0)
4493 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004494 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004495
4496 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004497 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004498
4499 // Check to ensure that Type is packed
4500 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004501 GEN_ERROR("Vector initializer to non-vector type '" +
4502 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004503
Dan Gohmanf4423b12008-04-19 00:24:39 +00004504 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4505 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004506 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004507 ;}
4508 break;
4509
4510 case 177:
Chris Lattnera925a142008-04-23 05:37:08 +00004511#line 1714 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004512 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004513 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004514 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4515 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004516 if (PTy == 0)
4517 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004518 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004519
Dan Gohmanf4423b12008-04-19 00:24:39 +00004520 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4521 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004522 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004523 ;}
4524 break;
4525
4526 case 178:
Chris Lattnera925a142008-04-23 05:37:08 +00004527#line 1726 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004528 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004529 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004530 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4531 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4532 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004533 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004534 ;}
4535 break;
4536
4537 case 179:
Chris Lattnera925a142008-04-23 05:37:08 +00004538#line 1733 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004539 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004540 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004541 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4542 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004543 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004544 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004545
4546 // ConstExprs can exist in the body of a function, thus creating
4547 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004548 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004549 // symbol table instead of the module symbol table for the global symbol,
4550 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004551 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004552 //
4553 Function *SavedCurFn = CurFun.CurrentFunction;
4554 CurFun.CurrentFunction = 0;
4555
Dan Gohmanf4423b12008-04-19 00:24:39 +00004556 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004557 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004558
4559 CurFun.CurrentFunction = SavedCurFn;
4560
4561 // If this is an initializer for a constant pointer, which is referencing a
4562 // (currently) undefined variable, create a stub now that shall be replaced
4563 // in the future with the right type of variable.
4564 //
4565 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004566 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004567 const PointerType *PT = cast<PointerType>(Ty);
4568
4569 // First check to see if the forward references value is already created!
4570 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004571 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004572
4573 if (I != CurModule.GlobalRefs.end()) {
4574 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004575 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004576 } else {
4577 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004578 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4579 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4580 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004581 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004582
4583 // Create the forward referenced global.
4584 GlobalValue *GV;
4585 if (const FunctionType *FTy =
4586 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004587 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4588 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004589 } else {
4590 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004591 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004592 Name, CurModule.CurrentModule);
4593 }
4594
4595 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004596 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004597 V = GV;
4598 }
4599 }
4600
Dan Gohmanf4423b12008-04-19 00:24:39 +00004601 (yyval.ConstVal) = cast<GlobalValue>(V);
4602 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004603 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004604 ;}
4605 break;
4606
4607 case 180:
Chris Lattnera925a142008-04-23 05:37:08 +00004608#line 1799 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004609 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004610 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004611 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4612 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004613 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004614 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4615 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4616 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004617 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004618 ;}
4619 break;
4620
4621 case 181:
Chris Lattnera925a142008-04-23 05:37:08 +00004622#line 1809 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004623 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004624 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004625 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4626 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004627 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4628 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004629 (yyval.ConstVal) = Constant::getNullValue(Ty);
4630 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004631 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004632 ;}
4633 break;
4634
4635 case 182:
Chris Lattnera925a142008-04-23 05:37:08 +00004636#line 1819 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004637 { // integral constants
4638 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004639 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004640 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004641 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004642 ;}
4643 break;
4644
4645 case 183:
Chris Lattnera925a142008-04-23 05:37:08 +00004646#line 1825 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004647 { // arbitrary precision integer constants
4648 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4649 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004650 GEN_ERROR("Constant value does not fit in type");
4651 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004652 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4653 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4654 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004655 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004656 ;}
4657 break;
4658
4659 case 184:
Chris Lattnera925a142008-04-23 05:37:08 +00004660#line 1835 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004661 { // integral constants
4662 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004663 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004664 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004665 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004666 ;}
4667 break;
4668
4669 case 185:
Chris Lattnera925a142008-04-23 05:37:08 +00004670#line 1841 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004671 { // arbitrary precision integer constants
4672 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4673 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004674 GEN_ERROR("Constant value does not fit in type");
4675 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004676 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4677 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4678 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004679 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004680 ;}
4681 break;
4682
4683 case 186:
Chris Lattnera925a142008-04-23 05:37:08 +00004684#line 1851 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004685 { // Boolean constants
4686 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4687 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004688 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004689 ;}
4690 break;
4691
4692 case 187:
Chris Lattnera925a142008-04-23 05:37:08 +00004693#line 1856 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004694 { // Boolean constants
4695 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4696 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004697 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004698 ;}
4699 break;
4700
4701 case 188:
Chris Lattnera925a142008-04-23 05:37:08 +00004702#line 1861 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004703 { // Floating point constants
4704 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004705 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004706 // Lexer has no type info, so builds all float and double FP constants
4707 // as double. Fix this here. Long double is done right.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004708 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4709 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004710 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004711 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004712 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004713 ;}
4714 break;
4715
4716 case 189:
Chris Lattnera925a142008-04-23 05:37:08 +00004717#line 1874 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004718 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004719 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004720 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4721 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4722 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4723 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004724 GEN_ERROR("invalid cast opcode for cast from '" +
4725 Val->getType()->getDescription() + "' to '" +
4726 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004727 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4728 delete (yyvsp[(5) - (6)].TypeVal);
4729 ;}
4730 break;
4731
4732 case 190:
Chris Lattnera925a142008-04-23 05:37:08 +00004733#line 1886 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004734 {
4735 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004736 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004737
4738 const Type *IdxTy =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004739 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004740 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004741 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004742 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004743
Chris Lattnerf7469af2007-01-31 04:44:08 +00004744 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004745 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4746 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004747 IdxVec.push_back(C);
4748 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004749 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004750
Dan Gohmanf4423b12008-04-19 00:24:39 +00004751 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004752
Dan Gohmanf4423b12008-04-19 00:24:39 +00004753 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004754 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004755 ;}
4756 break;
4757
4758 case 191:
Chris Lattnera925a142008-04-23 05:37:08 +00004759#line 1908 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004760 {
4761 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004762 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004763 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004764 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004765 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004766 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004767 ;}
4768 break;
4769
4770 case 192:
Chris Lattnera925a142008-04-23 05:37:08 +00004771#line 1916 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004772 {
4773 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004774 GEN_ERROR("Binary operator types must match");
4775 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004776 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4777 ;}
4778 break;
4779
4780 case 193:
Chris Lattnera925a142008-04-23 05:37:08 +00004781#line 1922 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004782 {
4783 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004784 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004785 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4786 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4787 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004788 GEN_ERROR("Logical operator requires integral operands");
4789 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004790 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004791 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004792 ;}
4793 break;
4794
4795 case 194:
Chris Lattnera925a142008-04-23 05:37:08 +00004796#line 1933 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004797 {
4798 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004799 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004800 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4801 ;}
4802 break;
4803
4804 case 195:
Chris Lattnera925a142008-04-23 05:37:08 +00004805#line 1938 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004806 {
4807 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004808 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004809 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4810 ;}
4811 break;
4812
4813 case 196:
Chris Lattnera925a142008-04-23 05:37:08 +00004814#line 1943 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004815 {
4816 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004817 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004818 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004819 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004820 ;}
4821 break;
4822
4823 case 197:
Chris Lattnera925a142008-04-23 05:37:08 +00004824#line 1949 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004825 {
4826 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004827 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004828 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004829 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004830 ;}
4831 break;
4832
4833 case 198:
Chris Lattnera925a142008-04-23 05:37:08 +00004834#line 1955 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004835 {
4836 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004837 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004838 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004839 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004840 ;}
4841 break;
4842
4843 case 199:
Chris Lattnera925a142008-04-23 05:37:08 +00004844#line 1964 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004845 {
4846 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004847 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004848 ;}
4849 break;
4850
4851 case 200:
Chris Lattnera925a142008-04-23 05:37:08 +00004852#line 1968 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004853 {
4854 (yyval.ConstVector) = new std::vector<Constant*>();
4855 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004856 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004857 ;}
4858 break;
4859
4860 case 201:
Chris Lattnera925a142008-04-23 05:37:08 +00004861#line 1976 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004862 { (yyval.BoolVal) = false; ;}
4863 break;
4864
4865 case 202:
Chris Lattnera925a142008-04-23 05:37:08 +00004866#line 1976 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004867 { (yyval.BoolVal) = true; ;}
4868 break;
4869
4870 case 203:
Chris Lattnera925a142008-04-23 05:37:08 +00004871#line 1979 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004872 { (yyval.BoolVal) = true; ;}
4873 break;
4874
4875 case 204:
Chris Lattnera925a142008-04-23 05:37:08 +00004876#line 1979 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004877 { (yyval.BoolVal) = false; ;}
4878 break;
4879
4880 case 205:
Chris Lattnera925a142008-04-23 05:37:08 +00004881#line 1982 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004882 {
4883 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4884 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00004885 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004886 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4887 if (!Aliasee)
4888 GEN_ERROR("Aliases can be created only to global values");
4889
Dan Gohmanf4423b12008-04-19 00:24:39 +00004890 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004891 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004892 delete (yyvsp[(1) - (2)].TypeVal);
4893 ;}
4894 break;
4895
4896 case 206:
Chris Lattnera925a142008-04-23 05:37:08 +00004897#line 1994 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004898 {
4899 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4900 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4901 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004902 GEN_ERROR("invalid cast opcode for cast from '" +
4903 Val->getType()->getDescription() + "' to '" +
4904 DestTy->getDescription() + "'");
4905
Dan Gohmanf4423b12008-04-19 00:24:39 +00004906 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004907 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004908 delete (yyvsp[(5) - (6)].TypeVal);
4909 ;}
4910 break;
4911
4912 case 207:
Chris Lattnera925a142008-04-23 05:37:08 +00004913#line 2015 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004914 {
4915 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Christopher Lambbf3348d2007-12-12 08:45:45 +00004916 CurModule.ModuleDone();
4917 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004918 ;}
4919 break;
4920
4921 case 208:
Chris Lattnera925a142008-04-23 05:37:08 +00004922#line 2020 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004923 {
4924 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Dale Johannesen172f3112008-02-20 21:15:43 +00004925 CurModule.ModuleDone();
4926 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004927 ;}
4928 break;
4929
4930 case 211:
Chris Lattnera925a142008-04-23 05:37:08 +00004931#line 2033 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004932 { CurFun.isDeclare = false; ;}
4933 break;
4934
4935 case 212:
Chris Lattnera925a142008-04-23 05:37:08 +00004936#line 2033 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004937 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004938 CurFun.FunctionDone();
4939 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004940 ;}
4941 break;
4942
4943 case 213:
Chris Lattnera925a142008-04-23 05:37:08 +00004944#line 2037 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004945 { CurFun.isDeclare = true; ;}
4946 break;
4947
4948 case 214:
Chris Lattnera925a142008-04-23 05:37:08 +00004949#line 2037 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004950 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00004951 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004952 ;}
4953 break;
4954
4955 case 215:
Chris Lattnera925a142008-04-23 05:37:08 +00004956#line 2040 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004957 {
Dale Johannesen172f3112008-02-20 21:15:43 +00004958 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004959 ;}
4960 break;
4961
4962 case 216:
Chris Lattnera925a142008-04-23 05:37:08 +00004963#line 2043 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004964 {
Reid Spencer14310612006-12-31 05:40:51 +00004965 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004966 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004967 // Eagerly resolve types. This is not an optimization, this is a
4968 // requirement that is due to the fact that we could have this:
4969 //
4970 // %list = type { %list * }
4971 // %list = type { %list * } ; repeated type decl
4972 //
4973 // If types are not resolved eagerly, then the two types will not be
4974 // determined to be the same type!
4975 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00004976 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004977
Dan Gohmanf4423b12008-04-19 00:24:39 +00004978 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004979 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004980 // If this is a named type that is not a redefinition, add it to the slot
4981 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004982 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004983 }
Reid Spencera132e042006-12-03 05:46:11 +00004984
Dan Gohmanf4423b12008-04-19 00:24:39 +00004985 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004986 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004987 ;}
4988 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00004989
Dan Gohmanf4423b12008-04-19 00:24:39 +00004990 case 217:
Chris Lattnera925a142008-04-23 05:37:08 +00004991#line 2067 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004992 {
4993 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4994
4995 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004996 CHECK_FOR_ERROR
4997 // If this is a named type that is not a redefinition, add it to the slot
4998 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004999 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005000 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005001 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005002 ;}
5003 break;
5004
5005 case 218:
Chris Lattnera925a142008-04-23 05:37:08 +00005006#line 2079 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005007 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005008 /* "Externally Visible" Linkage */
Dan Gohmanf4423b12008-04-19 00:24:39 +00005009 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005010 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005011 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5012 (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 +00005013 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005014 ;}
5015 break;
5016
5017 case 219:
Chris Lattnera925a142008-04-23 05:37:08 +00005018#line 2086 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005019 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005020 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005021 ;}
5022 break;
5023
5024 case 220:
Chris Lattnera925a142008-04-23 05:37:08 +00005025#line 2090 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005026 {
5027 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005028 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005029 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 +00005030 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005031 ;}
5032 break;
5033
5034 case 221:
Chris Lattnera925a142008-04-23 05:37:08 +00005035#line 2095 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005036 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005037 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005038 ;}
5039 break;
5040
5041 case 222:
Chris Lattnera925a142008-04-23 05:37:08 +00005042#line 2099 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005043 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005044 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005045 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5046 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 +00005047 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005048 delete (yyvsp[(6) - (7)].TypeVal);
5049 ;}
5050 break;
5051
5052 case 223:
Chris Lattnera925a142008-04-23 05:37:08 +00005053#line 2105 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005054 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005055 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005056 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005057 ;}
5058 break;
5059
5060 case 224:
Chris Lattnera925a142008-04-23 05:37:08 +00005061#line 2109 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005062 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005063 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005064 if ((yyvsp[(1) - (5)].StrVal)) {
5065 Name = *(yyvsp[(1) - (5)].StrVal);
5066 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005067 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005068 if (Name.empty())
5069 GEN_ERROR("Alias name cannot be empty");
5070
Dan Gohmanf4423b12008-04-19 00:24:39 +00005071 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005072 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005073 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005074
Dan Gohmanf4423b12008-04-19 00:24:39 +00005075 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005076 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005077 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005078 InsertValue(GA, CurModule.Values);
Chris Lattner569f7372007-09-10 23:24:14 +00005079
5080
5081 // If there was a forward reference of this alias, resolve it now.
5082
5083 ValID ID;
5084 if (!Name.empty())
5085 ID = ValID::createGlobalName(Name);
5086 else
5087 ID = ValID::createGlobalID(CurModule.Values.size()-1);
5088
5089 if (GlobalValue *FWGV =
5090 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5091 // Replace uses of the fwdref with the actual alias.
5092 FWGV->replaceAllUsesWith(GA);
5093 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5094 GV->eraseFromParent();
5095 else
5096 cast<Function>(FWGV)->eraseFromParent();
5097 }
5098 ID.destroy();
5099
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005100 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005101 ;}
5102 break;
5103
5104 case 225:
Chris Lattnera925a142008-04-23 05:37:08 +00005105#line 2149 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005106 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005107 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005108 ;}
5109 break;
5110
5111 case 226:
Chris Lattnera925a142008-04-23 05:37:08 +00005112#line 2152 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005113 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005114 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005115 ;}
5116 break;
5117
5118 case 227:
Chris Lattnera925a142008-04-23 05:37:08 +00005119#line 2158 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005120 {
Chris Lattner66316012006-01-24 04:14:29 +00005121 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005122 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005123 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005124 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005125 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5126 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005127 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005128;}
5129 break;
5130
5131 case 228:
Chris Lattnera925a142008-04-23 05:37:08 +00005132#line 2168 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005133 {
5134 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5135 delete (yyvsp[(3) - (3)].StrVal);
5136 ;}
5137 break;
5138
5139 case 229:
Chris Lattnera925a142008-04-23 05:37:08 +00005140#line 2172 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005141 {
5142 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5143 delete (yyvsp[(3) - (3)].StrVal);
5144 ;}
5145 break;
5146
5147 case 231:
Chris Lattnera925a142008-04-23 05:37:08 +00005148#line 2179 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005149 {
5150 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5151 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005152 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005153 ;}
5154 break;
5155
5156 case 232:
Chris Lattnera925a142008-04-23 05:37:08 +00005157#line 2184 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005158 {
5159 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5160 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005161 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005162 ;}
5163 break;
5164
5165 case 233:
Chris Lattnera925a142008-04-23 05:37:08 +00005166#line 2189 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005167 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005168 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005169 ;}
5170 break;
5171
5172 case 234:
Chris Lattnera925a142008-04-23 05:37:08 +00005173#line 2198 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005174 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005175 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005176 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5177 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005178 GEN_ERROR("void typed arguments are invalid");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005179 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5180 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5181 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005182 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005183 ;}
5184 break;
5185
5186 case 235:
Chris Lattnera925a142008-04-23 05:37:08 +00005187#line 2208 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005188 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005189 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005190 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5191 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005192 GEN_ERROR("void typed arguments are invalid");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005193 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5194 (yyval.ArgList) = new ArgListType;
5195 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005196 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005197 ;}
5198 break;
5199
5200 case 236:
Chris Lattnera925a142008-04-23 05:37:08 +00005201#line 2219 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005202 {
5203 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005204 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005205 ;}
5206 break;
5207
5208 case 237:
Chris Lattnera925a142008-04-23 05:37:08 +00005209#line 2223 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005210 {
5211 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005212 struct ArgListEntry E;
5213 E.Ty = new PATypeHolder(Type::VoidTy);
5214 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00005215 E.Attrs = ParamAttr::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005216 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005217 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005218 ;}
5219 break;
5220
5221 case 238:
Chris Lattnera925a142008-04-23 05:37:08 +00005222#line 2232 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005223 {
5224 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005225 struct ArgListEntry E;
5226 E.Ty = new PATypeHolder(Type::VoidTy);
5227 E.Name = 0;
5228 E.Attrs = ParamAttr::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005229 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005230 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005231 ;}
5232 break;
5233
5234 case 239:
Chris Lattnera925a142008-04-23 05:37:08 +00005235#line 2241 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005236 {
5237 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005238 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005239 ;}
5240 break;
5241
5242 case 240:
Chris Lattnera925a142008-04-23 05:37:08 +00005243#line 2247 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005244 {
5245 std::string FunctionName(*(yyvsp[(3) - (10)].StrVal));
5246 delete (yyvsp[(3) - (10)].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005247
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005248 // Check the function result for abstractness if this is a define. We should
5249 // have no abstract types at this point
Dan Gohmanf4423b12008-04-19 00:24:39 +00005250 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (10)].TypeVal)))
5251 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (10)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005252
Chris Lattnera925a142008-04-23 05:37:08 +00005253 if (!FunctionType::isValidReturnType(*(yyvsp[(2) - (10)].TypeVal)))
5254 GEN_ERROR("Invalid result type for LLVM function");
5255
Reid Spencer68a24bd2005-08-27 18:50:39 +00005256 std::vector<const Type*> ParamTypeList;
Chris Lattner58d74912008-03-12 17:45:29 +00005257 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005258 if ((yyvsp[(7) - (10)].ParamAttrs) != ParamAttr::None)
5259 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(7) - (10)].ParamAttrs)));
5260 if ((yyvsp[(5) - (10)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005261 unsigned index = 1;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005262 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin(); I != (yyvsp[(5) - (10)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005263 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005264 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5265 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005266 ParamTypeList.push_back(Ty);
Chris Lattner58d74912008-03-12 17:45:29 +00005267 if (Ty != Type::VoidTy && I->Attrs != ParamAttr::None)
5268 Attrs.push_back(ParamAttrsWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005269 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005270 }
5271
5272 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5273 if (isVarArg) ParamTypeList.pop_back();
5274
Chris Lattner58d74912008-03-12 17:45:29 +00005275 PAListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005276 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00005277 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005278
Dan Gohmanf4423b12008-04-19 00:24:39 +00005279 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (10)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005280 const PointerType *PFT = PointerType::getUnqual(FT);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005281 delete (yyvsp[(2) - (10)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005282
5283 ValID ID;
5284 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005285 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005286 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005287 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005288 }
5289
5290 Function *Fn = 0;
5291 // See if this function was forward referenced. If so, recycle the object.
5292 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5293 // Move the function to the end of the list, from whereever it was
5294 // previously inserted.
5295 Fn = cast<Function>(FWRef);
Chris Lattner58d74912008-03-12 17:45:29 +00005296 assert(Fn->getParamAttrs().isEmpty() &&
5297 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005298 CurModule.CurrentModule->getFunctionList().remove(Fn);
5299 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5300 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005301 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005302 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005303 // The existing function doesn't have the same type. This is an overload
5304 // error.
5305 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsdc024672007-11-27 13:23:08 +00005306 } else if (Fn->getParamAttrs() != PAL) {
5307 // The existing function doesn't have the same parameter attributes.
5308 // This is an overload error.
5309 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005310 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005311 // Neither the existing or the current function is a declaration and they
5312 // have the same name and same type. Clearly this is a redefinition.
5313 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005314 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005315 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005316 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5317 AI != AE; ++AI)
5318 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005319 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005320 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005321 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5322 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005323 InsertValue(Fn, CurModule.Values);
5324 }
5325
5326 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005327
5328 if (CurFun.isDeclare) {
5329 // If we have declaration, always overwrite linkage. This will allow us to
5330 // correctly handle cases, when pointer to function is passed as argument to
5331 // another function.
5332 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005333 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005334 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005335 Fn->setCallingConv((yyvsp[(1) - (10)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00005336 Fn->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005337 Fn->setAlignment((yyvsp[(9) - (10)].UIntVal));
5338 if ((yyvsp[(8) - (10)].StrVal)) {
5339 Fn->setSection(*(yyvsp[(8) - (10)].StrVal));
5340 delete (yyvsp[(8) - (10)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005341 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005342 if ((yyvsp[(10) - (10)].StrVal)) {
5343 Fn->setCollector((yyvsp[(10) - (10)].StrVal)->c_str());
5344 delete (yyvsp[(10) - (10)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005345 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005346
5347 // Add all of the arguments we parsed to the function...
Dan Gohmanf4423b12008-04-19 00:24:39 +00005348 if ((yyvsp[(5) - (10)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005349 if (isVarArg) { // Nuke the last entry
Dan Gohmanf4423b12008-04-19 00:24:39 +00005350 assert((yyvsp[(5) - (10)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (10)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005351 "Not a varargs marker!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005352 delete (yyvsp[(5) - (10)].ArgList)->back().Ty;
5353 (yyvsp[(5) - (10)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005354 }
5355 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005356 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005357 unsigned Idx = 1;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005358 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin();
5359 I != (yyvsp[(5) - (10)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005360 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005361 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005362 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005363 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005364 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005365 }
Reid Spencera132e042006-12-03 05:46:11 +00005366
Dan Gohmanf4423b12008-04-19 00:24:39 +00005367 delete (yyvsp[(5) - (10)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005368 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005369 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005370;}
5371 break;
5372
5373 case 243:
Chris Lattnera925a142008-04-23 05:37:08 +00005374#line 2377 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005375 {
5376 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005377
5378 // Make sure that we keep track of the linkage type even if there was a
5379 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005380 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5381 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5382;}
5383 break;
5384
5385 case 246:
Chris Lattnera925a142008-04-23 05:37:08 +00005386#line 2388 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005387 {
5388 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005389 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005390;}
5391 break;
5392
5393 case 247:
Chris Lattnera925a142008-04-23 05:37:08 +00005394#line 2393 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005395 {
5396 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5397 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5398 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005399 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005400 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005401 ;}
5402 break;
5403
5404 case 248:
Chris Lattnera925a142008-04-23 05:37:08 +00005405#line 2405 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005406 {
5407 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005408 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005409 ;}
5410 break;
5411
5412 case 249:
Chris Lattnera925a142008-04-23 05:37:08 +00005413#line 2409 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005414 {
5415 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005416 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005417 ;}
5418 break;
5419
5420 case 250:
Chris Lattnera925a142008-04-23 05:37:08 +00005421#line 2414 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005422 { // A reference to a direct constant
5423 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005424 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005425 ;}
5426 break;
5427
5428 case 251:
Chris Lattnera925a142008-04-23 05:37:08 +00005429#line 2418 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005430 {
5431 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005432 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005433 ;}
5434 break;
5435
5436 case 252:
Chris Lattnera925a142008-04-23 05:37:08 +00005437#line 2422 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005438 { // Perhaps it's an FP constant?
5439 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005440 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005441 ;}
5442 break;
5443
5444 case 253:
Chris Lattnera925a142008-04-23 05:37:08 +00005445#line 2426 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005446 {
5447 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005448 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005449 ;}
5450 break;
5451
5452 case 254:
Chris Lattnera925a142008-04-23 05:37:08 +00005453#line 2430 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005454 {
5455 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005456 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005457 ;}
5458 break;
5459
5460 case 255:
Chris Lattnera925a142008-04-23 05:37:08 +00005461#line 2434 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005462 {
5463 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005464 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005465 ;}
5466 break;
5467
5468 case 256:
Chris Lattnera925a142008-04-23 05:37:08 +00005469#line 2438 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005470 {
5471 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005472 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005473 ;}
5474 break;
5475
5476 case 257:
Chris Lattnera925a142008-04-23 05:37:08 +00005477#line 2442 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005478 { // A vector zero constant.
5479 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005480 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005481 ;}
5482 break;
5483
5484 case 258:
Chris Lattnera925a142008-04-23 05:37:08 +00005485#line 2446 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005486 { // Nonempty unsized packed vector
5487 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5488 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005489
Reid Spencer9d6565a2007-02-15 02:26:10 +00005490 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005491 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005492 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005493 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005494 ETy,
5495 NumElements)
5496 )
5497 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005498
5499 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005500 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5501 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005502 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005503 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005504 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005505 }
5506
Dan Gohmanf4423b12008-04-19 00:24:39 +00005507 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5508 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005509 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005510 ;}
5511 break;
5512
5513 case 259:
Chris Lattnera925a142008-04-23 05:37:08 +00005514#line 2471 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005515 {
5516 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005517 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005518 ;}
5519 break;
5520
5521 case 260:
Chris Lattnera925a142008-04-23 05:37:08 +00005522#line 2475 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005523 {
5524 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5525 delete (yyvsp[(3) - (5)].StrVal);
5526 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005527 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005528 ;}
5529 break;
5530
5531 case 261:
Chris Lattnera925a142008-04-23 05:37:08 +00005532#line 2485 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005533 { // Is it an integer reference...?
5534 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005535 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005536 ;}
5537 break;
5538
5539 case 262:
Chris Lattnera925a142008-04-23 05:37:08 +00005540#line 2489 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005541 {
5542 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005543 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005544 ;}
5545 break;
5546
5547 case 263:
Chris Lattnera925a142008-04-23 05:37:08 +00005548#line 2493 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005549 { // Is it a named reference...?
5550 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5551 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005552 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005553 ;}
5554 break;
5555
5556 case 264:
Chris Lattnera925a142008-04-23 05:37:08 +00005557#line 2498 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005558 { // Is it a named reference...?
5559 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5560 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005561 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005562 ;}
5563 break;
5564
5565 case 267:
Chris Lattnera925a142008-04-23 05:37:08 +00005566#line 2511 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005567 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005568 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005569 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5570 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5571 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005572 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005573 ;}
5574 break;
5575
5576 case 268:
Chris Lattnera925a142008-04-23 05:37:08 +00005577#line 2520 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005578 {
5579 (yyval.ValueList) = new std::vector<Value *>();
5580 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005581 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005582 ;}
5583 break;
5584
5585 case 269:
Chris Lattnera925a142008-04-23 05:37:08 +00005586#line 2525 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005587 {
5588 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005589 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005590 ;}
5591 break;
5592
5593 case 270:
Chris Lattnera925a142008-04-23 05:37:08 +00005594#line 2530 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005595 {
5596 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005597 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005598 ;}
5599 break;
5600
5601 case 271:
Chris Lattnera925a142008-04-23 05:37:08 +00005602#line 2534 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005603 { // Do not allow functions with 0 basic blocks
5604 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005605 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005606 ;}
5607 break;
5608
5609 case 272:
Chris Lattnera925a142008-04-23 05:37:08 +00005610#line 2543 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005611 {
5612 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005613 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005614 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5615 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5616 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005617 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005618 ;}
5619 break;
5620
5621 case 273:
Chris Lattnera925a142008-04-23 05:37:08 +00005622#line 2552 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005623 {
5624 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005625 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5626 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00005627 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5628 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5629 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005630 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005631 ;}
5632 break;
Chris Lattner38905612008-02-19 04:36:25 +00005633
Dan Gohmanf4423b12008-04-19 00:24:39 +00005634 case 274:
Chris Lattnera925a142008-04-23 05:37:08 +00005635#line 2561 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005636 { // Empty space between instruction lists
5637 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum), 0);
5638 CHECK_FOR_ERROR
5639 ;}
5640 break;
5641
5642 case 275:
Chris Lattnera925a142008-04-23 05:37:08 +00005643#line 2565 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005644 { // Only the unwind to block
5645 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum), getBBVal((yyvsp[(3) - (3)].ValIDVal)));
5646 CHECK_FOR_ERROR
5647 ;}
5648 break;
5649
5650 case 276:
Chris Lattnera925a142008-04-23 05:37:08 +00005651#line 2569 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005652 { // Labelled (named) basic block
5653 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)), 0);
5654 delete (yyvsp[(1) - (1)].StrVal);
5655 CHECK_FOR_ERROR
5656 ;}
5657 break;
5658
5659 case 277:
Chris Lattnera925a142008-04-23 05:37:08 +00005660#line 2574 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005661 {
5662 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (4)].StrVal)), getBBVal((yyvsp[(4) - (4)].ValIDVal)));
5663 delete (yyvsp[(1) - (4)].StrVal);
5664 CHECK_FOR_ERROR
5665 ;}
5666 break;
5667
5668 case 278:
Chris Lattnera925a142008-04-23 05:37:08 +00005669#line 2581 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005670 { // Return with a result...
5671 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
5672 assert(!VL.empty() && "Invalid ret operands!");
5673 (yyval.TermInstVal) = ReturnInst::Create(&VL[0], VL.size());
5674 delete (yyvsp[(2) - (2)].ValueList);
5675 CHECK_FOR_ERROR
5676 ;}
5677 break;
5678
5679 case 279:
Chris Lattnera925a142008-04-23 05:37:08 +00005680#line 2588 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005681 { // Return with no result...
5682 (yyval.TermInstVal) = ReturnInst::Create();
5683 CHECK_FOR_ERROR
5684 ;}
5685 break;
5686
5687 case 280:
Chris Lattnera925a142008-04-23 05:37:08 +00005688#line 2592 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005689 { // Unconditional Branch...
5690 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5691 CHECK_FOR_ERROR
5692 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
5693 ;}
5694 break;
5695
5696 case 281:
Chris Lattnera925a142008-04-23 05:37:08 +00005697#line 2597 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005698 {
5699 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5700 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5701 CHECK_FOR_ERROR
5702 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5703 CHECK_FOR_ERROR
5704 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5705 CHECK_FOR_ERROR
5706 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
5707 ;}
5708 break;
5709
5710 case 282:
Chris Lattnera925a142008-04-23 05:37:08 +00005711#line 2607 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005712 {
5713 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5714 CHECK_FOR_ERROR
5715 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5716 CHECK_FOR_ERROR
5717 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5718 (yyval.TermInstVal) = S;
5719
5720 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5721 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005722 for (; I != E; ++I) {
5723 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5724 S->addCase(CI, I->second);
5725 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005726 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005727 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005728 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005729 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005730 ;}
5731 break;
5732
5733 case 283:
Chris Lattnera925a142008-04-23 05:37:08 +00005734#line 2626 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005735 {
5736 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005737 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005738 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005739 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00005740 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005741 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005742 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005743 ;}
5744 break;
5745
5746 case 284:
Chris Lattnera925a142008-04-23 05:37:08 +00005747#line 2636 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005748 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005749
Reid Spencer14310612006-12-31 05:40:51 +00005750 // Handle the short syntax
5751 const PointerType *PFTy = 0;
5752 const FunctionType *Ty = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005753 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005754 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5755 // Pull out the types of all of the arguments...
5756 std::vector<const Type*> ParamTypes;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005757 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00005758 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005759 const Type *Ty = I->Val->getType();
5760 if (Ty == Type::VoidTy)
5761 GEN_ERROR("Short call syntax cannot be used with varargs");
5762 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005763 }
Chris Lattnera925a142008-04-23 05:37:08 +00005764
5765 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (14)].TypeVal)))
5766 GEN_ERROR("Invalid result type for LLVM function");
5767
Dan Gohmanf4423b12008-04-19 00:24:39 +00005768 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005769 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005770 }
5771
Dan Gohmanf4423b12008-04-19 00:24:39 +00005772 delete (yyvsp[(3) - (14)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005773
Dan Gohmanf4423b12008-04-19 00:24:39 +00005774 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005775 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005776 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005777 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005778 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005779 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005780
Chris Lattner58d74912008-03-12 17:45:29 +00005781 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005782 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None)
5783 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(8) - (14)].ParamAttrs)));
Duncan Sandsdc024672007-11-27 13:23:08 +00005784
Reid Spencer14310612006-12-31 05:40:51 +00005785 // Check the arguments
5786 ValueList Args;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005787 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005788 // Make sure no arguments is a good thing!
5789 if (Ty->getNumParams() != 0)
5790 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005791 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005792 } else { // Has arguments?
5793 // Loop through FunctionType's arguments and ensure they are specified
5794 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005795 FunctionType::param_iterator I = Ty->param_begin();
5796 FunctionType::param_iterator E = Ty->param_end();
Dan Gohmanf4423b12008-04-19 00:24:39 +00005797 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00005798 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005799
Duncan Sandsdc024672007-11-27 13:23:08 +00005800 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005801 if (ArgI->Val->getType() != *I)
5802 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005803 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005804 Args.push_back(ArgI->Val);
Chris Lattner58d74912008-03-12 17:45:29 +00005805 if (ArgI->Attrs != ParamAttr::None)
5806 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005807 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005808
Reid Spencer14310612006-12-31 05:40:51 +00005809 if (Ty->isVarArg()) {
5810 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00005811 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005812 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner58d74912008-03-12 17:45:29 +00005813 if (ArgI->Attrs != ParamAttr::None)
5814 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00005815 }
Reid Spencer14310612006-12-31 05:40:51 +00005816 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005817 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005818 }
Reid Spencer14310612006-12-31 05:40:51 +00005819
Chris Lattner58d74912008-03-12 17:45:29 +00005820 PAListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00005821 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00005822 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00005823
Reid Spencer14310612006-12-31 05:40:51 +00005824 // Create the InvokeInst
Gabor Greife64d2482008-04-06 23:07:54 +00005825 InvokeInst *II = InvokeInst::Create(V, Normal, Except, Args.begin(),Args.end());
Dan Gohmanf4423b12008-04-19 00:24:39 +00005826 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00005827 II->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005828 (yyval.TermInstVal) = II;
5829 delete (yyvsp[(6) - (14)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005830 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005831 ;}
5832 break;
5833
5834 case 285:
Chris Lattnera925a142008-04-23 05:37:08 +00005835#line 2720 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005836 {
5837 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005838 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005839 ;}
5840 break;
5841
5842 case 286:
Chris Lattnera925a142008-04-23 05:37:08 +00005843#line 2724 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005844 {
5845 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005846 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005847 ;}
5848 break;
5849
5850 case 287:
Chris Lattnera925a142008-04-23 05:37:08 +00005851#line 2731 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005852 {
5853 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5854 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005855 CHECK_FOR_ERROR
5856 if (V == 0)
5857 GEN_ERROR("May only switch on a constant pool value");
5858
Dan Gohmanf4423b12008-04-19 00:24:39 +00005859 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005860 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005861 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5862 ;}
5863 break;
5864
5865 case 288:
Chris Lattnera925a142008-04-23 05:37:08 +00005866#line 2742 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005867 {
5868 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5869 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005870 CHECK_FOR_ERROR
5871
5872 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005873 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005874
Dan Gohmanf4423b12008-04-19 00:24:39 +00005875 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005876 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005877 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5878 ;}
5879 break;
5880
5881 case 289:
Chris Lattnera925a142008-04-23 05:37:08 +00005882#line 2755 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005883 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005884 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00005885 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005886 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005887 InsertValue((yyvsp[(2) - (2)].InstVal));
5888 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005889 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005890 ;}
5891 break;
5892
5893 case 290:
Chris Lattnera925a142008-04-23 05:37:08 +00005894#line 2765 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005895 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005896 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005897 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5898 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5899 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005900 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005901 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005902 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005903 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5904 delete (yyvsp[(1) - (6)].TypeVal);
5905 ;}
5906 break;
5907
5908 case 291:
Chris Lattnera925a142008-04-23 05:37:08 +00005909#line 2776 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005910 {
5911 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5912 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005913 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005914 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005915 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005916 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5917 ;}
5918 break;
5919
5920 case 292:
Chris Lattnera925a142008-04-23 05:37:08 +00005921#line 2786 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005922 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005923 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005924 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005925 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005926 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00005927 (yyval.ParamList) = new ParamList();
5928 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal));
5929 (yyval.ParamList)->push_back(E);
5930 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00005931 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005932 ;}
5933 break;
5934
5935 case 293:
Chris Lattnera925a142008-04-23 05:37:08 +00005936#line 2797 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005937 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005938 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00005939 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00005940 (yyval.ParamList) = new ParamList();
5941 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal));
5942 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00005943 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005944 ;}
5945 break;
5946
5947 case 294:
Chris Lattnera925a142008-04-23 05:37:08 +00005948#line 2805 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005949 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005950 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005951 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005952 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5953 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5954 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
5955 (yyval.ParamList)->push_back(E);
5956 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005957 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005958 ;}
5959 break;
5960
5961 case 295:
Chris Lattnera925a142008-04-23 05:37:08 +00005962#line 2815 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005963 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005964 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00005965 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5966 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal));
5967 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00005968 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005969 ;}
5970 break;
5971
5972 case 296:
Chris Lattnera925a142008-04-23 05:37:08 +00005973#line 2822 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005974 { (yyval.ParamList) = new ParamList(); ;}
5975 break;
5976
5977 case 297:
Chris Lattnera925a142008-04-23 05:37:08 +00005978#line 2825 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005979 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5980 break;
5981
5982 case 298:
Chris Lattnera925a142008-04-23 05:37:08 +00005983#line 2826 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005984 {
5985 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5986 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005987 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005988 ;}
5989 break;
5990
5991 case 299:
Chris Lattnera925a142008-04-23 05:37:08 +00005992#line 2833 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005993 {
5994 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005995 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005996 ;}
5997 break;
5998
5999 case 300:
Chris Lattnera925a142008-04-23 05:37:08 +00006000#line 2837 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006001 {
6002 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006003 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006004 ;}
6005 break;
6006
6007 case 301:
Chris Lattnera925a142008-04-23 05:37:08 +00006008#line 2842 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006009 {
Reid Spencer14310612006-12-31 05:40:51 +00006010 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006011 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6012 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
6013 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006014 GEN_ERROR(
6015 "Arithmetic operator requires integer, FP, or packed operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006016 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006017 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006018 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006019 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006020 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
6021 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006022 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006023 delete (yyvsp[(2) - (5)].TypeVal);
6024 ;}
6025 break;
6026
6027 case 302:
Chris Lattnera925a142008-04-23 05:37:08 +00006028#line 2858 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006029 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006030 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006031 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6032 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
6033 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
6034 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006035 GEN_ERROR("Logical operator requires integral operands");
6036 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006037 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006038 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006039 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006040 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006041 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
6042 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006043 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006044 delete (yyvsp[(2) - (5)].TypeVal);
6045 ;}
6046 break;
6047
6048 case 303:
Chris Lattnera925a142008-04-23 05:37:08 +00006049#line 2875 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006050 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006051 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006052 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6053 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006054 GEN_ERROR("Vector types not supported by icmp instruction");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006055 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006056 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006057 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006058 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006059 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
6060 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006061 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006062 delete (yyvsp[(3) - (6)].TypeVal);
6063 ;}
6064 break;
6065
6066 case 304:
Chris Lattnera925a142008-04-23 05:37:08 +00006067#line 2889 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006068 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006069 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006070 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6071 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006072 GEN_ERROR("Vector types not supported by fcmp instruction");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006073 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006074 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006075 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006076 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006077 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
6078 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006079 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006080 delete (yyvsp[(3) - (6)].TypeVal);
6081 ;}
6082 break;
6083
6084 case 305:
Chris Lattnera925a142008-04-23 05:37:08 +00006085#line 2903 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006086 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006087 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006088 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6089 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6090 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6091 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006092 GEN_ERROR("invalid cast opcode for cast from '" +
6093 Val->getType()->getDescription() + "' to '" +
6094 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006095 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
6096 delete (yyvsp[(4) - (4)].TypeVal);
6097 ;}
6098 break;
6099
6100 case 306:
Chris Lattnera925a142008-04-23 05:37:08 +00006101#line 2915 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006102 {
6103 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006104 GEN_ERROR("select condition must be boolean");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006105 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006106 GEN_ERROR("select value types should match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006107 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006108 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006109 ;}
6110 break;
6111
6112 case 307:
Chris Lattnera925a142008-04-23 05:37:08 +00006113#line 2923 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006114 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006115 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006116 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6117 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6118 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006119 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006120 ;}
6121 break;
6122
6123 case 308:
Chris Lattnera925a142008-04-23 05:37:08 +00006124#line 2930 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006125 {
6126 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006127 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006128 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006129 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006130 ;}
6131 break;
6132
6133 case 309:
Chris Lattnera925a142008-04-23 05:37:08 +00006134#line 2936 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006135 {
6136 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006137 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006138 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006139 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006140 ;}
6141 break;
6142
6143 case 310:
Chris Lattnera925a142008-04-23 05:37:08 +00006144#line 2942 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006145 {
6146 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006147 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006148 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006149 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006150 ;}
6151 break;
6152
6153 case 311:
Chris Lattnera925a142008-04-23 05:37:08 +00006154#line 2948 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006155 {
6156 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006157 if (!Ty->isFirstClassType())
6158 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006159 (yyval.InstVal) = PHINode::Create(Ty);
6160 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6161 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
6162 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006163 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006164 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6165 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006166 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006167 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006168 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006169 ;}
6170 break;
6171
6172 case 312:
Chris Lattnera925a142008-04-23 05:37:08 +00006173#line 2964 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006174 {
Reid Spencer14310612006-12-31 05:40:51 +00006175
6176 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006177 const PointerType *PFTy = 0;
6178 const FunctionType *Ty = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006179 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006180 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6181 // Pull out the types of all of the arguments...
6182 std::vector<const Type*> ParamTypes;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006183 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006184 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006185 const Type *Ty = I->Val->getType();
6186 if (Ty == Type::VoidTy)
6187 GEN_ERROR("Short call syntax cannot be used with varargs");
6188 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006189 }
Chris Lattnera925a142008-04-23 05:37:08 +00006190
6191 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (8)].TypeVal)))
6192 GEN_ERROR("Invalid result type for LLVM function");
6193
Dan Gohmanf4423b12008-04-19 00:24:39 +00006194 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006195 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006196 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006197
Dan Gohmanf4423b12008-04-19 00:24:39 +00006198 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006199 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006200
Reid Spencer7780acb2007-04-16 06:56:07 +00006201 // Check for call to invalid intrinsic to avoid crashing later.
6202 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006203 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006204 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6205 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006206 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6207 theF->getName() + "'");
6208 }
6209
Duncan Sandsdc024672007-11-27 13:23:08 +00006210 // Set up the ParamAttrs for the function
Chris Lattner58d74912008-03-12 17:45:29 +00006211 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006212 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None)
6213 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(8) - (8)].ParamAttrs)));
Reid Spencer14310612006-12-31 05:40:51 +00006214 // Check the arguments
6215 ValueList Args;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006216 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006217 // Make sure no arguments is a good thing!
6218 if (Ty->getNumParams() != 0)
6219 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006220 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006221 } else { // Has arguments?
6222 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006223 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006224 FunctionType::param_iterator I = Ty->param_begin();
6225 FunctionType::param_iterator E = Ty->param_end();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006226 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006227 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006228
Duncan Sandsdc024672007-11-27 13:23:08 +00006229 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006230 if (ArgI->Val->getType() != *I)
6231 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006232 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006233 Args.push_back(ArgI->Val);
Chris Lattner58d74912008-03-12 17:45:29 +00006234 if (ArgI->Attrs != ParamAttr::None)
6235 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006236 }
6237 if (Ty->isVarArg()) {
6238 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006239 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006240 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner58d74912008-03-12 17:45:29 +00006241 if (ArgI->Attrs != ParamAttr::None)
6242 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006243 }
Reid Spencer14310612006-12-31 05:40:51 +00006244 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006245 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006246 }
Duncan Sandsdc024672007-11-27 13:23:08 +00006247
6248 // Finish off the ParamAttrs and check them
Chris Lattner58d74912008-03-12 17:45:29 +00006249 PAListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006250 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00006251 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006252
Reid Spencer14310612006-12-31 05:40:51 +00006253 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006254 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006255 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6256 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00006257 CI->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006258 (yyval.InstVal) = CI;
6259 delete (yyvsp[(6) - (8)].ParamList);
6260 delete (yyvsp[(3) - (8)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006261 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006262 ;}
6263 break;
6264
6265 case 313:
Chris Lattnera925a142008-04-23 05:37:08 +00006266#line 3053 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006267 {
6268 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006269 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006270 ;}
6271 break;
6272
6273 case 314:
Chris Lattnera925a142008-04-23 05:37:08 +00006274#line 3058 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006275 {
6276 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006277 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006278 ;}
6279 break;
6280
6281 case 315:
Chris Lattnera925a142008-04-23 05:37:08 +00006282#line 3062 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006283 {
6284 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006285 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006286 ;}
6287 break;
6288
6289 case 316:
Chris Lattnera925a142008-04-23 05:37:08 +00006290#line 3069 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006291 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006292 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006293 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6294 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6295 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006296 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006297 ;}
6298 break;
6299
6300 case 317:
Chris Lattnera925a142008-04-23 05:37:08 +00006301#line 3076 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006302 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006303 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006304 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6305 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006306 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006307 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6308 delete (yyvsp[(2) - (6)].TypeVal);
6309 ;}
6310 break;
6311
6312 case 318:
Chris Lattnera925a142008-04-23 05:37:08 +00006313#line 3084 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006314 {
Reid Spencer14310612006-12-31 05:40:51 +00006315 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006316 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6317 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6318 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006319 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006320 ;}
6321 break;
6322
6323 case 319:
Chris Lattnera925a142008-04-23 05:37:08 +00006324#line 3091 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006325 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006326 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006327 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6328 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006329 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006330 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6331 delete (yyvsp[(2) - (6)].TypeVal);
6332 ;}
6333 break;
6334
6335 case 320:
Chris Lattnera925a142008-04-23 05:37:08 +00006336#line 3099 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006337 {
6338 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006339 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006340 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6341 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006342 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006343 ;}
6344 break;
6345
6346 case 321:
Chris Lattnera925a142008-04-23 05:37:08 +00006347#line 3107 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006348 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006349 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006350 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6351 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006352 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006353 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6354 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006355 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006356 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6357 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006358 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006359 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6360 delete (yyvsp[(3) - (5)].TypeVal);
6361 ;}
6362 break;
6363
6364 case 322:
Chris Lattnera925a142008-04-23 05:37:08 +00006365#line 3121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006366 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006367 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006368 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6369 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006370 if (!PT)
6371 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006372 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006373 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006374 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6375 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006376 "' into space of type '" + ElTy->getDescription() + "'");
6377
Dan Gohmanf4423b12008-04-19 00:24:39 +00006378 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006379 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006380 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6381 delete (yyvsp[(5) - (7)].TypeVal);
6382 ;}
6383 break;
6384
6385 case 323:
Chris Lattnera925a142008-04-23 05:37:08 +00006386#line 3138 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006387 {
6388 Value *TmpVal = getVal((yyvsp[(2) - (5)].TypeVal)->get(), (yyvsp[(3) - (5)].ValIDVal));
6389 if (!GetResultInst::isValidOperands(TmpVal, (yyvsp[(5) - (5)].UInt64Val)))
Devang Patel5a970972008-02-19 22:27:01 +00006390 GEN_ERROR("Invalid getresult operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006391 (yyval.InstVal) = new GetResultInst(TmpVal, (yyvsp[(5) - (5)].UInt64Val));
6392 delete (yyvsp[(2) - (5)].TypeVal);
Devang Patel5a970972008-02-19 22:27:01 +00006393 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006394 ;}
6395 break;
6396
6397 case 324:
Chris Lattnera925a142008-04-23 05:37:08 +00006398#line 3146 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006399 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006400 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006401 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6402 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006403 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006404
Dan Gohmanf4423b12008-04-19 00:24:39 +00006405 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 +00006406 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006407 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6408 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006409 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006410 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
6411 delete (yyvsp[(2) - (4)].TypeVal);
6412 delete (yyvsp[(4) - (4)].ValueList);
6413 ;}
6414 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006415
Dan Gohmanf4423b12008-04-19 00:24:39 +00006416
6417/* Line 1267 of yacc.c. */
Chris Lattnera925a142008-04-23 05:37:08 +00006418#line 6419 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006419 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00006420 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006421 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6422
6423 YYPOPSTACK (yylen);
6424 yylen = 0;
6425 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006426
6427 *++yyvsp = yyval;
6428
6429
Dan Gohmanf4423b12008-04-19 00:24:39 +00006430 /* Now `shift' the result of the reduction. Determine what state
6431 that goes to, based on the state we popped back to and the rule
6432 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006433
6434 yyn = yyr1[yyn];
6435
Dan Gohmanf4423b12008-04-19 00:24:39 +00006436 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6437 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006438 yystate = yytable[yystate];
6439 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00006440 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00006441
6442 goto yynewstate;
6443
6444
Dan Gohmanf4423b12008-04-19 00:24:39 +00006445/*------------------------------------.
6446| yyerrlab -- here on detecting error |
6447`------------------------------------*/
6448yyerrlab:
6449 /* If not already recovering from an error, report this error. */
6450 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006451 {
6452 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006453#if ! YYERROR_VERBOSE
6454 yyerror (YY_("syntax error"));
6455#else
6456 {
6457 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6458 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6459 {
6460 YYSIZE_T yyalloc = 2 * yysize;
6461 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6462 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6463 if (yymsg != yymsgbuf)
6464 YYSTACK_FREE (yymsg);
6465 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6466 if (yymsg)
6467 yymsg_alloc = yyalloc;
6468 else
6469 {
6470 yymsg = yymsgbuf;
6471 yymsg_alloc = sizeof yymsgbuf;
6472 }
6473 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00006474
Dan Gohmanf4423b12008-04-19 00:24:39 +00006475 if (0 < yysize && yysize <= yymsg_alloc)
6476 {
6477 (void) yysyntax_error (yymsg, yystate, yychar);
6478 yyerror (yymsg);
6479 }
6480 else
6481 {
6482 yyerror (YY_("syntax error"));
6483 if (yysize != 0)
6484 goto yyexhaustedlab;
6485 }
6486 }
6487#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006488 }
6489
Dan Gohmanf4423b12008-04-19 00:24:39 +00006490
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006491
6492 if (yyerrstatus == 3)
6493 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00006494 /* If just tried and failed to reuse look-ahead token after an
6495 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006496
Dan Gohmanf4423b12008-04-19 00:24:39 +00006497 if (yychar <= YYEOF)
6498 {
6499 /* Return failure if at end of input. */
6500 if (yychar == YYEOF)
6501 YYABORT;
6502 }
6503 else
6504 {
6505 yydestruct ("Error: discarding",
6506 yytoken, &yylval);
6507 yychar = YYEMPTY;
6508 }
6509 }
6510
6511 /* Else will try to reuse look-ahead token after shifting the error
6512 token. */
6513 goto yyerrlab1;
6514
6515
6516/*---------------------------------------------------.
6517| yyerrorlab -- error raised explicitly by YYERROR. |
6518`---------------------------------------------------*/
6519yyerrorlab:
6520
6521 /* Pacify compilers like GCC when the user code never invokes
6522 YYERROR and the label yyerrorlab therefore never appears in user
6523 code. */
6524 if (/*CONSTCOND*/ 0)
6525 goto yyerrorlab;
6526
6527 /* Do not reclaim the symbols of the rule which action triggered
6528 this YYERROR. */
6529 YYPOPSTACK (yylen);
6530 yylen = 0;
6531 YY_STACK_PRINT (yyss, yyssp);
6532 yystate = *yyssp;
6533 goto yyerrlab1;
6534
6535
6536/*-------------------------------------------------------------.
6537| yyerrlab1 -- common code for both syntax error and YYERROR. |
6538`-------------------------------------------------------------*/
6539yyerrlab1:
6540 yyerrstatus = 3; /* Each real token shifted decrements this. */
6541
6542 for (;;)
6543 {
6544 yyn = yypact[yystate];
6545 if (yyn != YYPACT_NINF)
6546 {
6547 yyn += YYTERROR;
6548 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6549 {
6550 yyn = yytable[yyn];
6551 if (0 < yyn)
6552 break;
6553 }
6554 }
6555
6556 /* Pop the current state because it cannot handle the error token. */
6557 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006558 YYABORT;
6559
Dale Johannesencdd509a2007-09-07 21:07:57 +00006560
Dan Gohmanf4423b12008-04-19 00:24:39 +00006561 yydestruct ("Error: popping",
6562 yystos[yystate], yyvsp);
6563 YYPOPSTACK (1);
6564 yystate = *yyssp;
6565 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006566 }
6567
6568 if (yyn == YYFINAL)
6569 YYACCEPT;
6570
Reid Spencer68a24bd2005-08-27 18:50:39 +00006571 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006572
6573
6574 /* Shift the error token. */
6575 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00006576
Reid Spencer68a24bd2005-08-27 18:50:39 +00006577 yystate = yyn;
6578 goto yynewstate;
6579
Gabor Greife64d2482008-04-06 23:07:54 +00006580
Dan Gohmanf4423b12008-04-19 00:24:39 +00006581/*-------------------------------------.
6582| yyacceptlab -- YYACCEPT comes here. |
6583`-------------------------------------*/
6584yyacceptlab:
6585 yyresult = 0;
6586 goto yyreturn;
6587
6588/*-----------------------------------.
6589| yyabortlab -- YYABORT comes here. |
6590`-----------------------------------*/
6591yyabortlab:
6592 yyresult = 1;
6593 goto yyreturn;
6594
6595#ifndef yyoverflow
6596/*-------------------------------------------------.
6597| yyexhaustedlab -- memory exhaustion comes here. |
6598`-------------------------------------------------*/
6599yyexhaustedlab:
6600 yyerror (YY_("memory exhausted"));
6601 yyresult = 2;
6602 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00006603#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00006604
6605yyreturn:
6606 if (yychar != YYEOF && yychar != YYEMPTY)
6607 yydestruct ("Cleanup: discarding lookahead",
6608 yytoken, &yylval);
6609 /* Do not reclaim the symbols of the rule which action triggered
6610 this YYABORT or YYACCEPT. */
6611 YYPOPSTACK (yylen);
6612 YY_STACK_PRINT (yyss, yyssp);
6613 while (yyssp != yyss)
6614 {
6615 yydestruct ("Cleanup: popping",
6616 yystos[*yyssp], yyvsp);
6617 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00006618 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006619#ifndef yyoverflow
6620 if (yyss != yyssa)
6621 YYSTACK_FREE (yyss);
6622#endif
6623#if YYERROR_VERBOSE
6624 if (yymsg != yymsgbuf)
6625 YYSTACK_FREE (yymsg);
6626#endif
6627 /* Make sure YYID is used. */
6628 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006629}
Dan Gohmanf4423b12008-04-19 00:24:39 +00006630
6631
Chris Lattnera925a142008-04-23 05:37:08 +00006632#line 3163 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006633
6634
Reid Spencer14310612006-12-31 05:40:51 +00006635// common code from the two 'RunVMAsmParser' functions
6636static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00006637 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00006638 // Check to make sure the parser succeeded
6639 if (yyparse()) {
6640 if (ParserResult)
6641 delete ParserResult;
6642 return 0;
6643 }
6644
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006645 // Emit an error if there are any unresolved types left.
6646 if (!CurModule.LateResolveTypes.empty()) {
6647 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6648 if (DID.Type == ValID::LocalName) {
6649 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6650 } else {
6651 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6652 }
6653 if (ParserResult)
6654 delete ParserResult;
6655 return 0;
6656 }
6657
6658 // Emit an error if there are any unresolved values left.
6659 if (!CurModule.LateResolveValues.empty()) {
6660 Value *V = CurModule.LateResolveValues.back();
6661 std::map<Value*, std::pair<ValID, int> >::iterator I =
6662 CurModule.PlaceHolderInfo.find(V);
6663
6664 if (I != CurModule.PlaceHolderInfo.end()) {
6665 ValID &DID = I->second.first;
6666 if (DID.Type == ValID::LocalName) {
6667 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6668 } else {
6669 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6670 }
6671 if (ParserResult)
6672 delete ParserResult;
6673 return 0;
6674 }
6675 }
6676
Reid Spencer14310612006-12-31 05:40:51 +00006677 // Check to make sure that parsing produced a result
6678 if (!ParserResult)
6679 return 0;
6680
6681 // Reset ParserResult variable while saving its value for the result.
6682 Module *Result = ParserResult;
6683 ParserResult = 0;
6684
6685 return Result;
6686}
6687
Reid Spencer61c83e02006-08-18 08:43:06 +00006688void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00006689 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00006690 // TODO: column number in exception
6691 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00006692 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00006693 TriggerError = 1;
6694}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006695
6696int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00006697 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006698 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00006699 if (yychar != YYEMPTY && yychar != 0) {
6700 errMsg += " while reading token: '";
6701 errMsg += std::string(LLLgetTokenStart(),
6702 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
6703 }
Reid Spencer61c83e02006-08-18 08:43:06 +00006704 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006705 return 0;
6706}
Dan Gohmanf4423b12008-04-19 00:24:39 +00006707