blob: 6140f0b7b4c9220909474dc7ecbb3fb97311e9a6 [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,
Dale Johannesenc7071cc2008-05-14 20:13:36 +0000123 COMMON = 304,
124 OPAQUE = 305,
125 EXTERNAL = 306,
126 TARGET = 307,
127 TRIPLE = 308,
128 ALIGN = 309,
129 ADDRSPACE = 310,
130 DEPLIBS = 311,
131 CALL = 312,
132 TAIL = 313,
133 ASM_TOK = 314,
134 MODULE = 315,
135 SIDEEFFECT = 316,
136 CC_TOK = 317,
137 CCC_TOK = 318,
138 FASTCC_TOK = 319,
139 COLDCC_TOK = 320,
140 X86_STDCALLCC_TOK = 321,
141 X86_FASTCALLCC_TOK = 322,
Dale Johannesendfe8c842008-09-26 19:32:34 +0000142 DATALAYOUT = 323,
143 RET = 324,
144 BR = 325,
145 SWITCH = 326,
146 INVOKE = 327,
147 UNWIND = 328,
148 UNREACHABLE = 329,
149 ADD = 330,
150 SUB = 331,
151 MUL = 332,
152 UDIV = 333,
153 SDIV = 334,
154 FDIV = 335,
155 UREM = 336,
156 SREM = 337,
157 FREM = 338,
158 AND = 339,
159 OR = 340,
160 XOR = 341,
161 SHL = 342,
162 LSHR = 343,
163 ASHR = 344,
164 ICMP = 345,
165 FCMP = 346,
166 VICMP = 347,
167 VFCMP = 348,
168 EQ = 349,
169 NE = 350,
170 SLT = 351,
171 SGT = 352,
172 SLE = 353,
173 SGE = 354,
174 ULT = 355,
175 UGT = 356,
176 ULE = 357,
177 UGE = 358,
178 OEQ = 359,
179 ONE = 360,
180 OLT = 361,
181 OGT = 362,
182 OLE = 363,
183 OGE = 364,
184 ORD = 365,
185 UNO = 366,
186 UEQ = 367,
187 UNE = 368,
188 MALLOC = 369,
189 ALLOCA = 370,
190 FREE = 371,
191 LOAD = 372,
192 STORE = 373,
193 GETELEMENTPTR = 374,
194 TRUNC = 375,
195 ZEXT = 376,
196 SEXT = 377,
197 FPTRUNC = 378,
198 FPEXT = 379,
199 BITCAST = 380,
200 UITOFP = 381,
201 SITOFP = 382,
202 FPTOUI = 383,
203 FPTOSI = 384,
204 INTTOPTR = 385,
205 PTRTOINT = 386,
206 PHI_TOK = 387,
207 SELECT = 388,
208 VAARG = 389,
209 EXTRACTELEMENT = 390,
210 INSERTELEMENT = 391,
211 SHUFFLEVECTOR = 392,
212 GETRESULT = 393,
213 EXTRACTVALUE = 394,
214 INSERTVALUE = 395,
215 SIGNEXT = 396,
216 ZEROEXT = 397,
217 NORETURN = 398,
218 INREG = 399,
219 SRET = 400,
220 NOUNWIND = 401,
221 NOALIAS = 402,
222 BYVAL = 403,
223 NEST = 404,
224 READNONE = 405,
225 READONLY = 406,
226 GC = 407,
Devang Patel652203f2008-09-29 20:49:50 +0000227 OPTSIZE = 408,
228 NOINLINE = 409,
229 ALWAYSINLINE = 410,
230 DEFAULT = 411,
231 HIDDEN = 412,
232 PROTECTED = 413
Dan Gohmanf4423b12008-04-19 00:24:39 +0000233 };
234#endif
235/* Tokens. */
236#define ESINT64VAL 258
237#define EUINT64VAL 259
238#define ESAPINTVAL 260
239#define EUAPINTVAL 261
240#define LOCALVAL_ID 262
241#define GLOBALVAL_ID 263
242#define FPVAL 264
243#define VOID 265
244#define INTTYPE 266
245#define FLOAT 267
246#define DOUBLE 268
247#define X86_FP80 269
248#define FP128 270
249#define PPC_FP128 271
250#define LABEL 272
251#define TYPE 273
252#define LOCALVAR 274
253#define GLOBALVAR 275
254#define LABELSTR 276
255#define STRINGCONSTANT 277
256#define ATSTRINGCONSTANT 278
257#define PCTSTRINGCONSTANT 279
258#define ZEROINITIALIZER 280
259#define TRUETOK 281
260#define FALSETOK 282
261#define BEGINTOK 283
262#define ENDTOK 284
263#define DECLARE 285
264#define DEFINE 286
265#define GLOBAL 287
266#define CONSTANT 288
267#define SECTION 289
268#define ALIAS 290
269#define VOLATILE 291
270#define THREAD_LOCAL 292
271#define TO 293
272#define DOTDOTDOT 294
273#define NULL_TOK 295
274#define UNDEF 296
275#define INTERNAL 297
276#define LINKONCE 298
277#define WEAK 299
278#define APPENDING 300
279#define DLLIMPORT 301
280#define DLLEXPORT 302
281#define EXTERN_WEAK 303
Dale Johannesenc7071cc2008-05-14 20:13:36 +0000282#define COMMON 304
283#define OPAQUE 305
284#define EXTERNAL 306
285#define TARGET 307
286#define TRIPLE 308
287#define ALIGN 309
288#define ADDRSPACE 310
289#define DEPLIBS 311
290#define CALL 312
291#define TAIL 313
292#define ASM_TOK 314
293#define MODULE 315
294#define SIDEEFFECT 316
295#define CC_TOK 317
296#define CCC_TOK 318
297#define FASTCC_TOK 319
298#define COLDCC_TOK 320
299#define X86_STDCALLCC_TOK 321
300#define X86_FASTCALLCC_TOK 322
Dale Johannesendfe8c842008-09-26 19:32:34 +0000301#define DATALAYOUT 323
302#define RET 324
303#define BR 325
304#define SWITCH 326
305#define INVOKE 327
306#define UNWIND 328
307#define UNREACHABLE 329
308#define ADD 330
309#define SUB 331
310#define MUL 332
311#define UDIV 333
312#define SDIV 334
313#define FDIV 335
314#define UREM 336
315#define SREM 337
316#define FREM 338
317#define AND 339
318#define OR 340
319#define XOR 341
320#define SHL 342
321#define LSHR 343
322#define ASHR 344
323#define ICMP 345
324#define FCMP 346
325#define VICMP 347
326#define VFCMP 348
327#define EQ 349
328#define NE 350
329#define SLT 351
330#define SGT 352
331#define SLE 353
332#define SGE 354
333#define ULT 355
334#define UGT 356
335#define ULE 357
336#define UGE 358
337#define OEQ 359
338#define ONE 360
339#define OLT 361
340#define OGT 362
341#define OLE 363
342#define OGE 364
343#define ORD 365
344#define UNO 366
345#define UEQ 367
346#define UNE 368
347#define MALLOC 369
348#define ALLOCA 370
349#define FREE 371
350#define LOAD 372
351#define STORE 373
352#define GETELEMENTPTR 374
353#define TRUNC 375
354#define ZEXT 376
355#define SEXT 377
356#define FPTRUNC 378
357#define FPEXT 379
358#define BITCAST 380
359#define UITOFP 381
360#define SITOFP 382
361#define FPTOUI 383
362#define FPTOSI 384
363#define INTTOPTR 385
364#define PTRTOINT 386
365#define PHI_TOK 387
366#define SELECT 388
367#define VAARG 389
368#define EXTRACTELEMENT 390
369#define INSERTELEMENT 391
370#define SHUFFLEVECTOR 392
371#define GETRESULT 393
372#define EXTRACTVALUE 394
373#define INSERTVALUE 395
374#define SIGNEXT 396
375#define ZEROEXT 397
376#define NORETURN 398
377#define INREG 399
378#define SRET 400
379#define NOUNWIND 401
380#define NOALIAS 402
381#define BYVAL 403
382#define NEST 404
383#define READNONE 405
384#define READONLY 406
385#define GC 407
Devang Patel652203f2008-09-29 20:49:50 +0000386#define OPTSIZE 408
387#define NOINLINE 409
388#define ALWAYSINLINE 410
389#define DEFAULT 411
390#define HIDDEN 412
391#define PROTECTED 413
Dan Gohmanf4423b12008-04-19 00:24:39 +0000392
393
394
395
396/* Copy the first part of user declarations. */
Devang Patel652203f2008-09-29 20:49:50 +0000397#line 14 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000398
399#include "ParserInternals.h"
400#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000401#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000402#include "llvm/Instructions.h"
403#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000404#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000405#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000406#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000407#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000408#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000409#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000410#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000411#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000412#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000413#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000414#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000415#include <utility>
416
Reid Spencere4f47592006-08-18 17:32:55 +0000417// The following is a gross hack. In order to rid the libAsmParser library of
418// exceptions, we have to have a way of getting the yyparse function to go into
419// an error situation. So, whenever we want an error to occur, the GenerateError
Eric Christopher2a5196f2008-09-24 04:55:49 +0000420// function (see bottom of file) sets TriggerError. Then, at the end of each
421// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
422// (a goto) to put YACC in error state. Furthermore, several calls to
Reid Spencere4f47592006-08-18 17:32:55 +0000423// GenerateError are made from inside productions and they must simulate the
424// previous exception behavior by exiting the production immediately. We have
425// replaced these with the GEN_ERROR macro which calls GeneratError and then
Eric Christopher2a5196f2008-09-24 04:55:49 +0000426// immediately invokes YYERROR. This would be so much cleaner if it was a
Reid Spencere4f47592006-08-18 17:32:55 +0000427// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000428static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000429#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000430#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
431
Reid Spencer68a24bd2005-08-27 18:50:39 +0000432int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
433int yylex(); // declaration" of xxx warnings.
434int yyparse();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000435using namespace llvm;
436
437static Module *ParserResult;
438
439// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
440// relating to upreferences in the input stream.
441//
442//#define DEBUG_UPREFS 1
443#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000444#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000445#else
446#define UR_OUT(X)
447#endif
448
449#define YYERROR_VERBOSE 1
450
Chris Lattnerb475c422005-11-12 18:22:38 +0000451static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000452
453
454// This contains info used when building the body of a function. It is
455// destroyed when the function is completed.
456//
457typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000458
Eric Christopher2a5196f2008-09-24 04:55:49 +0000459static void
Reid Spencer93c40032007-03-19 18:40:50 +0000460ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000461
462static struct PerModuleInfo {
463 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000464 ValueList Values; // Module level numbered definitions
465 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000466 std::vector<PATypeHolder> Types;
467 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000468
469 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000470 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000471 /// that we can resolve them later and print error messages as appropriate.
472 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
473
474 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
475 // references to global values. Global values may be referenced before they
476 // are defined, and if so, the temporary object that they represent is held
477 // here. This is used for forward references of GlobalValues.
478 //
479 typedef std::map<std::pair<const PointerType *,
480 ValID>, GlobalValue*> GlobalRefsType;
481 GlobalRefsType GlobalRefs;
482
483 void ModuleDone() {
484 // If we could not resolve some functions at function compilation time
485 // (calls to functions before they are defined), resolve them now... Types
486 // are resolved when the constant pool has been completely parsed.
487 //
488 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000489 if (TriggerError)
490 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000491
492 // Check to make sure that all global value forward references have been
493 // resolved!
494 //
495 if (!GlobalRefs.empty()) {
496 std::string UndefinedReferences = "Unresolved global references exist:\n";
497
498 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
499 I != E; ++I) {
500 UndefinedReferences += " " + I->first.first->getDescription() + " " +
501 I->first.second.getName() + "\n";
502 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000503 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000504 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000505 }
506
Chandler Carruth02202192007-08-04 01:56:21 +0000507 // Look for intrinsic functions and CallInst that need to be upgraded
508 for (Module::iterator FI = CurrentModule->begin(),
509 FE = CurrentModule->end(); FI != FE; )
510 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
511
Reid Spencer68a24bd2005-08-27 18:50:39 +0000512 Values.clear(); // Clear out function local definitions
513 Types.clear();
514 CurrentModule = 0;
515 }
516
Reid Spencer68a24bd2005-08-27 18:50:39 +0000517 // GetForwardRefForGlobal - Check to see if there is a forward reference
518 // for this global. If so, remove it from the GlobalRefs map and return it.
519 // If not, just return null.
520 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
521 // Check to see if there is a forward reference to this global variable...
522 // if there is, eliminate it and patch the reference to use the new def'n.
523 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
524 GlobalValue *Ret = 0;
525 if (I != GlobalRefs.end()) {
526 Ret = I->second;
527 GlobalRefs.erase(I);
528 }
529 return Ret;
530 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000531
532 bool TypeIsUnresolved(PATypeHolder* PATy) {
533 // If it isn't abstract, its resolved
534 const Type* Ty = PATy->get();
535 if (!Ty->isAbstract())
536 return false;
537 // Traverse the type looking for abstract types. If it isn't abstract then
Eric Christopher2a5196f2008-09-24 04:55:49 +0000538 // we don't need to traverse that leg of the type.
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000539 std::vector<const Type*> WorkList, SeenList;
540 WorkList.push_back(Ty);
541 while (!WorkList.empty()) {
542 const Type* Ty = WorkList.back();
543 SeenList.push_back(Ty);
544 WorkList.pop_back();
545 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
546 // Check to see if this is an unresolved type
547 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
548 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
549 for ( ; I != E; ++I) {
550 if (I->second.get() == OpTy)
551 return true;
552 }
553 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
554 const Type* TheTy = SeqTy->getElementType();
555 if (TheTy->isAbstract() && TheTy != Ty) {
Eric Christopher2a5196f2008-09-24 04:55:49 +0000556 std::vector<const Type*>::iterator I = SeenList.begin(),
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000557 E = SeenList.end();
558 for ( ; I != E; ++I)
559 if (*I == TheTy)
560 break;
561 if (I == E)
562 WorkList.push_back(TheTy);
563 }
564 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
565 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
566 const Type* TheTy = StrTy->getElementType(i);
567 if (TheTy->isAbstract() && TheTy != Ty) {
Eric Christopher2a5196f2008-09-24 04:55:49 +0000568 std::vector<const Type*>::iterator I = SeenList.begin(),
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000569 E = SeenList.end();
570 for ( ; I != E; ++I)
571 if (*I == TheTy)
572 break;
573 if (I == E)
574 WorkList.push_back(TheTy);
575 }
576 }
577 }
578 }
579 return false;
580 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000581} CurModule;
582
583static struct PerFunctionInfo {
584 Function *CurrentFunction; // Pointer to current function being created
585
Reid Spencer93c40032007-03-19 18:40:50 +0000586 ValueList Values; // Keep track of #'d definitions
587 unsigned NextValNum;
588 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000589 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000590 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000591 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000592
593 /// BBForwardRefs - When we see forward references to basic blocks, keep
594 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000595 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000596
597 inline PerFunctionInfo() {
598 CurrentFunction = 0;
599 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000600 Linkage = GlobalValue::ExternalLinkage;
601 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000602 }
603
604 inline void FunctionStart(Function *M) {
605 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000606 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000607 }
608
609 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000610 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000611 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000612 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000613 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000614 return;
615 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000616
617 // Resolve all forward references now.
618 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
619
620 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000621 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000622 CurrentFunction = 0;
623 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000624 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000625 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626 }
627} CurFun; // Info for the current function...
628
629static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
630
631
632//===----------------------------------------------------------------------===//
633// Code to handle definitions of all the types
634//===----------------------------------------------------------------------===//
635
Chris Lattner15bd0952008-08-29 17:20:18 +0000636/// InsertValue - Insert a value into the value table. If it is named, this
637/// returns -1, otherwise it returns the slot number for the value.
638static int InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
Reid Spencer93c40032007-03-19 18:40:50 +0000639 // Things that have names or are void typed don't get slot numbers
640 if (V->hasName() || (V->getType() == Type::VoidTy))
Chris Lattner15bd0952008-08-29 17:20:18 +0000641 return -1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000642
Reid Spencer93c40032007-03-19 18:40:50 +0000643 // In the case of function values, we have to allow for the forward reference
644 // of basic blocks, which are included in the numbering. Consequently, we keep
Eric Christopher2a5196f2008-09-24 04:55:49 +0000645 // track of the next insertion location with NextValNum. When a BB gets
Reid Spencer93c40032007-03-19 18:40:50 +0000646 // inserted, it could change the size of the CurFun.Values vector.
647 if (&ValueTab == &CurFun.Values) {
648 if (ValueTab.size() <= CurFun.NextValNum)
649 ValueTab.resize(CurFun.NextValNum+1);
650 ValueTab[CurFun.NextValNum++] = V;
Chris Lattner15bd0952008-08-29 17:20:18 +0000651 return CurFun.NextValNum-1;
Eric Christopher2a5196f2008-09-24 04:55:49 +0000652 }
Reid Spencer93c40032007-03-19 18:40:50 +0000653 // For all other lists, its okay to just tack it on the back of the vector.
654 ValueTab.push_back(V);
Chris Lattner15bd0952008-08-29 17:20:18 +0000655 return ValueTab.size()-1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000656}
657
658static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
659 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000660 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000661 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000662 if (D.Num < CurModule.Types.size())
663 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000664 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000665 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000666 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000667 D.destroy(); // Free old strdup'd memory...
668 return N;
669 }
670 break;
671 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000672 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000673 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000674 }
675
676 // If we reached here, we referenced either a symbol that we don't know about
677 // or an id number that hasn't been read yet. We may be referencing something
678 // forward, so just create an entry to be resolved later and get to it...
679 //
680 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
681
682
683 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000684 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000685 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000686 return 0;
687 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000688 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000689 return 0;
690 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000691 }
692
Reid Spencer861d9d62006-11-28 07:29:44 +0000693 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000694 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000695 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000696
Reid Spencer861d9d62006-11-28 07:29:44 +0000697 Type *Typ = OpaqueType::get();
698 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
699 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000700 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000701
Reid Spencer93c40032007-03-19 18:40:50 +0000702// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000703// the provided ValID. If the value exists and has already been defined, return
704// it. Otherwise return null.
705//
Reid Spencer93c40032007-03-19 18:40:50 +0000706static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000707 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000708 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000709 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000710 return 0;
711 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000712
713 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000714 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000715 // Check that the number is within bounds.
Eric Christopher2a5196f2008-09-24 04:55:49 +0000716 if (D.Num >= CurFun.Values.size())
Reid Spencer93c40032007-03-19 18:40:50 +0000717 return 0;
718 Value *Result = CurFun.Values[D.Num];
719 if (Ty != Result->getType()) {
720 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +0000721 Result->getType()->getDescription() + "' does not match "
Reid Spencer93c40032007-03-19 18:40:50 +0000722 "expected type, '" + Ty->getDescription() + "'");
723 return 0;
724 }
725 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000726 }
727 case ValID::GlobalID: { // Is it a numbered definition?
Eric Christopher2a5196f2008-09-24 04:55:49 +0000728 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000729 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000730 Value *Result = CurModule.Values[D.Num];
731 if (Ty != Result->getType()) {
732 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +0000733 Result->getType()->getDescription() + "' does not match "
Reid Spencer93c40032007-03-19 18:40:50 +0000734 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000735 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000736 }
737 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000738 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000739
Reid Spencer41dff5e2007-01-26 08:05:27 +0000740 case ValID::LocalName: { // Is it a named definition?
Eric Christopher2a5196f2008-09-24 04:55:49 +0000741 if (!inFunctionScope())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000742 return 0;
743 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000744 Value *N = SymTab.lookup(D.getName());
Eric Christopher2a5196f2008-09-24 04:55:49 +0000745 if (N == 0)
Reid Spenceref9b9a72007-02-05 20:47:22 +0000746 return 0;
747 if (N->getType() != Ty)
748 return 0;
Eric Christopher2a5196f2008-09-24 04:55:49 +0000749
Reid Spencer41dff5e2007-01-26 08:05:27 +0000750 D.destroy(); // Free old strdup'd memory...
751 return N;
752 }
753 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000754 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000755 Value *N = SymTab.lookup(D.getName());
Eric Christopher2a5196f2008-09-24 04:55:49 +0000756 if (N == 0)
Reid Spenceref9b9a72007-02-05 20:47:22 +0000757 return 0;
758 if (N->getType() != Ty)
759 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000760
761 D.destroy(); // Free old strdup'd memory...
762 return N;
763 }
764
765 // Check to make sure that "Ty" is an integral type, and that our
766 // value will fit into the specified type...
767 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner38905612008-02-19 04:36:25 +0000768 if (!isa<IntegerType>(Ty) ||
769 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000770 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000771 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000772 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000773 return 0;
774 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000775 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776
777 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000778 if (isa<IntegerType>(Ty) &&
779 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Reid Spencerb83eb642006-10-20 07:07:24 +0000780 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner38905612008-02-19 04:36:25 +0000781
782 if (!isa<IntegerType>(Ty) ||
783 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
784 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
785 "' is invalid or out of range for type '" +
786 Ty->getDescription() + "'");
787 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000788 }
Chris Lattner38905612008-02-19 04:36:25 +0000789 // This is really a signed reference. Transmogrify.
790 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000791
Chris Lattner1913b942008-07-11 00:30:39 +0000792 case ValID::ConstAPInt: // Is it an unsigned const pool reference?
793 if (!isa<IntegerType>(Ty)) {
794 GenerateError("Integral constant '" + D.getName() +
795 "' is invalid or out of range for type '" +
796 Ty->getDescription() + "'");
797 return 0;
798 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000799
Chris Lattner1913b942008-07-11 00:30:39 +0000800 {
801 APSInt Tmp = *D.ConstPoolInt;
802 Tmp.extOrTrunc(Ty->getPrimitiveSizeInBits());
803 return ConstantInt::get(Tmp);
804 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000805
Reid Spencer68a24bd2005-08-27 18:50:39 +0000806 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000807 if (!Ty->isFloatingPoint() ||
808 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000809 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000810 return 0;
811 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000812 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +0000813 // as double. Fix this here. Long double does not need this.
814 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
815 Ty==Type::FloatTy)
Dale Johannesencdd509a2007-09-07 21:07:57 +0000816 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000817 return ConstantFP::get(*D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000818
819 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000820 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000821 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000822 return 0;
823 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000824 return ConstantPointerNull::get(cast<PointerType>(Ty));
825
826 case ValID::ConstUndefVal: // Is it an undef value?
827 return UndefValue::get(Ty);
828
Chris Lattner7aa61892005-12-21 17:53:23 +0000829 case ValID::ConstZeroVal: // Is it a zero value?
830 return Constant::getNullValue(Ty);
Eric Christopher2a5196f2008-09-24 04:55:49 +0000831
Reid Spencer68a24bd2005-08-27 18:50:39 +0000832 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000833 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000834 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000835 return 0;
836 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000837 return D.ConstantValue;
838
Chris Lattner0e9c3762006-01-25 22:27:16 +0000839 case ValID::InlineAsmVal: { // Inline asm expression
840 const PointerType *PTy = dyn_cast<PointerType>(Ty);
841 const FunctionType *FTy =
842 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000843 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000844 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000845 return 0;
846 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000847 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
848 D.IAD->HasSideEffects);
849 D.destroy(); // Free InlineAsmDescriptor.
850 return IA;
851 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000852 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000853 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000854 return 0;
855 } // End of switch
856
Reid Spencera9720f52007-02-05 17:04:00 +0000857 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000858 return 0;
859}
860
Reid Spencer93c40032007-03-19 18:40:50 +0000861// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000862// value is not already defined, it "improvises" by creating a placeholder var
863// that looks and acts just like the requested variable. When the value is
864// defined later, all uses of the placeholder variable are replaced with the
865// real thing.
866//
867static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000868 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000869 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000870 return 0;
871 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000872
873 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000874 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000875 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000876 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000877
Reid Spencer5b7e7532006-09-28 19:28:24 +0000878 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Dan Gohmane4977cf2008-05-23 01:55:30 +0000879 GenerateError("Invalid use of a non-first-class type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000880 return 0;
881 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000882
883 // If we reached here, we referenced either a symbol that we don't know about
884 // or an id number that hasn't been read yet. We may be referencing something
885 // forward, so just create an entry to be resolved later and get to it...
886 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000887 switch (ID.Type) {
888 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000889 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000890 const PointerType *PTy = dyn_cast<PointerType>(Ty);
891 if (!PTy) {
892 GenerateError("Invalid type for reference to global" );
893 return 0;
894 }
895 const Type* ElTy = PTy->getElementType();
896 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greife64d2482008-04-06 23:07:54 +0000897 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000898 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000899 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
900 (Module*)0, false, PTy->getAddressSpace());
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000901 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000902 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000903 default:
904 V = new Argument(Ty);
905 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000906
Reid Spencer68a24bd2005-08-27 18:50:39 +0000907 // Remember where this forward reference came from. FIXME, shouldn't we try
908 // to recycle these things??
909 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsdc024672007-11-27 13:23:08 +0000910 LLLgetLineNo())));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000911
912 if (inFunctionScope())
913 InsertValue(V, CurFun.LateResolveValues);
914 else
915 InsertValue(V, CurModule.LateResolveValues);
916 return V;
917}
918
Reid Spencer93c40032007-03-19 18:40:50 +0000919/// defineBBVal - This is a definition of a new basic block with the specified
920/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Chris Lattnercc81d152008-05-04 17:18:47 +0000921static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000922 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000923
Reid Spencer68a24bd2005-08-27 18:50:39 +0000924 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000925
Reid Spencer93c40032007-03-19 18:40:50 +0000926 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000927
Reid Spencer93c40032007-03-19 18:40:50 +0000928 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
929 if (BBI != CurFun.BBForwardRefs.end()) {
930 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000931 // The forward declaration could have been inserted anywhere in the
932 // function: insert it into the correct place now.
933 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
934 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000935
Reid Spencer66728ef2007-03-20 01:13:36 +0000936 // We're about to erase the entry, save the key so we can clean it up.
937 ValID Tmp = BBI->first;
938
Reid Spencer93c40032007-03-19 18:40:50 +0000939 // Erase the forward ref from the map as its no longer "forward"
940 CurFun.BBForwardRefs.erase(ID);
941
Eric Christopher2a5196f2008-09-24 04:55:49 +0000942 // The key has been removed from the map but so we don't want to leave
Reid Spencer66728ef2007-03-20 01:13:36 +0000943 // strdup'd memory around so destroy it too.
944 Tmp.destroy();
945
Reid Spencer93c40032007-03-19 18:40:50 +0000946 // If its a numbered definition, bump the number and set the BB value.
947 if (ID.Type == ValID::LocalID) {
948 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
949 InsertValue(BB);
950 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000951 } else {
952 // We haven't seen this BB before and its first mention is a definition.
Devang Patel67909432008-03-03 18:58:47 +0000953 // Just create it and return it.
954 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greife64d2482008-04-06 23:07:54 +0000955 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel67909432008-03-03 18:58:47 +0000956 if (ID.Type == ValID::LocalID) {
957 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
958 InsertValue(BB);
959 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000960 }
Reid Spencer93c40032007-03-19 18:40:50 +0000961
Devang Patel67909432008-03-03 18:58:47 +0000962 ID.destroy();
Reid Spencer93c40032007-03-19 18:40:50 +0000963 return BB;
964}
965
966/// getBBVal - get an existing BB value or create a forward reference for it.
Eric Christopher2a5196f2008-09-24 04:55:49 +0000967///
Reid Spencer93c40032007-03-19 18:40:50 +0000968static BasicBlock *getBBVal(const ValID &ID) {
969 assert(inFunctionScope() && "Can't get basic block at global scope!");
970
971 BasicBlock *BB = 0;
972
973 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
974 if (BBI != CurFun.BBForwardRefs.end()) {
975 BB = BBI->second;
976 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000977 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000978 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000979 if (N) {
Reid Spencer93c40032007-03-19 18:40:50 +0000980 if (N->getType()->getTypeID() == Type::LabelTyID)
981 BB = cast<BasicBlock>(N);
982 else
983 GenerateError("Reference to label '" + Name + "' is actually of type '"+
984 N->getType()->getDescription() + "'");
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000985 }
Reid Spencer93c40032007-03-19 18:40:50 +0000986 } else if (ID.Type == ValID::LocalID) {
987 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
988 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
989 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
990 else
Eric Christopher2a5196f2008-09-24 04:55:49 +0000991 GenerateError("Reference to label '%" + utostr(ID.Num) +
992 "' is actually of type '"+
Reid Spencer93c40032007-03-19 18:40:50 +0000993 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
994 }
995 } else {
996 GenerateError("Illegal label reference " + ID.getName());
997 return 0;
998 }
999
1000 // If its already been defined, return it now.
1001 if (BB) {
1002 ID.destroy(); // Free strdup'd memory.
1003 return BB;
1004 }
1005
1006 // Otherwise, this block has not been seen before, create it.
1007 std::string Name;
1008 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001009 Name = ID.getName();
Gabor Greife64d2482008-04-06 23:07:54 +00001010 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Reid Spencer93c40032007-03-19 18:40:50 +00001011
1012 // Insert it in the forward refs map.
1013 CurFun.BBForwardRefs[ID] = BB;
1014
Reid Spencer68a24bd2005-08-27 18:50:39 +00001015 return BB;
1016}
1017
1018
1019//===----------------------------------------------------------------------===//
1020// Code to handle forward references in instructions
1021//===----------------------------------------------------------------------===//
1022//
1023// This code handles the late binding needed with statements that reference
1024// values not defined yet... for example, a forward branch, or the PHI node for
1025// a loop body.
1026//
1027// This keeps a table (CurFun.LateResolveValues) of all such forward references
1028// and back patchs after we are done.
1029//
1030
1031// ResolveDefinitions - If we could not resolve some defs at parsing
1032// time (forward branches, phi functions for loops, etc...) resolve the
1033// defs now...
1034//
Eric Christopher2a5196f2008-09-24 04:55:49 +00001035static void
Reid Spencer93c40032007-03-19 18:40:50 +00001036ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001037 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +00001038 while (!LateResolvers.empty()) {
1039 Value *V = LateResolvers.back();
1040 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001041
Reid Spencer93c40032007-03-19 18:40:50 +00001042 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1043 CurModule.PlaceHolderInfo.find(V);
1044 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001045
Reid Spencer93c40032007-03-19 18:40:50 +00001046 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001047
Reid Spencer93c40032007-03-19 18:40:50 +00001048 Value *TheRealValue = getExistingVal(V->getType(), DID);
1049 if (TriggerError)
1050 return;
1051 if (TheRealValue) {
1052 V->replaceAllUsesWith(TheRealValue);
1053 delete V;
1054 CurModule.PlaceHolderInfo.erase(PHI);
1055 } else if (FutureLateResolvers) {
1056 // Functions have their unresolved items forwarded to the module late
1057 // resolver table
1058 InsertValue(V, *FutureLateResolvers);
1059 } else {
1060 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1061 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1062 "' of type '" + V->getType()->getDescription() + "'",
1063 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001064 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001065 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001066 GenerateError("Reference to an invalid definition: #" +
1067 itostr(DID.Num) + " of type '" +
1068 V->getType()->getDescription() + "'",
1069 PHI->second.second);
1070 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001071 }
1072 }
1073 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001074 LateResolvers.clear();
1075}
1076
1077// ResolveTypeTo - A brand new type was just declared. This means that (if
1078// name is not null) things referencing Name can be resolved. Otherwise, things
1079// refering to the number can be resolved. Do this now.
1080//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001081static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001082 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001083 if (Name)
1084 D = ValID::createLocalName(*Name);
Eric Christopher2a5196f2008-09-24 04:55:49 +00001085 else
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001086 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001087
Reid Spencer861d9d62006-11-28 07:29:44 +00001088 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001089 CurModule.LateResolveTypes.find(D);
1090 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001091 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001092 CurModule.LateResolveTypes.erase(I);
1093 }
1094}
1095
1096// setValueName - Set the specified value to the name given. The name may be
1097// null potentially, in which case this is a noop. The string passed in is
1098// assumed to be a malloc'd string buffer, and is free'd by this function.
1099//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001100static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001101 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001102 std::string Name(*NameStr); // Copy string
1103 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001104
Reid Spencer41dff5e2007-01-26 08:05:27 +00001105 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001106 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001107 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001108 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001109
Reid Spencera9720f52007-02-05 17:04:00 +00001110 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001111 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1112 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001113 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001114 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001115 return;
1116 }
1117
1118 // Set the name.
1119 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001120}
1121
1122/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1123/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001124static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001125ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001126 GlobalValue::LinkageTypes Linkage,
1127 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001128 bool isConstantGlobal, const Type *Ty,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001129 Constant *Initializer, bool IsThreadLocal,
1130 unsigned AddressSpace = 0) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001131 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001132 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001133 return 0;
1134 }
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001135 if (Ty == Type::LabelTy) {
1136 GenerateError("Cannot declare global vars of label type");
1137 return 0;
1138 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001139
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001140 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001141
1142 std::string Name;
1143 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001144 Name = *NameStr; // Copy string
1145 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001146 }
1147
1148 // See if this global value was forward referenced. If so, recycle the
1149 // object.
1150 ValID ID;
1151 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001152 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001153 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001154 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001155 }
1156
1157 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1158 // Move the global to the end of the list, from whereever it was
1159 // previously inserted.
1160 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1161 CurModule.CurrentModule->getGlobalList().remove(GV);
1162 CurModule.CurrentModule->getGlobalList().push_back(GV);
1163 GV->setInitializer(Initializer);
1164 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001165 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001166 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001167 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001168 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001169 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001170 }
1171
Reid Spenceref9b9a72007-02-05 20:47:22 +00001172 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001173 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001174 // if the global we're parsing has an initializer (is a definition) and
1175 // has external linkage.
1176 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1177 // If there is already a global with external linkage with this name
1178 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1179 // If we allow this GVar to get created, it will be renamed in the
1180 // symbol table because it conflicts with an existing GVar. We can't
1181 // allow redefinition of GVars whose linking indicates that their name
1182 // must stay the same. Issue the error.
1183 GenerateError("Redefinition of global variable named '" + Name +
1184 "' of type '" + Ty->getDescription() + "'");
1185 return 0;
1186 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001187 }
1188
1189 // Otherwise there is no existing GV to use, create one now.
1190 GlobalVariable *GV =
1191 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001192 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001193 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001194 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001195 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001196}
1197
1198// setTypeName - Set the specified type to the name given. The name may be
1199// null potentially, in which case this is a noop. The string passed in is
1200// assumed to be a malloc'd string buffer, and is freed by this function.
1201//
1202// This function returns true if the type has already been defined, but is
1203// allowed to be redefined in the specified context. If the name is a new name
1204// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001205static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001206 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001207 if (NameStr == 0) return false;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001208
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001209 std::string Name(*NameStr); // Copy string
1210 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001211
1212 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001213 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001214 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001215 return false;
1216 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001217
1218 // Set the type name, checking for conflicts as we do so.
1219 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1220
1221 if (AlreadyExists) { // Inserting a name that is already defined???
1222 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001223 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001224
1225 // There is only one case where this is allowed: when we are refining an
1226 // opaque type. In this case, Existing will be an opaque type.
1227 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1228 // We ARE replacing an opaque type!
1229 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1230 return true;
1231 }
1232
1233 // Otherwise, this is an attempt to redefine a type. That's okay if
1234 // the redefinition is identical to the original. This will be so if
1235 // Existing and T point to the same Type object. In this one case we
1236 // allow the equivalent redefinition.
1237 if (Existing == T) return true; // Yes, it's equal.
1238
1239 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001240 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001241 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001242 }
1243
1244 return false;
1245}
1246
1247//===----------------------------------------------------------------------===//
1248// Code for handling upreferences in type names...
1249//
1250
1251// TypeContains - Returns true if Ty directly contains E in it.
1252//
1253static bool TypeContains(const Type *Ty, const Type *E) {
1254 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1255 E) != Ty->subtype_end();
1256}
1257
1258namespace {
1259 struct UpRefRecord {
1260 // NestingLevel - The number of nesting levels that need to be popped before
1261 // this type is resolved.
1262 unsigned NestingLevel;
1263
1264 // LastContainedTy - This is the type at the current binding level for the
1265 // type. Every time we reduce the nesting level, this gets updated.
1266 const Type *LastContainedTy;
1267
1268 // UpRefTy - This is the actual opaque type that the upreference is
1269 // represented with.
1270 OpaqueType *UpRefTy;
1271
1272 UpRefRecord(unsigned NL, OpaqueType *URTy)
1273 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1274 };
1275}
1276
1277// UpRefs - A list of the outstanding upreferences that need to be resolved.
1278static std::vector<UpRefRecord> UpRefs;
1279
1280/// HandleUpRefs - Every time we finish a new layer of types, this function is
1281/// called. It loops through the UpRefs vector, which is a list of the
1282/// currently active types. For each type, if the up reference is contained in
1283/// the newly completed type, we decrement the level count. When the level
1284/// count reaches zero, the upreferenced type is the type that is passed in:
1285/// thus we can complete the cycle.
1286///
1287static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001288 // If Ty isn't abstract, or if there are no up-references in it, then there is
1289 // nothing to resolve here.
1290 if (!ty->isAbstract() || UpRefs.empty()) return ty;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001291
Reid Spencer68a24bd2005-08-27 18:50:39 +00001292 PATypeHolder Ty(ty);
1293 UR_OUT("Type '" << Ty->getDescription() <<
1294 "' newly formed. Resolving upreferences.\n" <<
1295 UpRefs.size() << " upreferences active!\n");
1296
1297 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1298 // to zero), we resolve them all together before we resolve them to Ty. At
1299 // the end of the loop, if there is anything to resolve to Ty, it will be in
1300 // this variable.
1301 OpaqueType *TypeToResolve = 0;
1302
1303 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1304 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1305 << UpRefs[i].second->getDescription() << ") = "
1306 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1307 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1308 // Decrement level of upreference
1309 unsigned Level = --UpRefs[i].NestingLevel;
1310 UpRefs[i].LastContainedTy = Ty;
1311 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1312 if (Level == 0) { // Upreference should be resolved!
1313 if (!TypeToResolve) {
1314 TypeToResolve = UpRefs[i].UpRefTy;
1315 } else {
1316 UR_OUT(" * Resolving upreference for "
1317 << UpRefs[i].second->getDescription() << "\n";
1318 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1319 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1320 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1321 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1322 }
1323 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1324 --i; // Do not skip the next element...
1325 }
1326 }
1327 }
1328
1329 if (TypeToResolve) {
1330 UR_OUT(" * Resolving upreference for "
1331 << UpRefs[i].second->getDescription() << "\n";
1332 std::string OldName = TypeToResolve->getDescription());
1333 TypeToResolve->refineAbstractTypeTo(Ty);
1334 }
1335
1336 return Ty;
1337}
1338
Reid Spencer68a24bd2005-08-27 18:50:39 +00001339//===----------------------------------------------------------------------===//
1340// RunVMAsmParser - Define an interface to this parser
1341//===----------------------------------------------------------------------===//
1342//
Reid Spencer14310612006-12-31 05:40:51 +00001343static Module* RunParser(Module * M);
1344
Duncan Sandsdc024672007-11-27 13:23:08 +00001345Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1346 InitLLLexer(MB);
1347 Module *M = RunParser(new Module(LLLgetFilename()));
1348 FreeLexer();
1349 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001350}
1351
1352
Dan Gohmanf4423b12008-04-19 00:24:39 +00001353
1354/* Enabling traces. */
1355#ifndef YYDEBUG
1356# define YYDEBUG 0
1357#endif
1358
1359/* Enabling verbose error messages. */
1360#ifdef YYERROR_VERBOSE
1361# undef YYERROR_VERBOSE
1362# define YYERROR_VERBOSE 1
1363#else
1364# define YYERROR_VERBOSE 0
1365#endif
1366
1367/* Enabling the token table. */
1368#ifndef YYTOKEN_TABLE
1369# define YYTOKEN_TABLE 0
1370#endif
1371
1372#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1373typedef union YYSTYPE
Devang Patel652203f2008-09-29 20:49:50 +00001374#line 970 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001375{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001376 llvm::Module *ModuleVal;
1377 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001378 llvm::BasicBlock *BasicBlockVal;
1379 llvm::TerminatorInst *TermInstVal;
1380 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001381 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001382
Reid Spencera132e042006-12-03 05:46:11 +00001383 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001384 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001385 llvm::PATypeHolder *TypeVal;
1386 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001387 std::vector<llvm::Value*> *ValueList;
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001388 std::vector<unsigned> *ConstantList;
Reid Spencer14310612006-12-31 05:40:51 +00001389 llvm::ArgListType *ArgList;
1390 llvm::TypeWithAttrs TypeWithAttrs;
1391 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001392 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001393
Reid Spencer68a24bd2005-08-27 18:50:39 +00001394 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001395 std::list<std::pair<llvm::Value*,
1396 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001397 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001398 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001399
1400 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001401 llvm::GlobalValue::VisibilityTypes Visibility;
Devang Patel05988662008-09-25 21:00:45 +00001402 llvm::Attributes Attributes;
Reid Spencer38c91a92007-02-28 02:24:54 +00001403 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001404 int64_t SInt64Val;
1405 uint64_t UInt64Val;
1406 int SIntVal;
1407 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001408 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001409 bool BoolVal;
1410
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001411 std::string *StrVal; // This memory must be deleted
1412 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001413
Reid Spencera132e042006-12-03 05:46:11 +00001414 llvm::Instruction::BinaryOps BinaryOpVal;
1415 llvm::Instruction::TermOps TermOpVal;
1416 llvm::Instruction::MemoryOps MemOpVal;
1417 llvm::Instruction::CastOps CastOpVal;
1418 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001419 llvm::ICmpInst::Predicate IPredicate;
1420 llvm::FCmpInst::Predicate FPredicate;
Dan Gohmanf4423b12008-04-19 00:24:39 +00001421}
Dan Gohman180c1692008-06-23 18:43:26 +00001422/* Line 193 of yacc.c. */
Devang Patel652203f2008-09-29 20:49:50 +00001423#line 1424 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001424 YYSTYPE;
1425# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1426# define YYSTYPE_IS_DECLARED 1
1427# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001428#endif
1429
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001430
Reid Spencer68a24bd2005-08-27 18:50:39 +00001431
Dan Gohmanf4423b12008-04-19 00:24:39 +00001432/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001433
1434
Dan Gohmanf4423b12008-04-19 00:24:39 +00001435/* Line 216 of yacc.c. */
Devang Patel652203f2008-09-29 20:49:50 +00001436#line 1437 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001437
Dan Gohmanf4423b12008-04-19 00:24:39 +00001438#ifdef short
1439# undef short
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001440#endif
1441
Dan Gohmanf4423b12008-04-19 00:24:39 +00001442#ifdef YYTYPE_UINT8
1443typedef YYTYPE_UINT8 yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001444#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00001445typedef unsigned char yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001446#endif
1447
Dan Gohmanf4423b12008-04-19 00:24:39 +00001448#ifdef YYTYPE_INT8
1449typedef YYTYPE_INT8 yytype_int8;
1450#elif (defined __STDC__ || defined __C99__FUNC__ \
1451 || defined __cplusplus || defined _MSC_VER)
1452typedef signed char yytype_int8;
1453#else
1454typedef short int yytype_int8;
1455#endif
1456
1457#ifdef YYTYPE_UINT16
1458typedef YYTYPE_UINT16 yytype_uint16;
1459#else
1460typedef unsigned short int yytype_uint16;
1461#endif
1462
1463#ifdef YYTYPE_INT16
1464typedef YYTYPE_INT16 yytype_int16;
1465#else
1466typedef short int yytype_int16;
1467#endif
1468
1469#ifndef YYSIZE_T
1470# ifdef __SIZE_TYPE__
1471# define YYSIZE_T __SIZE_TYPE__
1472# elif defined size_t
1473# define YYSIZE_T size_t
1474# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1475 || defined __cplusplus || defined _MSC_VER)
1476# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1477# define YYSIZE_T size_t
1478# else
1479# define YYSIZE_T unsigned int
1480# endif
1481#endif
1482
1483#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1484
1485#ifndef YY_
Dan Gohman180c1692008-06-23 18:43:26 +00001486# if defined YYENABLE_NLS && YYENABLE_NLS
Dan Gohmanf4423b12008-04-19 00:24:39 +00001487# if ENABLE_NLS
1488# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1489# define YY_(msgid) dgettext ("bison-runtime", msgid)
1490# endif
1491# endif
1492# ifndef YY_
1493# define YY_(msgid) msgid
1494# endif
1495#endif
1496
1497/* Suppress unused-variable warnings by "using" E. */
1498#if ! defined lint || defined __GNUC__
1499# define YYUSE(e) ((void) (e))
1500#else
1501# define YYUSE(e) /* empty */
1502#endif
1503
1504/* Identity function, used to suppress warnings about constant conditions. */
1505#ifndef lint
1506# define YYID(n) (n)
1507#else
1508#if (defined __STDC__ || defined __C99__FUNC__ \
1509 || defined __cplusplus || defined _MSC_VER)
1510static int
1511YYID (int i)
1512#else
1513static int
1514YYID (i)
1515 int i;
1516#endif
1517{
1518 return i;
1519}
1520#endif
1521
1522#if ! defined yyoverflow || YYERROR_VERBOSE
1523
1524/* The parser invokes alloca or malloc; define the necessary symbols. */
1525
1526# ifdef YYSTACK_USE_ALLOCA
1527# if YYSTACK_USE_ALLOCA
1528# ifdef __GNUC__
1529# define YYSTACK_ALLOC __builtin_alloca
1530# elif defined __BUILTIN_VA_ARG_INCR
1531# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1532# elif defined _AIX
1533# define YYSTACK_ALLOC __alloca
1534# elif defined _MSC_VER
1535# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1536# define alloca _alloca
1537# else
1538# define YYSTACK_ALLOC alloca
1539# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1540 || defined __cplusplus || defined _MSC_VER)
1541# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1542# ifndef _STDLIB_H
1543# define _STDLIB_H 1
1544# endif
1545# endif
1546# endif
1547# endif
1548# endif
1549
1550# ifdef YYSTACK_ALLOC
1551 /* Pacify GCC's `empty if-body' warning. */
1552# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1553# ifndef YYSTACK_ALLOC_MAXIMUM
1554 /* The OS might guarantee only one guard page at the bottom of the stack,
1555 and a page size can be as small as 4096 bytes. So we cannot safely
1556 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1557 to allow for a few compiler-allocated temporary stack slots. */
1558# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1559# endif
1560# else
1561# define YYSTACK_ALLOC YYMALLOC
1562# define YYSTACK_FREE YYFREE
1563# ifndef YYSTACK_ALLOC_MAXIMUM
1564# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1565# endif
1566# if (defined __cplusplus && ! defined _STDLIB_H \
1567 && ! ((defined YYMALLOC || defined malloc) \
1568 && (defined YYFREE || defined free)))
1569# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1570# ifndef _STDLIB_H
1571# define _STDLIB_H 1
1572# endif
1573# endif
1574# ifndef YYMALLOC
1575# define YYMALLOC malloc
1576# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1577 || defined __cplusplus || defined _MSC_VER)
1578void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1579# endif
1580# endif
1581# ifndef YYFREE
1582# define YYFREE free
1583# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1584 || defined __cplusplus || defined _MSC_VER)
1585void free (void *); /* INFRINGES ON USER NAME SPACE */
1586# endif
1587# endif
1588# endif
1589#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1590
1591
1592#if (! defined yyoverflow \
1593 && (! defined __cplusplus \
1594 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1595
1596/* A type that is properly aligned for any stack member. */
1597union yyalloc
1598{
1599 yytype_int16 yyss;
1600 YYSTYPE yyvs;
1601 };
1602
1603/* The size of the maximum gap between one aligned stack and the next. */
1604# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1605
1606/* The size of an array large to enough to hold all stacks, each with
1607 N elements. */
1608# define YYSTACK_BYTES(N) \
1609 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1610 + YYSTACK_GAP_MAXIMUM)
1611
1612/* Copy COUNT objects from FROM to TO. The source and destination do
1613 not overlap. */
1614# ifndef YYCOPY
1615# if defined __GNUC__ && 1 < __GNUC__
1616# define YYCOPY(To, From, Count) \
1617 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1618# else
1619# define YYCOPY(To, From, Count) \
1620 do \
1621 { \
1622 YYSIZE_T yyi; \
1623 for (yyi = 0; yyi < (Count); yyi++) \
1624 (To)[yyi] = (From)[yyi]; \
1625 } \
1626 while (YYID (0))
1627# endif
1628# endif
1629
1630/* Relocate STACK from its old location to the new one. The
1631 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1632 elements in the stack, and YYPTR gives the new location of the
1633 stack. Advance YYPTR to a properly aligned location for the next
1634 stack. */
1635# define YYSTACK_RELOCATE(Stack) \
1636 do \
1637 { \
1638 YYSIZE_T yynewbytes; \
1639 YYCOPY (&yyptr->Stack, Stack, yysize); \
1640 Stack = &yyptr->Stack; \
1641 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1642 yyptr += yynewbytes / sizeof (*yyptr); \
1643 } \
1644 while (YYID (0))
1645
1646#endif
1647
1648/* YYFINAL -- State number of the termination state. */
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001649#define YYFINAL 44
Dan Gohmanf4423b12008-04-19 00:24:39 +00001650/* YYLAST -- Last index in YYTABLE. */
Devang Patel652203f2008-09-29 20:49:50 +00001651#define YYLAST 2439
Dan Gohmanf4423b12008-04-19 00:24:39 +00001652
1653/* YYNTOKENS -- Number of terminals. */
Devang Patel652203f2008-09-29 20:49:50 +00001654#define YYNTOKENS 173
Dan Gohmanf4423b12008-04-19 00:24:39 +00001655/* YYNNTS -- Number of nonterminals. */
Devang Patel652203f2008-09-29 20:49:50 +00001656#define YYNNTS 89
Dan Gohmanf4423b12008-04-19 00:24:39 +00001657/* YYNRULES -- Number of rules. */
Devang Patel652203f2008-09-29 20:49:50 +00001658#define YYNRULES 354
Dan Gohmanf4423b12008-04-19 00:24:39 +00001659/* YYNRULES -- Number of states. */
Devang Patel652203f2008-09-29 20:49:50 +00001660#define YYNSTATES 717
Dan Gohmanf4423b12008-04-19 00:24:39 +00001661
1662/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1663#define YYUNDEFTOK 2
Devang Patel652203f2008-09-29 20:49:50 +00001664#define YYMAXUTOK 413
Dan Gohmanf4423b12008-04-19 00:24:39 +00001665
1666#define YYTRANSLATE(YYX) \
1667 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1668
1669/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1670static const yytype_uint8 yytranslate[] =
1671{
1672 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1673 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1674 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1675 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001676 159, 160, 163, 2, 162, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001677 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001678 168, 161, 169, 2, 2, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001679 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1680 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001681 2, 165, 164, 167, 2, 2, 2, 2, 2, 172,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001682 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1683 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001684 166, 2, 2, 170, 2, 171, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001685 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1686 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1688 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1689 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1690 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1691 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1692 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1693 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1694 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1695 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1696 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1697 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1698 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1699 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1700 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1701 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1702 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1703 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1704 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1705 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1706 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1707 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1708 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1709 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1710 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1711 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Dan Gohmane4977cf2008-05-23 01:55:30 +00001712 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
Devang Patel652203f2008-09-29 20:49:50 +00001713 155, 156, 157, 158
Dan Gohmanf4423b12008-04-19 00:24:39 +00001714};
1715
1716#if YYDEBUG
1717/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1718 YYRHS. */
1719static const yytype_uint16 yyprhs[] =
1720{
1721 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1722 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1723 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1724 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1725 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1726 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1727 119, 121, 123, 125, 127, 129, 130, 135, 136, 139,
Chris Lattner15bd0952008-08-29 17:20:18 +00001728 140, 143, 145, 147, 149, 150, 153, 155, 157, 159,
1729 161, 163, 165, 167, 169, 171, 172, 174, 176, 178,
1730 179, 181, 183, 184, 186, 188, 190, 192, 193, 195,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001731 197, 198, 200, 202, 204, 206, 208, 211, 213, 215,
1732 217, 219, 221, 223, 225, 227, 229, 232, 233, 236,
Devang Patel652203f2008-09-29 20:49:50 +00001733 238, 240, 242, 243, 246, 248, 250, 252, 254, 256,
1734 258, 260, 262, 264, 266, 267, 270, 271, 274, 275,
1735 278, 279, 283, 286, 287, 289, 290, 294, 296, 299,
1736 301, 303, 305, 307, 309, 311, 313, 315, 317, 321,
1737 323, 326, 332, 338, 344, 350, 354, 357, 363, 368,
1738 371, 373, 375, 377, 381, 383, 387, 389, 390, 392,
1739 396, 401, 405, 409, 414, 419, 423, 430, 436, 439,
1740 442, 445, 448, 451, 454, 457, 460, 463, 466, 469,
1741 472, 479, 485, 494, 501, 508, 516, 524, 532, 540,
1742 547, 556, 565, 571, 579, 583, 585, 587, 589, 591,
1743 592, 595, 602, 604, 605, 607, 610, 611, 615, 616,
1744 620, 624, 628, 632, 633, 642, 643, 653, 654, 664,
1745 670, 673, 677, 679, 683, 687, 691, 695, 697, 698,
1746 704, 708, 710, 714, 716, 717, 729, 731, 733, 738,
1747 740, 742, 745, 749, 750, 752, 754, 756, 758, 760,
1748 762, 764, 766, 768, 770, 772, 776, 780, 783, 786,
1749 790, 793, 799, 804, 806, 812, 814, 816, 818, 820,
1750 822, 824, 827, 829, 833, 836, 839, 843, 847, 850,
1751 851, 853, 856, 859, 863, 873, 883, 892, 908, 910,
1752 912, 919, 925, 928, 931, 938, 946, 951, 956, 963,
1753 970, 971, 972, 976, 979, 983, 986, 988, 994, 1000,
1754 1007, 1014, 1021, 1028, 1033, 1040, 1045, 1050, 1057, 1064,
1755 1067, 1077, 1079, 1081, 1082, 1086, 1093, 1097, 1104, 1107,
1756 1113, 1121, 1127, 1132, 1137
Dan Gohmanf4423b12008-04-19 00:24:39 +00001757};
1758
1759/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1760static const yytype_int16 yyrhs[] =
1761{
Devang Patel652203f2008-09-29 20:49:50 +00001762 222, 0, -1, 75, -1, 76, -1, 77, -1, 78,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001763 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
1764 -1, 87, -1, 88, -1, 89, -1, 84, -1, 85,
1765 -1, 86, -1, 120, -1, 121, -1, 122, -1, 123,
1766 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
1767 -1, 129, -1, 130, -1, 131, -1, 94, -1, 95,
1768 -1, 96, -1, 97, -1, 98, -1, 99, -1, 100,
1769 -1, 101, -1, 102, -1, 103, -1, 104, -1, 105,
1770 -1, 106, -1, 107, -1, 108, -1, 109, -1, 110,
1771 -1, 111, -1, 112, -1, 113, -1, 100, -1, 101,
1772 -1, 102, -1, 103, -1, 26, -1, 27, -1, 11,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001773 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
Devang Patel652203f2008-09-29 20:49:50 +00001774 -1, 19, -1, 22, -1, 24, -1, 181, -1, -1,
1775 55, 159, 4, 160, -1, -1, 181, 161, -1, -1,
1776 7, 161, -1, 20, -1, 23, -1, 188, -1, -1,
1777 186, 161, -1, 42, -1, 44, -1, 43, -1, 45,
Chris Lattner15bd0952008-08-29 17:20:18 +00001778 -1, 47, -1, 49, -1, 46, -1, 48, -1, 51,
Devang Patel652203f2008-09-29 20:49:50 +00001779 -1, -1, 156, -1, 157, -1, 158, -1, -1, 46,
Chris Lattner15bd0952008-08-29 17:20:18 +00001780 -1, 48, -1, -1, 42, -1, 43, -1, 44, -1,
1781 47, -1, -1, 44, -1, 42, -1, -1, 63, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001782 64, -1, 65, -1, 66, -1, 67, -1, 62, 4,
1783 -1, 142, -1, 121, -1, 141, -1, 122, -1, 144,
1784 -1, 145, -1, 147, -1, 148, -1, 149, -1, 54,
Devang Patel652203f2008-09-29 20:49:50 +00001785 4, -1, -1, 197, 196, -1, 144, -1, 142, -1,
1786 141, -1, -1, 199, 198, -1, 143, -1, 146, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001787 144, -1, 142, -1, 141, -1, 150, -1, 151, -1,
Devang Patel652203f2008-09-29 20:49:50 +00001788 154, -1, 155, -1, 153, -1, -1, 201, 200, -1,
1789 -1, 152, 22, -1, -1, 54, 4, -1, -1, 162,
1790 54, 4, -1, 34, 22, -1, -1, 205, -1, -1,
1791 162, 208, 207, -1, 205, -1, 54, 4, -1, 11,
1792 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1793 -1, 17, -1, 50, -1, 209, -1, 210, 183, 163,
1794 -1, 244, -1, 164, 4, -1, 210, 159, 214, 160,
1795 201, -1, 10, 159, 214, 160, 201, -1, 165, 4,
1796 166, 210, 167, -1, 168, 4, 166, 210, 169, -1,
1797 170, 215, 171, -1, 170, 171, -1, 168, 170, 215,
1798 171, 169, -1, 168, 170, 171, 169, -1, 210, 197,
1799 -1, 210, -1, 10, -1, 211, -1, 213, 162, 211,
1800 -1, 213, -1, 213, 162, 39, -1, 39, -1, -1,
1801 210, -1, 215, 162, 210, -1, 210, 165, 218, 167,
1802 -1, 210, 165, 167, -1, 210, 172, 22, -1, 210,
1803 168, 218, 169, -1, 210, 170, 218, 171, -1, 210,
1804 170, 171, -1, 210, 168, 170, 218, 171, 169, -1,
1805 210, 168, 170, 171, 169, -1, 210, 40, -1, 210,
1806 41, -1, 210, 244, -1, 210, 217, -1, 210, 25,
1807 -1, 179, 3, -1, 179, 5, -1, 179, 4, -1,
1808 179, 6, -1, 11, 26, -1, 11, 27, -1, 180,
1809 9, -1, 176, 159, 216, 38, 210, 160, -1, 119,
1810 159, 216, 256, 160, -1, 133, 159, 216, 162, 216,
1811 162, 216, 160, -1, 174, 159, 216, 162, 216, 160,
1812 -1, 175, 159, 216, 162, 216, 160, -1, 90, 177,
1813 159, 216, 162, 216, 160, -1, 91, 178, 159, 216,
1814 162, 216, 160, -1, 92, 177, 159, 216, 162, 216,
1815 160, -1, 93, 178, 159, 216, 162, 216, 160, -1,
1816 135, 159, 216, 162, 216, 160, -1, 136, 159, 216,
1817 162, 216, 162, 216, 160, -1, 137, 159, 216, 162,
1818 216, 162, 216, 160, -1, 139, 159, 216, 257, 160,
1819 -1, 140, 159, 216, 162, 216, 257, 160, -1, 218,
1820 162, 216, -1, 216, -1, 32, -1, 33, -1, 37,
1821 -1, -1, 212, 244, -1, 125, 159, 221, 38, 210,
1822 160, -1, 223, -1, -1, 224, -1, 223, 224, -1,
1823 -1, 31, 225, 240, -1, -1, 30, 226, 241, -1,
1824 60, 59, 230, -1, 184, 18, 210, -1, 184, 18,
1825 10, -1, -1, 187, 191, 220, 219, 216, 183, 227,
1826 207, -1, -1, 187, 189, 191, 220, 219, 216, 183,
1827 228, 207, -1, -1, 187, 190, 191, 220, 219, 210,
1828 183, 229, 207, -1, 187, 191, 35, 194, 221, -1,
1829 52, 231, -1, 56, 161, 232, -1, 22, -1, 53,
1830 161, 22, -1, 68, 161, 22, -1, 165, 233, 167,
1831 -1, 233, 162, 22, -1, 22, -1, -1, 234, 162,
1832 210, 197, 182, -1, 210, 197, 182, -1, 234, -1,
1833 234, 162, 39, -1, 39, -1, -1, 195, 199, 212,
1834 186, 159, 235, 160, 201, 206, 203, 202, -1, 28,
1835 -1, 170, -1, 193, 191, 236, 237, -1, 29, -1,
1836 171, -1, 248, 239, -1, 192, 191, 236, -1, -1,
1837 61, -1, 3, -1, 4, -1, 5, -1, 6, -1,
1838 9, -1, 26, -1, 27, -1, 40, -1, 41, -1,
1839 25, -1, 168, 218, 169, -1, 165, 218, 167, -1,
1840 165, 167, -1, 172, 22, -1, 170, 218, 171, -1,
1841 170, 171, -1, 168, 170, 218, 171, 169, -1, 168,
1842 170, 171, 169, -1, 217, -1, 59, 242, 22, 162,
1843 22, -1, 7, -1, 8, -1, 181, -1, 186, -1,
1844 244, -1, 243, -1, 210, 245, -1, 246, -1, 247,
1845 162, 246, -1, 248, 249, -1, 238, 249, -1, 250,
1846 184, 251, -1, 250, 185, 251, -1, 250, 253, -1,
1847 -1, 21, -1, 69, 247, -1, 69, 10, -1, 70,
1848 17, 245, -1, 70, 11, 245, 162, 17, 245, 162,
1849 17, 245, -1, 71, 179, 245, 162, 17, 245, 165,
1850 252, 167, -1, 71, 179, 245, 162, 17, 245, 165,
1851 167, -1, 72, 195, 199, 212, 245, 159, 255, 160,
1852 201, 38, 17, 245, 73, 17, 245, -1, 73, -1,
1853 74, -1, 252, 179, 243, 162, 17, 245, -1, 179,
1854 243, 162, 17, 245, -1, 184, 259, -1, 185, 259,
1855 -1, 210, 165, 245, 162, 245, 167, -1, 254, 162,
1856 165, 245, 162, 245, 167, -1, 210, 197, 245, 197,
1857 -1, 17, 197, 245, 197, -1, 255, 162, 210, 197,
1858 245, 197, -1, 255, 162, 17, 197, 245, 197, -1,
1859 -1, -1, 256, 162, 246, -1, 162, 4, -1, 257,
1860 162, 4, -1, 58, 57, -1, 57, -1, 174, 210,
1861 245, 162, 245, -1, 175, 210, 245, 162, 245, -1,
1862 90, 177, 210, 245, 162, 245, -1, 91, 178, 210,
1863 245, 162, 245, -1, 92, 177, 210, 245, 162, 245,
1864 -1, 93, 178, 210, 245, 162, 245, -1, 176, 246,
1865 38, 210, -1, 133, 246, 162, 246, 162, 246, -1,
1866 134, 246, 162, 210, -1, 135, 246, 162, 246, -1,
1867 136, 246, 162, 246, 162, 246, -1, 137, 246, 162,
1868 246, 162, 246, -1, 132, 254, -1, 258, 195, 199,
1869 212, 245, 159, 255, 160, 201, -1, 261, -1, 36,
1870 -1, -1, 114, 210, 204, -1, 114, 210, 162, 11,
1871 245, 204, -1, 115, 210, 204, -1, 115, 210, 162,
1872 11, 245, 204, -1, 116, 246, -1, 260, 117, 210,
1873 245, 204, -1, 260, 118, 246, 162, 210, 245, 204,
1874 -1, 138, 210, 245, 162, 4, -1, 119, 210, 245,
1875 256, -1, 139, 210, 245, 257, -1, 140, 210, 245,
1876 162, 210, 245, 257, -1
Dan Gohmanf4423b12008-04-19 00:24:39 +00001877};
1878
1879/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1880static const yytype_uint16 yyrline[] =
1881{
Devang Patel652203f2008-09-29 20:49:50 +00001882 0, 1136, 1136, 1136, 1136, 1136, 1136, 1136, 1136, 1136,
1883 1136, 1137, 1137, 1137, 1137, 1137, 1137, 1138, 1138, 1138,
1884 1138, 1138, 1138, 1139, 1139, 1139, 1139, 1139, 1139, 1142,
1885 1142, 1143, 1143, 1144, 1144, 1145, 1145, 1146, 1146, 1150,
1886 1150, 1151, 1151, 1152, 1152, 1153, 1153, 1154, 1154, 1155,
1887 1155, 1156, 1156, 1157, 1158, 1163, 1164, 1164, 1164, 1164,
1888 1164, 1166, 1166, 1166, 1167, 1167, 1169, 1170, 1174, 1178,
1889 1183, 1189, 1189, 1191, 1192, 1197, 1203, 1204, 1205, 1206,
1890 1207, 1208, 1212, 1213, 1214, 1218, 1219, 1220, 1221, 1225,
1891 1226, 1227, 1231, 1232, 1233, 1234, 1235, 1239, 1240, 1241,
1892 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1257, 1258, 1259,
1893 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1270, 1271, 1276,
1894 1277, 1278, 1281, 1282, 1288, 1289, 1290, 1291, 1292, 1293,
1895 1294, 1295, 1296, 1297, 1300, 1301, 1307, 1308, 1315, 1316,
1896 1322, 1323, 1332, 1340, 1341, 1346, 1347, 1348, 1353, 1366,
1897 1366, 1366, 1366, 1366, 1366, 1366, 1369, 1373, 1377, 1384,
1898 1389, 1397, 1426, 1451, 1456, 1466, 1476, 1480, 1490, 1497,
1899 1506, 1513, 1518, 1523, 1530, 1531, 1538, 1545, 1553, 1559,
1900 1571, 1599, 1615, 1642, 1670, 1696, 1716, 1742, 1762, 1774,
1901 1781, 1847, 1857, 1867, 1873, 1883, 1889, 1899, 1905, 1911,
1902 1924, 1936, 1957, 1965, 1971, 1982, 1987, 1992, 1997, 2002,
1903 2008, 2014, 2020, 2028, 2039, 2043, 2051, 2051, 2054, 2054,
1904 2057, 2069, 2090, 2095, 2103, 2104, 2108, 2108, 2112, 2112,
1905 2115, 2118, 2142, 2154, 2153, 2165, 2164, 2174, 2173, 2184,
1906 2224, 2227, 2233, 2243, 2247, 2252, 2254, 2259, 2264, 2273,
1907 2283, 2294, 2298, 2307, 2316, 2321, 2469, 2469, 2471, 2480,
1908 2480, 2482, 2487, 2499, 2503, 2508, 2512, 2516, 2521, 2526,
1909 2530, 2534, 2538, 2542, 2546, 2550, 2572, 2594, 2600, 2613,
1910 2625, 2630, 2642, 2648, 2652, 2662, 2666, 2670, 2675, 2682,
1911 2682, 2688, 2697, 2702, 2707, 2711, 2720, 2729, 2742, 2751,
1912 2755, 2763, 2783, 2787, 2792, 2803, 2822, 2831, 2935, 2939,
1913 2946, 2957, 2970, 2979, 2992, 3003, 3013, 3024, 3032, 3042,
1914 3049, 3052, 3053, 3061, 3067, 3076, 3080, 3085, 3101, 3118,
1915 3130, 3142, 3156, 3170, 3182, 3203, 3210, 3216, 3222, 3228,
1916 3243, 3353, 3358, 3362, 3369, 3376, 3386, 3393, 3403, 3411,
1917 3425, 3442, 3456, 3471, 3486
Dan Gohmanf4423b12008-04-19 00:24:39 +00001918};
1919#endif
1920
1921#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1922/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1923 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1924static const char *const yytname[] =
1925{
1926 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1927 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1928 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1929 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1930 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1931 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1932 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1933 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001934 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "COMMON", "OPAQUE",
Dan Gohmanf4423b12008-04-19 00:24:39 +00001935 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1936 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1937 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Dale Johannesendfe8c842008-09-26 19:32:34 +00001938 "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
1939 "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
1940 "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "VICMP",
1941 "VFCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1942 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1943 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1944 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1945 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1946 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1947 "GETRESULT", "EXTRACTVALUE", "INSERTVALUE", "SIGNEXT", "ZEROEXT",
1948 "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST",
Devang Patel652203f2008-09-29 20:49:50 +00001949 "READNONE", "READONLY", "GC", "OPTSIZE", "NOINLINE", "ALWAYSINLINE",
1950 "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'",
1951 "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'",
1952 "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates",
1953 "FPredicates", "IntType", "FPType", "LocalName", "OptLocalName",
1954 "OptAddrSpace", "OptLocalAssign", "LocalNumber", "GlobalName",
1955 "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
Devang Pateld4980812008-09-02 20:52:40 +00001956 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
Devang Patel05988662008-09-25 21:00:45 +00001957 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "Attribute",
Devang Patel652203f2008-09-29 20:49:50 +00001958 "OptAttributes", "RetAttr", "OptRetAttrs", "FuncAttr", "OptFuncAttrs",
1959 "OptGC", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1960 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1961 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1962 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "ThreadLocal",
1963 "AliaseeRef", "Module", "DefinitionList", "Definition", "@1", "@2", "@3",
1964 "@4", "@5", "AsmBlock", "TargetDefinition", "LibrariesDefinition",
1965 "LibList", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1966 "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect",
1967 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1968 "ReturnedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1969 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ParamList",
1970 "IndexList", "ConstantIndexList", "OptTailCall", "InstVal",
Chris Lattner15bd0952008-08-29 17:20:18 +00001971 "OptVolatile", "MemoryInst", 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00001972};
1973#endif
1974
1975# ifdef YYPRINT
1976/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1977 token YYLEX-NUM. */
1978static const yytype_uint16 yytoknum[] =
1979{
1980 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1981 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1982 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1983 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1984 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1985 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1986 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1987 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1988 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1989 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1990 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1991 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1992 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1993 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1994 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Devang Patel652203f2008-09-29 20:49:50 +00001995 405, 406, 407, 408, 409, 410, 411, 412, 413, 40,
1996 41, 61, 44, 42, 92, 91, 120, 93, 60, 62,
1997 123, 125, 99
Dan Gohmanf4423b12008-04-19 00:24:39 +00001998};
1999# endif
2000
2001/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002002static const yytype_uint16 yyr1[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002003{
Devang Patel652203f2008-09-29 20:49:50 +00002004 0, 173, 174, 174, 174, 174, 174, 174, 174, 174,
2005 174, 175, 175, 175, 175, 175, 175, 176, 176, 176,
2006 176, 176, 176, 176, 176, 176, 176, 176, 176, 177,
2007 177, 177, 177, 177, 177, 177, 177, 177, 177, 178,
2008 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
2009 178, 178, 178, 178, 178, 179, 180, 180, 180, 180,
2010 180, 181, 181, 181, 182, 182, 183, 183, 184, 184,
2011 185, 186, 186, 187, 187, 188, 189, 189, 189, 189,
2012 189, 189, 190, 190, 190, 191, 191, 191, 191, 192,
2013 192, 192, 193, 193, 193, 193, 193, 194, 194, 194,
2014 195, 195, 195, 195, 195, 195, 195, 196, 196, 196,
2015 196, 196, 196, 196, 196, 196, 196, 197, 197, 198,
2016 198, 198, 199, 199, 200, 200, 200, 200, 200, 200,
2017 200, 200, 200, 200, 201, 201, 202, 202, 203, 203,
2018 204, 204, 205, 206, 206, 207, 207, 208, 208, 209,
2019 209, 209, 209, 209, 209, 209, 210, 210, 210, 210,
2020 210, 210, 210, 210, 210, 210, 210, 210, 210, 211,
2021 212, 212, 213, 213, 214, 214, 214, 214, 215, 215,
2022 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
2023 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
2024 217, 217, 217, 217, 217, 217, 217, 217, 217, 217,
2025 217, 217, 217, 217, 218, 218, 219, 219, 220, 220,
2026 221, 221, 222, 222, 223, 223, 225, 224, 226, 224,
2027 224, 224, 224, 227, 224, 228, 224, 229, 224, 224,
2028 224, 224, 230, 231, 231, 232, 233, 233, 233, 234,
2029 234, 235, 235, 235, 235, 236, 237, 237, 238, 239,
2030 239, 240, 241, 242, 242, 243, 243, 243, 243, 243,
2031 243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
2032 243, 243, 243, 243, 243, 244, 244, 244, 244, 245,
2033 245, 246, 247, 247, 248, 248, 249, 249, 250, 250,
2034 250, 251, 251, 251, 251, 251, 251, 251, 251, 251,
2035 252, 252, 253, 253, 254, 254, 255, 255, 255, 255,
2036 255, 256, 256, 257, 257, 258, 258, 259, 259, 259,
2037 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
2038 259, 259, 260, 260, 261, 261, 261, 261, 261, 261,
2039 261, 261, 261, 261, 261
Dan Gohmanf4423b12008-04-19 00:24:39 +00002040};
2041
2042/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2043static const yytype_uint8 yyr2[] =
2044{
2045 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2046 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2047 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2048 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2049 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2050 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2051 1, 1, 1, 1, 1, 0, 4, 0, 2, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002052 2, 1, 1, 1, 0, 2, 1, 1, 1, 1,
2053 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,
2054 1, 1, 0, 1, 1, 1, 1, 0, 1, 1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002055 0, 1, 1, 1, 1, 1, 2, 1, 1, 1,
2056 1, 1, 1, 1, 1, 1, 2, 0, 2, 1,
Devang Patel652203f2008-09-29 20:49:50 +00002057 1, 1, 0, 2, 1, 1, 1, 1, 1, 1,
2058 1, 1, 1, 1, 0, 2, 0, 2, 0, 2,
2059 0, 3, 2, 0, 1, 0, 3, 1, 2, 1,
2060 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
2061 2, 5, 5, 5, 5, 3, 2, 5, 4, 2,
2062 1, 1, 1, 3, 1, 3, 1, 0, 1, 3,
2063 4, 3, 3, 4, 4, 3, 6, 5, 2, 2,
2064 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2065 6, 5, 8, 6, 6, 7, 7, 7, 7, 6,
2066 8, 8, 5, 7, 3, 1, 1, 1, 1, 0,
2067 2, 6, 1, 0, 1, 2, 0, 3, 0, 3,
2068 3, 3, 3, 0, 8, 0, 9, 0, 9, 5,
2069 2, 3, 1, 3, 3, 3, 3, 1, 0, 5,
2070 3, 1, 3, 1, 0, 11, 1, 1, 4, 1,
2071 1, 2, 3, 0, 1, 1, 1, 1, 1, 1,
2072 1, 1, 1, 1, 1, 3, 3, 2, 2, 3,
2073 2, 5, 4, 1, 5, 1, 1, 1, 1, 1,
2074 1, 2, 1, 3, 2, 2, 3, 3, 2, 0,
2075 1, 2, 2, 3, 9, 9, 8, 15, 1, 1,
2076 6, 5, 2, 2, 6, 7, 4, 4, 6, 6,
2077 0, 0, 3, 2, 3, 2, 1, 5, 5, 6,
2078 6, 6, 6, 4, 6, 4, 4, 6, 6, 2,
2079 9, 1, 1, 0, 3, 6, 3, 6, 2, 5,
2080 7, 5, 4, 4, 7
Dan Gohmanf4423b12008-04-19 00:24:39 +00002081};
2082
2083/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2084 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2085 means the default is an error. */
2086static const yytype_uint16 yydefact[] =
2087{
Devang Patel652203f2008-09-29 20:49:50 +00002088 74, 61, 71, 62, 72, 63, 228, 226, 0, 0,
2089 0, 0, 0, 0, 85, 73, 0, 74, 224, 89,
2090 92, 0, 0, 240, 0, 0, 68, 0, 75, 76,
Chris Lattner15bd0952008-08-29 17:20:18 +00002091 78, 77, 79, 82, 80, 83, 81, 84, 86, 87,
Devang Patel652203f2008-09-29 20:49:50 +00002092 88, 85, 85, 219, 1, 225, 90, 91, 85, 229,
2093 93, 94, 95, 96, 85, 299, 227, 299, 0, 0,
2094 248, 241, 242, 230, 285, 286, 232, 149, 150, 151,
2095 154, 153, 152, 155, 156, 0, 0, 0, 0, 287,
2096 288, 157, 231, 159, 219, 219, 97, 218, 0, 100,
2097 100, 300, 295, 69, 259, 260, 261, 294, 243, 244,
2098 247, 0, 177, 160, 0, 0, 0, 0, 166, 178,
2099 0, 0, 177, 0, 0, 0, 99, 98, 0, 216,
2100 217, 0, 0, 101, 102, 103, 104, 105, 122, 262,
2101 0, 0, 343, 343, 298, 0, 245, 176, 117, 172,
2102 174, 0, 0, 0, 0, 0, 0, 165, 0, 0,
2103 158, 0, 0, 171, 0, 170, 0, 239, 149, 150,
2104 151, 154, 153, 152, 0, 0, 67, 67, 106, 0,
2105 256, 257, 258, 70, 342, 326, 0, 0, 0, 0,
2106 100, 308, 309, 2, 3, 4, 5, 6, 7, 8,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002107 9, 10, 14, 15, 16, 11, 12, 13, 0, 0,
2108 0, 0, 0, 0, 0, 0, 17, 18, 19, 20,
2109 21, 22, 23, 24, 25, 26, 27, 28, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002111 296, 100, 312, 0, 341, 297, 313, 246, 169, 0,
2112 134, 67, 67, 168, 0, 179, 0, 134, 67, 67,
2113 0, 220, 197, 198, 193, 195, 194, 196, 199, 192,
2114 188, 189, 0, 0, 0, 0, 0, 0, 0, 0,
Dan Gohmane4977cf2008-05-23 01:55:30 +00002115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002116 191, 190, 233, 121, 120, 119, 123, 0, 325, 302,
2117 67, 292, 301, 0, 0, 55, 0, 122, 29, 30,
2118 31, 32, 33, 34, 35, 36, 37, 38, 0, 53,
2119 54, 49, 50, 51, 52, 39, 40, 41, 42, 43,
2120 44, 45, 46, 47, 48, 0, 0, 0, 140, 140,
2121 348, 67, 67, 339, 0, 0, 0, 0, 0, 67,
2122 67, 67, 67, 67, 0, 122, 0, 0, 0, 108,
2123 110, 109, 107, 111, 112, 113, 114, 115, 118, 175,
2124 173, 162, 163, 164, 167, 66, 161, 235, 237, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002125 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002126 0, 181, 215, 0, 0, 0, 185, 0, 182, 0,
2127 0, 0, 145, 0, 265, 266, 267, 268, 269, 274,
2128 270, 271, 272, 273, 263, 0, 0, 0, 0, 283,
2129 290, 289, 291, 0, 0, 303, 0, 0, 67, 67,
2130 67, 67, 0, 344, 0, 346, 321, 0, 0, 0,
2131 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2132 0, 67, 0, 116, 128, 127, 124, 126, 125, 129,
2133 130, 133, 131, 132, 135, 145, 145, 0, 0, 0,
2134 0, 0, 321, 0, 0, 0, 0, 0, 0, 0,
2135 180, 166, 178, 0, 183, 184, 0, 0, 0, 0,
2136 234, 254, 264, 0, 277, 0, 0, 0, 280, 0,
2137 278, 293, 0, 0, 0, 0, 0, 0, 0, 0,
2138 0, 0, 352, 0, 0, 0, 335, 336, 0, 0,
2139 0, 0, 353, 0, 0, 0, 333, 0, 140, 0,
2140 236, 238, 67, 0, 0, 0, 0, 0, 0, 0,
2141 0, 0, 0, 0, 214, 187, 0, 0, 0, 0,
2142 0, 0, 147, 145, 253, 117, 251, 0, 0, 276,
2143 166, 0, 275, 279, 0, 0, 0, 0, 0, 0,
2144 0, 140, 141, 140, 0, 0, 0, 0, 0, 0,
2145 351, 323, 0, 67, 327, 328, 0, 0, 349, 67,
2146 221, 0, 0, 0, 0, 201, 0, 0, 0, 0,
2147 212, 0, 186, 0, 0, 67, 142, 148, 146, 65,
2148 0, 134, 0, 282, 0, 0, 0, 320, 329, 330,
2149 331, 332, 345, 347, 322, 0, 0, 334, 337, 338,
2150 324, 0, 320, 140, 0, 0, 0, 0, 0, 209,
2151 0, 0, 0, 203, 204, 200, 64, 250, 252, 117,
2152 143, 284, 281, 0, 0, 117, 117, 0, 314, 0,
2153 354, 0, 350, 205, 206, 207, 208, 0, 0, 0,
2154 213, 65, 144, 138, 0, 306, 0, 0, 0, 0,
2155 134, 0, 315, 134, 202, 210, 211, 249, 0, 136,
2156 304, 0, 305, 0, 108, 110, 117, 117, 0, 117,
2157 117, 340, 139, 0, 255, 0, 0, 317, 316, 0,
2158 0, 0, 137, 0, 0, 0, 117, 117, 311, 0,
2159 0, 319, 318, 310, 0, 0, 307
Dan Gohmanf4423b12008-04-19 00:24:39 +00002160};
2161
2162/* YYDEFGOTO[NTERM-NUM]. */
2163static const yytype_int16 yydefgoto[] =
2164{
Devang Patel652203f2008-09-29 20:49:50 +00002165 -1, 277, 278, 279, 308, 325, 164, 165, 79, 637,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002166 113, 12, 133, 80, 14, 15, 41, 42, 43, 48,
Devang Patel652203f2008-09-29 20:49:50 +00002167 54, 118, 128, 358, 238, 286, 169, 454, 361, 694,
2168 679, 423, 542, 663, 480, 543, 81, 166, 139, 156,
2169 140, 141, 110, 382, 409, 383, 121, 88, 157, 16,
2170 17, 18, 20, 19, 392, 455, 456, 63, 23, 61,
2171 101, 546, 547, 129, 172, 55, 96, 56, 49, 483,
2172 410, 83, 412, 291, 292, 57, 92, 93, 230, 667,
2173 134, 333, 647, 502, 512, 231, 232, 233, 234
Dan Gohmanf4423b12008-04-19 00:24:39 +00002174};
2175
2176/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2177 STATE-NUM. */
Devang Patel652203f2008-09-29 20:49:50 +00002178#define YYPACT_NINF -620
Dan Gohmanf4423b12008-04-19 00:24:39 +00002179static const yytype_int16 yypact[] =
2180{
Devang Patel652203f2008-09-29 20:49:50 +00002181 484, -620, -620, -620, -620, -620, -620, -620, -14, -116,
2182 -6, -83, 104, -31, 24, -620, 161, 528, -620, 238,
2183 204, 43, 49, -620, 5, 196, -620, 1912, -620, -620,
2184 -620, -620, -620, -620, -620, -620, -620, -620, -620, -620,
2185 -620, 173, 173, 227, -620, -620, -620, -620, 173, -620,
2186 -620, -620, -620, -620, 173, 202, -620, -9, 234, 243,
2187 246, -620, -620, -620, -620, -620, 67, -620, -620, -620,
2188 -620, -620, -620, -620, -620, 273, 285, 3, 624, -620,
2189 -620, -620, 4, -620, 201, 201, 253, -620, 81, 240,
2190 240, -620, -620, 39, -620, -620, -620, -620, -620, -620,
2191 -620, -59, 1564, -620, 128, 132, 643, 67, -620, 4,
2192 -114, 165, 1564, 145, 81, 81, -620, -620, 1605, -620,
2193 -620, 2014, 324, -620, -620, -620, -620, -620, -620, -620,
2194 -13, 188, 2299, 2299, -620, 328, -620, -620, 4, -620,
2195 189, 194, 2076, 2076, 186, -111, 2076, -620, 352, 205,
2196 -620, 2014, 2076, 67, 208, 4, 247, -620, 216, 351,
2197 355, 359, 365, 368, 269, 372, 1625, 306, -620, 1517,
2198 -620, -620, -620, -620, -620, -620, 325, 2094, 38, 373,
2199 240, -620, -620, -620, -620, -620, -620, -620, -620, -620,
2200 -620, -620, -620, -620, -620, -620, -620, -620, 298, 336,
2201 298, 336, 2076, 2076, 2076, 2076, -620, -620, -620, -620,
2202 -620, -620, -620, -620, -620, -620, -620, -620, 2076, 2076,
2203 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076,
2204 -620, 240, -620, 66, -620, -620, -620, -620, 231, 1791,
2205 -620, -17, -21, -620, 214, 4, 225, -620, 306, -5,
2206 1605, -620, -620, -620, -620, -620, -620, -620, -620, -620,
2207 -620, -620, 298, 336, 298, 336, 229, 230, 249, 250,
2208 251, 252, 256, 1809, 2117, 690, 364, 257, 259, 261,
2209 -620, -620, -620, -620, -620, -620, -620, 114, -620, 67,
2210 1019, -620, 262, 1189, 1189, -620, 1189, -620, -620, -620,
2211 -620, -620, -620, -620, -620, -620, -620, -620, 2076, -620,
2212 -620, -620, -620, -620, -620, -620, -620, -620, -620, -620,
2213 -620, -620, -620, -620, -620, 2076, 2076, 2076, -23, 28,
2214 -620, 1019, -18, 265, 266, 268, 272, 288, 289, 1019,
2215 1019, 1019, 1019, 1019, 383, -620, 2076, 2076, 398, -620,
2216 -620, -620, -620, -620, -620, -620, -620, -620, -620, -620,
2217 -620, 137, -620, -620, -620, -620, 137, -620, 145, 385,
2218 293, 294, 295, 297, 2014, 2014, 2014, 2014, 2014, 2014,
2219 2014, -620, -620, -56, 1069, -74, -620, -80, -620, 2014,
2220 2014, 2014, 296, 300, -620, -620, -620, -620, -620, -620,
2221 -620, -620, -620, -620, 396, 1832, 2135, 1239, 403, -620,
2222 -620, -620, -620, 2076, 299, -620, 301, 1517, 1019, 1019,
2223 1019, 1019, 8, -620, 33, -620, -620, 1189, 303, 2076,
2224 2076, 2076, 2076, 2076, 302, 304, 307, 308, 309, 2076,
2225 1517, 1019, 312, -620, -620, -620, -620, -620, -620, -620,
2226 -620, -620, -620, -620, -620, 296, 296, 2076, 2014, 2014,
2227 2014, 2014, -620, 317, 318, 319, 320, 304, 323, 2014,
2228 -620, 326, 1471, -77, -620, -620, 327, 330, 424, 2,
2229 -620, 1850, -620, 443, -620, -52, 1280, -73, -620, -72,
2230 -620, -620, 469, 471, 1189, 332, 334, 337, 338, 1189,
2231 494, 1189, 339, 343, 1189, 347, 4, -620, 348, 349,
2232 508, 519, 362, 2076, 1189, 1189, 4, 1189, 363, 2076,
2233 -620, -620, 26, 367, 375, 377, 387, 149, 2014, 2014,
2234 2014, 2014, 157, 2014, -620, -620, 357, 2014, 2014, 2076,
2235 505, 526, -620, 296, -620, 4, 391, 394, 393, -620,
2236 366, -62, -620, -620, 1189, 1189, 386, 1189, 1189, 1189,
2237 1189, 363, -620, 363, 2076, 1189, 395, 2076, 2076, 2076,
2238 -620, -620, 552, 1019, -620, -620, 405, 511, -620, 1019,
2239 -620, 2014, 2014, 2014, 2014, -620, 400, 406, 407, 408,
2240 -620, 304, -620, 411, 412, 57, -620, -620, -620, 11,
2241 1891, -620, 545, -620, 399, 413, 414, 2179, -620, -620,
2242 -620, -620, -620, -620, -620, 409, 1189, -620, -620, -620,
2243 -620, 304, 2179, 363, 417, 418, 423, 425, 2014, -620,
2244 2014, 2014, 180, -620, -620, -620, -620, -620, -620, 4,
2245 172, -620, -620, 556, -3, 46, 4, 181, -620, 422,
2246 362, 184, -620, -620, -620, -620, -620, 430, 431, 432,
2247 -620, 11, -620, 539, 1189, -620, 1337, -1, 865, 865,
2248 -620, 2197, -620, -620, -620, -620, -620, -620, 590, 445,
2249 -620, 433, -620, 1337, 446, 453, -620, -620, 86, 46,
2250 4, 137, -620, 582, -620, 596, 452, 231, 231, 598,
2251 865, 865, -620, 1189, 599, 1189, -620, -620, -620, 1189,
2252 544, 231, 231, -620, 603, 1189, -620
Dan Gohmanf4423b12008-04-19 00:24:39 +00002253};
2254
2255/* YYPGOTO[NTERM-NUM]. */
2256static const yytype_int16 yypgoto[] =
2257{
Devang Patel652203f2008-09-29 20:49:50 +00002258 -620, 42, 112, 200, -160, -158, -177, -620, 0, -39,
2259 -151, 531, -620, 9, -620, -620, -620, -620, 77, -620,
2260 -620, -620, -152, -620, -518, -620, -268, -620, -244, -620,
2261 -620, -311, -15, -620, -414, -620, -620, -26, 389, -164,
2262 -620, 514, 523, 142, -162, -261, 220, 263, 380, -620,
2263 -620, 625, -620, -620, -620, -620, -620, -620, -620, -620,
2264 -620, -620, -620, 559, -620, -620, -620, -620, -620, -620,
2265 -619, -82, 267, -198, -620, -620, 595, -620, 535, -620,
2266 -620, -620, 47, 215, -456, -620, 543, -620, -620
Dan Gohmanf4423b12008-04-19 00:24:39 +00002267};
2268
2269/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2270 positive, shift that token. If negative, reduce the rule which
2271 number is the opposite. If zero, do what YYDEFACT says.
2272 If YYTABLE_NINF, syntax error. */
Devang Patel652203f2008-09-29 20:49:50 +00002273#define YYTABLE_NINF -224
Dan Gohmanf4423b12008-04-19 00:24:39 +00002274static const yytype_int16 yytable[] =
2275{
Devang Patel652203f2008-09-29 20:49:50 +00002276 11, 82, 296, 366, 280, 287, 330, 105, 295, 13,
2277 295, 532, 91, 385, 387, 170, 282, 11, 425, 499,
2278 94, 334, 335, 336, 337, 338, 13, 599, 297, 417,
2279 1, 344, 111, 3, 111, 5, 540, 111, 111, 21,
2280 326, 520, 521, 327, 501, 24, 131, 681, 146, 293,
2281 111, 146, 109, 25, 22, 294, 541, 147, 1, 111,
2282 244, 3, 500, 5, 696, 348, 29, 30, 31, 32,
2283 33, 34, 35, 36, 251, 37, 138, 440, 26, 345,
2284 109, 111, 469, 111, 281, 469, 138, 500, 469, 469,
2285 469, 475, 155, 11, 536, 474, 552, 367, 368, 553,
2286 469, -155, 370, 135, 372, 371, 469, 373, 136, 604,
2287 469, 470, 111, 119, 120, 549, 241, 242, 84, 85,
2288 245, 661, 27, 473, 699, 89, 249, 668, 669, 598,
2289 28, 90, 349, 350, 2, 632, 112, 4, 112, 422,
2290 -67, 112, 112, 155, 485, 487, 489, 427, 363, 442,
2291 362, 290, 351, 352, 112, 353, 354, 171, 355, 356,
2292 357, 44, 95, 112, 665, 650, 682, -67, 697, 698,
2293 60, 700, 701, 106, 227, 227, 328, 329, 290, 331,
2294 38, 39, 40, 346, 347, 112, 580, 112, 711, 712,
2295 424, -67, 332, 290, 290, 290, 290, 290, 339, 340,
2296 341, 342, 343, 290, 58, -155, 540, 578, 411, -155,
2297 59, 411, 411, 138, 411, 491, 112, 635, 62, -55,
2298 -55, -55, -55, 91, 155, 551, 102, 444, 445, 446,
2299 447, 505, 448, 507, 508, 509, 449, 450, 87, 451,
2300 452, 453, 252, 253, 228, 228, 50, 51, 52, 411,
2301 612, 53, 613, 494, 64, 65, 98, 411, 411, 411,
2302 411, 411, 86, 167, 87, 99, 1, 2, 100, 3,
2303 4, 5, 254, 255, 256, 257, 517, 103, 444, 445,
2304 446, 447, 418, 448, 46, 348, 47, 449, 450, 104,
2305 451, 452, 453, 248, 142, 116, 393, 117, 143, 419,
2306 420, 421, 122, 123, 124, 125, 126, 127, 150, 585,
2307 280, 564, 652, 444, 445, 446, 447, 590, 448, 572,
2308 441, 290, 449, 450, 148, 451, 452, 453, 168, 38,
2309 39, 40, 229, 229, 151, 152, 411, 411, 411, 411,
2310 660, 670, 572, 671, 673, 411, 671, 114, 115, 173,
2311 237, 239, 349, 350, 240, 243, 246, 640, 472, 411,
2312 -56, 111, 309, 310, -57, 247, 614, 250, -60, 617,
2313 618, 619, 351, 352, -59, 353, 354, -58, 355, 356,
2314 357, 258, 288, 364, 295, 365, 388, 290, 374, 375,
2315 281, 155, 298, 299, 300, 301, 302, 303, 304, 305,
2316 306, 307, 443, 290, 506, 290, 290, 290, 376, 377,
2317 378, 379, 411, 516, 155, 380, 389, 411, 390, 411,
2318 391, 439, 411, 457, 413, 490, 688, 428, 429, 691,
2319 430, 522, 411, 411, 431, 411, 311, 312, 313, 314,
2320 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2321 432, 433, 458, 459, 460, 545, 461, 482, 479, 481,
2322 472, 492, 539, 493, 510, 548, 511, 666, 504, 513,
2323 514, 515, 411, 411, 519, 411, 411, 411, 411, 528,
2324 529, 530, 531, 411, -223, 533, 554, 573, 555, 537,
2325 683, 411, 538, 579, 557, 535, 558, 411, 562, 559,
2326 560, 564, -69, 1, 2, 565, 3, 4, 5, 567,
2327 568, 569, 570, 595, 6, 7, 462, 463, 464, 465,
2328 466, 467, 468, 571, 572, 577, 592, 596, -222, 581,
2329 597, 476, 477, 478, 411, 603, 8, 582, 290, 583,
2330 9, 290, 290, 290, 10, 607, -69, 1, 2, 584,
2331 3, 4, 5, 600, 601, 602, 620, 616, 6, 7,
2332 414, 415, 628, 416, 622, 500, 629, 641, 642, 630,
2333 631, 633, 634, 664, 639, 643, 648, 653, 654, 644,
2334 8, 646, 411, 655, 9, 656, 411, 411, 10, 672,
2335 674, 675, 676, 678, 692, 695, 646, 693, 426, 636,
2336 523, 524, 525, 526, 702, -18, 434, 435, 436, 437,
2337 438, 534, -19, 703, 704, 705, 709, 714, 411, 411,
2338 715, 411, 677, 411, 132, 662, 149, 411, 360, 145,
2339 369, 64, 65, 411, 107, 67, 68, 69, 70, 71,
2340 72, 73, 45, 1, 2, 690, 3, 4, 5, 130,
2341 64, 65, 97, 107, 67, 68, 69, 70, 71, 72,
2342 73, 636, 1, 2, 0, 3, 4, 5, 235, 651,
2343 586, 587, 588, 589, 74, 591, 236, 527, 0, 593,
2344 594, 0, 0, 0, 0, 495, 496, 497, 498, 0,
2345 0, 0, 0, 74, 503, 0, 0, 64, 65, 0,
2346 107, 158, 159, 160, 161, 162, 163, 73, 518, 1,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002347 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002348 0, 0, 0, 624, 625, 626, 627, 0, 0, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002349 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002350 74, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002351 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002352 0, 556, 0, 0, 0, 0, 561, 0, 563, 0,
2353 657, 566, 658, 659, 0, 0, 0, 0, 0, 0,
2354 0, 574, 575, 0, 576, 0, 0, 0, 75, 76,
2355 0, 0, 77, 0, 78, 108, 0, 0, 0, 0,
2356 0, 0, 0, 0, 0, 0, 0, 75, 76, 0,
2357 0, 77, 0, 78, 144, 0, 0, 0, 0, 0,
2358 0, 605, 606, 0, 608, 609, 610, 611, 0, 0,
2359 0, 0, 615, 0, 0, 0, 0, 0, 0, 0,
2360 621, 0, 0, 0, 0, 0, 623, 0, 0, 0,
2361 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2362 78, 386, 0, 0, 0, 0, 0, 0, 394, 395,
2363 396, 397, 64, 65, 398, 0, 0, 0, 0, 0,
2364 0, 0, 0, 649, 1, 2, 0, 3, 4, 5,
2365 399, 400, 401, 0, 0, 0, 0, 0, 0, 0,
2366 0, 0, 0, 0, 0, 402, 403, 0, 0, 0,
2367 0, 0, 0, 0, 0, 0, 0, 0, 0, 348,
2368 0, 0, 0, 0, 404, 0, 0, 0, 0, 0,
2369 0, 680, 0, 0, 0, 686, 687, 0, 0, 0,
2370 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
2371 193, 194, 195, 196, 197, 262, 263, 264, 265, 0,
2372 0, 0, 0, 0, 0, 0, 0, 706, 707, 0,
2373 708, 0, 710, 0, 0, 0, 713, 0, 0, 0,
2374 0, 0, 716, 0, 266, 206, 684, 685, 209, 210,
2375 211, 212, 213, 214, 215, 216, 217, 0, 267, 0,
2376 268, 269, 270, 0, 271, 272, 351, 352, 0, 353,
2377 354, 0, 355, 356, 357, 0, 0, 0, 0, 0,
2378 0, 0, 394, 395, 396, 397, 64, 65, 398, 0,
2379 405, 0, 0, 406, 0, 407, 0, 408, 1, 2,
2380 0, 3, 4, 5, 399, 400, 401, 0, 0, 0,
2381 0, 0, 0, 0, 0, 0, 0, 0, 0, 402,
2382 403, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2383 0, 0, 0, 0, 111, 0, 64, 65, 404, 107,
2384 158, 159, 160, 161, 162, 163, 73, 0, 1, 2,
2385 0, 3, 4, 5, 183, 184, 185, 186, 187, 188,
2386 189, 190, 191, 192, 193, 194, 195, 196, 197, 262,
2387 263, 264, 265, 0, 0, 0, 0, 0, 0, 74,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002388 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002389 0, 0, 0, 0, 0, 0, 0, 0, 266, 206,
2390 207, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2391 217, 0, 267, 0, 268, 269, 270, 0, 271, 272,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002392 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002393 0, 0, 0, 0, 0, 0, 0, 0, 112, 0,
2394 0, 0, 0, 0, 405, 0, 0, 406, 0, 407,
2395 0, 408, 394, 395, 396, 397, 64, 65, 398, 0,
2396 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
2397 0, 3, 4, 5, 399, 400, 401, 0, 0, 0,
2398 0, 0, 0, 0, 0, 0, 0, 0, 0, 402,
2399 403, 0, 0, 75, 76, 0, 0, 77, 0, 78,
2400 471, 0, 0, 0, 0, 0, 64, 65, 404, 107,
2401 158, 159, 160, 161, 162, 163, 73, 0, 1, 2,
2402 0, 3, 4, 5, 183, 184, 185, 186, 187, 188,
2403 189, 190, 191, 192, 193, 194, 195, 196, 197, 262,
2404 263, 264, 265, 0, 0, 0, 0, 64, 65, 74,
2405 107, 158, 159, 160, 161, 162, 163, 73, 0, 1,
2406 2, 0, 3, 4, 5, 0, 0, 0, 266, 206,
2407 207, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2408 217, 0, 267, 0, 268, 269, 270, 0, 271, 272,
2409 74, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2410 394, 395, 396, 397, 0, 0, 398, 0, 0, 0,
2411 0, 0, 0, 0, 405, 0, 0, 406, 0, 407,
2412 0, 408, 399, 400, 401, 0, 0, 0, 0, 0,
2413 0, 0, 0, 0, 0, 0, 0, 402, 403, 0,
2414 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2415 0, 0, 0, 0, 0, 0, 404, 0, 0, 0,
2416 0, 0, 0, 75, 76, 0, 0, 77, 0, 78,
2417 488, 0, 183, 184, 185, 186, 187, 188, 189, 190,
2418 191, 192, 193, 194, 195, 196, 197, 262, 263, 264,
2419 265, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2420 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2421 78, 550, 0, 0, 0, 0, 266, 206, 207, 208,
2422 209, 210, 211, 212, 213, 214, 215, 216, 217, 0,
2423 267, 0, 268, 269, 270, 0, 271, 272, 64, 65,
2424 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2425 1, 2, 0, 3, 4, 5, 259, 0, 0, 0,
2426 0, 0, 405, 0, 0, 406, 0, 407, 0, 408,
2427 0, 260, 261, 0, 0, 0, 0, 0, 0, 0,
2428 0, 0, 0, 0, 64, 65, 111, 153, 67, 68,
2429 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
2430 4, 5, 0, 0, 0, 0, 183, 184, 185, 186,
2431 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
2432 197, 262, 263, 264, 265, 0, 0, 74, 0, 0,
2433 0, 64, 65, 0, 107, 67, 68, 69, 70, 71,
2434 72, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2435 266, 206, 207, 208, 209, 210, 211, 212, 213, 214,
2436 215, 216, 217, 137, 267, 0, 268, 269, 270, 0,
2437 271, 272, 64, 65, 74, 153, 67, 68, 69, 70,
2438 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2439 112, 0, 64, 65, -67, 0, 273, 0, 0, 274,
2440 0, 275, 0, 276, 1, 2, 0, 3, 4, 5,
2441 259, 0, 0, 0, 0, 74, 0, 0, 283, 284,
2442 0, 285, 0, 0, 0, 260, 261, 0, 0, 0,
2443 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2444 111, 75, 76, 0, 0, 77, 0, 78, 0, 0,
2445 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2446 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
2447 193, 194, 195, 196, 197, 262, 263, 264, 265, 0,
2448 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2449 154, 0, 77, 0, 78, 0, 0, 0, 0, 0,
2450 0, 0, 0, 0, 266, 206, 207, 208, 209, 210,
2451 211, 212, 213, 214, 215, 216, 217, 0, 267, 0,
2452 268, 269, 270, 0, 271, 272, 0, 0, 0, 75,
2453 76, 0, 0, 77, 0, 78, 0, 0, 0, 0,
2454 0, 0, 0, 0, 112, 0, 0, 0, 0, 0,
2455 273, 0, 0, 274, 0, 275, 0, 276, 64, 65,
2456 0, 107, 67, 68, 69, 70, 71, 72, 73, 0,
2457 1, 2, 0, 3, 4, 5, 64, 65, 0, 107,
2458 158, 159, 160, 161, 162, 163, 73, 0, 1, 2,
2459 359, 3, 4, 5, 0, 0, 0, 0, 0, 64,
2460 65, 74, 107, 158, 159, 160, 161, 162, 163, 73,
2461 0, 1, 2, 0, 3, 4, 5, 64, 65, 74,
2462 107, 67, 68, 69, 70, 71, 72, 73, 0, 1,
2463 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2464 0, 0, 74, 0, 0, 0, 0, 0, 0, 544,
2465 0, 0, 0, 0, 0, 0, 0, 0, 64, 65,
2466 74, 107, 67, 68, 69, 70, 71, 72, 73, 0,
2467 1, 2, 0, 3, 4, 5, 0, 0, 0, 64,
2468 65, 0, 66, 67, 68, 69, 70, 71, 72, 73,
2469 638, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2470 0, 74, 0, 0, 0, 0, 0, 0, 0, 0,
2471 0, 0, 0, 0, 0, 75, 76, 0, 0, 77,
2472 0, 78, 74, 0, 0, 0, 0, 0, 0, 0,
2473 0, 0, 0, 75, 76, 0, 381, 77, 0, 78,
2474 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2475 0, 0, 0, 0, 0, 0, 75, 76, 0, 484,
2476 77, 0, 78, 0, 0, 0, 0, 0, 0, 0,
2477 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2478 78, 64, 65, 0, 107, 158, 159, 160, 161, 162,
2479 163, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2480 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2481 0, 0, 0, 0, 0, 75, 76, 0, 0, 77,
2482 0, 78, 0, 0, 74, 0, 0, 0, 0, 0,
2483 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2484 77, 0, 78, 64, 65, 0, 107, 67, 68, 69,
2485 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
2486 5, 64, 65, 0, 289, 67, 68, 69, 70, 71,
2487 72, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2488 0, 0, 0, 0, 64, 65, 74, 107, 158, 159,
2489 160, 161, 162, 163, 73, 0, 1, 2, 0, 3,
2490 4, 5, 64, 65, 74, 107, 158, 159, 160, 161,
2491 162, 163, 73, 0, 1, 2, 0, 3, 4, 5,
2492 0, 0, 0, 0, 0, 0, 0, 74, 0, 0,
2493 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2494 0, 0, 77, 0, 78, 74, 64, 65, 0, 107,
2495 67, 68, 69, 70, 71, 72, 645, 0, 1, 2,
2496 0, 3, 4, 5, 64, 65, 0, 107, 67, 68,
2497 69, 70, 71, 72, 689, 0, 1, 2, 0, 3,
2498 4, 5, 0, 0, 0, 0, 0, 0, 0, 74,
2499 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2500 75, 76, 0, 0, 77, 0, 78, 74, 0, 0,
2501 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2502 0, 0, 77, 0, 78, 0, 0, 0, 0, 0,
2503 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2504 0, 75, 76, 0, 0, 77, 0, 384, 0, 0,
2505 0, 0, 0, 0, 0, 0, 0, 0, 0, 75,
2506 76, 0, 0, 77, 0, 486, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002507 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2508 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002509 0, 0, 0, 0, 0, 174, 0, 0, 0, 0,
2510 0, 0, 0, 75, 76, 0, 0, 77, 0, 78,
2511 0, 0, 0, 0, 0, 0, 175, 176, 0, 0,
2512 0, 75, 76, 0, 0, 77, 0, 78, 177, 178,
2513 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
2514 189, 190, 191, 192, 193, 194, 195, 196, 197, 198,
2515 199, 200, 201, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002516 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002517 0, 0, 0, 202, 203, 204, 0, 0, 205, 206,
2518 207, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2519 217, 218, 219, 220, 221, 222, 223, 224, 225, 226
Dan Gohmanf4423b12008-04-19 00:24:39 +00002520};
2521
2522static const yytype_int16 yycheck[] =
2523{
Devang Patel652203f2008-09-29 20:49:50 +00002524 0, 27, 179, 247, 166, 169, 204, 4, 11, 0,
2525 11, 467, 21, 274, 275, 28, 167, 17, 329, 11,
2526 29, 219, 220, 221, 222, 223, 17, 545, 180, 297,
2527 19, 229, 55, 22, 55, 24, 34, 55, 55, 53,
2528 200, 455, 456, 201, 11, 161, 7, 666, 162, 11,
2529 55, 162, 78, 59, 68, 17, 54, 171, 19, 55,
2530 171, 22, 54, 24, 683, 54, 42, 43, 44, 45,
2531 46, 47, 48, 49, 156, 51, 102, 345, 161, 231,
2532 106, 55, 162, 55, 166, 162, 112, 54, 162, 162,
2533 162, 171, 118, 93, 171, 169, 169, 248, 249, 171,
2534 162, 55, 262, 162, 264, 263, 162, 265, 167, 171,
2535 162, 167, 55, 32, 33, 167, 142, 143, 41, 42,
2536 146, 639, 18, 384, 38, 48, 152, 645, 646, 543,
2537 161, 54, 121, 122, 20, 591, 159, 23, 159, 162,
2538 163, 159, 159, 169, 405, 406, 407, 165, 169, 347,
2539 167, 177, 141, 142, 159, 144, 145, 170, 147, 148,
2540 149, 0, 171, 159, 167, 621, 167, 163, 686, 687,
2541 165, 689, 690, 170, 132, 133, 202, 203, 204, 205,
2542 156, 157, 158, 117, 118, 159, 160, 159, 706, 707,
2543 162, 163, 218, 219, 220, 221, 222, 223, 224, 225,
2544 226, 227, 228, 229, 161, 159, 34, 518, 290, 163,
2545 161, 293, 294, 239, 296, 413, 159, 160, 22, 3,
2546 4, 5, 6, 21, 250, 486, 159, 141, 142, 143,
2547 144, 429, 146, 431, 432, 433, 150, 151, 37, 153,
2548 154, 155, 26, 27, 132, 133, 42, 43, 44, 331,
2549 561, 47, 563, 417, 7, 8, 22, 339, 340, 341,
2550 342, 343, 35, 121, 37, 22, 19, 20, 22, 22,
2551 23, 24, 3, 4, 5, 6, 440, 4, 141, 142,
2552 143, 144, 308, 146, 46, 54, 48, 150, 151, 4,
2553 153, 154, 155, 151, 166, 42, 287, 44, 166, 325,
2554 326, 327, 62, 63, 64, 65, 66, 67, 163, 160,
2555 472, 162, 623, 141, 142, 143, 144, 160, 146, 162,
2556 346, 347, 150, 151, 159, 153, 154, 155, 4, 156,
2557 157, 158, 132, 133, 114, 115, 418, 419, 420, 421,
2558 160, 160, 162, 162, 160, 427, 162, 84, 85, 161,
2559 22, 162, 121, 122, 160, 169, 4, 601, 384, 441,
2560 9, 55, 26, 27, 9, 160, 564, 159, 9, 567,
2561 568, 569, 141, 142, 9, 144, 145, 9, 147, 148,
2562 149, 9, 57, 169, 11, 160, 22, 413, 159, 159,
2563 472, 417, 94, 95, 96, 97, 98, 99, 100, 101,
2564 102, 103, 4, 429, 430, 431, 432, 433, 159, 159,
2565 159, 159, 494, 439, 440, 159, 159, 499, 159, 501,
2566 159, 38, 504, 38, 162, 22, 670, 162, 162, 673,
2567 162, 457, 514, 515, 162, 517, 100, 101, 102, 103,
2568 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
2569 162, 162, 159, 159, 159, 481, 159, 61, 162, 159,
2570 486, 162, 38, 162, 162, 22, 162, 644, 165, 162,
2571 162, 162, 554, 555, 162, 557, 558, 559, 560, 162,
2572 162, 162, 162, 565, 0, 162, 17, 513, 17, 162,
2573 667, 573, 162, 519, 162, 169, 162, 579, 4, 162,
2574 162, 162, 18, 19, 20, 162, 22, 23, 24, 162,
2575 162, 162, 4, 539, 30, 31, 374, 375, 376, 377,
2576 378, 379, 380, 4, 162, 162, 169, 22, 0, 162,
2577 4, 389, 390, 391, 616, 169, 52, 162, 564, 162,
2578 56, 567, 568, 569, 60, 159, 18, 19, 20, 162,
2579 22, 23, 24, 162, 160, 162, 4, 162, 30, 31,
2580 293, 294, 162, 296, 159, 54, 160, 22, 169, 162,
2581 162, 160, 160, 17, 600, 162, 167, 160, 160, 165,
2582 52, 607, 664, 160, 56, 160, 668, 669, 60, 167,
2583 160, 160, 160, 54, 4, 162, 622, 152, 331, 599,
2584 458, 459, 460, 461, 22, 159, 339, 340, 341, 342,
2585 343, 469, 159, 17, 162, 17, 17, 73, 700, 701,
2586 17, 703, 661, 705, 93, 640, 112, 709, 239, 106,
2587 250, 7, 8, 715, 10, 11, 12, 13, 14, 15,
2588 16, 17, 17, 19, 20, 671, 22, 23, 24, 90,
2589 7, 8, 57, 10, 11, 12, 13, 14, 15, 16,
2590 17, 661, 19, 20, -1, 22, 23, 24, 133, 622,
2591 528, 529, 530, 531, 50, 533, 133, 462, -1, 537,
2592 538, -1, -1, -1, -1, 418, 419, 420, 421, -1,
2593 -1, -1, -1, 50, 427, -1, -1, 7, 8, -1,
2594 10, 11, 12, 13, 14, 15, 16, 17, 441, 19,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002595 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002596 -1, -1, -1, 581, 582, 583, 584, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002597 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002598 50, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002599 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002600 -1, 494, -1, -1, -1, -1, 499, -1, 501, -1,
2601 628, 504, 630, 631, -1, -1, -1, -1, -1, -1,
2602 -1, 514, 515, -1, 517, -1, -1, -1, 164, 165,
2603 -1, -1, 168, -1, 170, 171, -1, -1, -1, -1,
2604 -1, -1, -1, -1, -1, -1, -1, 164, 165, -1,
2605 -1, 168, -1, 170, 171, -1, -1, -1, -1, -1,
2606 -1, 554, 555, -1, 557, 558, 559, 560, -1, -1,
2607 -1, -1, 565, -1, -1, -1, -1, -1, -1, -1,
2608 573, -1, -1, -1, -1, -1, 579, -1, -1, -1,
2609 -1, -1, -1, -1, 164, 165, -1, -1, 168, -1,
2610 170, 171, -1, -1, -1, -1, -1, -1, 3, 4,
2611 5, 6, 7, 8, 9, -1, -1, -1, -1, -1,
2612 -1, -1, -1, 616, 19, 20, -1, 22, 23, 24,
2613 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
2614 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2615 -1, -1, -1, -1, -1, -1, -1, -1, -1, 54,
2616 -1, -1, -1, -1, 59, -1, -1, -1, -1, -1,
2617 -1, 664, -1, -1, -1, 668, 669, -1, -1, -1,
2618 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2619 85, 86, 87, 88, 89, 90, 91, 92, 93, -1,
2620 -1, -1, -1, -1, -1, -1, -1, 700, 701, -1,
2621 703, -1, 705, -1, -1, -1, 709, -1, -1, -1,
2622 -1, -1, 715, -1, 119, 120, 121, 122, 123, 124,
2623 125, 126, 127, 128, 129, 130, 131, -1, 133, -1,
2624 135, 136, 137, -1, 139, 140, 141, 142, -1, 144,
2625 145, -1, 147, 148, 149, -1, -1, -1, -1, -1,
2626 -1, -1, 3, 4, 5, 6, 7, 8, 9, -1,
2627 165, -1, -1, 168, -1, 170, -1, 172, 19, 20,
2628 -1, 22, 23, 24, 25, 26, 27, -1, -1, -1,
2629 -1, -1, -1, -1, -1, -1, -1, -1, -1, 40,
2630 41, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2631 -1, -1, -1, -1, 55, -1, 7, 8, 59, 10,
Devang Pateld4980812008-09-02 20:52:40 +00002632 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Devang Patel652203f2008-09-29 20:49:50 +00002633 -1, 22, 23, 24, 75, 76, 77, 78, 79, 80,
2634 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2635 91, 92, 93, -1, -1, -1, -1, -1, -1, 50,
Devang Pateld4980812008-09-02 20:52:40 +00002636 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002637 -1, -1, -1, -1, -1, -1, -1, -1, 119, 120,
2638 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
2639 131, -1, 133, -1, 135, 136, 137, -1, 139, 140,
2640 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2641 -1, -1, -1, -1, -1, -1, -1, -1, 159, -1,
2642 -1, -1, -1, -1, 165, -1, -1, 168, -1, 170,
2643 -1, 172, 3, 4, 5, 6, 7, 8, 9, -1,
2644 -1, -1, -1, -1, -1, -1, -1, -1, 19, 20,
2645 -1, 22, 23, 24, 25, 26, 27, -1, -1, -1,
2646 -1, -1, -1, -1, -1, -1, -1, -1, -1, 40,
2647 41, -1, -1, 164, 165, -1, -1, 168, -1, 170,
2648 171, -1, -1, -1, -1, -1, 7, 8, 59, 10,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002649 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Devang Patel652203f2008-09-29 20:49:50 +00002650 -1, 22, 23, 24, 75, 76, 77, 78, 79, 80,
2651 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2652 91, 92, 93, -1, -1, -1, -1, 7, 8, 50,
Devang Pateld4980812008-09-02 20:52:40 +00002653 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
Devang Patel652203f2008-09-29 20:49:50 +00002654 20, -1, 22, 23, 24, -1, -1, -1, 119, 120,
2655 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
2656 131, -1, 133, -1, 135, 136, 137, -1, 139, 140,
2657 50, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2658 3, 4, 5, 6, -1, -1, 9, -1, -1, -1,
2659 -1, -1, -1, -1, 165, -1, -1, 168, -1, 170,
2660 -1, 172, 25, 26, 27, -1, -1, -1, -1, -1,
2661 -1, -1, -1, -1, -1, -1, -1, 40, 41, -1,
Devang Pateld4980812008-09-02 20:52:40 +00002662 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002663 -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
2664 -1, -1, -1, 164, 165, -1, -1, 168, -1, 170,
2665 171, -1, 75, 76, 77, 78, 79, 80, 81, 82,
2666 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2667 93, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2668 -1, -1, -1, -1, 164, 165, -1, -1, 168, -1,
2669 170, 171, -1, -1, -1, -1, 119, 120, 121, 122,
2670 123, 124, 125, 126, 127, 128, 129, 130, 131, -1,
2671 133, -1, 135, 136, 137, -1, 139, 140, 7, 8,
2672 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2673 19, 20, -1, 22, 23, 24, 25, -1, -1, -1,
2674 -1, -1, 165, -1, -1, 168, -1, 170, -1, 172,
2675 -1, 40, 41, -1, -1, -1, -1, -1, -1, -1,
2676 -1, -1, -1, -1, 7, 8, 55, 10, 11, 12,
2677 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2678 23, 24, -1, -1, -1, -1, 75, 76, 77, 78,
2679 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2680 89, 90, 91, 92, 93, -1, -1, 50, -1, -1,
2681 -1, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2682 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2683 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2684 129, 130, 131, 39, 133, -1, 135, 136, 137, -1,
2685 139, 140, 7, 8, 50, 10, 11, 12, 13, 14,
2686 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2687 159, -1, 7, 8, 163, -1, 165, -1, -1, 168,
2688 -1, 170, -1, 172, 19, 20, -1, 22, 23, 24,
2689 25, -1, -1, -1, -1, 50, -1, -1, 141, 142,
2690 -1, 144, -1, -1, -1, 40, 41, -1, -1, -1,
2691 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2692 55, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2693 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2694 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2695 85, 86, 87, 88, 89, 90, 91, 92, 93, -1,
2696 -1, -1, -1, -1, -1, -1, -1, -1, 164, 165,
2697 125, -1, 168, -1, 170, -1, -1, -1, -1, -1,
2698 -1, -1, -1, -1, 119, 120, 121, 122, 123, 124,
2699 125, 126, 127, 128, 129, 130, 131, -1, 133, -1,
2700 135, 136, 137, -1, 139, 140, -1, -1, -1, 164,
2701 165, -1, -1, 168, -1, 170, -1, -1, -1, -1,
2702 -1, -1, -1, -1, 159, -1, -1, -1, -1, -1,
2703 165, -1, -1, 168, -1, 170, -1, 172, 7, 8,
2704 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002705 19, 20, -1, 22, 23, 24, 7, 8, -1, 10,
2706 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Devang Patel652203f2008-09-29 20:49:50 +00002707 39, 22, 23, 24, -1, -1, -1, -1, -1, 7,
2708 8, 50, 10, 11, 12, 13, 14, 15, 16, 17,
2709 -1, 19, 20, -1, 22, 23, 24, 7, 8, 50,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002710 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2711 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002712 -1, -1, 50, -1, -1, -1, -1, -1, -1, 39,
2713 -1, -1, -1, -1, -1, -1, -1, -1, 7, 8,
2714 50, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2715 19, 20, -1, 22, 23, 24, -1, -1, -1, 7,
2716 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2717 39, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2718 -1, 50, -1, -1, -1, -1, -1, -1, -1, -1,
2719 -1, -1, -1, -1, -1, 164, 165, -1, -1, 168,
2720 -1, 170, 50, -1, -1, -1, -1, -1, -1, -1,
2721 -1, -1, -1, 164, 165, -1, 167, 168, -1, 170,
Chris Lattner15bd0952008-08-29 17:20:18 +00002722 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002723 -1, -1, -1, -1, -1, -1, 164, 165, -1, 167,
2724 168, -1, 170, -1, -1, -1, -1, -1, -1, -1,
2725 -1, -1, -1, -1, 164, 165, -1, -1, 168, -1,
2726 170, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2727 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002728 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002729 -1, -1, -1, -1, -1, 164, 165, -1, -1, 168,
2730 -1, 170, -1, -1, 50, -1, -1, -1, -1, -1,
2731 -1, -1, -1, -1, -1, -1, 164, 165, -1, -1,
2732 168, -1, 170, 7, 8, -1, 10, 11, 12, 13,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002733 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2734 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2735 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002736 -1, -1, -1, -1, 7, 8, 50, 10, 11, 12,
2737 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2738 23, 24, 7, 8, 50, 10, 11, 12, 13, 14,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002739 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
Devang Patel652203f2008-09-29 20:49:50 +00002740 -1, -1, -1, -1, -1, -1, -1, 50, -1, -1,
2741 -1, -1, -1, -1, -1, -1, -1, -1, 164, 165,
2742 -1, -1, 168, -1, 170, 50, 7, 8, -1, 10,
2743 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2744 -1, 22, 23, 24, 7, 8, -1, 10, 11, 12,
2745 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2746 23, 24, -1, -1, -1, -1, -1, -1, -1, 50,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002747 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002748 164, 165, -1, -1, 168, -1, 170, 50, -1, -1,
2749 -1, -1, -1, -1, -1, -1, -1, -1, 164, 165,
2750 -1, -1, 168, -1, 170, -1, -1, -1, -1, -1,
2751 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2752 -1, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2753 -1, -1, -1, -1, -1, -1, -1, -1, -1, 164,
2754 165, -1, -1, 168, -1, 170, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002755 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002756 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002757 -1, -1, -1, -1, -1, 36, -1, -1, -1, -1,
2758 -1, -1, -1, 164, 165, -1, -1, 168, -1, 170,
2759 -1, -1, -1, -1, -1, -1, 57, 58, -1, -1,
2760 -1, 164, 165, -1, -1, 168, -1, 170, 69, 70,
2761 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2762 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2763 91, 92, 93, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002764 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002765 -1, -1, -1, 114, 115, 116, -1, -1, 119, 120,
2766 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
2767 131, 132, 133, 134, 135, 136, 137, 138, 139, 140
Dan Gohmanf4423b12008-04-19 00:24:39 +00002768};
2769
2770/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2771 symbol of state STATE-NUM. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002772static const yytype_uint16 yystos[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002773{
Dale Johannesenc7071cc2008-05-14 20:13:36 +00002774 0, 19, 20, 22, 23, 24, 30, 31, 52, 56,
Devang Patel652203f2008-09-29 20:49:50 +00002775 60, 181, 184, 186, 187, 188, 222, 223, 224, 226,
2776 225, 53, 68, 231, 161, 59, 161, 18, 161, 42,
2777 43, 44, 45, 46, 47, 48, 49, 51, 156, 157,
2778 158, 189, 190, 191, 0, 224, 46, 48, 192, 241,
2779 42, 43, 44, 47, 193, 238, 240, 248, 161, 161,
2780 165, 232, 22, 230, 7, 8, 10, 11, 12, 13,
2781 14, 15, 16, 17, 50, 164, 165, 168, 170, 181,
2782 186, 209, 210, 244, 191, 191, 35, 37, 220, 191,
2783 191, 21, 249, 250, 29, 171, 239, 249, 22, 22,
2784 22, 233, 159, 4, 4, 4, 170, 10, 171, 210,
2785 215, 55, 159, 183, 220, 220, 42, 44, 194, 32,
2786 33, 219, 62, 63, 64, 65, 66, 67, 195, 236,
2787 236, 7, 184, 185, 253, 162, 167, 39, 210, 211,
2788 213, 214, 166, 166, 171, 215, 162, 171, 159, 214,
2789 163, 219, 219, 10, 125, 210, 212, 221, 11, 12,
2790 13, 14, 15, 16, 179, 180, 210, 216, 4, 199,
2791 28, 170, 237, 161, 36, 57, 58, 69, 70, 71,
Chris Lattner15bd0952008-08-29 17:20:18 +00002792 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2793 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002794 92, 93, 114, 115, 116, 119, 120, 121, 122, 123,
Chris Lattner15bd0952008-08-29 17:20:18 +00002795 124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
Devang Patel652203f2008-09-29 20:49:50 +00002796 134, 135, 136, 137, 138, 139, 140, 174, 175, 176,
2797 251, 258, 259, 260, 261, 251, 259, 22, 197, 162,
2798 160, 210, 210, 169, 171, 210, 4, 160, 216, 210,
2799 159, 244, 26, 27, 3, 4, 5, 6, 9, 25,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002800 40, 41, 90, 91, 92, 93, 119, 133, 135, 136,
Devang Patel652203f2008-09-29 20:49:50 +00002801 137, 139, 140, 165, 168, 170, 172, 174, 175, 176,
2802 217, 244, 183, 141, 142, 144, 198, 212, 57, 10,
2803 210, 246, 247, 11, 17, 11, 179, 195, 94, 95,
2804 96, 97, 98, 99, 100, 101, 102, 103, 177, 26,
2805 27, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2806 109, 110, 111, 112, 113, 178, 177, 178, 210, 210,
2807 246, 210, 210, 254, 246, 246, 246, 246, 246, 210,
2808 210, 210, 210, 210, 246, 195, 117, 118, 54, 121,
2809 122, 141, 142, 144, 145, 147, 148, 149, 196, 39,
2810 211, 201, 167, 169, 169, 160, 201, 183, 183, 221,
2811 177, 178, 177, 178, 159, 159, 159, 159, 159, 159,
2812 159, 167, 216, 218, 170, 218, 171, 218, 22, 159,
2813 159, 159, 227, 186, 3, 4, 5, 6, 9, 25,
2814 26, 27, 40, 41, 59, 165, 168, 170, 172, 217,
2815 243, 244, 245, 162, 245, 245, 245, 199, 210, 210,
2816 210, 210, 162, 204, 162, 204, 245, 165, 162, 162,
2817 162, 162, 162, 162, 245, 245, 245, 245, 245, 38,
2818 199, 210, 246, 4, 141, 142, 143, 144, 146, 150,
2819 151, 153, 154, 155, 200, 228, 229, 38, 159, 159,
2820 159, 159, 216, 216, 216, 216, 216, 216, 216, 162,
2821 167, 171, 210, 218, 169, 171, 216, 216, 216, 162,
2822 207, 159, 61, 242, 167, 218, 170, 218, 171, 218,
2823 22, 246, 162, 162, 212, 245, 245, 245, 245, 11,
2824 54, 11, 256, 245, 165, 246, 210, 246, 246, 246,
2825 162, 162, 257, 162, 162, 162, 210, 212, 245, 162,
2826 207, 207, 210, 216, 216, 216, 216, 256, 162, 162,
2827 162, 162, 257, 162, 216, 169, 171, 162, 162, 38,
2828 34, 54, 205, 208, 39, 210, 234, 235, 22, 167,
2829 171, 218, 169, 171, 17, 17, 245, 162, 162, 162,
2830 162, 245, 4, 245, 162, 162, 245, 162, 162, 162,
2831 4, 4, 162, 210, 245, 245, 245, 162, 204, 210,
2832 160, 162, 162, 162, 162, 160, 216, 216, 216, 216,
2833 160, 216, 169, 216, 216, 210, 22, 4, 207, 197,
2834 162, 160, 162, 169, 171, 245, 245, 159, 245, 245,
2835 245, 245, 204, 204, 246, 245, 162, 246, 246, 246,
2836 4, 245, 159, 245, 216, 216, 216, 216, 162, 160,
2837 162, 162, 257, 160, 160, 160, 181, 182, 39, 210,
2838 201, 22, 169, 162, 165, 17, 210, 255, 167, 245,
2839 257, 255, 204, 160, 160, 160, 160, 216, 216, 216,
2840 160, 197, 205, 206, 17, 167, 179, 252, 197, 197,
2841 160, 162, 167, 160, 160, 160, 160, 182, 54, 203,
2842 245, 243, 167, 179, 121, 122, 245, 245, 201, 17,
2843 210, 201, 4, 152, 202, 162, 243, 197, 197, 38,
2844 197, 197, 22, 17, 162, 17, 245, 245, 245, 17,
2845 245, 197, 197, 245, 73, 17, 245
Dan Gohmanf4423b12008-04-19 00:24:39 +00002846};
David Greene718fda32007-08-01 03:59:32 +00002847
Reid Spencer68a24bd2005-08-27 18:50:39 +00002848#define yyerrok (yyerrstatus = 0)
2849#define yyclearin (yychar = YYEMPTY)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002850#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002851#define YYEOF 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00002852
Reid Spencer68a24bd2005-08-27 18:50:39 +00002853#define YYACCEPT goto yyacceptlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002854#define YYABORT goto yyabortlab
2855#define YYERROR goto yyerrorlab
2856
2857
2858/* Like YYERROR except do call yyerror. This remains here temporarily
2859 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002860 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00002861
Reid Spencer68a24bd2005-08-27 18:50:39 +00002862#define YYFAIL goto yyerrlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002863
Reid Spencer68a24bd2005-08-27 18:50:39 +00002864#define YYRECOVERING() (!!yyerrstatus)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002865
2866#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002867do \
2868 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002869 { \
2870 yychar = (Token); \
2871 yylval = (Value); \
2872 yytoken = YYTRANSLATE (yychar); \
2873 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002874 goto yybackup; \
2875 } \
2876 else \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002877 { \
2878 yyerror (YY_("syntax error: cannot back up")); \
2879 YYERROR; \
2880 } \
2881while (YYID (0))
2882
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002883
Reid Spencer68a24bd2005-08-27 18:50:39 +00002884#define YYTERROR 1
2885#define YYERRCODE 256
2886
Dan Gohmanf4423b12008-04-19 00:24:39 +00002887
2888/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2889 If N is 0, then set CURRENT to the empty location which ends
2890 the previous symbol: RHS[0] (always defined). */
2891
2892#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2893#ifndef YYLLOC_DEFAULT
2894# define YYLLOC_DEFAULT(Current, Rhs, N) \
2895 do \
2896 if (YYID (N)) \
2897 { \
2898 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2899 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2900 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2901 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2902 } \
2903 else \
2904 { \
2905 (Current).first_line = (Current).last_line = \
2906 YYRHSLOC (Rhs, 0).last_line; \
2907 (Current).first_column = (Current).last_column = \
2908 YYRHSLOC (Rhs, 0).last_column; \
2909 } \
2910 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002911#endif
2912
Dan Gohmanf4423b12008-04-19 00:24:39 +00002913
2914/* YY_LOCATION_PRINT -- Print the location on the stream.
2915 This macro was not mandated originally: define only if we know
2916 we won't break user code: when these are the locations we know. */
2917
2918#ifndef YY_LOCATION_PRINT
Dan Gohman180c1692008-06-23 18:43:26 +00002919# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
Dan Gohmanf4423b12008-04-19 00:24:39 +00002920# define YY_LOCATION_PRINT(File, Loc) \
2921 fprintf (File, "%d.%d-%d.%d", \
2922 (Loc).first_line, (Loc).first_column, \
2923 (Loc).last_line, (Loc).last_column)
2924# else
2925# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2926# endif
2927#endif
2928
2929
2930/* YYLEX -- calling `yylex' with the right arguments. */
2931
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002932#ifdef YYLEX_PARAM
Dan Gohmanf4423b12008-04-19 00:24:39 +00002933# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002934#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002935# define YYLEX yylex ()
Gabor Greife64d2482008-04-06 23:07:54 +00002936#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002937
2938/* Enable debugging if requested. */
2939#if YYDEBUG
2940
2941# ifndef YYFPRINTF
2942# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2943# define YYFPRINTF fprintf
2944# endif
2945
2946# define YYDPRINTF(Args) \
2947do { \
2948 if (yydebug) \
2949 YYFPRINTF Args; \
2950} while (YYID (0))
2951
2952# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2953do { \
2954 if (yydebug) \
2955 { \
2956 YYFPRINTF (stderr, "%s ", Title); \
2957 yy_symbol_print (stderr, \
2958 Type, Value); \
2959 YYFPRINTF (stderr, "\n"); \
2960 } \
2961} while (YYID (0))
2962
2963
2964/*--------------------------------.
2965| Print this symbol on YYOUTPUT. |
2966`--------------------------------*/
2967
2968/*ARGSUSED*/
2969#if (defined __STDC__ || defined __C99__FUNC__ \
2970 || defined __cplusplus || defined _MSC_VER)
2971static void
2972yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greife64d2482008-04-06 23:07:54 +00002973#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002974static void
2975yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2976 FILE *yyoutput;
2977 int yytype;
2978 YYSTYPE const * const yyvaluep;
Gabor Greife64d2482008-04-06 23:07:54 +00002979#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002980{
2981 if (!yyvaluep)
2982 return;
2983# ifdef YYPRINT
2984 if (yytype < YYNTOKENS)
2985 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2986# else
2987 YYUSE (yyoutput);
2988# endif
2989 switch (yytype)
2990 {
2991 default:
2992 break;
2993 }
2994}
2995
2996
2997/*--------------------------------.
2998| Print this symbol on YYOUTPUT. |
2999`--------------------------------*/
3000
3001#if (defined __STDC__ || defined __C99__FUNC__ \
3002 || defined __cplusplus || defined _MSC_VER)
3003static void
3004yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3005#else
3006static void
3007yy_symbol_print (yyoutput, yytype, yyvaluep)
3008 FILE *yyoutput;
3009 int yytype;
3010 YYSTYPE const * const yyvaluep;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003011#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003012{
3013 if (yytype < YYNTOKENS)
3014 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3015 else
3016 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner38905612008-02-19 04:36:25 +00003017
Dan Gohmanf4423b12008-04-19 00:24:39 +00003018 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3019 YYFPRINTF (yyoutput, ")");
3020}
Chris Lattner38905612008-02-19 04:36:25 +00003021
Dan Gohmanf4423b12008-04-19 00:24:39 +00003022/*------------------------------------------------------------------.
3023| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3024| TOP (included). |
3025`------------------------------------------------------------------*/
Chris Lattner38905612008-02-19 04:36:25 +00003026
Dan Gohmanf4423b12008-04-19 00:24:39 +00003027#if (defined __STDC__ || defined __C99__FUNC__ \
3028 || defined __cplusplus || defined _MSC_VER)
3029static void
3030yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3031#else
3032static void
3033yy_stack_print (bottom, top)
3034 yytype_int16 *bottom;
3035 yytype_int16 *top;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003036#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003037{
3038 YYFPRINTF (stderr, "Stack now");
3039 for (; bottom <= top; ++bottom)
3040 YYFPRINTF (stderr, " %d", *bottom);
3041 YYFPRINTF (stderr, "\n");
3042}
Chris Lattner38905612008-02-19 04:36:25 +00003043
Dan Gohmanf4423b12008-04-19 00:24:39 +00003044# define YY_STACK_PRINT(Bottom, Top) \
3045do { \
3046 if (yydebug) \
3047 yy_stack_print ((Bottom), (Top)); \
3048} while (YYID (0))
Chris Lattner38905612008-02-19 04:36:25 +00003049
Dan Gohmanf4423b12008-04-19 00:24:39 +00003050
3051/*------------------------------------------------.
3052| Report that the YYRULE is going to be reduced. |
3053`------------------------------------------------*/
3054
3055#if (defined __STDC__ || defined __C99__FUNC__ \
3056 || defined __cplusplus || defined _MSC_VER)
3057static void
3058yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3059#else
3060static void
3061yy_reduce_print (yyvsp, yyrule)
3062 YYSTYPE *yyvsp;
3063 int yyrule;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003064#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003065{
3066 int yynrhs = yyr2[yyrule];
3067 int yyi;
3068 unsigned long int yylno = yyrline[yyrule];
3069 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3070 yyrule - 1, yylno);
3071 /* The symbols being reduced. */
3072 for (yyi = 0; yyi < yynrhs; yyi++)
3073 {
3074 fprintf (stderr, " $%d = ", yyi + 1);
3075 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3076 &(yyvsp[(yyi + 1) - (yynrhs)])
3077 );
3078 fprintf (stderr, "\n");
3079 }
3080}
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003081
Dan Gohmanf4423b12008-04-19 00:24:39 +00003082# define YY_REDUCE_PRINT(Rule) \
3083do { \
3084 if (yydebug) \
3085 yy_reduce_print (yyvsp, Rule); \
3086} while (YYID (0))
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003087
Dan Gohmanf4423b12008-04-19 00:24:39 +00003088/* Nonzero means print parse trace. It is left uninitialized so that
3089 multiple parsers can coexist. */
3090int yydebug;
3091#else /* !YYDEBUG */
3092# define YYDPRINTF(Args)
3093# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3094# define YY_STACK_PRINT(Bottom, Top)
3095# define YY_REDUCE_PRINT(Rule)
3096#endif /* !YYDEBUG */
3097
3098
3099/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003100#ifndef YYINITDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003101# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00003102#endif
3103
Dan Gohmanf4423b12008-04-19 00:24:39 +00003104/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3105 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00003106
Dan Gohmanf4423b12008-04-19 00:24:39 +00003107 Do not make this value too large; the results are undefined if
3108 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3109 evaluated with infinite-precision integer arithmetic. */
David Greene718fda32007-08-01 03:59:32 +00003110
Reid Spencer68a24bd2005-08-27 18:50:39 +00003111#ifndef YYMAXDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003112# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00003113#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003114
Reid Spencer68a24bd2005-08-27 18:50:39 +00003115
3116
Dan Gohmanf4423b12008-04-19 00:24:39 +00003117#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00003118
Dan Gohmanf4423b12008-04-19 00:24:39 +00003119# ifndef yystrlen
3120# if defined __GLIBC__ && defined _STRING_H
3121# define yystrlen strlen
3122# else
3123/* Return the length of YYSTR. */
3124#if (defined __STDC__ || defined __C99__FUNC__ \
3125 || defined __cplusplus || defined _MSC_VER)
3126static YYSIZE_T
3127yystrlen (const char *yystr)
Chris Lattner38905612008-02-19 04:36:25 +00003128#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003129static YYSIZE_T
3130yystrlen (yystr)
3131 const char *yystr;
3132#endif
3133{
3134 YYSIZE_T yylen;
3135 for (yylen = 0; yystr[yylen]; yylen++)
3136 continue;
3137 return yylen;
3138}
3139# endif
3140# endif
3141
3142# ifndef yystpcpy
3143# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3144# define yystpcpy stpcpy
3145# else
3146/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3147 YYDEST. */
3148#if (defined __STDC__ || defined __C99__FUNC__ \
3149 || defined __cplusplus || defined _MSC_VER)
3150static char *
3151yystpcpy (char *yydest, const char *yysrc)
3152#else
3153static char *
3154yystpcpy (yydest, yysrc)
3155 char *yydest;
3156 const char *yysrc;
3157#endif
3158{
3159 char *yyd = yydest;
3160 const char *yys = yysrc;
3161
3162 while ((*yyd++ = *yys++) != '\0')
3163 continue;
3164
3165 return yyd - 1;
3166}
3167# endif
3168# endif
3169
3170# ifndef yytnamerr
3171/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3172 quotes and backslashes, so that it's suitable for yyerror. The
3173 heuristic is that double-quoting is unnecessary unless the string
3174 contains an apostrophe, a comma, or backslash (other than
3175 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3176 null, do not copy; instead, return the length of what the result
3177 would have been. */
3178static YYSIZE_T
3179yytnamerr (char *yyres, const char *yystr)
3180{
3181 if (*yystr == '"')
3182 {
3183 YYSIZE_T yyn = 0;
3184 char const *yyp = yystr;
3185
3186 for (;;)
3187 switch (*++yyp)
3188 {
3189 case '\'':
3190 case ',':
3191 goto do_not_strip_quotes;
3192
3193 case '\\':
3194 if (*++yyp != '\\')
3195 goto do_not_strip_quotes;
3196 /* Fall through. */
3197 default:
3198 if (yyres)
3199 yyres[yyn] = *yyp;
3200 yyn++;
3201 break;
3202
3203 case '"':
3204 if (yyres)
3205 yyres[yyn] = '\0';
3206 return yyn;
3207 }
3208 do_not_strip_quotes: ;
3209 }
3210
3211 if (! yyres)
3212 return yystrlen (yystr);
3213
3214 return yystpcpy (yyres, yystr) - yyres;
3215}
3216# endif
3217
3218/* Copy into YYRESULT an error message about the unexpected token
3219 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3220 including the terminating null byte. If YYRESULT is null, do not
3221 copy anything; just return the number of bytes that would be
3222 copied. As a special case, return 0 if an ordinary "syntax error"
3223 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3224 size calculation. */
3225static YYSIZE_T
3226yysyntax_error (char *yyresult, int yystate, int yychar)
3227{
3228 int yyn = yypact[yystate];
3229
3230 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3231 return 0;
3232 else
3233 {
3234 int yytype = YYTRANSLATE (yychar);
3235 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3236 YYSIZE_T yysize = yysize0;
3237 YYSIZE_T yysize1;
3238 int yysize_overflow = 0;
3239 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3240 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3241 int yyx;
3242
3243# if 0
3244 /* This is so xgettext sees the translatable formats that are
3245 constructed on the fly. */
3246 YY_("syntax error, unexpected %s");
3247 YY_("syntax error, unexpected %s, expecting %s");
3248 YY_("syntax error, unexpected %s, expecting %s or %s");
3249 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3250 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3251# endif
3252 char *yyfmt;
3253 char const *yyf;
3254 static char const yyunexpected[] = "syntax error, unexpected %s";
3255 static char const yyexpecting[] = ", expecting %s";
3256 static char const yyor[] = " or %s";
3257 char yyformat[sizeof yyunexpected
3258 + sizeof yyexpecting - 1
3259 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3260 * (sizeof yyor - 1))];
3261 char const *yyprefix = yyexpecting;
3262
3263 /* Start YYX at -YYN if negative to avoid negative indexes in
3264 YYCHECK. */
3265 int yyxbegin = yyn < 0 ? -yyn : 0;
3266
3267 /* Stay within bounds of both yycheck and yytname. */
3268 int yychecklim = YYLAST - yyn + 1;
3269 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3270 int yycount = 1;
3271
3272 yyarg[0] = yytname[yytype];
3273 yyfmt = yystpcpy (yyformat, yyunexpected);
3274
3275 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3276 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3277 {
3278 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3279 {
3280 yycount = 1;
3281 yysize = yysize0;
3282 yyformat[sizeof yyunexpected - 1] = '\0';
3283 break;
3284 }
3285 yyarg[yycount++] = yytname[yyx];
3286 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3287 yysize_overflow |= (yysize1 < yysize);
3288 yysize = yysize1;
3289 yyfmt = yystpcpy (yyfmt, yyprefix);
3290 yyprefix = yyor;
3291 }
3292
3293 yyf = YY_(yyformat);
3294 yysize1 = yysize + yystrlen (yyf);
3295 yysize_overflow |= (yysize1 < yysize);
3296 yysize = yysize1;
3297
3298 if (yysize_overflow)
3299 return YYSIZE_MAXIMUM;
3300
3301 if (yyresult)
3302 {
3303 /* Avoid sprintf, as that infringes on the user's name space.
3304 Don't have undefined behavior even if the translation
3305 produced a string with the wrong number of "%s"s. */
3306 char *yyp = yyresult;
3307 int yyi = 0;
3308 while ((*yyp = *yyf) != '\0')
3309 {
3310 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3311 {
3312 yyp += yytnamerr (yyp, yyarg[yyi++]);
3313 yyf += 2;
3314 }
3315 else
3316 {
3317 yyp++;
3318 yyf++;
3319 }
3320 }
3321 }
3322 return yysize;
3323 }
3324}
3325#endif /* YYERROR_VERBOSE */
3326
3327
3328/*-----------------------------------------------.
3329| Release the memory associated to this symbol. |
3330`-----------------------------------------------*/
3331
3332/*ARGSUSED*/
3333#if (defined __STDC__ || defined __C99__FUNC__ \
3334 || defined __cplusplus || defined _MSC_VER)
3335static void
3336yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3337#else
3338static void
3339yydestruct (yymsg, yytype, yyvaluep)
3340 const char *yymsg;
3341 int yytype;
3342 YYSTYPE *yyvaluep;
3343#endif
3344{
3345 YYUSE (yyvaluep);
3346
3347 if (!yymsg)
3348 yymsg = "Deleting";
3349 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3350
3351 switch (yytype)
3352 {
3353
3354 default:
3355 break;
3356 }
3357}
3358
3359
3360/* Prevent warnings from -Wmissing-prototypes. */
3361
3362#ifdef YYPARSE_PARAM
3363#if defined __STDC__ || defined __cplusplus
3364int yyparse (void *YYPARSE_PARAM);
3365#else
3366int yyparse ();
3367#endif
3368#else /* ! YYPARSE_PARAM */
3369#if defined __STDC__ || defined __cplusplus
David Greene5fd22a82007-09-04 18:46:50 +00003370int yyparse (void);
Gabor Greife64d2482008-04-06 23:07:54 +00003371#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003372int yyparse ();
Scott Michel15dcd8e2008-01-30 03:10:00 +00003373#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003374#endif /* ! YYPARSE_PARAM */
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003375
Chris Lattner38905612008-02-19 04:36:25 +00003376
Dan Gohmanf4423b12008-04-19 00:24:39 +00003377
3378/* The look-ahead symbol. */
3379int yychar;
3380
3381/* The semantic value of the look-ahead symbol. */
3382YYSTYPE yylval;
3383
3384/* Number of syntax errors so far. */
3385int yynerrs;
3386
3387
3388
3389/*----------.
3390| yyparse. |
3391`----------*/
3392
3393#ifdef YYPARSE_PARAM
3394#if (defined __STDC__ || defined __C99__FUNC__ \
3395 || defined __cplusplus || defined _MSC_VER)
3396int
3397yyparse (void *YYPARSE_PARAM)
3398#else
3399int
3400yyparse (YYPARSE_PARAM)
3401 void *YYPARSE_PARAM;
3402#endif
3403#else /* ! YYPARSE_PARAM */
3404#if (defined __STDC__ || defined __C99__FUNC__ \
3405 || defined __cplusplus || defined _MSC_VER)
3406int
3407yyparse (void)
3408#else
3409int
3410yyparse ()
3411
Gabor Greife64d2482008-04-06 23:07:54 +00003412#endif
3413#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003414{
3415
3416 int yystate;
3417 int yyn;
3418 int yyresult;
3419 /* Number of tokens to shift before error messages enabled. */
3420 int yyerrstatus;
3421 /* Look-ahead token as an internal (translated) token number. */
3422 int yytoken = 0;
3423#if YYERROR_VERBOSE
3424 /* Buffer for error messages, and its allocated size. */
3425 char yymsgbuf[128];
3426 char *yymsg = yymsgbuf;
3427 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greife64d2482008-04-06 23:07:54 +00003428#endif
Chris Lattner38905612008-02-19 04:36:25 +00003429
Dan Gohmanf4423b12008-04-19 00:24:39 +00003430 /* Three stacks and their tools:
3431 `yyss': related to states,
3432 `yyvs': related to semantic values,
3433 `yyls': related to locations.
3434
3435 Refer to the stacks thru separate pointers, to allow yyoverflow
3436 to reallocate them elsewhere. */
3437
3438 /* The state stack. */
3439 yytype_int16 yyssa[YYINITDEPTH];
3440 yytype_int16 *yyss = yyssa;
3441 yytype_int16 *yyssp;
3442
3443 /* The semantic value stack. */
3444 YYSTYPE yyvsa[YYINITDEPTH];
3445 YYSTYPE *yyvs = yyvsa;
3446 YYSTYPE *yyvsp;
3447
3448
3449
3450#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3451
3452 YYSIZE_T yystacksize = YYINITDEPTH;
3453
3454 /* The variables used to return semantic value and location from the
3455 action routines. */
3456 YYSTYPE yyval;
3457
3458
3459 /* The number of symbols on the RHS of the reduced rule.
3460 Keep to zero when no symbol should be popped. */
3461 int yylen = 0;
3462
3463 YYDPRINTF ((stderr, "Starting parse\n"));
3464
Reid Spencer68a24bd2005-08-27 18:50:39 +00003465 yystate = 0;
3466 yyerrstatus = 0;
3467 yynerrs = 0;
3468 yychar = YYEMPTY; /* Cause a token to be read. */
3469
3470 /* Initialize stack pointers.
3471 Waste one element of value and location stack
3472 so that they stay on the same level as the state stack.
3473 The wasted elements are never initialized. */
3474
Dan Gohmanf4423b12008-04-19 00:24:39 +00003475 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003476 yyvsp = yyvs;
3477
Dan Gohmanf4423b12008-04-19 00:24:39 +00003478 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003479
Dan Gohmanf4423b12008-04-19 00:24:39 +00003480/*------------------------------------------------------------.
3481| yynewstate -- Push a new state, which is found in yystate. |
3482`------------------------------------------------------------*/
3483 yynewstate:
3484 /* In all cases, when you get here, the value and location stacks
3485 have just been pushed. So pushing a state here evens the stacks. */
3486 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003487
Dan Gohmanf4423b12008-04-19 00:24:39 +00003488 yysetstate:
3489 *yyssp = yystate;
3490
3491 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003492 {
3493 /* Get the current used size of the three stacks, in elements. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003494 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003495
3496#ifdef yyoverflow
Dan Gohmanf4423b12008-04-19 00:24:39 +00003497 {
3498 /* Give user a chance to reallocate the stack. Use copies of
3499 these so that the &'s don't force the real ones into
3500 memory. */
3501 YYSTYPE *yyvs1 = yyvs;
3502 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003503
Dan Gohmanf4423b12008-04-19 00:24:39 +00003504
3505 /* Each stack pointer address is followed by the size of the
3506 data in use in that stack, in bytes. This used to be a
3507 conditional around just the two extra args, but that might
3508 be undefined if yyoverflow is a macro. */
3509 yyoverflow (YY_("memory exhausted"),
3510 &yyss1, yysize * sizeof (*yyssp),
3511 &yyvs1, yysize * sizeof (*yyvsp),
3512
3513 &yystacksize);
3514
3515 yyss = yyss1;
3516 yyvs = yyvs1;
3517 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003518#else /* no yyoverflow */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003519# ifndef YYSTACK_RELOCATE
3520 goto yyexhaustedlab;
3521# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003522 /* Extend the stack our own way. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003523 if (YYMAXDEPTH <= yystacksize)
3524 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003525 yystacksize *= 2;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003526 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003527 yystacksize = YYMAXDEPTH;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003528
3529 {
3530 yytype_int16 *yyss1 = yyss;
3531 union yyalloc *yyptr =
3532 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3533 if (! yyptr)
3534 goto yyexhaustedlab;
3535 YYSTACK_RELOCATE (yyss);
3536 YYSTACK_RELOCATE (yyvs);
3537
3538# undef YYSTACK_RELOCATE
3539 if (yyss1 != yyssa)
3540 YYSTACK_FREE (yyss1);
3541 }
3542# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003543#endif /* no yyoverflow */
3544
Dan Gohmanf4423b12008-04-19 00:24:39 +00003545 yyssp = yyss + yysize - 1;
3546 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003547
3548
Dan Gohmanf4423b12008-04-19 00:24:39 +00003549 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3550 (unsigned long int) yystacksize));
3551
3552 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003553 YYABORT;
3554 }
3555
Dan Gohmanf4423b12008-04-19 00:24:39 +00003556 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003557
3558 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003559
Dan Gohmanf4423b12008-04-19 00:24:39 +00003560/*-----------.
3561| yybackup. |
3562`-----------*/
3563yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003564
Dan Gohmanf4423b12008-04-19 00:24:39 +00003565 /* Do appropriate processing given the current state. Read a
3566 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003567
Dan Gohmanf4423b12008-04-19 00:24:39 +00003568 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003569 yyn = yypact[yystate];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003570 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003571 goto yydefault;
3572
Dan Gohmanf4423b12008-04-19 00:24:39 +00003573 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003574
Dan Gohmanf4423b12008-04-19 00:24:39 +00003575 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003576 if (yychar == YYEMPTY)
3577 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003578 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003579 yychar = YYLEX;
3580 }
3581
Dan Gohmanf4423b12008-04-19 00:24:39 +00003582 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003583 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003584 yychar = yytoken = YYEOF;
3585 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003586 }
3587 else
3588 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003589 yytoken = YYTRANSLATE (yychar);
3590 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003591 }
3592
Dan Gohmanf4423b12008-04-19 00:24:39 +00003593 /* If the proper action on seeing token YYTOKEN is to reduce or to
3594 detect an error, take that action. */
3595 yyn += yytoken;
3596 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003597 goto yydefault;
3598 yyn = yytable[yyn];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003599 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003600 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003601 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003602 goto yyerrlab;
3603 yyn = -yyn;
3604 goto yyreduce;
3605 }
3606
3607 if (yyn == YYFINAL)
3608 YYACCEPT;
3609
Dan Gohmanf4423b12008-04-19 00:24:39 +00003610 /* Count tokens shifted since error; after three, turn off error
3611 status. */
3612 if (yyerrstatus)
3613 yyerrstatus--;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003614
Dan Gohmanf4423b12008-04-19 00:24:39 +00003615 /* Shift the look-ahead token. */
3616 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003617
Dan Gohmanf4423b12008-04-19 00:24:39 +00003618 /* Discard the shifted token unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003619 if (yychar != YYEOF)
3620 yychar = YYEMPTY;
3621
Gabor Greife64d2482008-04-06 23:07:54 +00003622 yystate = yyn;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003623 *++yyvsp = yylval;
3624
Reid Spencer68a24bd2005-08-27 18:50:39 +00003625 goto yynewstate;
3626
Gabor Greife64d2482008-04-06 23:07:54 +00003627
Dan Gohmanf4423b12008-04-19 00:24:39 +00003628/*-----------------------------------------------------------.
3629| yydefault -- do the default action for the current state. |
3630`-----------------------------------------------------------*/
3631yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003632 yyn = yydefact[yystate];
3633 if (yyn == 0)
3634 goto yyerrlab;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003635 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003636
Dan Gohmanf4423b12008-04-19 00:24:39 +00003637
3638/*-----------------------------.
3639| yyreduce -- Do a reduction. |
3640`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003641yyreduce:
Dan Gohmanf4423b12008-04-19 00:24:39 +00003642 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003643 yylen = yyr2[yyn];
3644
Dan Gohmanf4423b12008-04-19 00:24:39 +00003645 /* If YYLEN is nonzero, implement the default value of the action:
3646 `$$ = $1'.
3647
3648 Otherwise, the following line sets YYVAL to garbage.
3649 This behavior is undocumented and Bison
3650 users should not rely upon it. Assigning to YYVAL
3651 unconditionally makes the parser a bit smaller, and it avoids a
3652 GCC warning that YYVAL may be used uninitialized. */
3653 yyval = yyvsp[1-yylen];
3654
3655
3656 YY_REDUCE_PRINT (yyn);
3657 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003658 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003659 case 29:
Devang Patel652203f2008-09-29 20:49:50 +00003660#line 1142 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003661 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3662 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003663
Dan Gohmanf4423b12008-04-19 00:24:39 +00003664 case 30:
Devang Patel652203f2008-09-29 20:49:50 +00003665#line 1142 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003666 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3667 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003668
Dan Gohmanf4423b12008-04-19 00:24:39 +00003669 case 31:
Devang Patel652203f2008-09-29 20:49:50 +00003670#line 1143 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003671 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3672 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003673
Dan Gohmanf4423b12008-04-19 00:24:39 +00003674 case 32:
Devang Patel652203f2008-09-29 20:49:50 +00003675#line 1143 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003676 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3677 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003678
Dan Gohmanf4423b12008-04-19 00:24:39 +00003679 case 33:
Devang Patel652203f2008-09-29 20:49:50 +00003680#line 1144 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003681 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3682 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003683
Dan Gohmanf4423b12008-04-19 00:24:39 +00003684 case 34:
Devang Patel652203f2008-09-29 20:49:50 +00003685#line 1144 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003686 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3687 break;
3688
3689 case 35:
Devang Patel652203f2008-09-29 20:49:50 +00003690#line 1145 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003691 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3692 break;
3693
3694 case 36:
Devang Patel652203f2008-09-29 20:49:50 +00003695#line 1145 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003696 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3697 break;
3698
3699 case 37:
Devang Patel652203f2008-09-29 20:49:50 +00003700#line 1146 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003701 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3702 break;
3703
3704 case 38:
Devang Patel652203f2008-09-29 20:49:50 +00003705#line 1146 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003706 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3707 break;
3708
3709 case 39:
Devang Patel652203f2008-09-29 20:49:50 +00003710#line 1150 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003711 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3712 break;
3713
3714 case 40:
Devang Patel652203f2008-09-29 20:49:50 +00003715#line 1150 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003716 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3717 break;
3718
3719 case 41:
Devang Patel652203f2008-09-29 20:49:50 +00003720#line 1151 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003721 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3722 break;
3723
3724 case 42:
Devang Patel652203f2008-09-29 20:49:50 +00003725#line 1151 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003726 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3727 break;
3728
3729 case 43:
Devang Patel652203f2008-09-29 20:49:50 +00003730#line 1152 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003731 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3732 break;
3733
3734 case 44:
Devang Patel652203f2008-09-29 20:49:50 +00003735#line 1152 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003736 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3737 break;
3738
3739 case 45:
Devang Patel652203f2008-09-29 20:49:50 +00003740#line 1153 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003741 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3742 break;
3743
3744 case 46:
Devang Patel652203f2008-09-29 20:49:50 +00003745#line 1153 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003746 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3747 break;
3748
3749 case 47:
Devang Patel652203f2008-09-29 20:49:50 +00003750#line 1154 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003751 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3752 break;
3753
3754 case 48:
Devang Patel652203f2008-09-29 20:49:50 +00003755#line 1154 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003756 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3757 break;
3758
3759 case 49:
Devang Patel652203f2008-09-29 20:49:50 +00003760#line 1155 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003761 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3762 break;
3763
3764 case 50:
Devang Patel652203f2008-09-29 20:49:50 +00003765#line 1155 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003766 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3767 break;
3768
3769 case 51:
Devang Patel652203f2008-09-29 20:49:50 +00003770#line 1156 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003771 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3772 break;
3773
3774 case 52:
Devang Patel652203f2008-09-29 20:49:50 +00003775#line 1156 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003776 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3777 break;
3778
3779 case 53:
Devang Patel652203f2008-09-29 20:49:50 +00003780#line 1157 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003781 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3782 break;
3783
3784 case 54:
Devang Patel652203f2008-09-29 20:49:50 +00003785#line 1158 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003786 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3787 break;
3788
3789 case 65:
Devang Patel652203f2008-09-29 20:49:50 +00003790#line 1167 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003791 { (yyval.StrVal) = 0; ;}
3792 break;
3793
3794 case 66:
Devang Patel652203f2008-09-29 20:49:50 +00003795#line 1169 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003796 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3797 break;
3798
3799 case 67:
Devang Patel652203f2008-09-29 20:49:50 +00003800#line 1170 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003801 { (yyval.UIntVal)=0; ;}
3802 break;
3803
3804 case 68:
Devang Patel652203f2008-09-29 20:49:50 +00003805#line 1174 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003806 {
3807 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003808 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003809 ;}
3810 break;
3811
3812 case 69:
Devang Patel652203f2008-09-29 20:49:50 +00003813#line 1178 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003814 {
3815 (yyval.StrVal) = 0;
Christopher Lambbf3348d2007-12-12 08:45:45 +00003816 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003817 ;}
3818 break;
3819
Chris Lattner15bd0952008-08-29 17:20:18 +00003820 case 70:
Devang Patel652203f2008-09-29 20:49:50 +00003821#line 1183 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003822 {
Chris Lattner15bd0952008-08-29 17:20:18 +00003823 (yyval.UIntVal) = (yyvsp[(1) - (2)].UIntVal);
3824 CHECK_FOR_ERROR
3825;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003826 break;
3827
3828 case 74:
Devang Patel652203f2008-09-29 20:49:50 +00003829#line 1192 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003830 {
3831 (yyval.StrVal) = 0;
3832 CHECK_FOR_ERROR
3833 ;}
3834 break;
3835
3836 case 75:
Devang Patel652203f2008-09-29 20:49:50 +00003837#line 1197 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003838 {
3839 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00003840 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003841 ;}
3842 break;
3843
Chris Lattner15bd0952008-08-29 17:20:18 +00003844 case 76:
Devang Patel652203f2008-09-29 20:49:50 +00003845#line 1203 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003846 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3847 break;
3848
Chris Lattner15bd0952008-08-29 17:20:18 +00003849 case 77:
Devang Patel652203f2008-09-29 20:49:50 +00003850#line 1204 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003851 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3852 break;
3853
Chris Lattner15bd0952008-08-29 17:20:18 +00003854 case 78:
Devang Patel652203f2008-09-29 20:49:50 +00003855#line 1205 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003856 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3857 break;
3858
Chris Lattner15bd0952008-08-29 17:20:18 +00003859 case 79:
Devang Patel652203f2008-09-29 20:49:50 +00003860#line 1206 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003861 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3862 break;
3863
Chris Lattner15bd0952008-08-29 17:20:18 +00003864 case 80:
Devang Patel652203f2008-09-29 20:49:50 +00003865#line 1207 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003866 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3867 break;
3868
Chris Lattner15bd0952008-08-29 17:20:18 +00003869 case 81:
Devang Patel652203f2008-09-29 20:49:50 +00003870#line 1208 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003871 { (yyval.Linkage) = GlobalValue::CommonLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003872 break;
3873
Chris Lattner15bd0952008-08-29 17:20:18 +00003874 case 82:
Devang Patel652203f2008-09-29 20:49:50 +00003875#line 1212 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003876 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003877 break;
3878
Chris Lattner15bd0952008-08-29 17:20:18 +00003879 case 83:
Devang Patel652203f2008-09-29 20:49:50 +00003880#line 1213 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003881 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003882 break;
3883
Chris Lattner15bd0952008-08-29 17:20:18 +00003884 case 84:
Devang Patel652203f2008-09-29 20:49:50 +00003885#line 1214 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003886 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003887 break;
3888
Dan Gohmanf4423b12008-04-19 00:24:39 +00003889 case 85:
Devang Patel652203f2008-09-29 20:49:50 +00003890#line 1218 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003891 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003892 break;
3893
3894 case 86:
Devang Patel652203f2008-09-29 20:49:50 +00003895#line 1219 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003896 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003897 break;
3898
3899 case 87:
Devang Patel652203f2008-09-29 20:49:50 +00003900#line 1220 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003901 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003902 break;
3903
3904 case 88:
Devang Patel652203f2008-09-29 20:49:50 +00003905#line 1221 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003906 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003907 break;
3908
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003909 case 89:
Devang Patel652203f2008-09-29 20:49:50 +00003910#line 1225 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003911 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003912 break;
3913
3914 case 90:
Devang Patel652203f2008-09-29 20:49:50 +00003915#line 1226 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003916 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003917 break;
3918
3919 case 91:
Devang Patel652203f2008-09-29 20:49:50 +00003920#line 1227 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003921 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003922 break;
3923
3924 case 92:
Devang Patel652203f2008-09-29 20:49:50 +00003925#line 1231 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003926 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3927 break;
3928
Chris Lattner15bd0952008-08-29 17:20:18 +00003929 case 93:
Devang Patel652203f2008-09-29 20:49:50 +00003930#line 1232 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003931 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003932 break;
3933
Chris Lattner15bd0952008-08-29 17:20:18 +00003934 case 94:
Devang Patel652203f2008-09-29 20:49:50 +00003935#line 1233 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003936 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3937 break;
3938
3939 case 95:
Devang Patel652203f2008-09-29 20:49:50 +00003940#line 1234 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003941 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3942 break;
3943
3944 case 96:
Devang Patel652203f2008-09-29 20:49:50 +00003945#line 1235 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003946 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3947 break;
3948
3949 case 97:
Devang Patel652203f2008-09-29 20:49:50 +00003950#line 1239 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003951 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3952 break;
3953
3954 case 98:
Devang Patel652203f2008-09-29 20:49:50 +00003955#line 1240 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003956 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3957 break;
3958
Dan Gohmanf4423b12008-04-19 00:24:39 +00003959 case 99:
Devang Patel652203f2008-09-29 20:49:50 +00003960#line 1241 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003961 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003962 break;
3963
3964 case 100:
Devang Patel652203f2008-09-29 20:49:50 +00003965#line 1244 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003966 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003967 break;
3968
3969 case 101:
Devang Patel652203f2008-09-29 20:49:50 +00003970#line 1245 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003971 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003972 break;
3973
3974 case 102:
Devang Patel652203f2008-09-29 20:49:50 +00003975#line 1246 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003976 { (yyval.UIntVal) = CallingConv::Fast; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003977 break;
3978
3979 case 103:
Devang Patel652203f2008-09-29 20:49:50 +00003980#line 1247 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003981 { (yyval.UIntVal) = CallingConv::Cold; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003982 break;
3983
3984 case 104:
Devang Patel652203f2008-09-29 20:49:50 +00003985#line 1248 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003986 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003987 break;
3988
3989 case 105:
Devang Patel652203f2008-09-29 20:49:50 +00003990#line 1249 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003991 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00003992 break;
3993
3994 case 106:
Devang Patel652203f2008-09-29 20:49:50 +00003995#line 1250 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003996 {
3997 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003998 GEN_ERROR("Calling conv too large");
Dan Gohmanf4423b12008-04-19 00:24:39 +00003999 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004000 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004001 ;}
4002 break;
4003
Dale Johannesendfe8c842008-09-26 19:32:34 +00004004 case 107:
Devang Patel652203f2008-09-29 20:49:50 +00004005#line 1257 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesendfe8c842008-09-26 19:32:34 +00004006 { (yyval.Attributes) = Attribute::ZExt; ;}
4007 break;
4008
Dan Gohmanf4423b12008-04-19 00:24:39 +00004009 case 108:
Devang Patel652203f2008-09-29 20:49:50 +00004010#line 1258 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004011 { (yyval.Attributes) = Attribute::ZExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004012 break;
4013
4014 case 109:
Devang Patel652203f2008-09-29 20:49:50 +00004015#line 1259 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesendfe8c842008-09-26 19:32:34 +00004016 { (yyval.Attributes) = Attribute::SExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004017 break;
4018
4019 case 110:
Devang Patel652203f2008-09-29 20:49:50 +00004020#line 1260 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004021 { (yyval.Attributes) = Attribute::SExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004022 break;
4023
4024 case 111:
Devang Patel652203f2008-09-29 20:49:50 +00004025#line 1261 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004026 { (yyval.Attributes) = Attribute::InReg; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004027 break;
4028
Dale Johannesendfe8c842008-09-26 19:32:34 +00004029 case 112:
Devang Patel652203f2008-09-29 20:49:50 +00004030#line 1262 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004031 { (yyval.Attributes) = Attribute::StructRet; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004032 break;
4033
Dale Johannesendfe8c842008-09-26 19:32:34 +00004034 case 113:
Devang Patel652203f2008-09-29 20:49:50 +00004035#line 1263 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004036 { (yyval.Attributes) = Attribute::NoAlias; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004037 break;
4038
Dale Johannesendfe8c842008-09-26 19:32:34 +00004039 case 114:
Devang Patel652203f2008-09-29 20:49:50 +00004040#line 1264 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004041 { (yyval.Attributes) = Attribute::ByVal; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004042 break;
4043
Dale Johannesendfe8c842008-09-26 19:32:34 +00004044 case 115:
Devang Patel652203f2008-09-29 20:49:50 +00004045#line 1265 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004046 { (yyval.Attributes) = Attribute::Nest; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004047 break;
4048
Dale Johannesendfe8c842008-09-26 19:32:34 +00004049 case 116:
Devang Patel652203f2008-09-29 20:49:50 +00004050#line 1266 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004051 { (yyval.Attributes) =
4052 Attribute::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004053 break;
4054
Dale Johannesendfe8c842008-09-26 19:32:34 +00004055 case 117:
Devang Patel652203f2008-09-29 20:49:50 +00004056#line 1270 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004057 { (yyval.Attributes) = Attribute::None; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004058 break;
4059
Dale Johannesendfe8c842008-09-26 19:32:34 +00004060 case 118:
Devang Patel652203f2008-09-29 20:49:50 +00004061#line 1271 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesendfe8c842008-09-26 19:32:34 +00004062 {
4063 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4064 ;}
4065 break;
4066
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004067 case 119:
Devang Patel652203f2008-09-29 20:49:50 +00004068#line 1276 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004069 { (yyval.Attributes) = Attribute::InReg; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004070 break;
4071
Devang Patel652203f2008-09-29 20:49:50 +00004072 case 120:
4073#line 1277 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004074 { (yyval.Attributes) = Attribute::ZExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004075 break;
4076
Devang Patel652203f2008-09-29 20:49:50 +00004077 case 121:
4078#line 1278 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004079 { (yyval.Attributes) = Attribute::SExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004080 break;
4081
Devang Patel652203f2008-09-29 20:49:50 +00004082 case 122:
4083#line 1281 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004084 { (yyval.Attributes) = Attribute::None; ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00004085 break;
4086
Devang Patel652203f2008-09-29 20:49:50 +00004087 case 123:
4088#line 1282 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4089 {
4090 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4091 ;}
4092 break;
4093
4094 case 124:
4095#line 1288 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4096 { (yyval.Attributes) = Attribute::NoReturn; ;}
4097 break;
4098
4099 case 125:
4100#line 1289 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4101 { (yyval.Attributes) = Attribute::NoUnwind; ;}
4102 break;
4103
4104 case 126:
4105#line 1290 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4106 { (yyval.Attributes) = Attribute::InReg; ;}
4107 break;
4108
Dale Johannesendfe8c842008-09-26 19:32:34 +00004109 case 127:
Devang Patel652203f2008-09-29 20:49:50 +00004110#line 1291 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4111 { (yyval.Attributes) = Attribute::ZExt; ;}
4112 break;
4113
4114 case 128:
4115#line 1292 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4116 { (yyval.Attributes) = Attribute::SExt; ;}
4117 break;
4118
4119 case 129:
4120#line 1293 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4121 { (yyval.Attributes) = Attribute::ReadNone; ;}
4122 break;
4123
4124 case 130:
4125#line 1294 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4126 { (yyval.Attributes) = Attribute::ReadOnly; ;}
4127 break;
4128
4129 case 131:
4130#line 1295 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4131 { (yyval.Attributes) = Attribute::NoInline ;}
4132 break;
4133
4134 case 132:
4135#line 1296 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4136 { (yyval.Attributes) = Attribute::AlwaysInline ;}
4137 break;
4138
4139 case 133:
4140#line 1297 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4141 { (yyval.Attributes) = Attribute::OptimizeForSize ;}
4142 break;
4143
4144 case 134:
4145#line 1300 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4146 { (yyval.Attributes) = Attribute::None; ;}
4147 break;
4148
4149 case 135:
4150#line 1301 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004151 {
Devang Patel05988662008-09-25 21:00:45 +00004152 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
Chris Lattner15bd0952008-08-29 17:20:18 +00004153 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004154 break;
4155
Devang Patel652203f2008-09-29 20:49:50 +00004156 case 136:
4157#line 1307 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld4980812008-09-02 20:52:40 +00004158 { (yyval.StrVal) = 0; ;}
4159 break;
4160
Devang Patel652203f2008-09-29 20:49:50 +00004161 case 137:
4162#line 1308 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004163 {
4164 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4165 ;}
4166 break;
4167
Devang Patel652203f2008-09-29 20:49:50 +00004168 case 138:
4169#line 1315 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004170 { (yyval.UIntVal) = 0; ;}
4171 break;
4172
Devang Patel652203f2008-09-29 20:49:50 +00004173 case 139:
4174#line 1316 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004175 {
4176 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4177 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004178 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004179 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004180;}
4181 break;
4182
Devang Patel652203f2008-09-29 20:49:50 +00004183 case 140:
4184#line 1322 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004185 { (yyval.UIntVal) = 0; ;}
4186 break;
4187
Devang Patel652203f2008-09-29 20:49:50 +00004188 case 141:
4189#line 1323 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004190 {
4191 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4192 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lambbf3348d2007-12-12 08:45:45 +00004193 GEN_ERROR("Alignment must be a power of two");
4194 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004195;}
4196 break;
4197
Devang Patel652203f2008-09-29 20:49:50 +00004198 case 142:
4199#line 1332 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004200 {
4201 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
4202 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004203 GEN_ERROR("Invalid character in section name");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004204 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004205 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004206;}
4207 break;
4208
Devang Patel652203f2008-09-29 20:49:50 +00004209 case 143:
4210#line 1340 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004211 { (yyval.StrVal) = 0; ;}
4212 break;
4213
Devang Patel652203f2008-09-29 20:49:50 +00004214 case 144:
4215#line 1341 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004216 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4217 break;
4218
Devang Pateld4980812008-09-02 20:52:40 +00004219 case 145:
Devang Patel652203f2008-09-29 20:49:50 +00004220#line 1346 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004221 {;}
4222 break;
4223
Devang Pateld4980812008-09-02 20:52:40 +00004224 case 146:
Devang Patel652203f2008-09-29 20:49:50 +00004225#line 1347 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
4226 {;}
4227 break;
4228
4229 case 147:
4230#line 1348 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004231 {
4232 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4233 delete (yyvsp[(1) - (1)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004234 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004235 ;}
4236 break;
4237
Devang Patel652203f2008-09-29 20:49:50 +00004238 case 148:
4239#line 1353 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004240 {
4241 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004242 GEN_ERROR("Alignment must be a power of two");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004243 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004244 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004245 ;}
4246 break;
4247
Devang Patel652203f2008-09-29 20:49:50 +00004248 case 156:
4249#line 1369 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004250 {
4251 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004252 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004253 ;}
4254 break;
4255
Devang Patel652203f2008-09-29 20:49:50 +00004256 case 157:
4257#line 1373 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004258 {
4259 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004260 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004261 ;}
4262 break;
4263
Devang Patel652203f2008-09-29 20:49:50 +00004264 case 158:
4265#line 1377 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004266 { // Pointer type?
4267 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lambbf3348d2007-12-12 08:45:45 +00004268 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004269 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4270 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00004271 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004272 ;}
4273 break;
4274
Devang Patel652203f2008-09-29 20:49:50 +00004275 case 159:
4276#line 1384 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004277 { // Named types are also simple types...
4278 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004279 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004280 (yyval.TypeVal) = new PATypeHolder(tmp);
4281 ;}
4282 break;
4283
Devang Patel652203f2008-09-29 20:49:50 +00004284 case 160:
4285#line 1389 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004286 { // Type UpReference
4287 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004288 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohmanf4423b12008-04-19 00:24:39 +00004289 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4290 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004291 UR_OUT("New Upreference!\n");
4292 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004293 ;}
4294 break;
4295
Devang Patel652203f2008-09-29 20:49:50 +00004296 case 161:
4297#line 1397 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004298 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004299 // Allow but ignore attributes on function types; this permits auto-upgrade.
4300 // FIXME: remove in LLVM 3.0.
Chris Lattnera925a142008-04-23 05:37:08 +00004301 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4302 if (!FunctionType::isValidReturnType(RetTy))
4303 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004304
Reid Spencer41dff5e2007-01-26 08:05:27 +00004305 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004306 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004307 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004308 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004309 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004310 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004311
Reid Spencer41dff5e2007-01-26 08:05:27 +00004312 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4313 if (isVarArg) Params.pop_back();
4314
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004315 for (unsigned i = 0; i != Params.size(); ++i)
4316 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4317 GEN_ERROR("Function arguments must be value types!");
4318
4319 CHECK_FOR_ERROR
4320
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004321 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004322 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4323 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
Eric Christopher2a5196f2008-09-24 04:55:49 +00004324 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004325 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004326 ;}
4327 break;
4328
Devang Patel652203f2008-09-29 20:49:50 +00004329 case 162:
4330#line 1426 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004331 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004332 // Allow but ignore attributes on function types; this permits auto-upgrade.
4333 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004334 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004335 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004336 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004337 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004338 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004339 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004340
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004341 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4342 if (isVarArg) Params.pop_back();
4343
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004344 for (unsigned i = 0; i != Params.size(); ++i)
4345 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4346 GEN_ERROR("Function arguments must be value types!");
4347
4348 CHECK_FOR_ERROR
4349
Dan Gohmanf4423b12008-04-19 00:24:39 +00004350 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
4351 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
Eric Christopher2a5196f2008-09-24 04:55:49 +00004352 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004353 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004354 ;}
4355 break;
4356
Devang Patel652203f2008-09-29 20:49:50 +00004357 case 163:
4358#line 1451 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004359 { // Sized array type?
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004360 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (yyvsp[(2) - (5)].UInt64Val))));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004361 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004362 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004363 ;}
4364 break;
4365
Devang Patel652203f2008-09-29 20:49:50 +00004366 case 164:
4367#line 1456 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004368 { // Vector type?
4369 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4370 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004371 GEN_ERROR("Unsigned result not equal to signed result");
4372 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4373 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004374 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4375 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004376 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004377 ;}
4378 break;
4379
Devang Patel652203f2008-09-29 20:49:50 +00004380 case 165:
4381#line 1466 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004382 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004383 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004384 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4385 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004386 Elements.push_back(*I);
4387
Dan Gohmanf4423b12008-04-19 00:24:39 +00004388 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4389 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004390 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004391 ;}
4392 break;
4393
Devang Patel652203f2008-09-29 20:49:50 +00004394 case 166:
4395#line 1476 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004396 { // Empty structure type?
4397 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004398 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004399 ;}
4400 break;
4401
Devang Patel652203f2008-09-29 20:49:50 +00004402 case 167:
4403#line 1480 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004404 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004405 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004406 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4407 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004408 Elements.push_back(*I);
4409
Dan Gohmanf4423b12008-04-19 00:24:39 +00004410 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4411 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004412 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004413 ;}
4414 break;
4415
Devang Patel652203f2008-09-29 20:49:50 +00004416 case 168:
4417#line 1490 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004418 { // Empty structure type?
4419 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004420 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004421 ;}
4422 break;
4423
Devang Patel652203f2008-09-29 20:49:50 +00004424 case 169:
4425#line 1497 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004426 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004427 // Allow but ignore attributes on function types; this permits auto-upgrade.
4428 // FIXME: remove in LLVM 3.0.
Eric Christopher2a5196f2008-09-24 04:55:49 +00004429 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
Devang Patel05988662008-09-25 21:00:45 +00004430 (yyval.TypeWithAttrs).Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004431 ;}
4432 break;
4433
Devang Patel652203f2008-09-29 20:49:50 +00004434 case 170:
4435#line 1506 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004436 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004437 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004438 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4439 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004440 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004441 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4442 ;}
4443 break;
4444
Devang Patel652203f2008-09-29 20:49:50 +00004445 case 171:
4446#line 1513 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004447 {
4448 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4449 ;}
4450 break;
4451
Devang Patel652203f2008-09-29 20:49:50 +00004452 case 172:
4453#line 1518 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004454 {
4455 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4456 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004457 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004458 ;}
4459 break;
4460
Devang Patel652203f2008-09-29 20:49:50 +00004461 case 173:
4462#line 1523 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004463 {
4464 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004465 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004466 ;}
4467 break;
4468
Devang Patel652203f2008-09-29 20:49:50 +00004469 case 175:
4470#line 1531 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004471 {
4472 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Devang Patel05988662008-09-25 21:00:45 +00004473 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004474 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004475 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004476 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004477 ;}
4478 break;
4479
Devang Patel652203f2008-09-29 20:49:50 +00004480 case 176:
4481#line 1538 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004482 {
4483 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Devang Patel05988662008-09-25 21:00:45 +00004484 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004485 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004486 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004487 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004488 ;}
4489 break;
4490
Devang Patel652203f2008-09-29 20:49:50 +00004491 case 177:
4492#line 1545 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004493 {
4494 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004495 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004496 ;}
4497 break;
4498
Devang Patel652203f2008-09-29 20:49:50 +00004499 case 178:
4500#line 1553 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004501 {
4502 (yyval.TypeList) = new std::list<PATypeHolder>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004503 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004504 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004505 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004506 ;}
4507 break;
4508
Devang Patel652203f2008-09-29 20:49:50 +00004509 case 179:
4510#line 1559 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004511 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00004512 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004513 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004514 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004515 ;}
4516 break;
4517
Devang Patel652203f2008-09-29 20:49:50 +00004518 case 180:
4519#line 1571 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004520 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004521 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004522 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4523 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004524 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004525 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004526 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004527 const Type *ETy = ATy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004528 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004529
4530 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004531 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004532 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004533 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004534 utostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004535
4536 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004537 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4538 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004539 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004540 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004541 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004542 }
4543
Dan Gohmanf4423b12008-04-19 00:24:39 +00004544 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4545 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004546 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004547 ;}
4548 break;
4549
Devang Patel652203f2008-09-29 20:49:50 +00004550 case 181:
4551#line 1599 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004552 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004553 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004554 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4555 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004556 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004557 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004558 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004559
Dan Gohman180c1692008-06-23 18:43:26 +00004560 uint64_t NumElements = ATy->getNumElements();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004561 if (NumElements != uint64_t(-1) && NumElements != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004562 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Mon P Wang28873102008-06-25 08:15:39 +00004563 " arguments, but has size of " + utostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004564 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4565 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004566 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004567 ;}
4568 break;
4569
Devang Patel652203f2008-09-29 20:49:50 +00004570 case 182:
4571#line 1615 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004572 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004573 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004574 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4575 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004576 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004577 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004578 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004579
Dan Gohman180c1692008-06-23 18:43:26 +00004580 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004581 const Type *ETy = ATy->getElementType();
Mon P Wang28873102008-06-25 08:15:39 +00004582 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (3)].StrVal)->length())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004583 GEN_ERROR("Can't build string constant of size " +
Mon P Wang28873102008-06-25 08:15:39 +00004584 utostr((yyvsp[(3) - (3)].StrVal)->length()) +
4585 " when array has size " + utostr(NumElements) + "");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004586 std::vector<Constant*> Vals;
4587 if (ETy == Type::Int8Ty) {
Mon P Wang28873102008-06-25 08:15:39 +00004588 for (uint64_t i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004589 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004590 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004591 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004592 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4593 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004594 delete (yyvsp[(3) - (3)].StrVal);
4595 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4596 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004597 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004598 ;}
4599 break;
4600
Devang Patel652203f2008-09-29 20:49:50 +00004601 case 183:
4602#line 1642 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004603 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004604 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004605 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4606 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004607 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004608 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004609 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004610 const Type *ETy = PTy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004611 unsigned NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004612
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004613 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004614 if (NumElements != unsigned(-1) && NumElements != (unsigned)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004615 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004616 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004617 utostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004618
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004619 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004620 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4621 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004622 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004623 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004624 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004625 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004626
Dan Gohmanf4423b12008-04-19 00:24:39 +00004627 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4628 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004629 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004630 ;}
4631 break;
4632
Devang Patel652203f2008-09-29 20:49:50 +00004633 case 184:
4634#line 1670 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004635 {
4636 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004637 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004638 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004639 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004640
Dan Gohmanf4423b12008-04-19 00:24:39 +00004641 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004642 GEN_ERROR("Illegal number of initializers for structure type");
4643
4644 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004645 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4646 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004647 GEN_ERROR("Expected type '" +
4648 STy->getElementType(i)->getDescription() +
4649 "' for element #" + utostr(i) +
4650 " of structure initializer");
4651
4652 // Check to ensure that Type is not packed
4653 if (STy->isPacked())
4654 GEN_ERROR("Unpacked Initializer to vector type '" +
4655 STy->getDescription() + "'");
4656
Dan Gohmanf4423b12008-04-19 00:24:39 +00004657 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4658 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004659 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004660 ;}
4661 break;
4662
Devang Patel652203f2008-09-29 20:49:50 +00004663 case 185:
4664#line 1696 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004665 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004666 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004667 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4668 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004669 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004670 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004671 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004672
4673 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004674 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004675
4676 // Check to ensure that Type is not packed
4677 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004678 GEN_ERROR("Unpacked Initializer to vector type '" +
4679 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004680
Dan Gohmanf4423b12008-04-19 00:24:39 +00004681 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4682 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004683 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004684 ;}
4685 break;
4686
Devang Patel652203f2008-09-29 20:49:50 +00004687 case 186:
4688#line 1716 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004689 {
4690 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004691 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004692 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004693 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004694
Dan Gohmanf4423b12008-04-19 00:24:39 +00004695 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004696 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004697
4698 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004699 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4700 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004701 GEN_ERROR("Expected type '" +
4702 STy->getElementType(i)->getDescription() +
4703 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004704 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004705
4706 // Check to ensure that Type is packed
4707 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004708 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004709 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004710
Dan Gohmanf4423b12008-04-19 00:24:39 +00004711 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4712 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004713 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004714 ;}
4715 break;
4716
Devang Patel652203f2008-09-29 20:49:50 +00004717 case 187:
4718#line 1742 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004719 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004720 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004721 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4722 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004723 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004724 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004725 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004726
4727 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004728 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004729
4730 // Check to ensure that Type is packed
4731 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004732 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004733 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004734
Dan Gohmanf4423b12008-04-19 00:24:39 +00004735 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4736 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004737 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004738 ;}
4739 break;
4740
Devang Patel652203f2008-09-29 20:49:50 +00004741 case 188:
4742#line 1762 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004743 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004744 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004745 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4746 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004747 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004748 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004749 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004750
Dan Gohmanf4423b12008-04-19 00:24:39 +00004751 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4752 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004753 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004754 ;}
4755 break;
4756
Devang Patel652203f2008-09-29 20:49:50 +00004757 case 189:
4758#line 1774 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004759 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004760 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004761 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4762 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4763 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004764 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004765 ;}
4766 break;
4767
Devang Patel652203f2008-09-29 20:49:50 +00004768 case 190:
4769#line 1781 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004770 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004771 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004772 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4773 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004774 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004775 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004776
4777 // ConstExprs can exist in the body of a function, thus creating
4778 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004779 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004780 // symbol table instead of the module symbol table for the global symbol,
4781 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004782 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004783 //
4784 Function *SavedCurFn = CurFun.CurrentFunction;
4785 CurFun.CurrentFunction = 0;
4786
Dan Gohmanf4423b12008-04-19 00:24:39 +00004787 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004788 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004789
4790 CurFun.CurrentFunction = SavedCurFn;
4791
4792 // If this is an initializer for a constant pointer, which is referencing a
4793 // (currently) undefined variable, create a stub now that shall be replaced
4794 // in the future with the right type of variable.
4795 //
4796 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004797 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004798 const PointerType *PT = cast<PointerType>(Ty);
4799
4800 // First check to see if the forward references value is already created!
4801 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004802 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Eric Christopher2a5196f2008-09-24 04:55:49 +00004803
Reid Spencer68a24bd2005-08-27 18:50:39 +00004804 if (I != CurModule.GlobalRefs.end()) {
4805 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004806 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004807 } else {
4808 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004809 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4810 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4811 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004812 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004813
4814 // Create the forward referenced global.
4815 GlobalValue *GV;
Eric Christopher2a5196f2008-09-24 04:55:49 +00004816 if (const FunctionType *FTy =
Reid Spencer68a24bd2005-08-27 18:50:39 +00004817 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004818 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4819 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004820 } else {
4821 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004822 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004823 Name, CurModule.CurrentModule);
4824 }
4825
4826 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004827 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004828 V = GV;
4829 }
4830 }
4831
Dan Gohmanf4423b12008-04-19 00:24:39 +00004832 (yyval.ConstVal) = cast<GlobalValue>(V);
4833 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004834 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004835 ;}
4836 break;
4837
Devang Patel652203f2008-09-29 20:49:50 +00004838 case 191:
4839#line 1847 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004840 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004841 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004842 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4843 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004844 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004845 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4846 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4847 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004848 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004849 ;}
4850 break;
4851
Devang Patel652203f2008-09-29 20:49:50 +00004852 case 192:
4853#line 1857 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004854 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004855 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004856 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4857 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004858 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4859 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004860 (yyval.ConstVal) = Constant::getNullValue(Ty);
4861 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004862 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004863 ;}
4864 break;
4865
Devang Patel652203f2008-09-29 20:49:50 +00004866 case 193:
4867#line 1867 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004868 { // integral constants
4869 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004870 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004871 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004872 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004873 ;}
4874 break;
4875
Devang Patel652203f2008-09-29 20:49:50 +00004876 case 194:
4877#line 1873 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004878 { // arbitrary precision integer constants
4879 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4880 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004881 GEN_ERROR("Constant value does not fit in type");
4882 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004883 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4884 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4885 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004886 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004887 ;}
4888 break;
4889
Devang Patel652203f2008-09-29 20:49:50 +00004890 case 195:
4891#line 1883 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004892 { // integral constants
4893 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004894 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004895 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004896 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004897 ;}
4898 break;
4899
Devang Patel652203f2008-09-29 20:49:50 +00004900 case 196:
4901#line 1889 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004902 { // arbitrary precision integer constants
4903 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4904 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004905 GEN_ERROR("Constant value does not fit in type");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004906 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004907 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4908 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4909 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004910 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004911 ;}
4912 break;
4913
Devang Patel652203f2008-09-29 20:49:50 +00004914 case 197:
4915#line 1899 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004916 { // Boolean constants
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004917 if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
4918 GEN_ERROR("Constant true must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004919 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004920 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004921 ;}
4922 break;
4923
Devang Patel652203f2008-09-29 20:49:50 +00004924 case 198:
4925#line 1905 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004926 { // Boolean constants
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004927 if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
4928 GEN_ERROR("Constant false must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004929 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004930 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004931 ;}
4932 break;
4933
Devang Patel652203f2008-09-29 20:49:50 +00004934 case 199:
4935#line 1911 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004936 { // Floating point constants
4937 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004938 GEN_ERROR("Floating point constant invalid for type");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004939 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004940 // as double. Fix this here. Long double is done right.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004941 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4942 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004943 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004944 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004945 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004946 ;}
4947 break;
4948
Devang Patel652203f2008-09-29 20:49:50 +00004949 case 200:
4950#line 1924 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004951 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004952 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004953 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4954 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4955 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4956 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004957 GEN_ERROR("invalid cast opcode for cast from '" +
4958 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004959 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004960 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4961 delete (yyvsp[(5) - (6)].TypeVal);
4962 ;}
4963 break;
4964
Devang Patel652203f2008-09-29 20:49:50 +00004965 case 201:
4966#line 1936 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004967 {
4968 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004969 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004970
4971 const Type *IdxTy =
Dan Gohman041e2eb2008-05-15 19:50:34 +00004972 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004973 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004974 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004975
Chris Lattnerf7469af2007-01-31 04:44:08 +00004976 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004977 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4978 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004979 IdxVec.push_back(C);
4980 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004981 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004982
Dan Gohmanf4423b12008-04-19 00:24:39 +00004983 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004984
Dan Gohmanf4423b12008-04-19 00:24:39 +00004985 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004986 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004987 ;}
4988 break;
4989
Devang Patel652203f2008-09-29 20:49:50 +00004990 case 202:
4991#line 1957 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004992 {
4993 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004994 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004995 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004996 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004997 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004998 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004999 ;}
5000 break;
5001
Devang Patel652203f2008-09-29 20:49:50 +00005002 case 203:
5003#line 1965 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005004 {
5005 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005006 GEN_ERROR("Binary operator types must match");
5007 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005008 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
5009 ;}
5010 break;
5011
Devang Patel652203f2008-09-29 20:49:50 +00005012 case 204:
5013#line 1971 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005014 {
5015 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005016 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005017 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005018 if (!isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00005019 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005020 GEN_ERROR("Logical operator requires integral operands");
5021 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005022 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005023 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005024 ;}
5025 break;
5026
Devang Patel652203f2008-09-29 20:49:50 +00005027 case 205:
5028#line 1982 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005029 {
5030 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005031 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005032 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5033 ;}
5034 break;
5035
Devang Patel652203f2008-09-29 20:49:50 +00005036 case 206:
5037#line 1987 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005038 {
5039 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005040 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005041 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5042 ;}
5043 break;
5044
Devang Patel652203f2008-09-29 20:49:50 +00005045 case 207:
5046#line 1992 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005047 {
5048 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5049 GEN_ERROR("vicmp operand types must match");
5050 (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5051 ;}
5052 break;
5053
Devang Patel652203f2008-09-29 20:49:50 +00005054 case 208:
5055#line 1997 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005056 {
5057 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5058 GEN_ERROR("vfcmp operand types must match");
5059 (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5060 ;}
5061 break;
5062
Devang Patel652203f2008-09-29 20:49:50 +00005063 case 209:
5064#line 2002 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005065 {
5066 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005067 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005068 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005069 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005070 ;}
5071 break;
5072
Devang Patel652203f2008-09-29 20:49:50 +00005073 case 210:
5074#line 2008 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005075 {
5076 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005077 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005078 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005079 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005080 ;}
5081 break;
5082
Devang Patel652203f2008-09-29 20:49:50 +00005083 case 211:
5084#line 2014 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005085 {
5086 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005087 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005088 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005089 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005090 ;}
5091 break;
5092
Devang Patel652203f2008-09-29 20:49:50 +00005093 case 212:
5094#line 2020 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005095 {
5096 if (!isa<StructType>((yyvsp[(3) - (5)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (5)].ConstVal)->getType()))
5097 GEN_ERROR("ExtractValue requires an aggregate operand");
5098
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005099 (yyval.ConstVal) = ConstantExpr::getExtractValue((yyvsp[(3) - (5)].ConstVal), &(*(yyvsp[(4) - (5)].ConstantList))[0], (yyvsp[(4) - (5)].ConstantList)->size());
5100 delete (yyvsp[(4) - (5)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005101 CHECK_FOR_ERROR
5102 ;}
5103 break;
5104
Devang Patel652203f2008-09-29 20:49:50 +00005105 case 213:
5106#line 2028 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005107 {
5108 if (!isa<StructType>((yyvsp[(3) - (7)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (7)].ConstVal)->getType()))
5109 GEN_ERROR("InsertValue requires an aggregate operand");
5110
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005111 (yyval.ConstVal) = ConstantExpr::getInsertValue((yyvsp[(3) - (7)].ConstVal), (yyvsp[(5) - (7)].ConstVal), &(*(yyvsp[(6) - (7)].ConstantList))[0], (yyvsp[(6) - (7)].ConstantList)->size());
5112 delete (yyvsp[(6) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005113 CHECK_FOR_ERROR
5114 ;}
5115 break;
5116
Devang Patel652203f2008-09-29 20:49:50 +00005117 case 214:
5118#line 2039 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005119 {
5120 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005121 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005122 ;}
5123 break;
5124
Devang Patel652203f2008-09-29 20:49:50 +00005125 case 215:
5126#line 2043 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005127 {
5128 (yyval.ConstVector) = new std::vector<Constant*>();
5129 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005130 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005131 ;}
5132 break;
5133
Devang Patel652203f2008-09-29 20:49:50 +00005134 case 216:
5135#line 2051 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005136 { (yyval.BoolVal) = false; ;}
Nate Begemanac80ade2008-05-12 19:01:56 +00005137 break;
5138
Devang Pateld4980812008-09-02 20:52:40 +00005139 case 217:
Devang Patel652203f2008-09-29 20:49:50 +00005140#line 2051 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005141 { (yyval.BoolVal) = true; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005142 break;
5143
Devang Pateld4980812008-09-02 20:52:40 +00005144 case 218:
Devang Patel652203f2008-09-29 20:49:50 +00005145#line 2054 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
5146 { (yyval.BoolVal) = true; ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00005147 break;
5148
Dale Johannesendfe8c842008-09-26 19:32:34 +00005149 case 219:
Devang Patel652203f2008-09-29 20:49:50 +00005150#line 2054 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
5151 { (yyval.BoolVal) = false; ;}
5152 break;
5153
5154 case 220:
5155#line 2057 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005156 {
5157 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
5158 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00005159 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005160 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
5161 if (!Aliasee)
5162 GEN_ERROR("Aliases can be created only to global values");
5163
Dan Gohmanf4423b12008-04-19 00:24:39 +00005164 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005165 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005166 delete (yyvsp[(1) - (2)].TypeVal);
5167 ;}
5168 break;
5169
Devang Patel652203f2008-09-29 20:49:50 +00005170 case 221:
5171#line 2069 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005172 {
5173 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
5174 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
5175 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005176 GEN_ERROR("invalid cast opcode for cast from '" +
5177 Val->getType()->getDescription() + "' to '" +
5178 DestTy->getDescription() + "'");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005179
Dan Gohmanf4423b12008-04-19 00:24:39 +00005180 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005181 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005182 delete (yyvsp[(5) - (6)].TypeVal);
5183 ;}
5184 break;
5185
Devang Pateld4980812008-09-02 20:52:40 +00005186 case 222:
Devang Patel652203f2008-09-29 20:49:50 +00005187#line 2090 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005188 {
5189 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5190 CurModule.ModuleDone();
5191 CHECK_FOR_ERROR;
5192 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005193 break;
5194
Devang Patel652203f2008-09-29 20:49:50 +00005195 case 223:
5196#line 2095 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
5197 {
5198 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5199 CurModule.ModuleDone();
5200 CHECK_FOR_ERROR;
5201 ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00005202 break;
5203
Dale Johannesendfe8c842008-09-26 19:32:34 +00005204 case 226:
Devang Patel652203f2008-09-29 20:49:50 +00005205#line 2108 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
5206 { CurFun.isDeclare = false; ;}
5207 break;
5208
5209 case 227:
5210#line 2108 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005211 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005212 CurFun.FunctionDone();
5213 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005214 ;}
5215 break;
5216
Devang Patel652203f2008-09-29 20:49:50 +00005217 case 228:
5218#line 2112 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005219 { CurFun.isDeclare = true; ;}
5220 break;
5221
Devang Pateld4980812008-09-02 20:52:40 +00005222 case 229:
Devang Patel652203f2008-09-29 20:49:50 +00005223#line 2112 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005224 {
5225 CHECK_FOR_ERROR
5226 ;}
5227 break;
5228
Devang Pateld4980812008-09-02 20:52:40 +00005229 case 230:
Devang Patel652203f2008-09-29 20:49:50 +00005230#line 2115 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
5231 {
5232 CHECK_FOR_ERROR
5233 ;}
5234 break;
5235
5236 case 231:
5237#line 2118 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005238 {
Reid Spencer14310612006-12-31 05:40:51 +00005239 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005240 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005241 // Eagerly resolve types. This is not an optimization, this is a
5242 // requirement that is due to the fact that we could have this:
5243 //
5244 // %list = type { %list * }
5245 // %list = type { %list * } ; repeated type decl
5246 //
5247 // If types are not resolved eagerly, then the two types will not be
5248 // determined to be the same type!
5249 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00005250 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005251
Dan Gohmanf4423b12008-04-19 00:24:39 +00005252 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00005253 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005254 // If this is a named type that is not a redefinition, add it to the slot
5255 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005256 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005257 }
Reid Spencera132e042006-12-03 05:46:11 +00005258
Dan Gohmanf4423b12008-04-19 00:24:39 +00005259 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005260 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005261 ;}
5262 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00005263
Devang Patel652203f2008-09-29 20:49:50 +00005264 case 232:
5265#line 2142 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005266 {
5267 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
5268
5269 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005270 CHECK_FOR_ERROR
5271 // If this is a named type that is not a redefinition, add it to the slot
5272 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005273 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005274 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005275 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005276 ;}
5277 break;
5278
Devang Patel652203f2008-09-29 20:49:50 +00005279 case 233:
5280#line 2154 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005281 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005282 /* "Externally Visible" Linkage */
Eric Christopher2a5196f2008-09-24 04:55:49 +00005283 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005284 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005285 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5286 (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 +00005287 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005288 ;}
5289 break;
5290
Devang Patel652203f2008-09-29 20:49:50 +00005291 case 234:
5292#line 2161 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005293 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005294 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005295 ;}
5296 break;
5297
Devang Patel652203f2008-09-29 20:49:50 +00005298 case 235:
5299#line 2165 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005300 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005301 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005302 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005303 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 +00005304 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005305 ;}
5306 break;
5307
Devang Patel652203f2008-09-29 20:49:50 +00005308 case 236:
5309#line 2170 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005310 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005311 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005312 ;}
5313 break;
5314
Devang Patel652203f2008-09-29 20:49:50 +00005315 case 237:
5316#line 2174 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005317 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005318 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005319 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5320 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 +00005321 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005322 delete (yyvsp[(6) - (7)].TypeVal);
5323 ;}
5324 break;
5325
Devang Patel652203f2008-09-29 20:49:50 +00005326 case 238:
5327#line 2180 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005328 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005329 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005330 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005331 ;}
5332 break;
5333
Devang Patel652203f2008-09-29 20:49:50 +00005334 case 239:
5335#line 2184 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005336 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005337 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005338 if ((yyvsp[(1) - (5)].StrVal)) {
5339 Name = *(yyvsp[(1) - (5)].StrVal);
5340 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005341 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005342 if (Name.empty())
5343 GEN_ERROR("Alias name cannot be empty");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005344
Dan Gohmanf4423b12008-04-19 00:24:39 +00005345 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005346 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005347 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005348
Dan Gohmanf4423b12008-04-19 00:24:39 +00005349 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005350 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005351 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005352 InsertValue(GA, CurModule.Values);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005353
5354
Chris Lattner569f7372007-09-10 23:24:14 +00005355 // If there was a forward reference of this alias, resolve it now.
Eric Christopher2a5196f2008-09-24 04:55:49 +00005356
Chris Lattner569f7372007-09-10 23:24:14 +00005357 ValID ID;
5358 if (!Name.empty())
5359 ID = ValID::createGlobalName(Name);
5360 else
5361 ID = ValID::createGlobalID(CurModule.Values.size()-1);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005362
Chris Lattner569f7372007-09-10 23:24:14 +00005363 if (GlobalValue *FWGV =
5364 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5365 // Replace uses of the fwdref with the actual alias.
5366 FWGV->replaceAllUsesWith(GA);
5367 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5368 GV->eraseFromParent();
5369 else
5370 cast<Function>(FWGV)->eraseFromParent();
5371 }
5372 ID.destroy();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005373
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005374 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005375 ;}
5376 break;
5377
Chris Lattnerccef6b52008-09-23 21:18:31 +00005378 case 240:
Devang Patel652203f2008-09-29 20:49:50 +00005379#line 2224 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005380 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005381 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005382 ;}
5383 break;
5384
Chris Lattnerccef6b52008-09-23 21:18:31 +00005385 case 241:
Devang Patel652203f2008-09-29 20:49:50 +00005386#line 2227 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
5387 {
5388 CHECK_FOR_ERROR
5389 ;}
5390 break;
5391
5392 case 242:
5393#line 2233 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005394 {
Chris Lattner66316012006-01-24 04:14:29 +00005395 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005396 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005397 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005398 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005399 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5400 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005401 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005402;}
5403 break;
5404
Devang Patel652203f2008-09-29 20:49:50 +00005405 case 243:
5406#line 2243 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005407 {
5408 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5409 delete (yyvsp[(3) - (3)].StrVal);
5410 ;}
5411 break;
5412
Devang Patel652203f2008-09-29 20:49:50 +00005413 case 244:
5414#line 2247 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005415 {
5416 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5417 delete (yyvsp[(3) - (3)].StrVal);
5418 ;}
5419 break;
5420
Devang Patel652203f2008-09-29 20:49:50 +00005421 case 246:
5422#line 2254 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005423 {
5424 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5425 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005426 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005427 ;}
5428 break;
5429
Devang Patel652203f2008-09-29 20:49:50 +00005430 case 247:
5431#line 2259 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005432 {
5433 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5434 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005435 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005436 ;}
5437 break;
5438
Devang Patel652203f2008-09-29 20:49:50 +00005439 case 248:
5440#line 2264 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005441 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005442 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005443 ;}
5444 break;
5445
Devang Patel652203f2008-09-29 20:49:50 +00005446 case 249:
5447#line 2273 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005448 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005449 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005450 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005451 if (!(*(yyvsp[(3) - (5)].TypeVal))->isFirstClassType())
5452 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005453 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].Attributes); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005454 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5455 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005456 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005457 ;}
5458 break;
5459
Devang Patel652203f2008-09-29 20:49:50 +00005460 case 250:
5461#line 2283 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005462 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005463 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005464 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005465 if (!(*(yyvsp[(1) - (3)].TypeVal))->isFirstClassType())
5466 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005467 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].Attributes); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005468 (yyval.ArgList) = new ArgListType;
5469 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005470 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005471 ;}
5472 break;
5473
Devang Patel652203f2008-09-29 20:49:50 +00005474 case 251:
5475#line 2294 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005476 {
5477 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005478 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005479 ;}
5480 break;
5481
Devang Patel652203f2008-09-29 20:49:50 +00005482 case 252:
5483#line 2298 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005484 {
5485 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005486 struct ArgListEntry E;
5487 E.Ty = new PATypeHolder(Type::VoidTy);
5488 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005489 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005490 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005491 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005492 ;}
5493 break;
5494
Devang Patel652203f2008-09-29 20:49:50 +00005495 case 253:
5496#line 2307 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005497 {
5498 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005499 struct ArgListEntry E;
5500 E.Ty = new PATypeHolder(Type::VoidTy);
5501 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005502 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005503 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005504 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005505 ;}
5506 break;
5507
Devang Patel652203f2008-09-29 20:49:50 +00005508 case 254:
5509#line 2316 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005510 {
5511 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005512 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005513 ;}
5514 break;
5515
Devang Patel652203f2008-09-29 20:49:50 +00005516 case 255:
5517#line 2322 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005518 {
Devang Patel652203f2008-09-29 20:49:50 +00005519 std::string FunctionName(*(yyvsp[(4) - (11)].StrVal));
5520 delete (yyvsp[(4) - (11)].StrVal); // Free strdup'd memory!
Eric Christopher2a5196f2008-09-24 04:55:49 +00005521
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005522 // Check the function result for abstractness if this is a define. We should
5523 // have no abstract types at this point
Devang Patel652203f2008-09-29 20:49:50 +00005524 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(3) - (11)].TypeVal)))
5525 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(3) - (11)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005526
Devang Patel652203f2008-09-29 20:49:50 +00005527 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (11)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00005528 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005529
Reid Spencer68a24bd2005-08-27 18:50:39 +00005530 std::vector<const Type*> ParamTypeList;
Devang Patel05988662008-09-25 21:00:45 +00005531 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00005532 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
5533 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00005534 Attributes RetAttrs = (yyvsp[(2) - (11)].Attributes);
5535 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None) {
5536 if ((yyvsp[(8) - (11)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005537 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00005538 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005539 }
Devang Patel652203f2008-09-29 20:49:50 +00005540 if ((yyvsp[(8) - (11)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005541 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00005542 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005543 }
Devang Patel652203f2008-09-29 20:49:50 +00005544 if ((yyvsp[(8) - (11)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00005545 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00005546 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00005547 }
Dale Johannesene7261862008-09-26 23:46:20 +00005548 }
Devang Patel652203f2008-09-29 20:49:50 +00005549 if (RetAttrs != Attribute::None)
5550 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
5551 if ((yyvsp[(6) - (11)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005552 unsigned index = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005553 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin(); I != (yyvsp[(6) - (11)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005554 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005555 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5556 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005557 ParamTypeList.push_back(Ty);
Devang Patel05988662008-09-25 21:00:45 +00005558 if (Ty != Type::VoidTy && I->Attrs != Attribute::None)
5559 Attrs.push_back(AttributeWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005560 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005561 }
Devang Patel652203f2008-09-29 20:49:50 +00005562 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None)
5563 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(8) - (11)].Attributes)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005564
5565 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5566 if (isVarArg) ParamTypeList.pop_back();
5567
Devang Patel05988662008-09-25 21:00:45 +00005568 AttrListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005569 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00005570 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005571
Devang Patel652203f2008-09-29 20:49:50 +00005572 FunctionType *FT = FunctionType::get(*(yyvsp[(3) - (11)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005573 const PointerType *PFT = PointerType::getUnqual(FT);
Devang Patel652203f2008-09-29 20:49:50 +00005574 delete (yyvsp[(3) - (11)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005575
5576 ValID ID;
5577 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005578 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005579 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005580 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005581 }
5582
5583 Function *Fn = 0;
5584 // See if this function was forward referenced. If so, recycle the object.
5585 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005586 // Move the function to the end of the list, from whereever it was
Reid Spencer68a24bd2005-08-27 18:50:39 +00005587 // previously inserted.
5588 Fn = cast<Function>(FWRef);
Devang Patel05988662008-09-25 21:00:45 +00005589 assert(Fn->getAttributes().isEmpty() &&
Chris Lattner58d74912008-03-12 17:45:29 +00005590 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005591 CurModule.CurrentModule->getFunctionList().remove(Fn);
5592 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5593 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005594 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005595 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005596 // The existing function doesn't have the same type. This is an overload
5597 // error.
5598 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Devang Patel05988662008-09-25 21:00:45 +00005599 } else if (Fn->getAttributes() != PAL) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005600 // The existing function doesn't have the same parameter attributes.
5601 // This is an overload error.
5602 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005603 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005604 // Neither the existing or the current function is a declaration and they
5605 // have the same name and same type. Clearly this is a redefinition.
5606 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005607 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005608 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005609 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5610 AI != AE; ++AI)
5611 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005612 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005613 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005614 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5615 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005616 InsertValue(Fn, CurModule.Values);
5617 }
5618
5619 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005620
5621 if (CurFun.isDeclare) {
5622 // If we have declaration, always overwrite linkage. This will allow us to
5623 // correctly handle cases, when pointer to function is passed as argument to
5624 // another function.
5625 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005626 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005627 }
Devang Pateld4980812008-09-02 20:52:40 +00005628 Fn->setCallingConv((yyvsp[(1) - (11)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00005629 Fn->setAttributes(PAL);
Devang Patel652203f2008-09-29 20:49:50 +00005630 Fn->setAlignment((yyvsp[(10) - (11)].UIntVal));
5631 if ((yyvsp[(9) - (11)].StrVal)) {
5632 Fn->setSection(*(yyvsp[(9) - (11)].StrVal));
5633 delete (yyvsp[(9) - (11)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005634 }
Devang Patel652203f2008-09-29 20:49:50 +00005635 if ((yyvsp[(11) - (11)].StrVal)) {
5636 Fn->setGC((yyvsp[(11) - (11)].StrVal)->c_str());
5637 delete (yyvsp[(11) - (11)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005638 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005639
5640 // Add all of the arguments we parsed to the function...
Devang Patel652203f2008-09-29 20:49:50 +00005641 if ((yyvsp[(6) - (11)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005642 if (isVarArg) { // Nuke the last entry
Devang Patel652203f2008-09-29 20:49:50 +00005643 assert((yyvsp[(6) - (11)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(6) - (11)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005644 "Not a varargs marker!");
Devang Patel652203f2008-09-29 20:49:50 +00005645 delete (yyvsp[(6) - (11)].ArgList)->back().Ty;
5646 (yyvsp[(6) - (11)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005647 }
5648 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005649 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005650 unsigned Idx = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005651 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin();
5652 I != (yyvsp[(6) - (11)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005653 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005654 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005655 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005656 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005657 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005658 }
Reid Spencera132e042006-12-03 05:46:11 +00005659
Devang Patel652203f2008-09-29 20:49:50 +00005660 delete (yyvsp[(6) - (11)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005661 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005662 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005663;}
5664 break;
5665
Devang Patel652203f2008-09-29 20:49:50 +00005666 case 258:
5667#line 2471 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005668 {
5669 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005670
5671 // Make sure that we keep track of the linkage type even if there was a
5672 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005673 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5674 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5675;}
5676 break;
5677
Devang Patel652203f2008-09-29 20:49:50 +00005678 case 261:
5679#line 2482 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005680 {
5681 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005682 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005683;}
5684 break;
5685
Devang Patel652203f2008-09-29 20:49:50 +00005686 case 262:
5687#line 2487 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005688 {
5689 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5690 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5691 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005692 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005693 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005694 ;}
5695 break;
5696
Devang Patel652203f2008-09-29 20:49:50 +00005697 case 263:
5698#line 2499 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005699 {
5700 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005701 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005702 ;}
5703 break;
5704
Devang Patel652203f2008-09-29 20:49:50 +00005705 case 264:
5706#line 2503 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005707 {
5708 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005709 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005710 ;}
5711 break;
5712
Devang Patel652203f2008-09-29 20:49:50 +00005713 case 265:
5714#line 2508 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005715 { // A reference to a direct constant
5716 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005717 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005718 ;}
5719 break;
5720
Devang Patel652203f2008-09-29 20:49:50 +00005721 case 266:
5722#line 2512 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005723 {
5724 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005725 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005726 ;}
5727 break;
5728
Devang Patel652203f2008-09-29 20:49:50 +00005729 case 267:
5730#line 2516 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005731 { // arbitrary precision integer constants
5732 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), true);
5733 delete (yyvsp[(1) - (1)].APIntVal);
5734 CHECK_FOR_ERROR
5735 ;}
5736 break;
5737
Devang Patel652203f2008-09-29 20:49:50 +00005738 case 268:
5739#line 2521 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005740 { // arbitrary precision integer constants
5741 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), false);
5742 delete (yyvsp[(1) - (1)].APIntVal);
5743 CHECK_FOR_ERROR
5744 ;}
5745 break;
5746
Devang Patel652203f2008-09-29 20:49:50 +00005747 case 269:
5748#line 2526 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005749 { // Perhaps it's an FP constant?
5750 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005751 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005752 ;}
5753 break;
5754
Devang Patel652203f2008-09-29 20:49:50 +00005755 case 270:
5756#line 2530 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005757 {
5758 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005759 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005760 ;}
5761 break;
5762
Devang Patel652203f2008-09-29 20:49:50 +00005763 case 271:
5764#line 2534 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005765 {
5766 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005767 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005768 ;}
5769 break;
5770
Devang Patel652203f2008-09-29 20:49:50 +00005771 case 272:
5772#line 2538 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005773 {
5774 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005775 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005776 ;}
5777 break;
5778
Devang Patel652203f2008-09-29 20:49:50 +00005779 case 273:
5780#line 2542 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005781 {
5782 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005783 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005784 ;}
5785 break;
5786
Devang Patel652203f2008-09-29 20:49:50 +00005787 case 274:
5788#line 2546 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005789 { // A vector zero constant.
5790 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005791 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005792 ;}
5793 break;
5794
Devang Patel652203f2008-09-29 20:49:50 +00005795 case 275:
5796#line 2550 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005797 { // Nonempty unsized packed vector
5798 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005799 unsigned NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005800
5801 if (!ETy->isInteger() && !ETy->isFloatingPoint())
5802 GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005803
Reid Spencer9d6565a2007-02-15 02:26:10 +00005804 VectorType* pt = VectorType::get(ETy, NumElements);
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005805 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
Eric Christopher2a5196f2008-09-24 04:55:49 +00005806
Reid Spencer68a24bd2005-08-27 18:50:39 +00005807 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005808 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5809 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005810 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005811 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005812 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005813 }
5814
Dan Gohmanf4423b12008-04-19 00:24:39 +00005815 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5816 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005817 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005818 ;}
5819 break;
5820
Devang Patel652203f2008-09-29 20:49:50 +00005821 case 276:
5822#line 2572 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005823 { // Nonempty unsized arr
5824 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005825 uint64_t NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005826
5827 if (!ETy->isFirstClassType())
5828 GEN_ERROR("Invalid array element type: " + ETy->getDescription());
5829
5830 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5831 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
5832
5833 // Verify all elements are correct type!
5834 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5835 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005836 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005837 ETy->getDescription() +"' as required!\nIt is of type '"+
5838 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
5839 }
5840
5841 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, *(yyvsp[(2) - (3)].ConstVector)));
5842 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5843 CHECK_FOR_ERROR
5844 ;}
5845 break;
5846
Devang Patel652203f2008-09-29 20:49:50 +00005847 case 277:
5848#line 2594 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005849 {
Dan Gohman180c1692008-06-23 18:43:26 +00005850 // Use undef instead of an array because it's inconvenient to determine
5851 // the element type at this point, there being no elements to examine.
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005852 (yyval.ValIDVal) = ValID::createUndef();
5853 CHECK_FOR_ERROR
5854 ;}
5855 break;
5856
Devang Patel652203f2008-09-29 20:49:50 +00005857 case 278:
5858#line 2600 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005859 {
Dan Gohman180c1692008-06-23 18:43:26 +00005860 uint64_t NumElements = (yyvsp[(2) - (2)].StrVal)->length();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005861 const Type *ETy = Type::Int8Ty;
5862
5863 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5864
5865 std::vector<Constant*> Vals;
5866 for (unsigned i = 0; i < (yyvsp[(2) - (2)].StrVal)->length(); ++i)
5867 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(2) - (2)].StrVal))[i]));
5868 delete (yyvsp[(2) - (2)].StrVal);
5869 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, Vals));
5870 CHECK_FOR_ERROR
5871 ;}
5872 break;
5873
Devang Patel652203f2008-09-29 20:49:50 +00005874 case 279:
5875#line 2613 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005876 {
5877 std::vector<const Type*> Elements((yyvsp[(2) - (3)].ConstVector)->size());
5878 for (unsigned i = 0, e = (yyvsp[(2) - (3)].ConstVector)->size(); i != e; ++i)
5879 Elements[i] = (*(yyvsp[(2) - (3)].ConstVector))[i]->getType();
5880
5881 const StructType *STy = StructType::get(Elements);
5882 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5883
5884 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(2) - (3)].ConstVector)));
5885 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5886 CHECK_FOR_ERROR
5887 ;}
5888 break;
5889
Devang Patel652203f2008-09-29 20:49:50 +00005890 case 280:
5891#line 2625 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005892 {
5893 const StructType *STy = StructType::get(std::vector<const Type*>());
5894 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5895 CHECK_FOR_ERROR
5896 ;}
5897 break;
5898
Devang Patel652203f2008-09-29 20:49:50 +00005899 case 281:
5900#line 2630 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005901 {
5902 std::vector<const Type*> Elements((yyvsp[(3) - (5)].ConstVector)->size());
5903 for (unsigned i = 0, e = (yyvsp[(3) - (5)].ConstVector)->size(); i != e; ++i)
5904 Elements[i] = (*(yyvsp[(3) - (5)].ConstVector))[i]->getType();
5905
5906 const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
5907 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5908
5909 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(3) - (5)].ConstVector)));
5910 delete PTy; delete (yyvsp[(3) - (5)].ConstVector);
5911 CHECK_FOR_ERROR
5912 ;}
5913 break;
5914
Devang Patel652203f2008-09-29 20:49:50 +00005915 case 282:
5916#line 2642 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005917 {
5918 const StructType *STy = StructType::get(std::vector<const Type*>(),
5919 /*isPacked=*/true);
5920 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5921 CHECK_FOR_ERROR
5922 ;}
5923 break;
5924
Devang Patel652203f2008-09-29 20:49:50 +00005925 case 283:
5926#line 2648 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005927 {
5928 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005929 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005930 ;}
5931 break;
5932
Devang Patel652203f2008-09-29 20:49:50 +00005933 case 284:
5934#line 2652 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005935 {
5936 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5937 delete (yyvsp[(3) - (5)].StrVal);
5938 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005939 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005940 ;}
5941 break;
5942
Devang Patel652203f2008-09-29 20:49:50 +00005943 case 285:
5944#line 2662 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005945 { // Is it an integer reference...?
5946 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005947 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005948 ;}
5949 break;
5950
Devang Patel652203f2008-09-29 20:49:50 +00005951 case 286:
5952#line 2666 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005953 {
5954 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005955 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005956 ;}
5957 break;
5958
Devang Patel652203f2008-09-29 20:49:50 +00005959 case 287:
5960#line 2670 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005961 { // Is it a named reference...?
5962 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5963 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005964 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005965 ;}
5966 break;
5967
Devang Patel652203f2008-09-29 20:49:50 +00005968 case 288:
5969#line 2675 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005970 { // Is it a named reference...?
5971 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5972 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005973 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005974 ;}
5975 break;
5976
Devang Patel652203f2008-09-29 20:49:50 +00005977 case 291:
5978#line 2688 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005979 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005980 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005981 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005982 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00005983 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005984 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005985 ;}
5986 break;
5987
Devang Patel652203f2008-09-29 20:49:50 +00005988 case 292:
5989#line 2697 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005990 {
5991 (yyval.ValueList) = new std::vector<Value *>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005992 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005993 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005994 ;}
5995 break;
5996
Devang Patel652203f2008-09-29 20:49:50 +00005997 case 293:
5998#line 2702 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005999 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006000 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00006001 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006002 ;}
6003 break;
6004
Devang Patel652203f2008-09-29 20:49:50 +00006005 case 294:
6006#line 2707 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006007 {
6008 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006009 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006010 ;}
6011 break;
6012
Devang Patel652203f2008-09-29 20:49:50 +00006013 case 295:
6014#line 2711 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006015 { // Do not allow functions with 0 basic blocks
Dan Gohmanf4423b12008-04-19 00:24:39 +00006016 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006017 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006018 ;}
6019 break;
6020
Devang Patel652203f2008-09-29 20:49:50 +00006021 case 296:
6022#line 2720 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006023 {
6024 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006025 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006026 InsertValue((yyvsp[(3) - (3)].TermInstVal));
6027 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6028 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006029 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006030 ;}
6031 break;
6032
Devang Patel652203f2008-09-29 20:49:50 +00006033 case 297:
6034#line 2729 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006035 {
6036 CHECK_FOR_ERROR
6037 int ValNum = InsertValue((yyvsp[(3) - (3)].TermInstVal));
6038 if (ValNum != (int)(yyvsp[(2) - (3)].UIntVal))
6039 GEN_ERROR("Result value number %" + utostr((yyvsp[(2) - (3)].UIntVal)) +
6040 " is incorrect, expected %" + utostr((unsigned)ValNum));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006041
Chris Lattner15bd0952008-08-29 17:20:18 +00006042 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6043 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
6044 CHECK_FOR_ERROR
6045;}
6046 break;
6047
Devang Patel652203f2008-09-29 20:49:50 +00006048 case 298:
6049#line 2742 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006050 {
6051 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006052 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
6053 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00006054 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
6055 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
6056 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006057 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006058 ;}
6059 break;
Chris Lattner38905612008-02-19 04:36:25 +00006060
Devang Patel652203f2008-09-29 20:49:50 +00006061 case 299:
6062#line 2751 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006063 { // Empty space between instruction lists
Chris Lattnercc81d152008-05-04 17:18:47 +00006064 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006065 CHECK_FOR_ERROR
6066 ;}
6067 break;
6068
Devang Patel652203f2008-09-29 20:49:50 +00006069 case 300:
6070#line 2755 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnercc81d152008-05-04 17:18:47 +00006071 { // Labelled (named) basic block
6072 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
6073 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006074 CHECK_FOR_ERROR
Chris Lattnercc81d152008-05-04 17:18:47 +00006075
Dan Gohmanf4423b12008-04-19 00:24:39 +00006076 ;}
6077 break;
6078
Devang Patel652203f2008-09-29 20:49:50 +00006079 case 301:
6080#line 2763 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006081 { // Return with a result...
6082 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
6083 assert(!VL.empty() && "Invalid ret operands!");
Dan Gohman1a570242008-07-23 00:54:54 +00006084 const Type *ReturnType = CurFun.CurrentFunction->getReturnType();
6085 if (VL.size() > 1 ||
6086 (isa<StructType>(ReturnType) &&
6087 (VL.empty() || VL[0]->getType() != ReturnType))) {
6088 Value *RV = UndefValue::get(ReturnType);
6089 for (unsigned i = 0, e = VL.size(); i != e; ++i) {
6090 Instruction *I = InsertValueInst::Create(RV, VL[i], i, "mrv");
6091 ((yyvsp[(-1) - (2)].BasicBlockVal))->getInstList().push_back(I);
6092 RV = I;
6093 }
6094 (yyval.TermInstVal) = ReturnInst::Create(RV);
6095 } else {
6096 (yyval.TermInstVal) = ReturnInst::Create(VL[0]);
6097 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006098 delete (yyvsp[(2) - (2)].ValueList);
6099 CHECK_FOR_ERROR
6100 ;}
6101 break;
6102
Devang Patel652203f2008-09-29 20:49:50 +00006103 case 302:
6104#line 2783 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006105 { // Return with no result...
6106 (yyval.TermInstVal) = ReturnInst::Create();
6107 CHECK_FOR_ERROR
6108 ;}
6109 break;
6110
Devang Patel652203f2008-09-29 20:49:50 +00006111 case 303:
6112#line 2787 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006113 { // Unconditional Branch...
6114 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6115 CHECK_FOR_ERROR
6116 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
6117 ;}
6118 break;
6119
Devang Patel652203f2008-09-29 20:49:50 +00006120 case 304:
6121#line 2792 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006122 {
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006123 if (cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() != 1)
6124 GEN_ERROR("Branch condition must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006125 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6126 CHECK_FOR_ERROR
6127 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6128 CHECK_FOR_ERROR
6129 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6130 CHECK_FOR_ERROR
6131 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
6132 ;}
6133 break;
6134
Devang Patel652203f2008-09-29 20:49:50 +00006135 case 305:
6136#line 2803 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006137 {
6138 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
6139 CHECK_FOR_ERROR
6140 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6141 CHECK_FOR_ERROR
6142 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6143 (yyval.TermInstVal) = S;
6144
6145 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6146 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00006147 for (; I != E; ++I) {
6148 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6149 S->addCase(CI, I->second);
6150 else
Reid Spencerb5334b02007-02-05 10:18:06 +00006151 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006152 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006153 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00006154 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006155 ;}
6156 break;
6157
Devang Patel652203f2008-09-29 20:49:50 +00006158 case 306:
6159#line 2822 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006160 {
6161 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006162 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006163 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006164 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00006165 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006166 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006167 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006168 ;}
6169 break;
6170
Devang Patel652203f2008-09-29 20:49:50 +00006171 case 307:
6172#line 2832 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006173 {
Reid Spencer3822ff52006-11-08 06:47:33 +00006174
Reid Spencer14310612006-12-31 05:40:51 +00006175 // Handle the short syntax
6176 const PointerType *PFTy = 0;
6177 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006178 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (15)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00006179 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6180 // Pull out the types of all of the arguments...
6181 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006182 ParamList::iterator I = (yyvsp[(7) - (15)].ParamList)->begin(), E = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006183 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006184 const Type *Ty = I->Val->getType();
6185 if (Ty == Type::VoidTy)
6186 GEN_ERROR("Short call syntax cannot be used with varargs");
6187 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006188 }
Eric Christopher2a5196f2008-09-24 04:55:49 +00006189
Devang Patel652203f2008-09-29 20:49:50 +00006190 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (15)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006191 GEN_ERROR("Invalid result type for LLVM function");
6192
Devang Patel652203f2008-09-29 20:49:50 +00006193 Ty = FunctionType::get((yyvsp[(4) - (15)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006194 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006195 }
6196
Devang Patel652203f2008-09-29 20:49:50 +00006197 delete (yyvsp[(4) - (15)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00006198
Devang Patel652203f2008-09-29 20:49:50 +00006199 Value *V = getVal(PFTy, (yyvsp[(5) - (15)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006200 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006201 BasicBlock *Normal = getBBVal((yyvsp[(12) - (15)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006202 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006203 BasicBlock *Except = getBBVal((yyvsp[(15) - (15)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00006204 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00006205
Devang Patel05988662008-09-25 21:00:45 +00006206 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006207 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6208 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006209 Attributes RetAttrs = (yyvsp[(3) - (15)].Attributes);
6210 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None) {
6211 if ((yyvsp[(9) - (15)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006212 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006213 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006214 }
Devang Patel652203f2008-09-29 20:49:50 +00006215 if ((yyvsp[(9) - (15)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006216 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006217 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006218 }
Devang Patel652203f2008-09-29 20:49:50 +00006219 if ((yyvsp[(9) - (15)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006220 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006221 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006222 }
Dale Johannesene7261862008-09-26 23:46:20 +00006223 }
Devang Patel652203f2008-09-29 20:49:50 +00006224 if (RetAttrs != Attribute::None)
6225 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006226
Reid Spencer14310612006-12-31 05:40:51 +00006227 // Check the arguments
6228 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006229 if ((yyvsp[(7) - (15)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00006230 // Make sure no arguments is a good thing!
6231 if (Ty->getNumParams() != 0)
6232 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006233 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006234 } else { // Has arguments?
6235 // Loop through FunctionType's arguments and ensure they are specified
6236 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00006237 FunctionType::param_iterator I = Ty->param_begin();
6238 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006239 ParamList::iterator ArgI = (yyvsp[(7) - (15)].ParamList)->begin(), ArgE = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006240 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006241
Duncan Sandsdc024672007-11-27 13:23:08 +00006242 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006243 if (ArgI->Val->getType() != *I)
6244 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006245 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006246 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006247 if (ArgI->Attrs != Attribute::None)
6248 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006249 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00006250
Reid Spencer14310612006-12-31 05:40:51 +00006251 if (Ty->isVarArg()) {
6252 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006253 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006254 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006255 if (ArgI->Attrs != Attribute::None)
6256 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006257 }
Reid Spencer14310612006-12-31 05:40:51 +00006258 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006259 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006260 }
Devang Patel652203f2008-09-29 20:49:50 +00006261 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None)
6262 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (15)].Attributes)));
Devang Patel05988662008-09-25 21:00:45 +00006263 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006264 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006265 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006266
Reid Spencer14310612006-12-31 05:40:51 +00006267 // Create the InvokeInst
Dan Gohman041e2eb2008-05-15 19:50:34 +00006268 InvokeInst *II = InvokeInst::Create(V, Normal, Except,
6269 Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006270 II->setCallingConv((yyvsp[(2) - (15)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006271 II->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006272 (yyval.TermInstVal) = II;
Devang Patel652203f2008-09-29 20:49:50 +00006273 delete (yyvsp[(7) - (15)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006274 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006275 ;}
6276 break;
6277
Devang Patel652203f2008-09-29 20:49:50 +00006278 case 308:
6279#line 2935 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006280 {
6281 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006282 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006283 ;}
6284 break;
6285
Devang Patel652203f2008-09-29 20:49:50 +00006286 case 309:
6287#line 2939 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006288 {
6289 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006290 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006291 ;}
6292 break;
6293
Devang Patel652203f2008-09-29 20:49:50 +00006294 case 310:
6295#line 2946 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006296 {
6297 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6298 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006299 CHECK_FOR_ERROR
6300 if (V == 0)
6301 GEN_ERROR("May only switch on a constant pool value");
6302
Dan Gohmanf4423b12008-04-19 00:24:39 +00006303 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006304 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006305 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6306 ;}
6307 break;
6308
Devang Patel652203f2008-09-29 20:49:50 +00006309 case 311:
6310#line 2957 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006311 {
6312 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6313 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006314 CHECK_FOR_ERROR
6315
6316 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00006317 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006318
Dan Gohmanf4423b12008-04-19 00:24:39 +00006319 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006320 CHECK_FOR_ERROR
Eric Christopher2a5196f2008-09-24 04:55:49 +00006321 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006322 ;}
6323 break;
6324
Devang Patel652203f2008-09-29 20:49:50 +00006325 case 312:
6326#line 2970 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006327 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006328 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00006329 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006330 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006331 InsertValue((yyvsp[(2) - (2)].InstVal));
6332 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006333 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006334 ;}
6335 break;
6336
Devang Patel652203f2008-09-29 20:49:50 +00006337 case 313:
6338#line 2979 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006339 {
6340 CHECK_FOR_ERROR
6341 int ValNum = InsertValue((yyvsp[(2) - (2)].InstVal));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006342
Chris Lattner15bd0952008-08-29 17:20:18 +00006343 if (ValNum != (int)(yyvsp[(1) - (2)].UIntVal))
6344 GEN_ERROR("Result value number %" + utostr((yyvsp[(1) - (2)].UIntVal)) +
6345 " is incorrect, expected %" + utostr((unsigned)ValNum));
6346
6347 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6348 CHECK_FOR_ERROR
6349 ;}
6350 break;
6351
Devang Patel652203f2008-09-29 20:49:50 +00006352 case 314:
6353#line 2992 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006354 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006355 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006356 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
6357 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
6358 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00006359 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006360 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006361 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006362 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6363 delete (yyvsp[(1) - (6)].TypeVal);
6364 ;}
6365 break;
6366
Devang Patel652203f2008-09-29 20:49:50 +00006367 case 315:
6368#line 3003 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006369 {
6370 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6371 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006372 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006373 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006374 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006375 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6376 ;}
6377 break;
6378
Devang Patel652203f2008-09-29 20:49:50 +00006379 case 316:
6380#line 3013 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006381 {
Devang Patel05988662008-09-25 21:00:45 +00006382 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006383 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006384 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006385 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00006386 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006387 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].Attributes) | (yyvsp[(4) - (4)].Attributes); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006388 (yyval.ParamList)->push_back(E);
6389 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00006390 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006391 ;}
6392 break;
6393
Devang Patel652203f2008-09-29 20:49:50 +00006394 case 317:
6395#line 3024 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006396 {
Devang Patel05988662008-09-25 21:00:45 +00006397 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006398 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00006399 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006400 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].Attributes) | (yyvsp[(4) - (4)].Attributes); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006401 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00006402 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006403 ;}
6404 break;
6405
Devang Patel652203f2008-09-29 20:49:50 +00006406 case 318:
6407#line 3032 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006408 {
Devang Patel05988662008-09-25 21:00:45 +00006409 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006410 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006411 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6412 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006413 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].Attributes) | (yyvsp[(6) - (6)].Attributes); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006414 (yyval.ParamList)->push_back(E);
6415 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006416 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006417 ;}
6418 break;
6419
Devang Patel652203f2008-09-29 20:49:50 +00006420 case 319:
6421#line 3042 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006422 {
Devang Patel05988662008-09-25 21:00:45 +00006423 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00006424 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006425 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].Attributes) | (yyvsp[(6) - (6)].Attributes); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006426 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006427 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006428 ;}
6429 break;
6430
Devang Patel652203f2008-09-29 20:49:50 +00006431 case 320:
6432#line 3049 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006433 { (yyval.ParamList) = new ParamList(); ;}
6434 break;
6435
Devang Patel652203f2008-09-29 20:49:50 +00006436 case 321:
6437#line 3052 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006438 { (yyval.ValueList) = new std::vector<Value*>(); ;}
6439 break;
6440
Devang Patel652203f2008-09-29 20:49:50 +00006441 case 322:
6442#line 3053 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006443 {
6444 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6445 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00006446 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006447 ;}
6448 break;
6449
Devang Patel652203f2008-09-29 20:49:50 +00006450 case 323:
6451#line 3061 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006452 {
6453 (yyval.ConstantList) = new std::vector<unsigned>();
6454 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
6455 GEN_ERROR("Index " + utostr((yyvsp[(2) - (2)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6456 (yyval.ConstantList)->push_back((yyvsp[(2) - (2)].UInt64Val));
6457 ;}
6458 break;
6459
Devang Patel652203f2008-09-29 20:49:50 +00006460 case 324:
6461#line 3067 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006462 {
6463 (yyval.ConstantList) = (yyvsp[(1) - (3)].ConstantList);
6464 if ((unsigned)(yyvsp[(3) - (3)].UInt64Val) != (yyvsp[(3) - (3)].UInt64Val))
6465 GEN_ERROR("Index " + utostr((yyvsp[(3) - (3)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6466 (yyval.ConstantList)->push_back((yyvsp[(3) - (3)].UInt64Val));
6467 CHECK_FOR_ERROR
6468 ;}
6469 break;
6470
Devang Patel652203f2008-09-29 20:49:50 +00006471 case 325:
6472#line 3076 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006473 {
6474 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006475 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006476 ;}
6477 break;
6478
Devang Patel652203f2008-09-29 20:49:50 +00006479 case 326:
6480#line 3080 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006481 {
6482 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006483 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006484 ;}
6485 break;
6486
Devang Patel652203f2008-09-29 20:49:50 +00006487 case 327:
6488#line 3085 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006489 {
Reid Spencer14310612006-12-31 05:40:51 +00006490 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006491 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006492 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
Dan Gohmanf4423b12008-04-19 00:24:39 +00006493 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006494 GEN_ERROR(
6495 "Arithmetic operator requires integer, FP, or packed operands");
Eric Christopher2a5196f2008-09-24 04:55:49 +00006496 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006497 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006498 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006499 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006500 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006501 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006502 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006503 delete (yyvsp[(2) - (5)].TypeVal);
6504 ;}
6505 break;
6506
Devang Patel652203f2008-09-29 20:49:50 +00006507 case 328:
6508#line 3101 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006509 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006510 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006511 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6512 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
Nate Begeman5bc1ea02008-07-29 15:49:41 +00006513 if (!isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00006514 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006515 GEN_ERROR("Logical operator requires integral operands");
6516 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006517 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006518 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006519 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006520 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006521 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006522 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006523 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006524 delete (yyvsp[(2) - (5)].TypeVal);
6525 ;}
6526 break;
6527
Devang Patel652203f2008-09-29 20:49:50 +00006528 case 329:
6529#line 3118 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006530 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006531 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006532 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006533 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006534 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006535 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006536 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006537 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006538 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006539 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006540 delete (yyvsp[(3) - (6)].TypeVal);
6541 ;}
6542 break;
6543
Devang Patel652203f2008-09-29 20:49:50 +00006544 case 330:
6545#line 3130 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006546 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006547 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006548 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006549 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006550 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006551 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006552 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006553 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006554 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006555 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006556 delete (yyvsp[(3) - (6)].TypeVal);
6557 ;}
6558 break;
6559
Devang Patel652203f2008-09-29 20:49:50 +00006560 case 331:
6561#line 3142 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006562 {
6563 if (!UpRefs.empty())
6564 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6565 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6566 GEN_ERROR("Scalar types not supported by vicmp instruction");
6567 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6568 CHECK_FOR_ERROR
6569 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6570 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006571 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006572 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006573 GEN_ERROR("vicmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006574 delete (yyvsp[(3) - (6)].TypeVal);
6575 ;}
6576 break;
6577
Devang Patel652203f2008-09-29 20:49:50 +00006578 case 332:
6579#line 3156 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006580 {
6581 if (!UpRefs.empty())
6582 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6583 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6584 GEN_ERROR("Scalar types not supported by vfcmp instruction");
6585 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6586 CHECK_FOR_ERROR
6587 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6588 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006589 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006590 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006591 GEN_ERROR("vfcmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006592 delete (yyvsp[(3) - (6)].TypeVal);
6593 ;}
6594 break;
6595
Devang Patel652203f2008-09-29 20:49:50 +00006596 case 333:
6597#line 3170 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006598 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006599 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006600 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6601 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6602 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6603 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006604 GEN_ERROR("invalid cast opcode for cast from '" +
6605 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00006606 DestTy->getDescription() + "'");
Dan Gohmane4977cf2008-05-23 01:55:30 +00006607 (yyval.InstVal) = CastInst::Create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006608 delete (yyvsp[(4) - (4)].TypeVal);
6609 ;}
6610 break;
6611
Devang Patel652203f2008-09-29 20:49:50 +00006612 case 334:
6613#line 3182 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006614 {
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006615 if (isa<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType())) {
6616 // vector select
6617 if (!isa<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType())
6618 || !isa<VectorType>((yyvsp[(6) - (6)].ValueVal)->getType()) )
6619 GEN_ERROR("vector select value types must be vector types");
6620 const VectorType* cond_type = cast<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType());
6621 const VectorType* select_type = cast<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType());
6622 if (cond_type->getElementType() != Type::Int1Ty)
6623 GEN_ERROR("vector select condition element type must be boolean");
6624 if (cond_type->getNumElements() != select_type->getNumElements())
6625 GEN_ERROR("vector select number of elements must be the same");
6626 } else {
6627 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
6628 GEN_ERROR("select condition must be boolean");
6629 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006630 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006631 GEN_ERROR("select value types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006632 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006633 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006634 ;}
6635 break;
6636
Devang Patel652203f2008-09-29 20:49:50 +00006637 case 335:
6638#line 3203 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006639 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006640 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006641 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6642 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6643 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006644 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006645 ;}
6646 break;
6647
Devang Patel652203f2008-09-29 20:49:50 +00006648 case 336:
6649#line 3210 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006650 {
6651 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006652 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006653 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006654 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006655 ;}
6656 break;
6657
Devang Patel652203f2008-09-29 20:49:50 +00006658 case 337:
6659#line 3216 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006660 {
6661 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006662 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006663 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006664 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006665 ;}
6666 break;
6667
Devang Patel652203f2008-09-29 20:49:50 +00006668 case 338:
6669#line 3222 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006670 {
6671 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006672 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006673 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006674 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006675 ;}
6676 break;
6677
Devang Patel652203f2008-09-29 20:49:50 +00006678 case 339:
6679#line 3228 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006680 {
6681 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006682 if (!Ty->isFirstClassType())
6683 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006684 (yyval.InstVal) = PHINode::Create(Ty);
6685 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6686 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006687 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006688 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006689 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6690 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006691 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006692 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006693 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006694 ;}
6695 break;
6696
Devang Patel652203f2008-09-29 20:49:50 +00006697 case 340:
6698#line 3244 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006699 {
Reid Spencer14310612006-12-31 05:40:51 +00006700
6701 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006702 const PointerType *PFTy = 0;
6703 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006704 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (9)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006705 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6706 // Pull out the types of all of the arguments...
6707 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006708 ParamList::iterator I = (yyvsp[(7) - (9)].ParamList)->begin(), E = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006709 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006710 const Type *Ty = I->Val->getType();
6711 if (Ty == Type::VoidTy)
6712 GEN_ERROR("Short call syntax cannot be used with varargs");
6713 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006714 }
Chris Lattnera925a142008-04-23 05:37:08 +00006715
Devang Patel652203f2008-09-29 20:49:50 +00006716 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (9)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006717 GEN_ERROR("Invalid result type for LLVM function");
6718
Devang Patel652203f2008-09-29 20:49:50 +00006719 Ty = FunctionType::get((yyvsp[(4) - (9)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006720 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006721 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006722
Devang Patel652203f2008-09-29 20:49:50 +00006723 Value *V = getVal(PFTy, (yyvsp[(5) - (9)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006724 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006725
Reid Spencer7780acb2007-04-16 06:56:07 +00006726 // Check for call to invalid intrinsic to avoid crashing later.
6727 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006728 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006729 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6730 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006731 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6732 theF->getName() + "'");
6733 }
6734
Devang Patel05988662008-09-25 21:00:45 +00006735 // Set up the Attributes for the function
6736 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006737 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6738 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006739 Attributes RetAttrs = (yyvsp[(3) - (9)].Attributes);
6740 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None) {
6741 if ((yyvsp[(9) - (9)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006742 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006743 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006744 }
Devang Patel652203f2008-09-29 20:49:50 +00006745 if ((yyvsp[(9) - (9)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006746 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006747 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006748 }
Devang Patel652203f2008-09-29 20:49:50 +00006749 if ((yyvsp[(9) - (9)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006750 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006751 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006752 }
Dale Johannesene7261862008-09-26 23:46:20 +00006753 }
Devang Patel652203f2008-09-29 20:49:50 +00006754 if (RetAttrs != Attribute::None)
6755 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006756
Eric Christopher2a5196f2008-09-24 04:55:49 +00006757 // Check the arguments
Reid Spencer14310612006-12-31 05:40:51 +00006758 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006759 if ((yyvsp[(7) - (9)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006760 // Make sure no arguments is a good thing!
6761 if (Ty->getNumParams() != 0)
6762 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006763 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006764 } else { // Has arguments?
6765 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006766 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006767 FunctionType::param_iterator I = Ty->param_begin();
6768 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006769 ParamList::iterator ArgI = (yyvsp[(7) - (9)].ParamList)->begin(), ArgE = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006770 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006771
Duncan Sandsdc024672007-11-27 13:23:08 +00006772 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006773 if (ArgI->Val->getType() != *I)
6774 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006775 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006776 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006777 if (ArgI->Attrs != Attribute::None)
6778 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006779 }
6780 if (Ty->isVarArg()) {
6781 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006782 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006783 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006784 if (ArgI->Attrs != Attribute::None)
6785 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006786 }
Reid Spencer14310612006-12-31 05:40:51 +00006787 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006788 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006789 }
Devang Patel652203f2008-09-29 20:49:50 +00006790 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None)
6791 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (9)].Attributes)));
Duncan Sandsdc024672007-11-27 13:23:08 +00006792
Devang Patel05988662008-09-25 21:00:45 +00006793 // Finish off the Attributes and check them
6794 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006795 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006796 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006797
Reid Spencer14310612006-12-31 05:40:51 +00006798 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006799 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006800 CI->setTailCall((yyvsp[(1) - (9)].BoolVal));
6801 CI->setCallingConv((yyvsp[(2) - (9)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006802 CI->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006803 (yyval.InstVal) = CI;
Devang Patel652203f2008-09-29 20:49:50 +00006804 delete (yyvsp[(7) - (9)].ParamList);
6805 delete (yyvsp[(4) - (9)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006806 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006807 ;}
6808 break;
6809
Devang Patel652203f2008-09-29 20:49:50 +00006810 case 341:
6811#line 3353 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006812 {
6813 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006814 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006815 ;}
6816 break;
6817
Devang Patel652203f2008-09-29 20:49:50 +00006818 case 342:
6819#line 3358 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006820 {
6821 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006822 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006823 ;}
6824 break;
6825
Devang Patel652203f2008-09-29 20:49:50 +00006826 case 343:
6827#line 3362 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006828 {
6829 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006830 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006831 ;}
6832 break;
6833
Devang Patel652203f2008-09-29 20:49:50 +00006834 case 344:
6835#line 3369 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006836 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006837 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006838 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6839 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6840 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006841 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006842 ;}
6843 break;
6844
Devang Patel652203f2008-09-29 20:49:50 +00006845 case 345:
6846#line 3376 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006847 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006848 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006849 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006850 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6851 GEN_ERROR("Malloc array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006852 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006853 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006854 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6855 delete (yyvsp[(2) - (6)].TypeVal);
6856 ;}
6857 break;
6858
Devang Patel652203f2008-09-29 20:49:50 +00006859 case 346:
6860#line 3386 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006861 {
Reid Spencer14310612006-12-31 05:40:51 +00006862 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006863 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6864 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6865 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006866 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006867 ;}
6868 break;
6869
Devang Patel652203f2008-09-29 20:49:50 +00006870 case 347:
6871#line 3393 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006872 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006873 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006874 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006875 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6876 GEN_ERROR("Alloca array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006877 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006878 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006879 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6880 delete (yyvsp[(2) - (6)].TypeVal);
6881 ;}
6882 break;
6883
Devang Patel652203f2008-09-29 20:49:50 +00006884 case 348:
6885#line 3403 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006886 {
6887 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Eric Christopher2a5196f2008-09-24 04:55:49 +00006888 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006889 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6890 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006891 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006892 ;}
6893 break;
6894
Devang Patel652203f2008-09-29 20:49:50 +00006895 case 349:
6896#line 3411 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006897 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006898 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006899 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6900 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006901 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006902 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6903 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006904 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006905 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6906 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006907 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006908 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6909 delete (yyvsp[(3) - (5)].TypeVal);
6910 ;}
6911 break;
6912
Devang Patel652203f2008-09-29 20:49:50 +00006913 case 350:
6914#line 3425 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006915 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006916 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006917 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6918 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006919 if (!PT)
6920 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006921 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006922 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006923 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6924 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006925 "' into space of type '" + ElTy->getDescription() + "'");
6926
Dan Gohmanf4423b12008-04-19 00:24:39 +00006927 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006928 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006929 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6930 delete (yyvsp[(5) - (7)].TypeVal);
6931 ;}
6932 break;
6933
Devang Patel652203f2008-09-29 20:49:50 +00006934 case 351:
6935#line 3442 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006936 {
Dan Gohman1a570242008-07-23 00:54:54 +00006937 if (!UpRefs.empty())
6938 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6939 if (!isa<StructType>((yyvsp[(2) - (5)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (5)].TypeVal)->get()))
6940 GEN_ERROR("getresult insn requires an aggregate operand");
6941 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].UInt64Val)))
6942 GEN_ERROR("Invalid getresult index for type '" +
6943 (*(yyvsp[(2) - (5)].TypeVal))->getDescription()+ "'");
6944
6945 Value *tmpVal = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Devang Patel5a970972008-02-19 22:27:01 +00006946 CHECK_FOR_ERROR
Dan Gohman1a570242008-07-23 00:54:54 +00006947 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(5) - (5)].UInt64Val));
6948 delete (yyvsp[(2) - (5)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006949 ;}
6950 break;
6951
Devang Patel652203f2008-09-29 20:49:50 +00006952 case 352:
6953#line 3456 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006954 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006955 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006956 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6957 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006958 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006959
Dan Gohman041e2eb2008-05-15 19:50:34 +00006960 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()))
Reid Spencer61c83e02006-08-18 08:43:06 +00006961 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006962 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6963 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006964 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006965 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006966 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006967 delete (yyvsp[(4) - (4)].ValueList);
6968 ;}
6969 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006970
Devang Patel652203f2008-09-29 20:49:50 +00006971 case 353:
6972#line 3471 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00006973 {
6974 if (!UpRefs.empty())
6975 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6976 if (!isa<StructType>((yyvsp[(2) - (4)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (4)].TypeVal)->get()))
6977 GEN_ERROR("extractvalue insn requires an aggregate operand");
6978
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006979 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end()))
Dan Gohmane4977cf2008-05-23 01:55:30 +00006980 GEN_ERROR("Invalid extractvalue indices for type '" +
6981 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6982 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
6983 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006984 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006985 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006986 delete (yyvsp[(4) - (4)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00006987 ;}
6988 break;
6989
Devang Patel652203f2008-09-29 20:49:50 +00006990 case 354:
6991#line 3486 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00006992 {
6993 if (!UpRefs.empty())
6994 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (7)].TypeVal))->getDescription());
6995 if (!isa<StructType>((yyvsp[(2) - (7)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (7)].TypeVal)->get()))
6996 GEN_ERROR("extractvalue insn requires an aggregate operand");
6997
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006998 if (ExtractValueInst::getIndexedType(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end()) != (yyvsp[(5) - (7)].TypeVal)->get())
Dan Gohmane4977cf2008-05-23 01:55:30 +00006999 GEN_ERROR("Invalid insertvalue indices for type '" +
7000 (*(yyvsp[(2) - (7)].TypeVal))->getDescription()+ "'");
7001 Value* aggVal = getVal(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(3) - (7)].ValIDVal));
7002 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
7003 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007004 (yyval.InstVal) = InsertValueInst::Create(aggVal, tmpVal, (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00007005 delete (yyvsp[(2) - (7)].TypeVal);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007006 delete (yyvsp[(5) - (7)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007007 delete (yyvsp[(7) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007008 ;}
7009 break;
7010
Dan Gohmanf4423b12008-04-19 00:24:39 +00007011
7012/* Line 1267 of yacc.c. */
Devang Patel652203f2008-09-29 20:49:50 +00007013#line 7014 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00007014 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00007015 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007016 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
7017
7018 YYPOPSTACK (yylen);
7019 yylen = 0;
7020 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007021
7022 *++yyvsp = yyval;
7023
7024
Dan Gohmanf4423b12008-04-19 00:24:39 +00007025 /* Now `shift' the result of the reduction. Determine what state
7026 that goes to, based on the state we popped back to and the rule
7027 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00007028
7029 yyn = yyr1[yyn];
7030
Dan Gohmanf4423b12008-04-19 00:24:39 +00007031 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
7032 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007033 yystate = yytable[yystate];
7034 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00007035 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00007036
7037 goto yynewstate;
7038
7039
Dan Gohmanf4423b12008-04-19 00:24:39 +00007040/*------------------------------------.
7041| yyerrlab -- here on detecting error |
7042`------------------------------------*/
7043yyerrlab:
7044 /* If not already recovering from an error, report this error. */
7045 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007046 {
7047 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007048#if ! YYERROR_VERBOSE
7049 yyerror (YY_("syntax error"));
7050#else
7051 {
7052 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
7053 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
7054 {
7055 YYSIZE_T yyalloc = 2 * yysize;
7056 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
7057 yyalloc = YYSTACK_ALLOC_MAXIMUM;
7058 if (yymsg != yymsgbuf)
7059 YYSTACK_FREE (yymsg);
7060 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
7061 if (yymsg)
7062 yymsg_alloc = yyalloc;
7063 else
7064 {
7065 yymsg = yymsgbuf;
7066 yymsg_alloc = sizeof yymsgbuf;
7067 }
7068 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00007069
Dan Gohmanf4423b12008-04-19 00:24:39 +00007070 if (0 < yysize && yysize <= yymsg_alloc)
7071 {
7072 (void) yysyntax_error (yymsg, yystate, yychar);
7073 yyerror (yymsg);
7074 }
7075 else
7076 {
7077 yyerror (YY_("syntax error"));
7078 if (yysize != 0)
7079 goto yyexhaustedlab;
7080 }
7081 }
7082#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007083 }
7084
Dan Gohmanf4423b12008-04-19 00:24:39 +00007085
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007086
7087 if (yyerrstatus == 3)
7088 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00007089 /* If just tried and failed to reuse look-ahead token after an
7090 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007091
Dan Gohmanf4423b12008-04-19 00:24:39 +00007092 if (yychar <= YYEOF)
7093 {
7094 /* Return failure if at end of input. */
7095 if (yychar == YYEOF)
7096 YYABORT;
7097 }
7098 else
7099 {
7100 yydestruct ("Error: discarding",
7101 yytoken, &yylval);
7102 yychar = YYEMPTY;
7103 }
7104 }
7105
7106 /* Else will try to reuse look-ahead token after shifting the error
7107 token. */
7108 goto yyerrlab1;
7109
7110
7111/*---------------------------------------------------.
7112| yyerrorlab -- error raised explicitly by YYERROR. |
7113`---------------------------------------------------*/
7114yyerrorlab:
7115
7116 /* Pacify compilers like GCC when the user code never invokes
7117 YYERROR and the label yyerrorlab therefore never appears in user
7118 code. */
7119 if (/*CONSTCOND*/ 0)
7120 goto yyerrorlab;
7121
7122 /* Do not reclaim the symbols of the rule which action triggered
7123 this YYERROR. */
7124 YYPOPSTACK (yylen);
7125 yylen = 0;
7126 YY_STACK_PRINT (yyss, yyssp);
7127 yystate = *yyssp;
7128 goto yyerrlab1;
7129
7130
7131/*-------------------------------------------------------------.
7132| yyerrlab1 -- common code for both syntax error and YYERROR. |
7133`-------------------------------------------------------------*/
7134yyerrlab1:
7135 yyerrstatus = 3; /* Each real token shifted decrements this. */
7136
7137 for (;;)
7138 {
7139 yyn = yypact[yystate];
7140 if (yyn != YYPACT_NINF)
7141 {
7142 yyn += YYTERROR;
7143 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7144 {
7145 yyn = yytable[yyn];
7146 if (0 < yyn)
7147 break;
7148 }
7149 }
7150
7151 /* Pop the current state because it cannot handle the error token. */
7152 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007153 YYABORT;
7154
Dale Johannesencdd509a2007-09-07 21:07:57 +00007155
Dan Gohmanf4423b12008-04-19 00:24:39 +00007156 yydestruct ("Error: popping",
7157 yystos[yystate], yyvsp);
7158 YYPOPSTACK (1);
7159 yystate = *yyssp;
7160 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007161 }
7162
7163 if (yyn == YYFINAL)
7164 YYACCEPT;
7165
Reid Spencer68a24bd2005-08-27 18:50:39 +00007166 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007167
7168
7169 /* Shift the error token. */
7170 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00007171
Reid Spencer68a24bd2005-08-27 18:50:39 +00007172 yystate = yyn;
7173 goto yynewstate;
7174
Gabor Greife64d2482008-04-06 23:07:54 +00007175
Dan Gohmanf4423b12008-04-19 00:24:39 +00007176/*-------------------------------------.
7177| yyacceptlab -- YYACCEPT comes here. |
7178`-------------------------------------*/
7179yyacceptlab:
7180 yyresult = 0;
7181 goto yyreturn;
7182
7183/*-----------------------------------.
7184| yyabortlab -- YYABORT comes here. |
7185`-----------------------------------*/
7186yyabortlab:
7187 yyresult = 1;
7188 goto yyreturn;
7189
7190#ifndef yyoverflow
7191/*-------------------------------------------------.
7192| yyexhaustedlab -- memory exhaustion comes here. |
7193`-------------------------------------------------*/
7194yyexhaustedlab:
7195 yyerror (YY_("memory exhausted"));
7196 yyresult = 2;
7197 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00007198#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00007199
7200yyreturn:
7201 if (yychar != YYEOF && yychar != YYEMPTY)
7202 yydestruct ("Cleanup: discarding lookahead",
7203 yytoken, &yylval);
7204 /* Do not reclaim the symbols of the rule which action triggered
7205 this YYABORT or YYACCEPT. */
7206 YYPOPSTACK (yylen);
7207 YY_STACK_PRINT (yyss, yyssp);
7208 while (yyssp != yyss)
7209 {
7210 yydestruct ("Cleanup: popping",
7211 yystos[*yyssp], yyvsp);
7212 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00007213 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007214#ifndef yyoverflow
7215 if (yyss != yyssa)
7216 YYSTACK_FREE (yyss);
7217#endif
7218#if YYERROR_VERBOSE
7219 if (yymsg != yymsgbuf)
7220 YYSTACK_FREE (yymsg);
7221#endif
7222 /* Make sure YYID is used. */
7223 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007224}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007225
7226
Devang Patel652203f2008-09-29 20:49:50 +00007227#line 3505 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00007228
7229
Reid Spencer14310612006-12-31 05:40:51 +00007230// common code from the two 'RunVMAsmParser' functions
7231static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00007232 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00007233 // Check to make sure the parser succeeded
7234 if (yyparse()) {
7235 if (ParserResult)
7236 delete ParserResult;
7237 return 0;
7238 }
7239
Reid Spencer0d60b5a2007-03-30 01:37:39 +00007240 // Emit an error if there are any unresolved types left.
7241 if (!CurModule.LateResolveTypes.empty()) {
7242 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
7243 if (DID.Type == ValID::LocalName) {
7244 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
7245 } else {
7246 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
7247 }
7248 if (ParserResult)
7249 delete ParserResult;
7250 return 0;
7251 }
7252
7253 // Emit an error if there are any unresolved values left.
7254 if (!CurModule.LateResolveValues.empty()) {
7255 Value *V = CurModule.LateResolveValues.back();
7256 std::map<Value*, std::pair<ValID, int> >::iterator I =
7257 CurModule.PlaceHolderInfo.find(V);
7258
7259 if (I != CurModule.PlaceHolderInfo.end()) {
7260 ValID &DID = I->second.first;
7261 if (DID.Type == ValID::LocalName) {
7262 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
7263 } else {
7264 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
7265 }
7266 if (ParserResult)
7267 delete ParserResult;
7268 return 0;
7269 }
7270 }
7271
Reid Spencer14310612006-12-31 05:40:51 +00007272 // Check to make sure that parsing produced a result
7273 if (!ParserResult)
7274 return 0;
7275
7276 // Reset ParserResult variable while saving its value for the result.
7277 Module *Result = ParserResult;
7278 ParserResult = 0;
7279
7280 return Result;
7281}
7282
Reid Spencer61c83e02006-08-18 08:43:06 +00007283void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007284 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00007285 // TODO: column number in exception
7286 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00007287 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00007288 TriggerError = 1;
7289}
Reid Spencer68a24bd2005-08-27 18:50:39 +00007290
7291int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007292 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00007293 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00007294 if (yychar != YYEMPTY && yychar != 0) {
7295 errMsg += " while reading token: '";
Eric Christopher2a5196f2008-09-24 04:55:49 +00007296 errMsg += std::string(LLLgetTokenStart(),
Duncan Sandsdc024672007-11-27 13:23:08 +00007297 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
7298 }
Reid Spencer61c83e02006-08-18 08:43:06 +00007299 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007300 return 0;
7301}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007302