blob: 581cd7c0f67353c70dd2899c9498a0ab1f98fde1 [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. */
Nuno Lopes9e9631d2008-10-03 15:45:58 +0000397#line 14 "/cvs/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 }
Nuno Lopes191dfb92008-10-03 15:52:39 +00001094 D.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001095}
1096
1097// setValueName - Set the specified value to the name given. The name may be
1098// null potentially, in which case this is a noop. The string passed in is
1099// assumed to be a malloc'd string buffer, and is free'd by this function.
1100//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001101static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001102 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001103 std::string Name(*NameStr); // Copy string
1104 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001105
Reid Spencer41dff5e2007-01-26 08:05:27 +00001106 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001107 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001108 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001109 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001110
Reid Spencera9720f52007-02-05 17:04:00 +00001111 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001112 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1113 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001114 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001115 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001116 return;
1117 }
1118
1119 // Set the name.
1120 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001121}
1122
1123/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1124/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001125static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001126ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001127 GlobalValue::LinkageTypes Linkage,
1128 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001129 bool isConstantGlobal, const Type *Ty,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001130 Constant *Initializer, bool IsThreadLocal,
1131 unsigned AddressSpace = 0) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001132 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001133 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001134 return 0;
1135 }
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001136 if (Ty == Type::LabelTy) {
1137 GenerateError("Cannot declare global vars of label type");
1138 return 0;
1139 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001140
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001141 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001142
1143 std::string Name;
1144 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001145 Name = *NameStr; // Copy string
1146 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001147 }
1148
1149 // See if this global value was forward referenced. If so, recycle the
1150 // object.
1151 ValID ID;
1152 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001153 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001154 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001155 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001156 }
1157
1158 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1159 // Move the global to the end of the list, from whereever it was
1160 // previously inserted.
1161 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1162 CurModule.CurrentModule->getGlobalList().remove(GV);
1163 CurModule.CurrentModule->getGlobalList().push_back(GV);
1164 GV->setInitializer(Initializer);
1165 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001166 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001167 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001168 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001169 InsertValue(GV, CurModule.Values);
Nuno Lopes191dfb92008-10-03 15:52:39 +00001170 ID.destroy();
Chris Lattnerb475c422005-11-12 18:22:38 +00001171 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001172 }
1173
Nuno Lopes191dfb92008-10-03 15:52:39 +00001174 ID.destroy();
1175
Reid Spenceref9b9a72007-02-05 20:47:22 +00001176 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001177 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001178 // if the global we're parsing has an initializer (is a definition) and
1179 // has external linkage.
1180 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1181 // If there is already a global with external linkage with this name
1182 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1183 // If we allow this GVar to get created, it will be renamed in the
1184 // symbol table because it conflicts with an existing GVar. We can't
1185 // allow redefinition of GVars whose linking indicates that their name
1186 // must stay the same. Issue the error.
1187 GenerateError("Redefinition of global variable named '" + Name +
1188 "' of type '" + Ty->getDescription() + "'");
1189 return 0;
1190 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001191 }
1192
1193 // Otherwise there is no existing GV to use, create one now.
1194 GlobalVariable *GV =
1195 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001196 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001197 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001198 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001199 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001200}
1201
1202// setTypeName - Set the specified type to the name given. The name may be
1203// null potentially, in which case this is a noop. The string passed in is
1204// assumed to be a malloc'd string buffer, and is freed by this function.
1205//
1206// This function returns true if the type has already been defined, but is
1207// allowed to be redefined in the specified context. If the name is a new name
1208// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001209static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001210 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001211 if (NameStr == 0) return false;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001212
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001213 std::string Name(*NameStr); // Copy string
1214 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001215
1216 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001217 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001218 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001219 return false;
1220 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001221
1222 // Set the type name, checking for conflicts as we do so.
1223 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1224
1225 if (AlreadyExists) { // Inserting a name that is already defined???
1226 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001227 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001228
1229 // There is only one case where this is allowed: when we are refining an
1230 // opaque type. In this case, Existing will be an opaque type.
1231 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1232 // We ARE replacing an opaque type!
1233 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1234 return true;
1235 }
1236
1237 // Otherwise, this is an attempt to redefine a type. That's okay if
1238 // the redefinition is identical to the original. This will be so if
1239 // Existing and T point to the same Type object. In this one case we
1240 // allow the equivalent redefinition.
1241 if (Existing == T) return true; // Yes, it's equal.
1242
1243 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001244 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001245 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001246 }
1247
1248 return false;
1249}
1250
1251//===----------------------------------------------------------------------===//
1252// Code for handling upreferences in type names...
1253//
1254
1255// TypeContains - Returns true if Ty directly contains E in it.
1256//
1257static bool TypeContains(const Type *Ty, const Type *E) {
1258 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1259 E) != Ty->subtype_end();
1260}
1261
1262namespace {
1263 struct UpRefRecord {
1264 // NestingLevel - The number of nesting levels that need to be popped before
1265 // this type is resolved.
1266 unsigned NestingLevel;
1267
1268 // LastContainedTy - This is the type at the current binding level for the
1269 // type. Every time we reduce the nesting level, this gets updated.
1270 const Type *LastContainedTy;
1271
1272 // UpRefTy - This is the actual opaque type that the upreference is
1273 // represented with.
1274 OpaqueType *UpRefTy;
1275
1276 UpRefRecord(unsigned NL, OpaqueType *URTy)
1277 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1278 };
1279}
1280
1281// UpRefs - A list of the outstanding upreferences that need to be resolved.
1282static std::vector<UpRefRecord> UpRefs;
1283
1284/// HandleUpRefs - Every time we finish a new layer of types, this function is
1285/// called. It loops through the UpRefs vector, which is a list of the
1286/// currently active types. For each type, if the up reference is contained in
1287/// the newly completed type, we decrement the level count. When the level
1288/// count reaches zero, the upreferenced type is the type that is passed in:
1289/// thus we can complete the cycle.
1290///
1291static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001292 // If Ty isn't abstract, or if there are no up-references in it, then there is
1293 // nothing to resolve here.
1294 if (!ty->isAbstract() || UpRefs.empty()) return ty;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001295
Reid Spencer68a24bd2005-08-27 18:50:39 +00001296 PATypeHolder Ty(ty);
1297 UR_OUT("Type '" << Ty->getDescription() <<
1298 "' newly formed. Resolving upreferences.\n" <<
1299 UpRefs.size() << " upreferences active!\n");
1300
1301 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1302 // to zero), we resolve them all together before we resolve them to Ty. At
1303 // the end of the loop, if there is anything to resolve to Ty, it will be in
1304 // this variable.
1305 OpaqueType *TypeToResolve = 0;
1306
1307 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1308 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1309 << UpRefs[i].second->getDescription() << ") = "
1310 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1311 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1312 // Decrement level of upreference
1313 unsigned Level = --UpRefs[i].NestingLevel;
1314 UpRefs[i].LastContainedTy = Ty;
1315 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1316 if (Level == 0) { // Upreference should be resolved!
1317 if (!TypeToResolve) {
1318 TypeToResolve = UpRefs[i].UpRefTy;
1319 } else {
1320 UR_OUT(" * Resolving upreference for "
1321 << UpRefs[i].second->getDescription() << "\n";
1322 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1323 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1324 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1325 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1326 }
1327 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1328 --i; // Do not skip the next element...
1329 }
1330 }
1331 }
1332
1333 if (TypeToResolve) {
1334 UR_OUT(" * Resolving upreference for "
1335 << UpRefs[i].second->getDescription() << "\n";
1336 std::string OldName = TypeToResolve->getDescription());
1337 TypeToResolve->refineAbstractTypeTo(Ty);
1338 }
1339
1340 return Ty;
1341}
1342
Reid Spencer68a24bd2005-08-27 18:50:39 +00001343//===----------------------------------------------------------------------===//
1344// RunVMAsmParser - Define an interface to this parser
1345//===----------------------------------------------------------------------===//
1346//
Reid Spencer14310612006-12-31 05:40:51 +00001347static Module* RunParser(Module * M);
1348
Duncan Sandsdc024672007-11-27 13:23:08 +00001349Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1350 InitLLLexer(MB);
1351 Module *M = RunParser(new Module(LLLgetFilename()));
1352 FreeLexer();
1353 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001354}
1355
1356
Dan Gohmanf4423b12008-04-19 00:24:39 +00001357
1358/* Enabling traces. */
1359#ifndef YYDEBUG
1360# define YYDEBUG 0
1361#endif
1362
1363/* Enabling verbose error messages. */
1364#ifdef YYERROR_VERBOSE
1365# undef YYERROR_VERBOSE
1366# define YYERROR_VERBOSE 1
1367#else
1368# define YYERROR_VERBOSE 0
1369#endif
1370
1371/* Enabling the token table. */
1372#ifndef YYTOKEN_TABLE
1373# define YYTOKEN_TABLE 0
1374#endif
1375
1376#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1377typedef union YYSTYPE
Nuno Lopes191dfb92008-10-03 15:52:39 +00001378#line 974 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001379{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001380 llvm::Module *ModuleVal;
1381 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001382 llvm::BasicBlock *BasicBlockVal;
1383 llvm::TerminatorInst *TermInstVal;
1384 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001385 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001386
Reid Spencera132e042006-12-03 05:46:11 +00001387 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001388 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001389 llvm::PATypeHolder *TypeVal;
1390 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001391 std::vector<llvm::Value*> *ValueList;
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001392 std::vector<unsigned> *ConstantList;
Reid Spencer14310612006-12-31 05:40:51 +00001393 llvm::ArgListType *ArgList;
1394 llvm::TypeWithAttrs TypeWithAttrs;
1395 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001396 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001397
Reid Spencer68a24bd2005-08-27 18:50:39 +00001398 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001399 std::list<std::pair<llvm::Value*,
1400 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001401 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001402 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001403
1404 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001405 llvm::GlobalValue::VisibilityTypes Visibility;
Devang Patel05988662008-09-25 21:00:45 +00001406 llvm::Attributes Attributes;
Reid Spencer38c91a92007-02-28 02:24:54 +00001407 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001408 int64_t SInt64Val;
1409 uint64_t UInt64Val;
1410 int SIntVal;
1411 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001412 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001413 bool BoolVal;
1414
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001415 std::string *StrVal; // This memory must be deleted
1416 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001417
Reid Spencera132e042006-12-03 05:46:11 +00001418 llvm::Instruction::BinaryOps BinaryOpVal;
1419 llvm::Instruction::TermOps TermOpVal;
1420 llvm::Instruction::MemoryOps MemOpVal;
1421 llvm::Instruction::CastOps CastOpVal;
1422 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001423 llvm::ICmpInst::Predicate IPredicate;
1424 llvm::FCmpInst::Predicate FPredicate;
Dan Gohmanf4423b12008-04-19 00:24:39 +00001425}
Nuno Lopes9e9631d2008-10-03 15:45:58 +00001426/* Line 187 of yacc.c. */
Nuno Lopes191dfb92008-10-03 15:52:39 +00001427#line 1428 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001428 YYSTYPE;
1429# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1430# define YYSTYPE_IS_DECLARED 1
1431# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001432#endif
1433
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001434
Reid Spencer68a24bd2005-08-27 18:50:39 +00001435
Dan Gohmanf4423b12008-04-19 00:24:39 +00001436/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001437
1438
Dan Gohmanf4423b12008-04-19 00:24:39 +00001439/* Line 216 of yacc.c. */
Nuno Lopes191dfb92008-10-03 15:52:39 +00001440#line 1441 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001441
Dan Gohmanf4423b12008-04-19 00:24:39 +00001442#ifdef short
1443# undef short
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001444#endif
1445
Dan Gohmanf4423b12008-04-19 00:24:39 +00001446#ifdef YYTYPE_UINT8
1447typedef YYTYPE_UINT8 yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001448#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00001449typedef unsigned char yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001450#endif
1451
Dan Gohmanf4423b12008-04-19 00:24:39 +00001452#ifdef YYTYPE_INT8
1453typedef YYTYPE_INT8 yytype_int8;
1454#elif (defined __STDC__ || defined __C99__FUNC__ \
1455 || defined __cplusplus || defined _MSC_VER)
1456typedef signed char yytype_int8;
1457#else
1458typedef short int yytype_int8;
1459#endif
1460
1461#ifdef YYTYPE_UINT16
1462typedef YYTYPE_UINT16 yytype_uint16;
1463#else
1464typedef unsigned short int yytype_uint16;
1465#endif
1466
1467#ifdef YYTYPE_INT16
1468typedef YYTYPE_INT16 yytype_int16;
1469#else
1470typedef short int yytype_int16;
1471#endif
1472
1473#ifndef YYSIZE_T
1474# ifdef __SIZE_TYPE__
1475# define YYSIZE_T __SIZE_TYPE__
1476# elif defined size_t
1477# define YYSIZE_T size_t
1478# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1479 || defined __cplusplus || defined _MSC_VER)
1480# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1481# define YYSIZE_T size_t
1482# else
1483# define YYSIZE_T unsigned int
1484# endif
1485#endif
1486
1487#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1488
1489#ifndef YY_
Nuno Lopes9e9631d2008-10-03 15:45:58 +00001490# if YYENABLE_NLS
Dan Gohmanf4423b12008-04-19 00:24:39 +00001491# if ENABLE_NLS
1492# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1493# define YY_(msgid) dgettext ("bison-runtime", msgid)
1494# endif
1495# endif
1496# ifndef YY_
1497# define YY_(msgid) msgid
1498# endif
1499#endif
1500
1501/* Suppress unused-variable warnings by "using" E. */
1502#if ! defined lint || defined __GNUC__
1503# define YYUSE(e) ((void) (e))
1504#else
1505# define YYUSE(e) /* empty */
1506#endif
1507
1508/* Identity function, used to suppress warnings about constant conditions. */
1509#ifndef lint
1510# define YYID(n) (n)
1511#else
1512#if (defined __STDC__ || defined __C99__FUNC__ \
1513 || defined __cplusplus || defined _MSC_VER)
1514static int
1515YYID (int i)
1516#else
1517static int
1518YYID (i)
1519 int i;
1520#endif
1521{
1522 return i;
1523}
1524#endif
1525
1526#if ! defined yyoverflow || YYERROR_VERBOSE
1527
1528/* The parser invokes alloca or malloc; define the necessary symbols. */
1529
1530# ifdef YYSTACK_USE_ALLOCA
1531# if YYSTACK_USE_ALLOCA
1532# ifdef __GNUC__
1533# define YYSTACK_ALLOC __builtin_alloca
1534# elif defined __BUILTIN_VA_ARG_INCR
1535# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1536# elif defined _AIX
1537# define YYSTACK_ALLOC __alloca
1538# elif defined _MSC_VER
1539# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1540# define alloca _alloca
1541# else
1542# define YYSTACK_ALLOC alloca
1543# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1544 || defined __cplusplus || defined _MSC_VER)
1545# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1546# ifndef _STDLIB_H
1547# define _STDLIB_H 1
1548# endif
1549# endif
1550# endif
1551# endif
1552# endif
1553
1554# ifdef YYSTACK_ALLOC
1555 /* Pacify GCC's `empty if-body' warning. */
1556# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1557# ifndef YYSTACK_ALLOC_MAXIMUM
1558 /* The OS might guarantee only one guard page at the bottom of the stack,
1559 and a page size can be as small as 4096 bytes. So we cannot safely
1560 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1561 to allow for a few compiler-allocated temporary stack slots. */
1562# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1563# endif
1564# else
1565# define YYSTACK_ALLOC YYMALLOC
1566# define YYSTACK_FREE YYFREE
1567# ifndef YYSTACK_ALLOC_MAXIMUM
1568# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1569# endif
1570# if (defined __cplusplus && ! defined _STDLIB_H \
1571 && ! ((defined YYMALLOC || defined malloc) \
1572 && (defined YYFREE || defined free)))
1573# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1574# ifndef _STDLIB_H
1575# define _STDLIB_H 1
1576# endif
1577# endif
1578# ifndef YYMALLOC
1579# define YYMALLOC malloc
1580# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1581 || defined __cplusplus || defined _MSC_VER)
1582void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1583# endif
1584# endif
1585# ifndef YYFREE
1586# define YYFREE free
1587# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1588 || defined __cplusplus || defined _MSC_VER)
1589void free (void *); /* INFRINGES ON USER NAME SPACE */
1590# endif
1591# endif
1592# endif
1593#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1594
1595
1596#if (! defined yyoverflow \
1597 && (! defined __cplusplus \
1598 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1599
1600/* A type that is properly aligned for any stack member. */
1601union yyalloc
1602{
1603 yytype_int16 yyss;
1604 YYSTYPE yyvs;
1605 };
1606
1607/* The size of the maximum gap between one aligned stack and the next. */
1608# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1609
1610/* The size of an array large to enough to hold all stacks, each with
1611 N elements. */
1612# define YYSTACK_BYTES(N) \
1613 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1614 + YYSTACK_GAP_MAXIMUM)
1615
1616/* Copy COUNT objects from FROM to TO. The source and destination do
1617 not overlap. */
1618# ifndef YYCOPY
1619# if defined __GNUC__ && 1 < __GNUC__
1620# define YYCOPY(To, From, Count) \
1621 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1622# else
1623# define YYCOPY(To, From, Count) \
1624 do \
1625 { \
1626 YYSIZE_T yyi; \
1627 for (yyi = 0; yyi < (Count); yyi++) \
1628 (To)[yyi] = (From)[yyi]; \
1629 } \
1630 while (YYID (0))
1631# endif
1632# endif
1633
1634/* Relocate STACK from its old location to the new one. The
1635 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1636 elements in the stack, and YYPTR gives the new location of the
1637 stack. Advance YYPTR to a properly aligned location for the next
1638 stack. */
1639# define YYSTACK_RELOCATE(Stack) \
1640 do \
1641 { \
1642 YYSIZE_T yynewbytes; \
1643 YYCOPY (&yyptr->Stack, Stack, yysize); \
1644 Stack = &yyptr->Stack; \
1645 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1646 yyptr += yynewbytes / sizeof (*yyptr); \
1647 } \
1648 while (YYID (0))
1649
1650#endif
1651
1652/* YYFINAL -- State number of the termination state. */
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001653#define YYFINAL 44
Dan Gohmanf4423b12008-04-19 00:24:39 +00001654/* YYLAST -- Last index in YYTABLE. */
Devang Patel652203f2008-09-29 20:49:50 +00001655#define YYLAST 2439
Dan Gohmanf4423b12008-04-19 00:24:39 +00001656
1657/* YYNTOKENS -- Number of terminals. */
Devang Patel652203f2008-09-29 20:49:50 +00001658#define YYNTOKENS 173
Dan Gohmanf4423b12008-04-19 00:24:39 +00001659/* YYNNTS -- Number of nonterminals. */
Devang Patel652203f2008-09-29 20:49:50 +00001660#define YYNNTS 89
Dan Gohmanf4423b12008-04-19 00:24:39 +00001661/* YYNRULES -- Number of rules. */
Devang Patel652203f2008-09-29 20:49:50 +00001662#define YYNRULES 354
Dan Gohmanf4423b12008-04-19 00:24:39 +00001663/* YYNRULES -- Number of states. */
Devang Patel652203f2008-09-29 20:49:50 +00001664#define YYNSTATES 717
Dan Gohmanf4423b12008-04-19 00:24:39 +00001665
1666/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1667#define YYUNDEFTOK 2
Devang Patel652203f2008-09-29 20:49:50 +00001668#define YYMAXUTOK 413
Dan Gohmanf4423b12008-04-19 00:24:39 +00001669
1670#define YYTRANSLATE(YYX) \
1671 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1672
1673/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1674static const yytype_uint8 yytranslate[] =
1675{
1676 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1677 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1678 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1679 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001680 159, 160, 163, 2, 162, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001681 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001682 168, 161, 169, 2, 2, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001683 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1684 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001685 2, 165, 164, 167, 2, 2, 2, 2, 2, 172,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001686 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001688 166, 2, 2, 170, 2, 171, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001689 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1690 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
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, 2, 2, 2, 2,
1698 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1699 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1700 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1701 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1702 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1703 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1704 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1705 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1706 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1707 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1708 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1709 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1710 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1711 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1712 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1713 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1714 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1715 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Dan Gohmane4977cf2008-05-23 01:55:30 +00001716 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
Devang Patel652203f2008-09-29 20:49:50 +00001717 155, 156, 157, 158
Dan Gohmanf4423b12008-04-19 00:24:39 +00001718};
1719
1720#if YYDEBUG
1721/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1722 YYRHS. */
1723static const yytype_uint16 yyprhs[] =
1724{
1725 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1726 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1727 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1728 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1729 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1730 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1731 119, 121, 123, 125, 127, 129, 130, 135, 136, 139,
Chris Lattner15bd0952008-08-29 17:20:18 +00001732 140, 143, 145, 147, 149, 150, 153, 155, 157, 159,
1733 161, 163, 165, 167, 169, 171, 172, 174, 176, 178,
1734 179, 181, 183, 184, 186, 188, 190, 192, 193, 195,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001735 197, 198, 200, 202, 204, 206, 208, 211, 213, 215,
1736 217, 219, 221, 223, 225, 227, 229, 232, 233, 236,
Devang Patel652203f2008-09-29 20:49:50 +00001737 238, 240, 242, 243, 246, 248, 250, 252, 254, 256,
1738 258, 260, 262, 264, 266, 267, 270, 271, 274, 275,
1739 278, 279, 283, 286, 287, 289, 290, 294, 296, 299,
1740 301, 303, 305, 307, 309, 311, 313, 315, 317, 321,
1741 323, 326, 332, 338, 344, 350, 354, 357, 363, 368,
1742 371, 373, 375, 377, 381, 383, 387, 389, 390, 392,
1743 396, 401, 405, 409, 414, 419, 423, 430, 436, 439,
1744 442, 445, 448, 451, 454, 457, 460, 463, 466, 469,
1745 472, 479, 485, 494, 501, 508, 516, 524, 532, 540,
1746 547, 556, 565, 571, 579, 583, 585, 587, 589, 591,
1747 592, 595, 602, 604, 605, 607, 610, 611, 615, 616,
1748 620, 624, 628, 632, 633, 642, 643, 653, 654, 664,
1749 670, 673, 677, 679, 683, 687, 691, 695, 697, 698,
1750 704, 708, 710, 714, 716, 717, 729, 731, 733, 738,
1751 740, 742, 745, 749, 750, 752, 754, 756, 758, 760,
1752 762, 764, 766, 768, 770, 772, 776, 780, 783, 786,
1753 790, 793, 799, 804, 806, 812, 814, 816, 818, 820,
1754 822, 824, 827, 829, 833, 836, 839, 843, 847, 850,
1755 851, 853, 856, 859, 863, 873, 883, 892, 908, 910,
1756 912, 919, 925, 928, 931, 938, 946, 951, 956, 963,
1757 970, 971, 972, 976, 979, 983, 986, 988, 994, 1000,
1758 1007, 1014, 1021, 1028, 1033, 1040, 1045, 1050, 1057, 1064,
1759 1067, 1077, 1079, 1081, 1082, 1086, 1093, 1097, 1104, 1107,
1760 1113, 1121, 1127, 1132, 1137
Dan Gohmanf4423b12008-04-19 00:24:39 +00001761};
1762
1763/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1764static const yytype_int16 yyrhs[] =
1765{
Devang Patel652203f2008-09-29 20:49:50 +00001766 222, 0, -1, 75, -1, 76, -1, 77, -1, 78,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001767 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
1768 -1, 87, -1, 88, -1, 89, -1, 84, -1, 85,
1769 -1, 86, -1, 120, -1, 121, -1, 122, -1, 123,
1770 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
1771 -1, 129, -1, 130, -1, 131, -1, 94, -1, 95,
1772 -1, 96, -1, 97, -1, 98, -1, 99, -1, 100,
1773 -1, 101, -1, 102, -1, 103, -1, 104, -1, 105,
1774 -1, 106, -1, 107, -1, 108, -1, 109, -1, 110,
1775 -1, 111, -1, 112, -1, 113, -1, 100, -1, 101,
1776 -1, 102, -1, 103, -1, 26, -1, 27, -1, 11,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001777 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
Devang Patel652203f2008-09-29 20:49:50 +00001778 -1, 19, -1, 22, -1, 24, -1, 181, -1, -1,
1779 55, 159, 4, 160, -1, -1, 181, 161, -1, -1,
1780 7, 161, -1, 20, -1, 23, -1, 188, -1, -1,
1781 186, 161, -1, 42, -1, 44, -1, 43, -1, 45,
Chris Lattner15bd0952008-08-29 17:20:18 +00001782 -1, 47, -1, 49, -1, 46, -1, 48, -1, 51,
Devang Patel652203f2008-09-29 20:49:50 +00001783 -1, -1, 156, -1, 157, -1, 158, -1, -1, 46,
Chris Lattner15bd0952008-08-29 17:20:18 +00001784 -1, 48, -1, -1, 42, -1, 43, -1, 44, -1,
1785 47, -1, -1, 44, -1, 42, -1, -1, 63, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001786 64, -1, 65, -1, 66, -1, 67, -1, 62, 4,
1787 -1, 142, -1, 121, -1, 141, -1, 122, -1, 144,
1788 -1, 145, -1, 147, -1, 148, -1, 149, -1, 54,
Devang Patel652203f2008-09-29 20:49:50 +00001789 4, -1, -1, 197, 196, -1, 144, -1, 142, -1,
1790 141, -1, -1, 199, 198, -1, 143, -1, 146, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001791 144, -1, 142, -1, 141, -1, 150, -1, 151, -1,
Devang Patel652203f2008-09-29 20:49:50 +00001792 154, -1, 155, -1, 153, -1, -1, 201, 200, -1,
1793 -1, 152, 22, -1, -1, 54, 4, -1, -1, 162,
1794 54, 4, -1, 34, 22, -1, -1, 205, -1, -1,
1795 162, 208, 207, -1, 205, -1, 54, 4, -1, 11,
1796 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1797 -1, 17, -1, 50, -1, 209, -1, 210, 183, 163,
1798 -1, 244, -1, 164, 4, -1, 210, 159, 214, 160,
1799 201, -1, 10, 159, 214, 160, 201, -1, 165, 4,
1800 166, 210, 167, -1, 168, 4, 166, 210, 169, -1,
1801 170, 215, 171, -1, 170, 171, -1, 168, 170, 215,
1802 171, 169, -1, 168, 170, 171, 169, -1, 210, 197,
1803 -1, 210, -1, 10, -1, 211, -1, 213, 162, 211,
1804 -1, 213, -1, 213, 162, 39, -1, 39, -1, -1,
1805 210, -1, 215, 162, 210, -1, 210, 165, 218, 167,
1806 -1, 210, 165, 167, -1, 210, 172, 22, -1, 210,
1807 168, 218, 169, -1, 210, 170, 218, 171, -1, 210,
1808 170, 171, -1, 210, 168, 170, 218, 171, 169, -1,
1809 210, 168, 170, 171, 169, -1, 210, 40, -1, 210,
1810 41, -1, 210, 244, -1, 210, 217, -1, 210, 25,
1811 -1, 179, 3, -1, 179, 5, -1, 179, 4, -1,
1812 179, 6, -1, 11, 26, -1, 11, 27, -1, 180,
1813 9, -1, 176, 159, 216, 38, 210, 160, -1, 119,
1814 159, 216, 256, 160, -1, 133, 159, 216, 162, 216,
1815 162, 216, 160, -1, 174, 159, 216, 162, 216, 160,
1816 -1, 175, 159, 216, 162, 216, 160, -1, 90, 177,
1817 159, 216, 162, 216, 160, -1, 91, 178, 159, 216,
1818 162, 216, 160, -1, 92, 177, 159, 216, 162, 216,
1819 160, -1, 93, 178, 159, 216, 162, 216, 160, -1,
1820 135, 159, 216, 162, 216, 160, -1, 136, 159, 216,
1821 162, 216, 162, 216, 160, -1, 137, 159, 216, 162,
1822 216, 162, 216, 160, -1, 139, 159, 216, 257, 160,
1823 -1, 140, 159, 216, 162, 216, 257, 160, -1, 218,
1824 162, 216, -1, 216, -1, 32, -1, 33, -1, 37,
1825 -1, -1, 212, 244, -1, 125, 159, 221, 38, 210,
1826 160, -1, 223, -1, -1, 224, -1, 223, 224, -1,
1827 -1, 31, 225, 240, -1, -1, 30, 226, 241, -1,
1828 60, 59, 230, -1, 184, 18, 210, -1, 184, 18,
1829 10, -1, -1, 187, 191, 220, 219, 216, 183, 227,
1830 207, -1, -1, 187, 189, 191, 220, 219, 216, 183,
1831 228, 207, -1, -1, 187, 190, 191, 220, 219, 210,
1832 183, 229, 207, -1, 187, 191, 35, 194, 221, -1,
1833 52, 231, -1, 56, 161, 232, -1, 22, -1, 53,
1834 161, 22, -1, 68, 161, 22, -1, 165, 233, 167,
1835 -1, 233, 162, 22, -1, 22, -1, -1, 234, 162,
1836 210, 197, 182, -1, 210, 197, 182, -1, 234, -1,
1837 234, 162, 39, -1, 39, -1, -1, 195, 199, 212,
1838 186, 159, 235, 160, 201, 206, 203, 202, -1, 28,
1839 -1, 170, -1, 193, 191, 236, 237, -1, 29, -1,
1840 171, -1, 248, 239, -1, 192, 191, 236, -1, -1,
1841 61, -1, 3, -1, 4, -1, 5, -1, 6, -1,
1842 9, -1, 26, -1, 27, -1, 40, -1, 41, -1,
1843 25, -1, 168, 218, 169, -1, 165, 218, 167, -1,
1844 165, 167, -1, 172, 22, -1, 170, 218, 171, -1,
1845 170, 171, -1, 168, 170, 218, 171, 169, -1, 168,
1846 170, 171, 169, -1, 217, -1, 59, 242, 22, 162,
1847 22, -1, 7, -1, 8, -1, 181, -1, 186, -1,
1848 244, -1, 243, -1, 210, 245, -1, 246, -1, 247,
1849 162, 246, -1, 248, 249, -1, 238, 249, -1, 250,
1850 184, 251, -1, 250, 185, 251, -1, 250, 253, -1,
1851 -1, 21, -1, 69, 247, -1, 69, 10, -1, 70,
1852 17, 245, -1, 70, 11, 245, 162, 17, 245, 162,
1853 17, 245, -1, 71, 179, 245, 162, 17, 245, 165,
1854 252, 167, -1, 71, 179, 245, 162, 17, 245, 165,
1855 167, -1, 72, 195, 199, 212, 245, 159, 255, 160,
1856 201, 38, 17, 245, 73, 17, 245, -1, 73, -1,
1857 74, -1, 252, 179, 243, 162, 17, 245, -1, 179,
1858 243, 162, 17, 245, -1, 184, 259, -1, 185, 259,
1859 -1, 210, 165, 245, 162, 245, 167, -1, 254, 162,
1860 165, 245, 162, 245, 167, -1, 210, 197, 245, 197,
1861 -1, 17, 197, 245, 197, -1, 255, 162, 210, 197,
1862 245, 197, -1, 255, 162, 17, 197, 245, 197, -1,
1863 -1, -1, 256, 162, 246, -1, 162, 4, -1, 257,
1864 162, 4, -1, 58, 57, -1, 57, -1, 174, 210,
1865 245, 162, 245, -1, 175, 210, 245, 162, 245, -1,
1866 90, 177, 210, 245, 162, 245, -1, 91, 178, 210,
1867 245, 162, 245, -1, 92, 177, 210, 245, 162, 245,
1868 -1, 93, 178, 210, 245, 162, 245, -1, 176, 246,
1869 38, 210, -1, 133, 246, 162, 246, 162, 246, -1,
1870 134, 246, 162, 210, -1, 135, 246, 162, 246, -1,
1871 136, 246, 162, 246, 162, 246, -1, 137, 246, 162,
1872 246, 162, 246, -1, 132, 254, -1, 258, 195, 199,
1873 212, 245, 159, 255, 160, 201, -1, 261, -1, 36,
1874 -1, -1, 114, 210, 204, -1, 114, 210, 162, 11,
1875 245, 204, -1, 115, 210, 204, -1, 115, 210, 162,
1876 11, 245, 204, -1, 116, 246, -1, 260, 117, 210,
1877 245, 204, -1, 260, 118, 246, 162, 210, 245, 204,
1878 -1, 138, 210, 245, 162, 4, -1, 119, 210, 245,
1879 256, -1, 139, 210, 245, 257, -1, 140, 210, 245,
1880 162, 210, 245, 257, -1
Dan Gohmanf4423b12008-04-19 00:24:39 +00001881};
1882
1883/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1884static const yytype_uint16 yyrline[] =
1885{
Nuno Lopes191dfb92008-10-03 15:52:39 +00001886 0, 1140, 1140, 1140, 1140, 1140, 1140, 1140, 1140, 1140,
1887 1140, 1141, 1141, 1141, 1141, 1141, 1141, 1142, 1142, 1142,
1888 1142, 1142, 1142, 1143, 1143, 1143, 1143, 1143, 1143, 1146,
1889 1146, 1147, 1147, 1148, 1148, 1149, 1149, 1150, 1150, 1154,
1890 1154, 1155, 1155, 1156, 1156, 1157, 1157, 1158, 1158, 1159,
1891 1159, 1160, 1160, 1161, 1162, 1167, 1168, 1168, 1168, 1168,
1892 1168, 1170, 1170, 1170, 1171, 1171, 1173, 1174, 1178, 1182,
1893 1187, 1193, 1193, 1195, 1196, 1201, 1207, 1208, 1209, 1210,
1894 1211, 1212, 1216, 1217, 1218, 1222, 1223, 1224, 1225, 1229,
1895 1230, 1231, 1235, 1236, 1237, 1238, 1239, 1243, 1244, 1245,
1896 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1261, 1262, 1263,
1897 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1274, 1275, 1280,
1898 1281, 1282, 1285, 1286, 1292, 1293, 1294, 1295, 1296, 1297,
1899 1298, 1299, 1300, 1301, 1304, 1305, 1311, 1312, 1319, 1320,
1900 1326, 1327, 1336, 1344, 1345, 1350, 1351, 1352, 1357, 1370,
1901 1370, 1370, 1370, 1370, 1370, 1370, 1373, 1377, 1381, 1388,
1902 1393, 1401, 1430, 1455, 1460, 1470, 1480, 1484, 1494, 1501,
1903 1510, 1517, 1522, 1527, 1534, 1535, 1542, 1549, 1557, 1563,
1904 1575, 1603, 1619, 1646, 1674, 1700, 1720, 1746, 1766, 1778,
1905 1785, 1851, 1861, 1871, 1877, 1887, 1893, 1903, 1909, 1915,
1906 1928, 1940, 1961, 1969, 1975, 1986, 1991, 1996, 2001, 2006,
1907 2012, 2018, 2024, 2032, 2043, 2047, 2055, 2055, 2058, 2058,
1908 2061, 2073, 2094, 2099, 2107, 2108, 2112, 2112, 2116, 2116,
1909 2119, 2122, 2146, 2158, 2157, 2169, 2168, 2178, 2177, 2188,
1910 2228, 2231, 2237, 2247, 2251, 2256, 2258, 2263, 2268, 2277,
1911 2287, 2298, 2302, 2311, 2320, 2325, 2474, 2474, 2476, 2485,
1912 2485, 2487, 2492, 2504, 2508, 2513, 2517, 2521, 2526, 2531,
1913 2535, 2539, 2543, 2547, 2551, 2555, 2577, 2599, 2605, 2618,
1914 2630, 2635, 2647, 2653, 2657, 2667, 2671, 2675, 2680, 2687,
1915 2687, 2693, 2702, 2707, 2712, 2716, 2725, 2734, 2747, 2756,
1916 2760, 2768, 2788, 2792, 2797, 2808, 2827, 2836, 2940, 2944,
1917 2951, 2962, 2975, 2984, 2997, 3008, 3018, 3029, 3037, 3047,
1918 3054, 3057, 3058, 3066, 3072, 3081, 3085, 3090, 3106, 3123,
1919 3135, 3147, 3161, 3175, 3187, 3208, 3215, 3221, 3227, 3233,
1920 3248, 3358, 3363, 3367, 3374, 3381, 3391, 3398, 3408, 3416,
1921 3430, 3447, 3461, 3476, 3491
Dan Gohmanf4423b12008-04-19 00:24:39 +00001922};
1923#endif
1924
1925#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1926/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1927 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1928static const char *const yytname[] =
1929{
1930 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1931 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1932 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1933 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1934 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1935 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1936 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1937 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001938 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "COMMON", "OPAQUE",
Dan Gohmanf4423b12008-04-19 00:24:39 +00001939 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1940 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1941 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Dale Johannesendfe8c842008-09-26 19:32:34 +00001942 "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
1943 "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
1944 "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "VICMP",
1945 "VFCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1946 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1947 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1948 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1949 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1950 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1951 "GETRESULT", "EXTRACTVALUE", "INSERTVALUE", "SIGNEXT", "ZEROEXT",
1952 "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST",
Devang Patel652203f2008-09-29 20:49:50 +00001953 "READNONE", "READONLY", "GC", "OPTSIZE", "NOINLINE", "ALWAYSINLINE",
1954 "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'",
1955 "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'",
1956 "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates",
1957 "FPredicates", "IntType", "FPType", "LocalName", "OptLocalName",
1958 "OptAddrSpace", "OptLocalAssign", "LocalNumber", "GlobalName",
1959 "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
Devang Pateld4980812008-09-02 20:52:40 +00001960 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
Devang Patel05988662008-09-25 21:00:45 +00001961 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "Attribute",
Devang Patel652203f2008-09-29 20:49:50 +00001962 "OptAttributes", "RetAttr", "OptRetAttrs", "FuncAttr", "OptFuncAttrs",
1963 "OptGC", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1964 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1965 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1966 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "ThreadLocal",
1967 "AliaseeRef", "Module", "DefinitionList", "Definition", "@1", "@2", "@3",
1968 "@4", "@5", "AsmBlock", "TargetDefinition", "LibrariesDefinition",
1969 "LibList", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1970 "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect",
1971 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1972 "ReturnedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1973 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ParamList",
1974 "IndexList", "ConstantIndexList", "OptTailCall", "InstVal",
Chris Lattner15bd0952008-08-29 17:20:18 +00001975 "OptVolatile", "MemoryInst", 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00001976};
1977#endif
1978
1979# ifdef YYPRINT
1980/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1981 token YYLEX-NUM. */
1982static const yytype_uint16 yytoknum[] =
1983{
1984 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1985 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1986 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1987 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1988 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1989 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1990 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1991 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1992 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1993 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1994 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1995 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1996 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1997 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1998 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Devang Patel652203f2008-09-29 20:49:50 +00001999 405, 406, 407, 408, 409, 410, 411, 412, 413, 40,
2000 41, 61, 44, 42, 92, 91, 120, 93, 60, 62,
2001 123, 125, 99
Dan Gohmanf4423b12008-04-19 00:24:39 +00002002};
2003# endif
2004
2005/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002006static const yytype_uint16 yyr1[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002007{
Devang Patel652203f2008-09-29 20:49:50 +00002008 0, 173, 174, 174, 174, 174, 174, 174, 174, 174,
2009 174, 175, 175, 175, 175, 175, 175, 176, 176, 176,
2010 176, 176, 176, 176, 176, 176, 176, 176, 176, 177,
2011 177, 177, 177, 177, 177, 177, 177, 177, 177, 178,
2012 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
2013 178, 178, 178, 178, 178, 179, 180, 180, 180, 180,
2014 180, 181, 181, 181, 182, 182, 183, 183, 184, 184,
2015 185, 186, 186, 187, 187, 188, 189, 189, 189, 189,
2016 189, 189, 190, 190, 190, 191, 191, 191, 191, 192,
2017 192, 192, 193, 193, 193, 193, 193, 194, 194, 194,
2018 195, 195, 195, 195, 195, 195, 195, 196, 196, 196,
2019 196, 196, 196, 196, 196, 196, 196, 197, 197, 198,
2020 198, 198, 199, 199, 200, 200, 200, 200, 200, 200,
2021 200, 200, 200, 200, 201, 201, 202, 202, 203, 203,
2022 204, 204, 205, 206, 206, 207, 207, 208, 208, 209,
2023 209, 209, 209, 209, 209, 209, 210, 210, 210, 210,
2024 210, 210, 210, 210, 210, 210, 210, 210, 210, 211,
2025 212, 212, 213, 213, 214, 214, 214, 214, 215, 215,
2026 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
2027 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
2028 217, 217, 217, 217, 217, 217, 217, 217, 217, 217,
2029 217, 217, 217, 217, 218, 218, 219, 219, 220, 220,
2030 221, 221, 222, 222, 223, 223, 225, 224, 226, 224,
2031 224, 224, 224, 227, 224, 228, 224, 229, 224, 224,
2032 224, 224, 230, 231, 231, 232, 233, 233, 233, 234,
2033 234, 235, 235, 235, 235, 236, 237, 237, 238, 239,
2034 239, 240, 241, 242, 242, 243, 243, 243, 243, 243,
2035 243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
2036 243, 243, 243, 243, 243, 244, 244, 244, 244, 245,
2037 245, 246, 247, 247, 248, 248, 249, 249, 250, 250,
2038 250, 251, 251, 251, 251, 251, 251, 251, 251, 251,
2039 252, 252, 253, 253, 254, 254, 255, 255, 255, 255,
2040 255, 256, 256, 257, 257, 258, 258, 259, 259, 259,
2041 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
2042 259, 259, 260, 260, 261, 261, 261, 261, 261, 261,
2043 261, 261, 261, 261, 261
Dan Gohmanf4423b12008-04-19 00:24:39 +00002044};
2045
2046/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2047static const yytype_uint8 yyr2[] =
2048{
2049 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2050 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2051 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2052 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2053 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2054 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2055 1, 1, 1, 1, 1, 0, 4, 0, 2, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002056 2, 1, 1, 1, 0, 2, 1, 1, 1, 1,
2057 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,
2058 1, 1, 0, 1, 1, 1, 1, 0, 1, 1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002059 0, 1, 1, 1, 1, 1, 2, 1, 1, 1,
2060 1, 1, 1, 1, 1, 1, 2, 0, 2, 1,
Devang Patel652203f2008-09-29 20:49:50 +00002061 1, 1, 0, 2, 1, 1, 1, 1, 1, 1,
2062 1, 1, 1, 1, 0, 2, 0, 2, 0, 2,
2063 0, 3, 2, 0, 1, 0, 3, 1, 2, 1,
2064 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
2065 2, 5, 5, 5, 5, 3, 2, 5, 4, 2,
2066 1, 1, 1, 3, 1, 3, 1, 0, 1, 3,
2067 4, 3, 3, 4, 4, 3, 6, 5, 2, 2,
2068 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2069 6, 5, 8, 6, 6, 7, 7, 7, 7, 6,
2070 8, 8, 5, 7, 3, 1, 1, 1, 1, 0,
2071 2, 6, 1, 0, 1, 2, 0, 3, 0, 3,
2072 3, 3, 3, 0, 8, 0, 9, 0, 9, 5,
2073 2, 3, 1, 3, 3, 3, 3, 1, 0, 5,
2074 3, 1, 3, 1, 0, 11, 1, 1, 4, 1,
2075 1, 2, 3, 0, 1, 1, 1, 1, 1, 1,
2076 1, 1, 1, 1, 1, 3, 3, 2, 2, 3,
2077 2, 5, 4, 1, 5, 1, 1, 1, 1, 1,
2078 1, 2, 1, 3, 2, 2, 3, 3, 2, 0,
2079 1, 2, 2, 3, 9, 9, 8, 15, 1, 1,
2080 6, 5, 2, 2, 6, 7, 4, 4, 6, 6,
2081 0, 0, 3, 2, 3, 2, 1, 5, 5, 6,
2082 6, 6, 6, 4, 6, 4, 4, 6, 6, 2,
2083 9, 1, 1, 0, 3, 6, 3, 6, 2, 5,
2084 7, 5, 4, 4, 7
Dan Gohmanf4423b12008-04-19 00:24:39 +00002085};
2086
2087/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2088 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2089 means the default is an error. */
2090static const yytype_uint16 yydefact[] =
2091{
Devang Patel652203f2008-09-29 20:49:50 +00002092 74, 61, 71, 62, 72, 63, 228, 226, 0, 0,
2093 0, 0, 0, 0, 85, 73, 0, 74, 224, 89,
2094 92, 0, 0, 240, 0, 0, 68, 0, 75, 76,
Chris Lattner15bd0952008-08-29 17:20:18 +00002095 78, 77, 79, 82, 80, 83, 81, 84, 86, 87,
Devang Patel652203f2008-09-29 20:49:50 +00002096 88, 85, 85, 219, 1, 225, 90, 91, 85, 229,
2097 93, 94, 95, 96, 85, 299, 227, 299, 0, 0,
2098 248, 241, 242, 230, 285, 286, 232, 149, 150, 151,
2099 154, 153, 152, 155, 156, 0, 0, 0, 0, 287,
2100 288, 157, 231, 159, 219, 219, 97, 218, 0, 100,
2101 100, 300, 295, 69, 259, 260, 261, 294, 243, 244,
2102 247, 0, 177, 160, 0, 0, 0, 0, 166, 178,
2103 0, 0, 177, 0, 0, 0, 99, 98, 0, 216,
2104 217, 0, 0, 101, 102, 103, 104, 105, 122, 262,
2105 0, 0, 343, 343, 298, 0, 245, 176, 117, 172,
2106 174, 0, 0, 0, 0, 0, 0, 165, 0, 0,
2107 158, 0, 0, 171, 0, 170, 0, 239, 149, 150,
2108 151, 154, 153, 152, 0, 0, 67, 67, 106, 0,
2109 256, 257, 258, 70, 342, 326, 0, 0, 0, 0,
2110 100, 308, 309, 2, 3, 4, 5, 6, 7, 8,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002111 9, 10, 14, 15, 16, 11, 12, 13, 0, 0,
2112 0, 0, 0, 0, 0, 0, 17, 18, 19, 20,
2113 21, 22, 23, 24, 25, 26, 27, 28, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002115 296, 100, 312, 0, 341, 297, 313, 246, 169, 0,
2116 134, 67, 67, 168, 0, 179, 0, 134, 67, 67,
2117 0, 220, 197, 198, 193, 195, 194, 196, 199, 192,
2118 188, 189, 0, 0, 0, 0, 0, 0, 0, 0,
Dan Gohmane4977cf2008-05-23 01:55:30 +00002119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002120 191, 190, 233, 121, 120, 119, 123, 0, 325, 302,
2121 67, 292, 301, 0, 0, 55, 0, 122, 29, 30,
2122 31, 32, 33, 34, 35, 36, 37, 38, 0, 53,
2123 54, 49, 50, 51, 52, 39, 40, 41, 42, 43,
2124 44, 45, 46, 47, 48, 0, 0, 0, 140, 140,
2125 348, 67, 67, 339, 0, 0, 0, 0, 0, 67,
2126 67, 67, 67, 67, 0, 122, 0, 0, 0, 108,
2127 110, 109, 107, 111, 112, 113, 114, 115, 118, 175,
2128 173, 162, 163, 164, 167, 66, 161, 235, 237, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002129 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002130 0, 181, 215, 0, 0, 0, 185, 0, 182, 0,
2131 0, 0, 145, 0, 265, 266, 267, 268, 269, 274,
2132 270, 271, 272, 273, 263, 0, 0, 0, 0, 283,
2133 290, 289, 291, 0, 0, 303, 0, 0, 67, 67,
2134 67, 67, 0, 344, 0, 346, 321, 0, 0, 0,
2135 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2136 0, 67, 0, 116, 128, 127, 124, 126, 125, 129,
2137 130, 133, 131, 132, 135, 145, 145, 0, 0, 0,
2138 0, 0, 321, 0, 0, 0, 0, 0, 0, 0,
2139 180, 166, 178, 0, 183, 184, 0, 0, 0, 0,
2140 234, 254, 264, 0, 277, 0, 0, 0, 280, 0,
2141 278, 293, 0, 0, 0, 0, 0, 0, 0, 0,
2142 0, 0, 352, 0, 0, 0, 335, 336, 0, 0,
2143 0, 0, 353, 0, 0, 0, 333, 0, 140, 0,
2144 236, 238, 67, 0, 0, 0, 0, 0, 0, 0,
2145 0, 0, 0, 0, 214, 187, 0, 0, 0, 0,
2146 0, 0, 147, 145, 253, 117, 251, 0, 0, 276,
2147 166, 0, 275, 279, 0, 0, 0, 0, 0, 0,
2148 0, 140, 141, 140, 0, 0, 0, 0, 0, 0,
2149 351, 323, 0, 67, 327, 328, 0, 0, 349, 67,
2150 221, 0, 0, 0, 0, 201, 0, 0, 0, 0,
2151 212, 0, 186, 0, 0, 67, 142, 148, 146, 65,
2152 0, 134, 0, 282, 0, 0, 0, 320, 329, 330,
2153 331, 332, 345, 347, 322, 0, 0, 334, 337, 338,
2154 324, 0, 320, 140, 0, 0, 0, 0, 0, 209,
2155 0, 0, 0, 203, 204, 200, 64, 250, 252, 117,
2156 143, 284, 281, 0, 0, 117, 117, 0, 314, 0,
2157 354, 0, 350, 205, 206, 207, 208, 0, 0, 0,
2158 213, 65, 144, 138, 0, 306, 0, 0, 0, 0,
2159 134, 0, 315, 134, 202, 210, 211, 249, 0, 136,
2160 304, 0, 305, 0, 108, 110, 117, 117, 0, 117,
2161 117, 340, 139, 0, 255, 0, 0, 317, 316, 0,
2162 0, 0, 137, 0, 0, 0, 117, 117, 311, 0,
2163 0, 319, 318, 310, 0, 0, 307
Dan Gohmanf4423b12008-04-19 00:24:39 +00002164};
2165
2166/* YYDEFGOTO[NTERM-NUM]. */
2167static const yytype_int16 yydefgoto[] =
2168{
Devang Patel652203f2008-09-29 20:49:50 +00002169 -1, 277, 278, 279, 308, 325, 164, 165, 79, 637,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002170 113, 12, 133, 80, 14, 15, 41, 42, 43, 48,
Devang Patel652203f2008-09-29 20:49:50 +00002171 54, 118, 128, 358, 238, 286, 169, 454, 361, 694,
2172 679, 423, 542, 663, 480, 543, 81, 166, 139, 156,
2173 140, 141, 110, 382, 409, 383, 121, 88, 157, 16,
2174 17, 18, 20, 19, 392, 455, 456, 63, 23, 61,
2175 101, 546, 547, 129, 172, 55, 96, 56, 49, 483,
2176 410, 83, 412, 291, 292, 57, 92, 93, 230, 667,
2177 134, 333, 647, 502, 512, 231, 232, 233, 234
Dan Gohmanf4423b12008-04-19 00:24:39 +00002178};
2179
2180/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2181 STATE-NUM. */
Devang Patel652203f2008-09-29 20:49:50 +00002182#define YYPACT_NINF -620
Dan Gohmanf4423b12008-04-19 00:24:39 +00002183static const yytype_int16 yypact[] =
2184{
Devang Patel652203f2008-09-29 20:49:50 +00002185 484, -620, -620, -620, -620, -620, -620, -620, -14, -116,
2186 -6, -83, 104, -31, 24, -620, 161, 528, -620, 238,
2187 204, 43, 49, -620, 5, 196, -620, 1912, -620, -620,
2188 -620, -620, -620, -620, -620, -620, -620, -620, -620, -620,
2189 -620, 173, 173, 227, -620, -620, -620, -620, 173, -620,
2190 -620, -620, -620, -620, 173, 202, -620, -9, 234, 243,
2191 246, -620, -620, -620, -620, -620, 67, -620, -620, -620,
2192 -620, -620, -620, -620, -620, 273, 285, 3, 624, -620,
2193 -620, -620, 4, -620, 201, 201, 253, -620, 81, 240,
2194 240, -620, -620, 39, -620, -620, -620, -620, -620, -620,
2195 -620, -59, 1564, -620, 128, 132, 643, 67, -620, 4,
2196 -114, 165, 1564, 145, 81, 81, -620, -620, 1605, -620,
2197 -620, 2014, 324, -620, -620, -620, -620, -620, -620, -620,
2198 -13, 188, 2299, 2299, -620, 328, -620, -620, 4, -620,
2199 189, 194, 2076, 2076, 186, -111, 2076, -620, 352, 205,
2200 -620, 2014, 2076, 67, 208, 4, 247, -620, 216, 351,
2201 355, 359, 365, 368, 269, 372, 1625, 306, -620, 1517,
2202 -620, -620, -620, -620, -620, -620, 325, 2094, 38, 373,
2203 240, -620, -620, -620, -620, -620, -620, -620, -620, -620,
2204 -620, -620, -620, -620, -620, -620, -620, -620, 298, 336,
2205 298, 336, 2076, 2076, 2076, 2076, -620, -620, -620, -620,
2206 -620, -620, -620, -620, -620, -620, -620, -620, 2076, 2076,
2207 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076,
2208 -620, 240, -620, 66, -620, -620, -620, -620, 231, 1791,
2209 -620, -17, -21, -620, 214, 4, 225, -620, 306, -5,
2210 1605, -620, -620, -620, -620, -620, -620, -620, -620, -620,
2211 -620, -620, 298, 336, 298, 336, 229, 230, 249, 250,
2212 251, 252, 256, 1809, 2117, 690, 364, 257, 259, 261,
2213 -620, -620, -620, -620, -620, -620, -620, 114, -620, 67,
2214 1019, -620, 262, 1189, 1189, -620, 1189, -620, -620, -620,
2215 -620, -620, -620, -620, -620, -620, -620, -620, 2076, -620,
2216 -620, -620, -620, -620, -620, -620, -620, -620, -620, -620,
2217 -620, -620, -620, -620, -620, 2076, 2076, 2076, -23, 28,
2218 -620, 1019, -18, 265, 266, 268, 272, 288, 289, 1019,
2219 1019, 1019, 1019, 1019, 383, -620, 2076, 2076, 398, -620,
2220 -620, -620, -620, -620, -620, -620, -620, -620, -620, -620,
2221 -620, 137, -620, -620, -620, -620, 137, -620, 145, 385,
2222 293, 294, 295, 297, 2014, 2014, 2014, 2014, 2014, 2014,
2223 2014, -620, -620, -56, 1069, -74, -620, -80, -620, 2014,
2224 2014, 2014, 296, 300, -620, -620, -620, -620, -620, -620,
2225 -620, -620, -620, -620, 396, 1832, 2135, 1239, 403, -620,
2226 -620, -620, -620, 2076, 299, -620, 301, 1517, 1019, 1019,
2227 1019, 1019, 8, -620, 33, -620, -620, 1189, 303, 2076,
2228 2076, 2076, 2076, 2076, 302, 304, 307, 308, 309, 2076,
2229 1517, 1019, 312, -620, -620, -620, -620, -620, -620, -620,
2230 -620, -620, -620, -620, -620, 296, 296, 2076, 2014, 2014,
2231 2014, 2014, -620, 317, 318, 319, 320, 304, 323, 2014,
2232 -620, 326, 1471, -77, -620, -620, 327, 330, 424, 2,
2233 -620, 1850, -620, 443, -620, -52, 1280, -73, -620, -72,
2234 -620, -620, 469, 471, 1189, 332, 334, 337, 338, 1189,
2235 494, 1189, 339, 343, 1189, 347, 4, -620, 348, 349,
2236 508, 519, 362, 2076, 1189, 1189, 4, 1189, 363, 2076,
2237 -620, -620, 26, 367, 375, 377, 387, 149, 2014, 2014,
2238 2014, 2014, 157, 2014, -620, -620, 357, 2014, 2014, 2076,
2239 505, 526, -620, 296, -620, 4, 391, 394, 393, -620,
2240 366, -62, -620, -620, 1189, 1189, 386, 1189, 1189, 1189,
2241 1189, 363, -620, 363, 2076, 1189, 395, 2076, 2076, 2076,
2242 -620, -620, 552, 1019, -620, -620, 405, 511, -620, 1019,
2243 -620, 2014, 2014, 2014, 2014, -620, 400, 406, 407, 408,
2244 -620, 304, -620, 411, 412, 57, -620, -620, -620, 11,
2245 1891, -620, 545, -620, 399, 413, 414, 2179, -620, -620,
2246 -620, -620, -620, -620, -620, 409, 1189, -620, -620, -620,
2247 -620, 304, 2179, 363, 417, 418, 423, 425, 2014, -620,
2248 2014, 2014, 180, -620, -620, -620, -620, -620, -620, 4,
2249 172, -620, -620, 556, -3, 46, 4, 181, -620, 422,
2250 362, 184, -620, -620, -620, -620, -620, 430, 431, 432,
2251 -620, 11, -620, 539, 1189, -620, 1337, -1, 865, 865,
2252 -620, 2197, -620, -620, -620, -620, -620, -620, 590, 445,
2253 -620, 433, -620, 1337, 446, 453, -620, -620, 86, 46,
2254 4, 137, -620, 582, -620, 596, 452, 231, 231, 598,
2255 865, 865, -620, 1189, 599, 1189, -620, -620, -620, 1189,
2256 544, 231, 231, -620, 603, 1189, -620
Dan Gohmanf4423b12008-04-19 00:24:39 +00002257};
2258
2259/* YYPGOTO[NTERM-NUM]. */
2260static const yytype_int16 yypgoto[] =
2261{
Devang Patel652203f2008-09-29 20:49:50 +00002262 -620, 42, 112, 200, -160, -158, -177, -620, 0, -39,
2263 -151, 531, -620, 9, -620, -620, -620, -620, 77, -620,
2264 -620, -620, -152, -620, -518, -620, -268, -620, -244, -620,
2265 -620, -311, -15, -620, -414, -620, -620, -26, 389, -164,
2266 -620, 514, 523, 142, -162, -261, 220, 263, 380, -620,
2267 -620, 625, -620, -620, -620, -620, -620, -620, -620, -620,
2268 -620, -620, -620, 559, -620, -620, -620, -620, -620, -620,
2269 -619, -82, 267, -198, -620, -620, 595, -620, 535, -620,
2270 -620, -620, 47, 215, -456, -620, 543, -620, -620
Dan Gohmanf4423b12008-04-19 00:24:39 +00002271};
2272
2273/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2274 positive, shift that token. If negative, reduce the rule which
2275 number is the opposite. If zero, do what YYDEFACT says.
2276 If YYTABLE_NINF, syntax error. */
Devang Patel652203f2008-09-29 20:49:50 +00002277#define YYTABLE_NINF -224
Dan Gohmanf4423b12008-04-19 00:24:39 +00002278static const yytype_int16 yytable[] =
2279{
Devang Patel652203f2008-09-29 20:49:50 +00002280 11, 82, 296, 366, 280, 287, 330, 105, 295, 13,
2281 295, 532, 91, 385, 387, 170, 282, 11, 425, 499,
2282 94, 334, 335, 336, 337, 338, 13, 599, 297, 417,
2283 1, 344, 111, 3, 111, 5, 540, 111, 111, 21,
2284 326, 520, 521, 327, 501, 24, 131, 681, 146, 293,
2285 111, 146, 109, 25, 22, 294, 541, 147, 1, 111,
2286 244, 3, 500, 5, 696, 348, 29, 30, 31, 32,
2287 33, 34, 35, 36, 251, 37, 138, 440, 26, 345,
2288 109, 111, 469, 111, 281, 469, 138, 500, 469, 469,
2289 469, 475, 155, 11, 536, 474, 552, 367, 368, 553,
2290 469, -155, 370, 135, 372, 371, 469, 373, 136, 604,
2291 469, 470, 111, 119, 120, 549, 241, 242, 84, 85,
2292 245, 661, 27, 473, 699, 89, 249, 668, 669, 598,
2293 28, 90, 349, 350, 2, 632, 112, 4, 112, 422,
2294 -67, 112, 112, 155, 485, 487, 489, 427, 363, 442,
2295 362, 290, 351, 352, 112, 353, 354, 171, 355, 356,
2296 357, 44, 95, 112, 665, 650, 682, -67, 697, 698,
2297 60, 700, 701, 106, 227, 227, 328, 329, 290, 331,
2298 38, 39, 40, 346, 347, 112, 580, 112, 711, 712,
2299 424, -67, 332, 290, 290, 290, 290, 290, 339, 340,
2300 341, 342, 343, 290, 58, -155, 540, 578, 411, -155,
2301 59, 411, 411, 138, 411, 491, 112, 635, 62, -55,
2302 -55, -55, -55, 91, 155, 551, 102, 444, 445, 446,
2303 447, 505, 448, 507, 508, 509, 449, 450, 87, 451,
2304 452, 453, 252, 253, 228, 228, 50, 51, 52, 411,
2305 612, 53, 613, 494, 64, 65, 98, 411, 411, 411,
2306 411, 411, 86, 167, 87, 99, 1, 2, 100, 3,
2307 4, 5, 254, 255, 256, 257, 517, 103, 444, 445,
2308 446, 447, 418, 448, 46, 348, 47, 449, 450, 104,
2309 451, 452, 453, 248, 142, 116, 393, 117, 143, 419,
2310 420, 421, 122, 123, 124, 125, 126, 127, 150, 585,
2311 280, 564, 652, 444, 445, 446, 447, 590, 448, 572,
2312 441, 290, 449, 450, 148, 451, 452, 453, 168, 38,
2313 39, 40, 229, 229, 151, 152, 411, 411, 411, 411,
2314 660, 670, 572, 671, 673, 411, 671, 114, 115, 173,
2315 237, 239, 349, 350, 240, 243, 246, 640, 472, 411,
2316 -56, 111, 309, 310, -57, 247, 614, 250, -60, 617,
2317 618, 619, 351, 352, -59, 353, 354, -58, 355, 356,
2318 357, 258, 288, 364, 295, 365, 388, 290, 374, 375,
2319 281, 155, 298, 299, 300, 301, 302, 303, 304, 305,
2320 306, 307, 443, 290, 506, 290, 290, 290, 376, 377,
2321 378, 379, 411, 516, 155, 380, 389, 411, 390, 411,
2322 391, 439, 411, 457, 413, 490, 688, 428, 429, 691,
2323 430, 522, 411, 411, 431, 411, 311, 312, 313, 314,
2324 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2325 432, 433, 458, 459, 460, 545, 461, 482, 479, 481,
2326 472, 492, 539, 493, 510, 548, 511, 666, 504, 513,
2327 514, 515, 411, 411, 519, 411, 411, 411, 411, 528,
2328 529, 530, 531, 411, -223, 533, 554, 573, 555, 537,
2329 683, 411, 538, 579, 557, 535, 558, 411, 562, 559,
2330 560, 564, -69, 1, 2, 565, 3, 4, 5, 567,
2331 568, 569, 570, 595, 6, 7, 462, 463, 464, 465,
2332 466, 467, 468, 571, 572, 577, 592, 596, -222, 581,
2333 597, 476, 477, 478, 411, 603, 8, 582, 290, 583,
2334 9, 290, 290, 290, 10, 607, -69, 1, 2, 584,
2335 3, 4, 5, 600, 601, 602, 620, 616, 6, 7,
2336 414, 415, 628, 416, 622, 500, 629, 641, 642, 630,
2337 631, 633, 634, 664, 639, 643, 648, 653, 654, 644,
2338 8, 646, 411, 655, 9, 656, 411, 411, 10, 672,
2339 674, 675, 676, 678, 692, 695, 646, 693, 426, 636,
2340 523, 524, 525, 526, 702, -18, 434, 435, 436, 437,
2341 438, 534, -19, 703, 704, 705, 709, 714, 411, 411,
2342 715, 411, 677, 411, 132, 662, 149, 411, 360, 145,
2343 369, 64, 65, 411, 107, 67, 68, 69, 70, 71,
2344 72, 73, 45, 1, 2, 690, 3, 4, 5, 130,
2345 64, 65, 97, 107, 67, 68, 69, 70, 71, 72,
2346 73, 636, 1, 2, 0, 3, 4, 5, 235, 651,
2347 586, 587, 588, 589, 74, 591, 236, 527, 0, 593,
2348 594, 0, 0, 0, 0, 495, 496, 497, 498, 0,
2349 0, 0, 0, 74, 503, 0, 0, 64, 65, 0,
2350 107, 158, 159, 160, 161, 162, 163, 73, 518, 1,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002351 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002352 0, 0, 0, 624, 625, 626, 627, 0, 0, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002353 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002354 74, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002355 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002356 0, 556, 0, 0, 0, 0, 561, 0, 563, 0,
2357 657, 566, 658, 659, 0, 0, 0, 0, 0, 0,
2358 0, 574, 575, 0, 576, 0, 0, 0, 75, 76,
2359 0, 0, 77, 0, 78, 108, 0, 0, 0, 0,
2360 0, 0, 0, 0, 0, 0, 0, 75, 76, 0,
2361 0, 77, 0, 78, 144, 0, 0, 0, 0, 0,
2362 0, 605, 606, 0, 608, 609, 610, 611, 0, 0,
2363 0, 0, 615, 0, 0, 0, 0, 0, 0, 0,
2364 621, 0, 0, 0, 0, 0, 623, 0, 0, 0,
2365 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2366 78, 386, 0, 0, 0, 0, 0, 0, 394, 395,
2367 396, 397, 64, 65, 398, 0, 0, 0, 0, 0,
2368 0, 0, 0, 649, 1, 2, 0, 3, 4, 5,
2369 399, 400, 401, 0, 0, 0, 0, 0, 0, 0,
2370 0, 0, 0, 0, 0, 402, 403, 0, 0, 0,
2371 0, 0, 0, 0, 0, 0, 0, 0, 0, 348,
2372 0, 0, 0, 0, 404, 0, 0, 0, 0, 0,
2373 0, 680, 0, 0, 0, 686, 687, 0, 0, 0,
2374 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
2375 193, 194, 195, 196, 197, 262, 263, 264, 265, 0,
2376 0, 0, 0, 0, 0, 0, 0, 706, 707, 0,
2377 708, 0, 710, 0, 0, 0, 713, 0, 0, 0,
2378 0, 0, 716, 0, 266, 206, 684, 685, 209, 210,
2379 211, 212, 213, 214, 215, 216, 217, 0, 267, 0,
2380 268, 269, 270, 0, 271, 272, 351, 352, 0, 353,
2381 354, 0, 355, 356, 357, 0, 0, 0, 0, 0,
2382 0, 0, 394, 395, 396, 397, 64, 65, 398, 0,
2383 405, 0, 0, 406, 0, 407, 0, 408, 1, 2,
2384 0, 3, 4, 5, 399, 400, 401, 0, 0, 0,
2385 0, 0, 0, 0, 0, 0, 0, 0, 0, 402,
2386 403, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2387 0, 0, 0, 0, 111, 0, 64, 65, 404, 107,
2388 158, 159, 160, 161, 162, 163, 73, 0, 1, 2,
2389 0, 3, 4, 5, 183, 184, 185, 186, 187, 188,
2390 189, 190, 191, 192, 193, 194, 195, 196, 197, 262,
2391 263, 264, 265, 0, 0, 0, 0, 0, 0, 74,
Chris Lattnerccef6b52008-09-23 21:18:31 +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, 266, 206,
2394 207, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2395 217, 0, 267, 0, 268, 269, 270, 0, 271, 272,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002396 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002397 0, 0, 0, 0, 0, 0, 0, 0, 112, 0,
2398 0, 0, 0, 0, 405, 0, 0, 406, 0, 407,
2399 0, 408, 394, 395, 396, 397, 64, 65, 398, 0,
2400 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
2401 0, 3, 4, 5, 399, 400, 401, 0, 0, 0,
2402 0, 0, 0, 0, 0, 0, 0, 0, 0, 402,
2403 403, 0, 0, 75, 76, 0, 0, 77, 0, 78,
2404 471, 0, 0, 0, 0, 0, 64, 65, 404, 107,
2405 158, 159, 160, 161, 162, 163, 73, 0, 1, 2,
2406 0, 3, 4, 5, 183, 184, 185, 186, 187, 188,
2407 189, 190, 191, 192, 193, 194, 195, 196, 197, 262,
2408 263, 264, 265, 0, 0, 0, 0, 64, 65, 74,
2409 107, 158, 159, 160, 161, 162, 163, 73, 0, 1,
2410 2, 0, 3, 4, 5, 0, 0, 0, 266, 206,
2411 207, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2412 217, 0, 267, 0, 268, 269, 270, 0, 271, 272,
2413 74, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2414 394, 395, 396, 397, 0, 0, 398, 0, 0, 0,
2415 0, 0, 0, 0, 405, 0, 0, 406, 0, 407,
2416 0, 408, 399, 400, 401, 0, 0, 0, 0, 0,
2417 0, 0, 0, 0, 0, 0, 0, 402, 403, 0,
2418 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2419 0, 0, 0, 0, 0, 0, 404, 0, 0, 0,
2420 0, 0, 0, 75, 76, 0, 0, 77, 0, 78,
2421 488, 0, 183, 184, 185, 186, 187, 188, 189, 190,
2422 191, 192, 193, 194, 195, 196, 197, 262, 263, 264,
2423 265, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2424 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2425 78, 550, 0, 0, 0, 0, 266, 206, 207, 208,
2426 209, 210, 211, 212, 213, 214, 215, 216, 217, 0,
2427 267, 0, 268, 269, 270, 0, 271, 272, 64, 65,
2428 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2429 1, 2, 0, 3, 4, 5, 259, 0, 0, 0,
2430 0, 0, 405, 0, 0, 406, 0, 407, 0, 408,
2431 0, 260, 261, 0, 0, 0, 0, 0, 0, 0,
2432 0, 0, 0, 0, 64, 65, 111, 153, 67, 68,
2433 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
2434 4, 5, 0, 0, 0, 0, 183, 184, 185, 186,
2435 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
2436 197, 262, 263, 264, 265, 0, 0, 74, 0, 0,
2437 0, 64, 65, 0, 107, 67, 68, 69, 70, 71,
2438 72, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2439 266, 206, 207, 208, 209, 210, 211, 212, 213, 214,
2440 215, 216, 217, 137, 267, 0, 268, 269, 270, 0,
2441 271, 272, 64, 65, 74, 153, 67, 68, 69, 70,
2442 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2443 112, 0, 64, 65, -67, 0, 273, 0, 0, 274,
2444 0, 275, 0, 276, 1, 2, 0, 3, 4, 5,
2445 259, 0, 0, 0, 0, 74, 0, 0, 283, 284,
2446 0, 285, 0, 0, 0, 260, 261, 0, 0, 0,
2447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2448 111, 75, 76, 0, 0, 77, 0, 78, 0, 0,
2449 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2450 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
2451 193, 194, 195, 196, 197, 262, 263, 264, 265, 0,
2452 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2453 154, 0, 77, 0, 78, 0, 0, 0, 0, 0,
2454 0, 0, 0, 0, 266, 206, 207, 208, 209, 210,
2455 211, 212, 213, 214, 215, 216, 217, 0, 267, 0,
2456 268, 269, 270, 0, 271, 272, 0, 0, 0, 75,
2457 76, 0, 0, 77, 0, 78, 0, 0, 0, 0,
2458 0, 0, 0, 0, 112, 0, 0, 0, 0, 0,
2459 273, 0, 0, 274, 0, 275, 0, 276, 64, 65,
2460 0, 107, 67, 68, 69, 70, 71, 72, 73, 0,
2461 1, 2, 0, 3, 4, 5, 64, 65, 0, 107,
2462 158, 159, 160, 161, 162, 163, 73, 0, 1, 2,
2463 359, 3, 4, 5, 0, 0, 0, 0, 0, 64,
2464 65, 74, 107, 158, 159, 160, 161, 162, 163, 73,
2465 0, 1, 2, 0, 3, 4, 5, 64, 65, 74,
2466 107, 67, 68, 69, 70, 71, 72, 73, 0, 1,
2467 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2468 0, 0, 74, 0, 0, 0, 0, 0, 0, 544,
2469 0, 0, 0, 0, 0, 0, 0, 0, 64, 65,
2470 74, 107, 67, 68, 69, 70, 71, 72, 73, 0,
2471 1, 2, 0, 3, 4, 5, 0, 0, 0, 64,
2472 65, 0, 66, 67, 68, 69, 70, 71, 72, 73,
2473 638, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2474 0, 74, 0, 0, 0, 0, 0, 0, 0, 0,
2475 0, 0, 0, 0, 0, 75, 76, 0, 0, 77,
2476 0, 78, 74, 0, 0, 0, 0, 0, 0, 0,
2477 0, 0, 0, 75, 76, 0, 381, 77, 0, 78,
2478 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2479 0, 0, 0, 0, 0, 0, 75, 76, 0, 484,
2480 77, 0, 78, 0, 0, 0, 0, 0, 0, 0,
2481 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2482 78, 64, 65, 0, 107, 158, 159, 160, 161, 162,
2483 163, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2484 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2485 0, 0, 0, 0, 0, 75, 76, 0, 0, 77,
2486 0, 78, 0, 0, 74, 0, 0, 0, 0, 0,
2487 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2488 77, 0, 78, 64, 65, 0, 107, 67, 68, 69,
2489 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
2490 5, 64, 65, 0, 289, 67, 68, 69, 70, 71,
2491 72, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2492 0, 0, 0, 0, 64, 65, 74, 107, 158, 159,
2493 160, 161, 162, 163, 73, 0, 1, 2, 0, 3,
2494 4, 5, 64, 65, 74, 107, 158, 159, 160, 161,
2495 162, 163, 73, 0, 1, 2, 0, 3, 4, 5,
2496 0, 0, 0, 0, 0, 0, 0, 74, 0, 0,
2497 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2498 0, 0, 77, 0, 78, 74, 64, 65, 0, 107,
2499 67, 68, 69, 70, 71, 72, 645, 0, 1, 2,
2500 0, 3, 4, 5, 64, 65, 0, 107, 67, 68,
2501 69, 70, 71, 72, 689, 0, 1, 2, 0, 3,
2502 4, 5, 0, 0, 0, 0, 0, 0, 0, 74,
2503 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2504 75, 76, 0, 0, 77, 0, 78, 74, 0, 0,
2505 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2506 0, 0, 77, 0, 78, 0, 0, 0, 0, 0,
2507 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2508 0, 75, 76, 0, 0, 77, 0, 384, 0, 0,
2509 0, 0, 0, 0, 0, 0, 0, 0, 0, 75,
2510 76, 0, 0, 77, 0, 486, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002511 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2512 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002513 0, 0, 0, 0, 0, 174, 0, 0, 0, 0,
2514 0, 0, 0, 75, 76, 0, 0, 77, 0, 78,
2515 0, 0, 0, 0, 0, 0, 175, 176, 0, 0,
2516 0, 75, 76, 0, 0, 77, 0, 78, 177, 178,
2517 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
2518 189, 190, 191, 192, 193, 194, 195, 196, 197, 198,
2519 199, 200, 201, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002520 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002521 0, 0, 0, 202, 203, 204, 0, 0, 205, 206,
2522 207, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2523 217, 218, 219, 220, 221, 222, 223, 224, 225, 226
Dan Gohmanf4423b12008-04-19 00:24:39 +00002524};
2525
2526static const yytype_int16 yycheck[] =
2527{
Devang Patel652203f2008-09-29 20:49:50 +00002528 0, 27, 179, 247, 166, 169, 204, 4, 11, 0,
2529 11, 467, 21, 274, 275, 28, 167, 17, 329, 11,
2530 29, 219, 220, 221, 222, 223, 17, 545, 180, 297,
2531 19, 229, 55, 22, 55, 24, 34, 55, 55, 53,
2532 200, 455, 456, 201, 11, 161, 7, 666, 162, 11,
2533 55, 162, 78, 59, 68, 17, 54, 171, 19, 55,
2534 171, 22, 54, 24, 683, 54, 42, 43, 44, 45,
2535 46, 47, 48, 49, 156, 51, 102, 345, 161, 231,
2536 106, 55, 162, 55, 166, 162, 112, 54, 162, 162,
2537 162, 171, 118, 93, 171, 169, 169, 248, 249, 171,
2538 162, 55, 262, 162, 264, 263, 162, 265, 167, 171,
2539 162, 167, 55, 32, 33, 167, 142, 143, 41, 42,
2540 146, 639, 18, 384, 38, 48, 152, 645, 646, 543,
2541 161, 54, 121, 122, 20, 591, 159, 23, 159, 162,
2542 163, 159, 159, 169, 405, 406, 407, 165, 169, 347,
2543 167, 177, 141, 142, 159, 144, 145, 170, 147, 148,
2544 149, 0, 171, 159, 167, 621, 167, 163, 686, 687,
2545 165, 689, 690, 170, 132, 133, 202, 203, 204, 205,
2546 156, 157, 158, 117, 118, 159, 160, 159, 706, 707,
2547 162, 163, 218, 219, 220, 221, 222, 223, 224, 225,
2548 226, 227, 228, 229, 161, 159, 34, 518, 290, 163,
2549 161, 293, 294, 239, 296, 413, 159, 160, 22, 3,
2550 4, 5, 6, 21, 250, 486, 159, 141, 142, 143,
2551 144, 429, 146, 431, 432, 433, 150, 151, 37, 153,
2552 154, 155, 26, 27, 132, 133, 42, 43, 44, 331,
2553 561, 47, 563, 417, 7, 8, 22, 339, 340, 341,
2554 342, 343, 35, 121, 37, 22, 19, 20, 22, 22,
2555 23, 24, 3, 4, 5, 6, 440, 4, 141, 142,
2556 143, 144, 308, 146, 46, 54, 48, 150, 151, 4,
2557 153, 154, 155, 151, 166, 42, 287, 44, 166, 325,
2558 326, 327, 62, 63, 64, 65, 66, 67, 163, 160,
2559 472, 162, 623, 141, 142, 143, 144, 160, 146, 162,
2560 346, 347, 150, 151, 159, 153, 154, 155, 4, 156,
2561 157, 158, 132, 133, 114, 115, 418, 419, 420, 421,
2562 160, 160, 162, 162, 160, 427, 162, 84, 85, 161,
2563 22, 162, 121, 122, 160, 169, 4, 601, 384, 441,
2564 9, 55, 26, 27, 9, 160, 564, 159, 9, 567,
2565 568, 569, 141, 142, 9, 144, 145, 9, 147, 148,
2566 149, 9, 57, 169, 11, 160, 22, 413, 159, 159,
2567 472, 417, 94, 95, 96, 97, 98, 99, 100, 101,
2568 102, 103, 4, 429, 430, 431, 432, 433, 159, 159,
2569 159, 159, 494, 439, 440, 159, 159, 499, 159, 501,
2570 159, 38, 504, 38, 162, 22, 670, 162, 162, 673,
2571 162, 457, 514, 515, 162, 517, 100, 101, 102, 103,
2572 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
2573 162, 162, 159, 159, 159, 481, 159, 61, 162, 159,
2574 486, 162, 38, 162, 162, 22, 162, 644, 165, 162,
2575 162, 162, 554, 555, 162, 557, 558, 559, 560, 162,
2576 162, 162, 162, 565, 0, 162, 17, 513, 17, 162,
2577 667, 573, 162, 519, 162, 169, 162, 579, 4, 162,
2578 162, 162, 18, 19, 20, 162, 22, 23, 24, 162,
2579 162, 162, 4, 539, 30, 31, 374, 375, 376, 377,
2580 378, 379, 380, 4, 162, 162, 169, 22, 0, 162,
2581 4, 389, 390, 391, 616, 169, 52, 162, 564, 162,
2582 56, 567, 568, 569, 60, 159, 18, 19, 20, 162,
2583 22, 23, 24, 162, 160, 162, 4, 162, 30, 31,
2584 293, 294, 162, 296, 159, 54, 160, 22, 169, 162,
2585 162, 160, 160, 17, 600, 162, 167, 160, 160, 165,
2586 52, 607, 664, 160, 56, 160, 668, 669, 60, 167,
2587 160, 160, 160, 54, 4, 162, 622, 152, 331, 599,
2588 458, 459, 460, 461, 22, 159, 339, 340, 341, 342,
2589 343, 469, 159, 17, 162, 17, 17, 73, 700, 701,
2590 17, 703, 661, 705, 93, 640, 112, 709, 239, 106,
2591 250, 7, 8, 715, 10, 11, 12, 13, 14, 15,
2592 16, 17, 17, 19, 20, 671, 22, 23, 24, 90,
2593 7, 8, 57, 10, 11, 12, 13, 14, 15, 16,
2594 17, 661, 19, 20, -1, 22, 23, 24, 133, 622,
2595 528, 529, 530, 531, 50, 533, 133, 462, -1, 537,
2596 538, -1, -1, -1, -1, 418, 419, 420, 421, -1,
2597 -1, -1, -1, 50, 427, -1, -1, 7, 8, -1,
2598 10, 11, 12, 13, 14, 15, 16, 17, 441, 19,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002599 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002600 -1, -1, -1, 581, 582, 583, 584, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002601 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002602 50, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002603 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002604 -1, 494, -1, -1, -1, -1, 499, -1, 501, -1,
2605 628, 504, 630, 631, -1, -1, -1, -1, -1, -1,
2606 -1, 514, 515, -1, 517, -1, -1, -1, 164, 165,
2607 -1, -1, 168, -1, 170, 171, -1, -1, -1, -1,
2608 -1, -1, -1, -1, -1, -1, -1, 164, 165, -1,
2609 -1, 168, -1, 170, 171, -1, -1, -1, -1, -1,
2610 -1, 554, 555, -1, 557, 558, 559, 560, -1, -1,
2611 -1, -1, 565, -1, -1, -1, -1, -1, -1, -1,
2612 573, -1, -1, -1, -1, -1, 579, -1, -1, -1,
2613 -1, -1, -1, -1, 164, 165, -1, -1, 168, -1,
2614 170, 171, -1, -1, -1, -1, -1, -1, 3, 4,
2615 5, 6, 7, 8, 9, -1, -1, -1, -1, -1,
2616 -1, -1, -1, 616, 19, 20, -1, 22, 23, 24,
2617 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
2618 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2619 -1, -1, -1, -1, -1, -1, -1, -1, -1, 54,
2620 -1, -1, -1, -1, 59, -1, -1, -1, -1, -1,
2621 -1, 664, -1, -1, -1, 668, 669, -1, -1, -1,
2622 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2623 85, 86, 87, 88, 89, 90, 91, 92, 93, -1,
2624 -1, -1, -1, -1, -1, -1, -1, 700, 701, -1,
2625 703, -1, 705, -1, -1, -1, 709, -1, -1, -1,
2626 -1, -1, 715, -1, 119, 120, 121, 122, 123, 124,
2627 125, 126, 127, 128, 129, 130, 131, -1, 133, -1,
2628 135, 136, 137, -1, 139, 140, 141, 142, -1, 144,
2629 145, -1, 147, 148, 149, -1, -1, -1, -1, -1,
2630 -1, -1, 3, 4, 5, 6, 7, 8, 9, -1,
2631 165, -1, -1, 168, -1, 170, -1, 172, 19, 20,
2632 -1, 22, 23, 24, 25, 26, 27, -1, -1, -1,
2633 -1, -1, -1, -1, -1, -1, -1, -1, -1, 40,
2634 41, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2635 -1, -1, -1, -1, 55, -1, 7, 8, 59, 10,
Devang Pateld4980812008-09-02 20:52:40 +00002636 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Devang Patel652203f2008-09-29 20:49:50 +00002637 -1, 22, 23, 24, 75, 76, 77, 78, 79, 80,
2638 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2639 91, 92, 93, -1, -1, -1, -1, -1, -1, 50,
Devang Pateld4980812008-09-02 20:52:40 +00002640 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002641 -1, -1, -1, -1, -1, -1, -1, -1, 119, 120,
2642 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
2643 131, -1, 133, -1, 135, 136, 137, -1, 139, 140,
2644 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2645 -1, -1, -1, -1, -1, -1, -1, -1, 159, -1,
2646 -1, -1, -1, -1, 165, -1, -1, 168, -1, 170,
2647 -1, 172, 3, 4, 5, 6, 7, 8, 9, -1,
2648 -1, -1, -1, -1, -1, -1, -1, -1, 19, 20,
2649 -1, 22, 23, 24, 25, 26, 27, -1, -1, -1,
2650 -1, -1, -1, -1, -1, -1, -1, -1, -1, 40,
2651 41, -1, -1, 164, 165, -1, -1, 168, -1, 170,
2652 171, -1, -1, -1, -1, -1, 7, 8, 59, 10,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002653 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Devang Patel652203f2008-09-29 20:49:50 +00002654 -1, 22, 23, 24, 75, 76, 77, 78, 79, 80,
2655 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2656 91, 92, 93, -1, -1, -1, -1, 7, 8, 50,
Devang Pateld4980812008-09-02 20:52:40 +00002657 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
Devang Patel652203f2008-09-29 20:49:50 +00002658 20, -1, 22, 23, 24, -1, -1, -1, 119, 120,
2659 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
2660 131, -1, 133, -1, 135, 136, 137, -1, 139, 140,
2661 50, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2662 3, 4, 5, 6, -1, -1, 9, -1, -1, -1,
2663 -1, -1, -1, -1, 165, -1, -1, 168, -1, 170,
2664 -1, 172, 25, 26, 27, -1, -1, -1, -1, -1,
2665 -1, -1, -1, -1, -1, -1, -1, 40, 41, -1,
Devang Pateld4980812008-09-02 20:52:40 +00002666 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002667 -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
2668 -1, -1, -1, 164, 165, -1, -1, 168, -1, 170,
2669 171, -1, 75, 76, 77, 78, 79, 80, 81, 82,
2670 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2671 93, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2672 -1, -1, -1, -1, 164, 165, -1, -1, 168, -1,
2673 170, 171, -1, -1, -1, -1, 119, 120, 121, 122,
2674 123, 124, 125, 126, 127, 128, 129, 130, 131, -1,
2675 133, -1, 135, 136, 137, -1, 139, 140, 7, 8,
2676 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2677 19, 20, -1, 22, 23, 24, 25, -1, -1, -1,
2678 -1, -1, 165, -1, -1, 168, -1, 170, -1, 172,
2679 -1, 40, 41, -1, -1, -1, -1, -1, -1, -1,
2680 -1, -1, -1, -1, 7, 8, 55, 10, 11, 12,
2681 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2682 23, 24, -1, -1, -1, -1, 75, 76, 77, 78,
2683 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2684 89, 90, 91, 92, 93, -1, -1, 50, -1, -1,
2685 -1, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2686 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2687 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2688 129, 130, 131, 39, 133, -1, 135, 136, 137, -1,
2689 139, 140, 7, 8, 50, 10, 11, 12, 13, 14,
2690 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2691 159, -1, 7, 8, 163, -1, 165, -1, -1, 168,
2692 -1, 170, -1, 172, 19, 20, -1, 22, 23, 24,
2693 25, -1, -1, -1, -1, 50, -1, -1, 141, 142,
2694 -1, 144, -1, -1, -1, 40, 41, -1, -1, -1,
2695 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2696 55, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2697 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2698 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2699 85, 86, 87, 88, 89, 90, 91, 92, 93, -1,
2700 -1, -1, -1, -1, -1, -1, -1, -1, 164, 165,
2701 125, -1, 168, -1, 170, -1, -1, -1, -1, -1,
2702 -1, -1, -1, -1, 119, 120, 121, 122, 123, 124,
2703 125, 126, 127, 128, 129, 130, 131, -1, 133, -1,
2704 135, 136, 137, -1, 139, 140, -1, -1, -1, 164,
2705 165, -1, -1, 168, -1, 170, -1, -1, -1, -1,
2706 -1, -1, -1, -1, 159, -1, -1, -1, -1, -1,
2707 165, -1, -1, 168, -1, 170, -1, 172, 7, 8,
2708 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002709 19, 20, -1, 22, 23, 24, 7, 8, -1, 10,
2710 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Devang Patel652203f2008-09-29 20:49:50 +00002711 39, 22, 23, 24, -1, -1, -1, -1, -1, 7,
2712 8, 50, 10, 11, 12, 13, 14, 15, 16, 17,
2713 -1, 19, 20, -1, 22, 23, 24, 7, 8, 50,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002714 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2715 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002716 -1, -1, 50, -1, -1, -1, -1, -1, -1, 39,
2717 -1, -1, -1, -1, -1, -1, -1, -1, 7, 8,
2718 50, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2719 19, 20, -1, 22, 23, 24, -1, -1, -1, 7,
2720 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2721 39, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2722 -1, 50, -1, -1, -1, -1, -1, -1, -1, -1,
2723 -1, -1, -1, -1, -1, 164, 165, -1, -1, 168,
2724 -1, 170, 50, -1, -1, -1, -1, -1, -1, -1,
2725 -1, -1, -1, 164, 165, -1, 167, 168, -1, 170,
Chris Lattner15bd0952008-08-29 17:20:18 +00002726 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002727 -1, -1, -1, -1, -1, -1, 164, 165, -1, 167,
2728 168, -1, 170, -1, -1, -1, -1, -1, -1, -1,
2729 -1, -1, -1, -1, 164, 165, -1, -1, 168, -1,
2730 170, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2731 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002732 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002733 -1, -1, -1, -1, -1, 164, 165, -1, -1, 168,
2734 -1, 170, -1, -1, 50, -1, -1, -1, -1, -1,
2735 -1, -1, -1, -1, -1, -1, 164, 165, -1, -1,
2736 168, -1, 170, 7, 8, -1, 10, 11, 12, 13,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002737 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2738 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2739 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002740 -1, -1, -1, -1, 7, 8, 50, 10, 11, 12,
2741 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2742 23, 24, 7, 8, 50, 10, 11, 12, 13, 14,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002743 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
Devang Patel652203f2008-09-29 20:49:50 +00002744 -1, -1, -1, -1, -1, -1, -1, 50, -1, -1,
2745 -1, -1, -1, -1, -1, -1, -1, -1, 164, 165,
2746 -1, -1, 168, -1, 170, 50, 7, 8, -1, 10,
2747 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2748 -1, 22, 23, 24, 7, 8, -1, 10, 11, 12,
2749 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2750 23, 24, -1, -1, -1, -1, -1, -1, -1, 50,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002751 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002752 164, 165, -1, -1, 168, -1, 170, 50, -1, -1,
2753 -1, -1, -1, -1, -1, -1, -1, -1, 164, 165,
2754 -1, -1, 168, -1, 170, -1, -1, -1, -1, -1,
2755 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2756 -1, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2757 -1, -1, -1, -1, -1, -1, -1, -1, -1, 164,
2758 165, -1, -1, 168, -1, 170, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002759 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002760 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002761 -1, -1, -1, -1, -1, 36, -1, -1, -1, -1,
2762 -1, -1, -1, 164, 165, -1, -1, 168, -1, 170,
2763 -1, -1, -1, -1, -1, -1, 57, 58, -1, -1,
2764 -1, 164, 165, -1, -1, 168, -1, 170, 69, 70,
2765 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2766 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2767 91, 92, 93, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002768 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002769 -1, -1, -1, 114, 115, 116, -1, -1, 119, 120,
2770 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
2771 131, 132, 133, 134, 135, 136, 137, 138, 139, 140
Dan Gohmanf4423b12008-04-19 00:24:39 +00002772};
2773
2774/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2775 symbol of state STATE-NUM. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002776static const yytype_uint16 yystos[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002777{
Dale Johannesenc7071cc2008-05-14 20:13:36 +00002778 0, 19, 20, 22, 23, 24, 30, 31, 52, 56,
Devang Patel652203f2008-09-29 20:49:50 +00002779 60, 181, 184, 186, 187, 188, 222, 223, 224, 226,
2780 225, 53, 68, 231, 161, 59, 161, 18, 161, 42,
2781 43, 44, 45, 46, 47, 48, 49, 51, 156, 157,
2782 158, 189, 190, 191, 0, 224, 46, 48, 192, 241,
2783 42, 43, 44, 47, 193, 238, 240, 248, 161, 161,
2784 165, 232, 22, 230, 7, 8, 10, 11, 12, 13,
2785 14, 15, 16, 17, 50, 164, 165, 168, 170, 181,
2786 186, 209, 210, 244, 191, 191, 35, 37, 220, 191,
2787 191, 21, 249, 250, 29, 171, 239, 249, 22, 22,
2788 22, 233, 159, 4, 4, 4, 170, 10, 171, 210,
2789 215, 55, 159, 183, 220, 220, 42, 44, 194, 32,
2790 33, 219, 62, 63, 64, 65, 66, 67, 195, 236,
2791 236, 7, 184, 185, 253, 162, 167, 39, 210, 211,
2792 213, 214, 166, 166, 171, 215, 162, 171, 159, 214,
2793 163, 219, 219, 10, 125, 210, 212, 221, 11, 12,
2794 13, 14, 15, 16, 179, 180, 210, 216, 4, 199,
2795 28, 170, 237, 161, 36, 57, 58, 69, 70, 71,
Chris Lattner15bd0952008-08-29 17:20:18 +00002796 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2797 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002798 92, 93, 114, 115, 116, 119, 120, 121, 122, 123,
Chris Lattner15bd0952008-08-29 17:20:18 +00002799 124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
Devang Patel652203f2008-09-29 20:49:50 +00002800 134, 135, 136, 137, 138, 139, 140, 174, 175, 176,
2801 251, 258, 259, 260, 261, 251, 259, 22, 197, 162,
2802 160, 210, 210, 169, 171, 210, 4, 160, 216, 210,
2803 159, 244, 26, 27, 3, 4, 5, 6, 9, 25,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002804 40, 41, 90, 91, 92, 93, 119, 133, 135, 136,
Devang Patel652203f2008-09-29 20:49:50 +00002805 137, 139, 140, 165, 168, 170, 172, 174, 175, 176,
2806 217, 244, 183, 141, 142, 144, 198, 212, 57, 10,
2807 210, 246, 247, 11, 17, 11, 179, 195, 94, 95,
2808 96, 97, 98, 99, 100, 101, 102, 103, 177, 26,
2809 27, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2810 109, 110, 111, 112, 113, 178, 177, 178, 210, 210,
2811 246, 210, 210, 254, 246, 246, 246, 246, 246, 210,
2812 210, 210, 210, 210, 246, 195, 117, 118, 54, 121,
2813 122, 141, 142, 144, 145, 147, 148, 149, 196, 39,
2814 211, 201, 167, 169, 169, 160, 201, 183, 183, 221,
2815 177, 178, 177, 178, 159, 159, 159, 159, 159, 159,
2816 159, 167, 216, 218, 170, 218, 171, 218, 22, 159,
2817 159, 159, 227, 186, 3, 4, 5, 6, 9, 25,
2818 26, 27, 40, 41, 59, 165, 168, 170, 172, 217,
2819 243, 244, 245, 162, 245, 245, 245, 199, 210, 210,
2820 210, 210, 162, 204, 162, 204, 245, 165, 162, 162,
2821 162, 162, 162, 162, 245, 245, 245, 245, 245, 38,
2822 199, 210, 246, 4, 141, 142, 143, 144, 146, 150,
2823 151, 153, 154, 155, 200, 228, 229, 38, 159, 159,
2824 159, 159, 216, 216, 216, 216, 216, 216, 216, 162,
2825 167, 171, 210, 218, 169, 171, 216, 216, 216, 162,
2826 207, 159, 61, 242, 167, 218, 170, 218, 171, 218,
2827 22, 246, 162, 162, 212, 245, 245, 245, 245, 11,
2828 54, 11, 256, 245, 165, 246, 210, 246, 246, 246,
2829 162, 162, 257, 162, 162, 162, 210, 212, 245, 162,
2830 207, 207, 210, 216, 216, 216, 216, 256, 162, 162,
2831 162, 162, 257, 162, 216, 169, 171, 162, 162, 38,
2832 34, 54, 205, 208, 39, 210, 234, 235, 22, 167,
2833 171, 218, 169, 171, 17, 17, 245, 162, 162, 162,
2834 162, 245, 4, 245, 162, 162, 245, 162, 162, 162,
2835 4, 4, 162, 210, 245, 245, 245, 162, 204, 210,
2836 160, 162, 162, 162, 162, 160, 216, 216, 216, 216,
2837 160, 216, 169, 216, 216, 210, 22, 4, 207, 197,
2838 162, 160, 162, 169, 171, 245, 245, 159, 245, 245,
2839 245, 245, 204, 204, 246, 245, 162, 246, 246, 246,
2840 4, 245, 159, 245, 216, 216, 216, 216, 162, 160,
2841 162, 162, 257, 160, 160, 160, 181, 182, 39, 210,
2842 201, 22, 169, 162, 165, 17, 210, 255, 167, 245,
2843 257, 255, 204, 160, 160, 160, 160, 216, 216, 216,
2844 160, 197, 205, 206, 17, 167, 179, 252, 197, 197,
2845 160, 162, 167, 160, 160, 160, 160, 182, 54, 203,
2846 245, 243, 167, 179, 121, 122, 245, 245, 201, 17,
2847 210, 201, 4, 152, 202, 162, 243, 197, 197, 38,
2848 197, 197, 22, 17, 162, 17, 245, 245, 245, 17,
2849 245, 197, 197, 245, 73, 17, 245
Dan Gohmanf4423b12008-04-19 00:24:39 +00002850};
David Greene718fda32007-08-01 03:59:32 +00002851
Reid Spencer68a24bd2005-08-27 18:50:39 +00002852#define yyerrok (yyerrstatus = 0)
2853#define yyclearin (yychar = YYEMPTY)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002854#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002855#define YYEOF 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00002856
Reid Spencer68a24bd2005-08-27 18:50:39 +00002857#define YYACCEPT goto yyacceptlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002858#define YYABORT goto yyabortlab
2859#define YYERROR goto yyerrorlab
2860
2861
2862/* Like YYERROR except do call yyerror. This remains here temporarily
2863 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002864 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00002865
Reid Spencer68a24bd2005-08-27 18:50:39 +00002866#define YYFAIL goto yyerrlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002867
Reid Spencer68a24bd2005-08-27 18:50:39 +00002868#define YYRECOVERING() (!!yyerrstatus)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002869
2870#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002871do \
2872 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002873 { \
2874 yychar = (Token); \
2875 yylval = (Value); \
2876 yytoken = YYTRANSLATE (yychar); \
2877 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002878 goto yybackup; \
2879 } \
2880 else \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002881 { \
2882 yyerror (YY_("syntax error: cannot back up")); \
2883 YYERROR; \
2884 } \
2885while (YYID (0))
2886
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002887
Reid Spencer68a24bd2005-08-27 18:50:39 +00002888#define YYTERROR 1
2889#define YYERRCODE 256
2890
Dan Gohmanf4423b12008-04-19 00:24:39 +00002891
2892/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2893 If N is 0, then set CURRENT to the empty location which ends
2894 the previous symbol: RHS[0] (always defined). */
2895
2896#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2897#ifndef YYLLOC_DEFAULT
2898# define YYLLOC_DEFAULT(Current, Rhs, N) \
2899 do \
2900 if (YYID (N)) \
2901 { \
2902 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2903 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2904 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2905 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2906 } \
2907 else \
2908 { \
2909 (Current).first_line = (Current).last_line = \
2910 YYRHSLOC (Rhs, 0).last_line; \
2911 (Current).first_column = (Current).last_column = \
2912 YYRHSLOC (Rhs, 0).last_column; \
2913 } \
2914 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002915#endif
2916
Dan Gohmanf4423b12008-04-19 00:24:39 +00002917
2918/* YY_LOCATION_PRINT -- Print the location on the stream.
2919 This macro was not mandated originally: define only if we know
2920 we won't break user code: when these are the locations we know. */
2921
2922#ifndef YY_LOCATION_PRINT
Nuno Lopes9e9631d2008-10-03 15:45:58 +00002923# if YYLTYPE_IS_TRIVIAL
Dan Gohmanf4423b12008-04-19 00:24:39 +00002924# define YY_LOCATION_PRINT(File, Loc) \
2925 fprintf (File, "%d.%d-%d.%d", \
2926 (Loc).first_line, (Loc).first_column, \
2927 (Loc).last_line, (Loc).last_column)
2928# else
2929# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2930# endif
2931#endif
2932
2933
2934/* YYLEX -- calling `yylex' with the right arguments. */
2935
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002936#ifdef YYLEX_PARAM
Dan Gohmanf4423b12008-04-19 00:24:39 +00002937# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002938#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002939# define YYLEX yylex ()
Gabor Greife64d2482008-04-06 23:07:54 +00002940#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002941
2942/* Enable debugging if requested. */
2943#if YYDEBUG
2944
2945# ifndef YYFPRINTF
2946# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2947# define YYFPRINTF fprintf
2948# endif
2949
2950# define YYDPRINTF(Args) \
2951do { \
2952 if (yydebug) \
2953 YYFPRINTF Args; \
2954} while (YYID (0))
2955
2956# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2957do { \
2958 if (yydebug) \
2959 { \
2960 YYFPRINTF (stderr, "%s ", Title); \
2961 yy_symbol_print (stderr, \
2962 Type, Value); \
2963 YYFPRINTF (stderr, "\n"); \
2964 } \
2965} while (YYID (0))
2966
2967
2968/*--------------------------------.
2969| Print this symbol on YYOUTPUT. |
2970`--------------------------------*/
2971
2972/*ARGSUSED*/
2973#if (defined __STDC__ || defined __C99__FUNC__ \
2974 || defined __cplusplus || defined _MSC_VER)
2975static void
2976yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greife64d2482008-04-06 23:07:54 +00002977#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002978static void
2979yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2980 FILE *yyoutput;
2981 int yytype;
2982 YYSTYPE const * const yyvaluep;
Gabor Greife64d2482008-04-06 23:07:54 +00002983#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002984{
2985 if (!yyvaluep)
2986 return;
2987# ifdef YYPRINT
2988 if (yytype < YYNTOKENS)
2989 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2990# else
2991 YYUSE (yyoutput);
2992# endif
2993 switch (yytype)
2994 {
2995 default:
2996 break;
2997 }
2998}
2999
3000
3001/*--------------------------------.
3002| Print this symbol on YYOUTPUT. |
3003`--------------------------------*/
3004
3005#if (defined __STDC__ || defined __C99__FUNC__ \
3006 || defined __cplusplus || defined _MSC_VER)
3007static void
3008yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3009#else
3010static void
3011yy_symbol_print (yyoutput, yytype, yyvaluep)
3012 FILE *yyoutput;
3013 int yytype;
3014 YYSTYPE const * const yyvaluep;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003015#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003016{
3017 if (yytype < YYNTOKENS)
3018 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3019 else
3020 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner38905612008-02-19 04:36:25 +00003021
Dan Gohmanf4423b12008-04-19 00:24:39 +00003022 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3023 YYFPRINTF (yyoutput, ")");
3024}
Chris Lattner38905612008-02-19 04:36:25 +00003025
Dan Gohmanf4423b12008-04-19 00:24:39 +00003026/*------------------------------------------------------------------.
3027| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3028| TOP (included). |
3029`------------------------------------------------------------------*/
Chris Lattner38905612008-02-19 04:36:25 +00003030
Dan Gohmanf4423b12008-04-19 00:24:39 +00003031#if (defined __STDC__ || defined __C99__FUNC__ \
3032 || defined __cplusplus || defined _MSC_VER)
3033static void
3034yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3035#else
3036static void
3037yy_stack_print (bottom, top)
3038 yytype_int16 *bottom;
3039 yytype_int16 *top;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003040#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003041{
3042 YYFPRINTF (stderr, "Stack now");
3043 for (; bottom <= top; ++bottom)
3044 YYFPRINTF (stderr, " %d", *bottom);
3045 YYFPRINTF (stderr, "\n");
3046}
Chris Lattner38905612008-02-19 04:36:25 +00003047
Dan Gohmanf4423b12008-04-19 00:24:39 +00003048# define YY_STACK_PRINT(Bottom, Top) \
3049do { \
3050 if (yydebug) \
3051 yy_stack_print ((Bottom), (Top)); \
3052} while (YYID (0))
Chris Lattner38905612008-02-19 04:36:25 +00003053
Dan Gohmanf4423b12008-04-19 00:24:39 +00003054
3055/*------------------------------------------------.
3056| Report that the YYRULE is going to be reduced. |
3057`------------------------------------------------*/
3058
3059#if (defined __STDC__ || defined __C99__FUNC__ \
3060 || defined __cplusplus || defined _MSC_VER)
3061static void
3062yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3063#else
3064static void
3065yy_reduce_print (yyvsp, yyrule)
3066 YYSTYPE *yyvsp;
3067 int yyrule;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003068#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003069{
3070 int yynrhs = yyr2[yyrule];
3071 int yyi;
3072 unsigned long int yylno = yyrline[yyrule];
3073 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3074 yyrule - 1, yylno);
3075 /* The symbols being reduced. */
3076 for (yyi = 0; yyi < yynrhs; yyi++)
3077 {
3078 fprintf (stderr, " $%d = ", yyi + 1);
3079 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3080 &(yyvsp[(yyi + 1) - (yynrhs)])
3081 );
3082 fprintf (stderr, "\n");
3083 }
3084}
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003085
Dan Gohmanf4423b12008-04-19 00:24:39 +00003086# define YY_REDUCE_PRINT(Rule) \
3087do { \
3088 if (yydebug) \
3089 yy_reduce_print (yyvsp, Rule); \
3090} while (YYID (0))
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003091
Dan Gohmanf4423b12008-04-19 00:24:39 +00003092/* Nonzero means print parse trace. It is left uninitialized so that
3093 multiple parsers can coexist. */
3094int yydebug;
3095#else /* !YYDEBUG */
3096# define YYDPRINTF(Args)
3097# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3098# define YY_STACK_PRINT(Bottom, Top)
3099# define YY_REDUCE_PRINT(Rule)
3100#endif /* !YYDEBUG */
3101
3102
3103/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003104#ifndef YYINITDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003105# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00003106#endif
3107
Dan Gohmanf4423b12008-04-19 00:24:39 +00003108/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3109 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00003110
Dan Gohmanf4423b12008-04-19 00:24:39 +00003111 Do not make this value too large; the results are undefined if
3112 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3113 evaluated with infinite-precision integer arithmetic. */
David Greene718fda32007-08-01 03:59:32 +00003114
Reid Spencer68a24bd2005-08-27 18:50:39 +00003115#ifndef YYMAXDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003116# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00003117#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003118
Reid Spencer68a24bd2005-08-27 18:50:39 +00003119
3120
Dan Gohmanf4423b12008-04-19 00:24:39 +00003121#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00003122
Dan Gohmanf4423b12008-04-19 00:24:39 +00003123# ifndef yystrlen
3124# if defined __GLIBC__ && defined _STRING_H
3125# define yystrlen strlen
3126# else
3127/* Return the length of YYSTR. */
3128#if (defined __STDC__ || defined __C99__FUNC__ \
3129 || defined __cplusplus || defined _MSC_VER)
3130static YYSIZE_T
3131yystrlen (const char *yystr)
Chris Lattner38905612008-02-19 04:36:25 +00003132#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003133static YYSIZE_T
3134yystrlen (yystr)
3135 const char *yystr;
3136#endif
3137{
3138 YYSIZE_T yylen;
3139 for (yylen = 0; yystr[yylen]; yylen++)
3140 continue;
3141 return yylen;
3142}
3143# endif
3144# endif
3145
3146# ifndef yystpcpy
3147# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3148# define yystpcpy stpcpy
3149# else
3150/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3151 YYDEST. */
3152#if (defined __STDC__ || defined __C99__FUNC__ \
3153 || defined __cplusplus || defined _MSC_VER)
3154static char *
3155yystpcpy (char *yydest, const char *yysrc)
3156#else
3157static char *
3158yystpcpy (yydest, yysrc)
3159 char *yydest;
3160 const char *yysrc;
3161#endif
3162{
3163 char *yyd = yydest;
3164 const char *yys = yysrc;
3165
3166 while ((*yyd++ = *yys++) != '\0')
3167 continue;
3168
3169 return yyd - 1;
3170}
3171# endif
3172# endif
3173
3174# ifndef yytnamerr
3175/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3176 quotes and backslashes, so that it's suitable for yyerror. The
3177 heuristic is that double-quoting is unnecessary unless the string
3178 contains an apostrophe, a comma, or backslash (other than
3179 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3180 null, do not copy; instead, return the length of what the result
3181 would have been. */
3182static YYSIZE_T
3183yytnamerr (char *yyres, const char *yystr)
3184{
3185 if (*yystr == '"')
3186 {
3187 YYSIZE_T yyn = 0;
3188 char const *yyp = yystr;
3189
3190 for (;;)
3191 switch (*++yyp)
3192 {
3193 case '\'':
3194 case ',':
3195 goto do_not_strip_quotes;
3196
3197 case '\\':
3198 if (*++yyp != '\\')
3199 goto do_not_strip_quotes;
3200 /* Fall through. */
3201 default:
3202 if (yyres)
3203 yyres[yyn] = *yyp;
3204 yyn++;
3205 break;
3206
3207 case '"':
3208 if (yyres)
3209 yyres[yyn] = '\0';
3210 return yyn;
3211 }
3212 do_not_strip_quotes: ;
3213 }
3214
3215 if (! yyres)
3216 return yystrlen (yystr);
3217
3218 return yystpcpy (yyres, yystr) - yyres;
3219}
3220# endif
3221
3222/* Copy into YYRESULT an error message about the unexpected token
3223 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3224 including the terminating null byte. If YYRESULT is null, do not
3225 copy anything; just return the number of bytes that would be
3226 copied. As a special case, return 0 if an ordinary "syntax error"
3227 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3228 size calculation. */
3229static YYSIZE_T
3230yysyntax_error (char *yyresult, int yystate, int yychar)
3231{
3232 int yyn = yypact[yystate];
3233
3234 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3235 return 0;
3236 else
3237 {
3238 int yytype = YYTRANSLATE (yychar);
3239 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3240 YYSIZE_T yysize = yysize0;
3241 YYSIZE_T yysize1;
3242 int yysize_overflow = 0;
3243 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3244 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3245 int yyx;
3246
3247# if 0
3248 /* This is so xgettext sees the translatable formats that are
3249 constructed on the fly. */
3250 YY_("syntax error, unexpected %s");
3251 YY_("syntax error, unexpected %s, expecting %s");
3252 YY_("syntax error, unexpected %s, expecting %s or %s");
3253 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3254 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3255# endif
3256 char *yyfmt;
3257 char const *yyf;
3258 static char const yyunexpected[] = "syntax error, unexpected %s";
3259 static char const yyexpecting[] = ", expecting %s";
3260 static char const yyor[] = " or %s";
3261 char yyformat[sizeof yyunexpected
3262 + sizeof yyexpecting - 1
3263 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3264 * (sizeof yyor - 1))];
3265 char const *yyprefix = yyexpecting;
3266
3267 /* Start YYX at -YYN if negative to avoid negative indexes in
3268 YYCHECK. */
3269 int yyxbegin = yyn < 0 ? -yyn : 0;
3270
3271 /* Stay within bounds of both yycheck and yytname. */
3272 int yychecklim = YYLAST - yyn + 1;
3273 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3274 int yycount = 1;
3275
3276 yyarg[0] = yytname[yytype];
3277 yyfmt = yystpcpy (yyformat, yyunexpected);
3278
3279 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3280 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3281 {
3282 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3283 {
3284 yycount = 1;
3285 yysize = yysize0;
3286 yyformat[sizeof yyunexpected - 1] = '\0';
3287 break;
3288 }
3289 yyarg[yycount++] = yytname[yyx];
3290 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3291 yysize_overflow |= (yysize1 < yysize);
3292 yysize = yysize1;
3293 yyfmt = yystpcpy (yyfmt, yyprefix);
3294 yyprefix = yyor;
3295 }
3296
3297 yyf = YY_(yyformat);
3298 yysize1 = yysize + yystrlen (yyf);
3299 yysize_overflow |= (yysize1 < yysize);
3300 yysize = yysize1;
3301
3302 if (yysize_overflow)
3303 return YYSIZE_MAXIMUM;
3304
3305 if (yyresult)
3306 {
3307 /* Avoid sprintf, as that infringes on the user's name space.
3308 Don't have undefined behavior even if the translation
3309 produced a string with the wrong number of "%s"s. */
3310 char *yyp = yyresult;
3311 int yyi = 0;
3312 while ((*yyp = *yyf) != '\0')
3313 {
3314 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3315 {
3316 yyp += yytnamerr (yyp, yyarg[yyi++]);
3317 yyf += 2;
3318 }
3319 else
3320 {
3321 yyp++;
3322 yyf++;
3323 }
3324 }
3325 }
3326 return yysize;
3327 }
3328}
3329#endif /* YYERROR_VERBOSE */
3330
3331
3332/*-----------------------------------------------.
3333| Release the memory associated to this symbol. |
3334`-----------------------------------------------*/
3335
3336/*ARGSUSED*/
3337#if (defined __STDC__ || defined __C99__FUNC__ \
3338 || defined __cplusplus || defined _MSC_VER)
3339static void
3340yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3341#else
3342static void
3343yydestruct (yymsg, yytype, yyvaluep)
3344 const char *yymsg;
3345 int yytype;
3346 YYSTYPE *yyvaluep;
3347#endif
3348{
3349 YYUSE (yyvaluep);
3350
3351 if (!yymsg)
3352 yymsg = "Deleting";
3353 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3354
3355 switch (yytype)
3356 {
3357
3358 default:
3359 break;
3360 }
3361}
3362
3363
3364/* Prevent warnings from -Wmissing-prototypes. */
3365
3366#ifdef YYPARSE_PARAM
3367#if defined __STDC__ || defined __cplusplus
3368int yyparse (void *YYPARSE_PARAM);
3369#else
3370int yyparse ();
3371#endif
3372#else /* ! YYPARSE_PARAM */
3373#if defined __STDC__ || defined __cplusplus
David Greene5fd22a82007-09-04 18:46:50 +00003374int yyparse (void);
Gabor Greife64d2482008-04-06 23:07:54 +00003375#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003376int yyparse ();
Scott Michel15dcd8e2008-01-30 03:10:00 +00003377#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003378#endif /* ! YYPARSE_PARAM */
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003379
Chris Lattner38905612008-02-19 04:36:25 +00003380
Dan Gohmanf4423b12008-04-19 00:24:39 +00003381
3382/* The look-ahead symbol. */
3383int yychar;
3384
3385/* The semantic value of the look-ahead symbol. */
3386YYSTYPE yylval;
3387
3388/* Number of syntax errors so far. */
3389int yynerrs;
3390
3391
3392
3393/*----------.
3394| yyparse. |
3395`----------*/
3396
3397#ifdef YYPARSE_PARAM
3398#if (defined __STDC__ || defined __C99__FUNC__ \
3399 || defined __cplusplus || defined _MSC_VER)
3400int
3401yyparse (void *YYPARSE_PARAM)
3402#else
3403int
3404yyparse (YYPARSE_PARAM)
3405 void *YYPARSE_PARAM;
3406#endif
3407#else /* ! YYPARSE_PARAM */
3408#if (defined __STDC__ || defined __C99__FUNC__ \
3409 || defined __cplusplus || defined _MSC_VER)
3410int
3411yyparse (void)
3412#else
3413int
3414yyparse ()
3415
Gabor Greife64d2482008-04-06 23:07:54 +00003416#endif
3417#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003418{
3419
3420 int yystate;
3421 int yyn;
3422 int yyresult;
3423 /* Number of tokens to shift before error messages enabled. */
3424 int yyerrstatus;
3425 /* Look-ahead token as an internal (translated) token number. */
3426 int yytoken = 0;
3427#if YYERROR_VERBOSE
3428 /* Buffer for error messages, and its allocated size. */
3429 char yymsgbuf[128];
3430 char *yymsg = yymsgbuf;
3431 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greife64d2482008-04-06 23:07:54 +00003432#endif
Chris Lattner38905612008-02-19 04:36:25 +00003433
Dan Gohmanf4423b12008-04-19 00:24:39 +00003434 /* Three stacks and their tools:
3435 `yyss': related to states,
3436 `yyvs': related to semantic values,
3437 `yyls': related to locations.
3438
3439 Refer to the stacks thru separate pointers, to allow yyoverflow
3440 to reallocate them elsewhere. */
3441
3442 /* The state stack. */
3443 yytype_int16 yyssa[YYINITDEPTH];
3444 yytype_int16 *yyss = yyssa;
3445 yytype_int16 *yyssp;
3446
3447 /* The semantic value stack. */
3448 YYSTYPE yyvsa[YYINITDEPTH];
3449 YYSTYPE *yyvs = yyvsa;
3450 YYSTYPE *yyvsp;
3451
3452
3453
3454#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3455
3456 YYSIZE_T yystacksize = YYINITDEPTH;
3457
3458 /* The variables used to return semantic value and location from the
3459 action routines. */
3460 YYSTYPE yyval;
3461
3462
3463 /* The number of symbols on the RHS of the reduced rule.
3464 Keep to zero when no symbol should be popped. */
3465 int yylen = 0;
3466
3467 YYDPRINTF ((stderr, "Starting parse\n"));
3468
Reid Spencer68a24bd2005-08-27 18:50:39 +00003469 yystate = 0;
3470 yyerrstatus = 0;
3471 yynerrs = 0;
3472 yychar = YYEMPTY; /* Cause a token to be read. */
3473
3474 /* Initialize stack pointers.
3475 Waste one element of value and location stack
3476 so that they stay on the same level as the state stack.
3477 The wasted elements are never initialized. */
3478
Dan Gohmanf4423b12008-04-19 00:24:39 +00003479 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003480 yyvsp = yyvs;
3481
Dan Gohmanf4423b12008-04-19 00:24:39 +00003482 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003483
Dan Gohmanf4423b12008-04-19 00:24:39 +00003484/*------------------------------------------------------------.
3485| yynewstate -- Push a new state, which is found in yystate. |
3486`------------------------------------------------------------*/
3487 yynewstate:
3488 /* In all cases, when you get here, the value and location stacks
3489 have just been pushed. So pushing a state here evens the stacks. */
3490 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003491
Dan Gohmanf4423b12008-04-19 00:24:39 +00003492 yysetstate:
3493 *yyssp = yystate;
3494
3495 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003496 {
3497 /* Get the current used size of the three stacks, in elements. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003498 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003499
3500#ifdef yyoverflow
Dan Gohmanf4423b12008-04-19 00:24:39 +00003501 {
3502 /* Give user a chance to reallocate the stack. Use copies of
3503 these so that the &'s don't force the real ones into
3504 memory. */
3505 YYSTYPE *yyvs1 = yyvs;
3506 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003507
Dan Gohmanf4423b12008-04-19 00:24:39 +00003508
3509 /* Each stack pointer address is followed by the size of the
3510 data in use in that stack, in bytes. This used to be a
3511 conditional around just the two extra args, but that might
3512 be undefined if yyoverflow is a macro. */
3513 yyoverflow (YY_("memory exhausted"),
3514 &yyss1, yysize * sizeof (*yyssp),
3515 &yyvs1, yysize * sizeof (*yyvsp),
3516
3517 &yystacksize);
3518
3519 yyss = yyss1;
3520 yyvs = yyvs1;
3521 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003522#else /* no yyoverflow */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003523# ifndef YYSTACK_RELOCATE
3524 goto yyexhaustedlab;
3525# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003526 /* Extend the stack our own way. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003527 if (YYMAXDEPTH <= yystacksize)
3528 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003529 yystacksize *= 2;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003530 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003531 yystacksize = YYMAXDEPTH;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003532
3533 {
3534 yytype_int16 *yyss1 = yyss;
3535 union yyalloc *yyptr =
3536 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3537 if (! yyptr)
3538 goto yyexhaustedlab;
3539 YYSTACK_RELOCATE (yyss);
3540 YYSTACK_RELOCATE (yyvs);
3541
3542# undef YYSTACK_RELOCATE
3543 if (yyss1 != yyssa)
3544 YYSTACK_FREE (yyss1);
3545 }
3546# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003547#endif /* no yyoverflow */
3548
Dan Gohmanf4423b12008-04-19 00:24:39 +00003549 yyssp = yyss + yysize - 1;
3550 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003551
3552
Dan Gohmanf4423b12008-04-19 00:24:39 +00003553 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3554 (unsigned long int) yystacksize));
3555
3556 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003557 YYABORT;
3558 }
3559
Dan Gohmanf4423b12008-04-19 00:24:39 +00003560 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003561
3562 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003563
Dan Gohmanf4423b12008-04-19 00:24:39 +00003564/*-----------.
3565| yybackup. |
3566`-----------*/
3567yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003568
Dan Gohmanf4423b12008-04-19 00:24:39 +00003569 /* Do appropriate processing given the current state. Read a
3570 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003571
Dan Gohmanf4423b12008-04-19 00:24:39 +00003572 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003573 yyn = yypact[yystate];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003574 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003575 goto yydefault;
3576
Dan Gohmanf4423b12008-04-19 00:24:39 +00003577 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003578
Dan Gohmanf4423b12008-04-19 00:24:39 +00003579 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003580 if (yychar == YYEMPTY)
3581 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003582 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003583 yychar = YYLEX;
3584 }
3585
Dan Gohmanf4423b12008-04-19 00:24:39 +00003586 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003587 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003588 yychar = yytoken = YYEOF;
3589 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003590 }
3591 else
3592 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003593 yytoken = YYTRANSLATE (yychar);
3594 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003595 }
3596
Dan Gohmanf4423b12008-04-19 00:24:39 +00003597 /* If the proper action on seeing token YYTOKEN is to reduce or to
3598 detect an error, take that action. */
3599 yyn += yytoken;
3600 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003601 goto yydefault;
3602 yyn = yytable[yyn];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003603 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003604 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003605 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003606 goto yyerrlab;
3607 yyn = -yyn;
3608 goto yyreduce;
3609 }
3610
3611 if (yyn == YYFINAL)
3612 YYACCEPT;
3613
Dan Gohmanf4423b12008-04-19 00:24:39 +00003614 /* Count tokens shifted since error; after three, turn off error
3615 status. */
3616 if (yyerrstatus)
3617 yyerrstatus--;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003618
Dan Gohmanf4423b12008-04-19 00:24:39 +00003619 /* Shift the look-ahead token. */
3620 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003621
Dan Gohmanf4423b12008-04-19 00:24:39 +00003622 /* Discard the shifted token unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003623 if (yychar != YYEOF)
3624 yychar = YYEMPTY;
3625
Gabor Greife64d2482008-04-06 23:07:54 +00003626 yystate = yyn;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003627 *++yyvsp = yylval;
3628
Reid Spencer68a24bd2005-08-27 18:50:39 +00003629 goto yynewstate;
3630
Gabor Greife64d2482008-04-06 23:07:54 +00003631
Dan Gohmanf4423b12008-04-19 00:24:39 +00003632/*-----------------------------------------------------------.
3633| yydefault -- do the default action for the current state. |
3634`-----------------------------------------------------------*/
3635yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003636 yyn = yydefact[yystate];
3637 if (yyn == 0)
3638 goto yyerrlab;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003639 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003640
Dan Gohmanf4423b12008-04-19 00:24:39 +00003641
3642/*-----------------------------.
3643| yyreduce -- Do a reduction. |
3644`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003645yyreduce:
Dan Gohmanf4423b12008-04-19 00:24:39 +00003646 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003647 yylen = yyr2[yyn];
3648
Dan Gohmanf4423b12008-04-19 00:24:39 +00003649 /* If YYLEN is nonzero, implement the default value of the action:
3650 `$$ = $1'.
3651
3652 Otherwise, the following line sets YYVAL to garbage.
3653 This behavior is undocumented and Bison
3654 users should not rely upon it. Assigning to YYVAL
3655 unconditionally makes the parser a bit smaller, and it avoids a
3656 GCC warning that YYVAL may be used uninitialized. */
3657 yyval = yyvsp[1-yylen];
3658
3659
3660 YY_REDUCE_PRINT (yyn);
3661 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003662 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003663 case 29:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003664#line 1146 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003665 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3666 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003667
Dan Gohmanf4423b12008-04-19 00:24:39 +00003668 case 30:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003669#line 1146 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003670 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3671 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003672
Dan Gohmanf4423b12008-04-19 00:24:39 +00003673 case 31:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003674#line 1147 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003675 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3676 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003677
Dan Gohmanf4423b12008-04-19 00:24:39 +00003678 case 32:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003679#line 1147 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003680 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3681 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003682
Dan Gohmanf4423b12008-04-19 00:24:39 +00003683 case 33:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003684#line 1148 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003685 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3686 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003687
Dan Gohmanf4423b12008-04-19 00:24:39 +00003688 case 34:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003689#line 1148 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003690 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3691 break;
3692
3693 case 35:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003694#line 1149 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003695 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3696 break;
3697
3698 case 36:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003699#line 1149 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003700 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3701 break;
3702
3703 case 37:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003704#line 1150 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003705 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3706 break;
3707
3708 case 38:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003709#line 1150 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003710 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3711 break;
3712
3713 case 39:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003714#line 1154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003715 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3716 break;
3717
3718 case 40:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003719#line 1154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003720 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3721 break;
3722
3723 case 41:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003724#line 1155 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003725 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3726 break;
3727
3728 case 42:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003729#line 1155 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003730 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3731 break;
3732
3733 case 43:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003734#line 1156 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003735 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3736 break;
3737
3738 case 44:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003739#line 1156 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003740 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3741 break;
3742
3743 case 45:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003744#line 1157 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003745 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3746 break;
3747
3748 case 46:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003749#line 1157 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003750 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3751 break;
3752
3753 case 47:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003754#line 1158 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003755 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3756 break;
3757
3758 case 48:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003759#line 1158 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003760 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3761 break;
3762
3763 case 49:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003764#line 1159 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003765 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3766 break;
3767
3768 case 50:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003769#line 1159 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003770 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3771 break;
3772
3773 case 51:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003774#line 1160 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003775 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3776 break;
3777
3778 case 52:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003779#line 1160 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003780 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3781 break;
3782
3783 case 53:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003784#line 1161 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003785 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3786 break;
3787
3788 case 54:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003789#line 1162 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003790 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3791 break;
3792
3793 case 65:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003794#line 1171 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003795 { (yyval.StrVal) = 0; ;}
3796 break;
3797
3798 case 66:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003799#line 1173 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003800 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3801 break;
3802
3803 case 67:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003804#line 1174 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003805 { (yyval.UIntVal)=0; ;}
3806 break;
3807
3808 case 68:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003809#line 1178 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003810 {
3811 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003812 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003813 ;}
3814 break;
3815
3816 case 69:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003817#line 1182 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003818 {
3819 (yyval.StrVal) = 0;
Christopher Lambbf3348d2007-12-12 08:45:45 +00003820 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003821 ;}
3822 break;
3823
Chris Lattner15bd0952008-08-29 17:20:18 +00003824 case 70:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003825#line 1187 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003826 {
Chris Lattner15bd0952008-08-29 17:20:18 +00003827 (yyval.UIntVal) = (yyvsp[(1) - (2)].UIntVal);
3828 CHECK_FOR_ERROR
3829;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003830 break;
3831
3832 case 74:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003833#line 1196 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003834 {
3835 (yyval.StrVal) = 0;
3836 CHECK_FOR_ERROR
3837 ;}
3838 break;
3839
3840 case 75:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003841#line 1201 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003842 {
3843 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00003844 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003845 ;}
3846 break;
3847
Chris Lattner15bd0952008-08-29 17:20:18 +00003848 case 76:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003849#line 1207 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003850 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3851 break;
3852
Chris Lattner15bd0952008-08-29 17:20:18 +00003853 case 77:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003854#line 1208 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003855 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3856 break;
3857
Chris Lattner15bd0952008-08-29 17:20:18 +00003858 case 78:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003859#line 1209 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003860 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3861 break;
3862
Chris Lattner15bd0952008-08-29 17:20:18 +00003863 case 79:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003864#line 1210 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003865 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3866 break;
3867
Chris Lattner15bd0952008-08-29 17:20:18 +00003868 case 80:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003869#line 1211 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003870 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3871 break;
3872
Chris Lattner15bd0952008-08-29 17:20:18 +00003873 case 81:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003874#line 1212 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003875 { (yyval.Linkage) = GlobalValue::CommonLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003876 break;
3877
Chris Lattner15bd0952008-08-29 17:20:18 +00003878 case 82:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003879#line 1216 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003880 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003881 break;
3882
Chris Lattner15bd0952008-08-29 17:20:18 +00003883 case 83:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003884#line 1217 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003885 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003886 break;
3887
Chris Lattner15bd0952008-08-29 17:20:18 +00003888 case 84:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003889#line 1218 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003890 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003891 break;
3892
Dan Gohmanf4423b12008-04-19 00:24:39 +00003893 case 85:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003894#line 1222 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003895 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003896 break;
3897
3898 case 86:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003899#line 1223 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003900 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003901 break;
3902
3903 case 87:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003904#line 1224 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003905 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003906 break;
3907
3908 case 88:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003909#line 1225 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003910 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003911 break;
3912
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003913 case 89:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003914#line 1229 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003915 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003916 break;
3917
3918 case 90:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003919#line 1230 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003920 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003921 break;
3922
3923 case 91:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003924#line 1231 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003925 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003926 break;
3927
3928 case 92:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003929#line 1235 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003930 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3931 break;
3932
Chris Lattner15bd0952008-08-29 17:20:18 +00003933 case 93:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003934#line 1236 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003935 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003936 break;
3937
Chris Lattner15bd0952008-08-29 17:20:18 +00003938 case 94:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003939#line 1237 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003940 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3941 break;
3942
3943 case 95:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003944#line 1238 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003945 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3946 break;
3947
3948 case 96:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003949#line 1239 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003950 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3951 break;
3952
3953 case 97:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003954#line 1243 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003955 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3956 break;
3957
3958 case 98:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003959#line 1244 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003960 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3961 break;
3962
Dan Gohmanf4423b12008-04-19 00:24:39 +00003963 case 99:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003964#line 1245 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003965 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003966 break;
3967
3968 case 100:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003969#line 1248 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003970 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003971 break;
3972
3973 case 101:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003974#line 1249 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003975 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003976 break;
3977
3978 case 102:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003979#line 1250 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003980 { (yyval.UIntVal) = CallingConv::Fast; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003981 break;
3982
3983 case 103:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003984#line 1251 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003985 { (yyval.UIntVal) = CallingConv::Cold; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003986 break;
3987
3988 case 104:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003989#line 1252 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003990 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003991 break;
3992
3993 case 105:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003994#line 1253 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003995 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00003996 break;
3997
3998 case 106:
Nuno Lopes191dfb92008-10-03 15:52:39 +00003999#line 1254 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004000 {
4001 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004002 GEN_ERROR("Calling conv too large");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004003 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004004 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004005 ;}
4006 break;
4007
Dale Johannesendfe8c842008-09-26 19:32:34 +00004008 case 107:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004009#line 1261 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesendfe8c842008-09-26 19:32:34 +00004010 { (yyval.Attributes) = Attribute::ZExt; ;}
4011 break;
4012
Dan Gohmanf4423b12008-04-19 00:24:39 +00004013 case 108:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004014#line 1262 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004015 { (yyval.Attributes) = Attribute::ZExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004016 break;
4017
4018 case 109:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004019#line 1263 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesendfe8c842008-09-26 19:32:34 +00004020 { (yyval.Attributes) = Attribute::SExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004021 break;
4022
4023 case 110:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004024#line 1264 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004025 { (yyval.Attributes) = Attribute::SExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004026 break;
4027
4028 case 111:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004029#line 1265 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004030 { (yyval.Attributes) = Attribute::InReg; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004031 break;
4032
Dale Johannesendfe8c842008-09-26 19:32:34 +00004033 case 112:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004034#line 1266 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004035 { (yyval.Attributes) = Attribute::StructRet; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004036 break;
4037
Dale Johannesendfe8c842008-09-26 19:32:34 +00004038 case 113:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004039#line 1267 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004040 { (yyval.Attributes) = Attribute::NoAlias; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004041 break;
4042
Dale Johannesendfe8c842008-09-26 19:32:34 +00004043 case 114:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004044#line 1268 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004045 { (yyval.Attributes) = Attribute::ByVal; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004046 break;
4047
Dale Johannesendfe8c842008-09-26 19:32:34 +00004048 case 115:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004049#line 1269 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004050 { (yyval.Attributes) = Attribute::Nest; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004051 break;
4052
Dale Johannesendfe8c842008-09-26 19:32:34 +00004053 case 116:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004054#line 1270 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004055 { (yyval.Attributes) =
4056 Attribute::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004057 break;
4058
Dale Johannesendfe8c842008-09-26 19:32:34 +00004059 case 117:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004060#line 1274 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004061 { (yyval.Attributes) = Attribute::None; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004062 break;
4063
Dale Johannesendfe8c842008-09-26 19:32:34 +00004064 case 118:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004065#line 1275 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesendfe8c842008-09-26 19:32:34 +00004066 {
4067 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4068 ;}
4069 break;
4070
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004071 case 119:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004072#line 1280 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004073 { (yyval.Attributes) = Attribute::InReg; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004074 break;
4075
Devang Patel652203f2008-09-29 20:49:50 +00004076 case 120:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004077#line 1281 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004078 { (yyval.Attributes) = Attribute::ZExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004079 break;
4080
Devang Patel652203f2008-09-29 20:49:50 +00004081 case 121:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004082#line 1282 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004083 { (yyval.Attributes) = Attribute::SExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004084 break;
4085
Devang Patel652203f2008-09-29 20:49:50 +00004086 case 122:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004087#line 1285 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004088 { (yyval.Attributes) = Attribute::None; ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00004089 break;
4090
Devang Patel652203f2008-09-29 20:49:50 +00004091 case 123:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004092#line 1286 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004093 {
4094 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4095 ;}
4096 break;
4097
4098 case 124:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004099#line 1292 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004100 { (yyval.Attributes) = Attribute::NoReturn; ;}
4101 break;
4102
4103 case 125:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004104#line 1293 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004105 { (yyval.Attributes) = Attribute::NoUnwind; ;}
4106 break;
4107
4108 case 126:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004109#line 1294 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004110 { (yyval.Attributes) = Attribute::InReg; ;}
4111 break;
4112
Dale Johannesendfe8c842008-09-26 19:32:34 +00004113 case 127:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004114#line 1295 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004115 { (yyval.Attributes) = Attribute::ZExt; ;}
4116 break;
4117
4118 case 128:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004119#line 1296 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004120 { (yyval.Attributes) = Attribute::SExt; ;}
4121 break;
4122
4123 case 129:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004124#line 1297 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004125 { (yyval.Attributes) = Attribute::ReadNone; ;}
4126 break;
4127
4128 case 130:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004129#line 1298 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004130 { (yyval.Attributes) = Attribute::ReadOnly; ;}
4131 break;
4132
4133 case 131:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004134#line 1299 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004135 { (yyval.Attributes) = Attribute::NoInline ;}
4136 break;
4137
4138 case 132:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004139#line 1300 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004140 { (yyval.Attributes) = Attribute::AlwaysInline ;}
4141 break;
4142
4143 case 133:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004144#line 1301 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004145 { (yyval.Attributes) = Attribute::OptimizeForSize ;}
4146 break;
4147
4148 case 134:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004149#line 1304 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004150 { (yyval.Attributes) = Attribute::None; ;}
4151 break;
4152
4153 case 135:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004154#line 1305 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004155 {
Devang Patel05988662008-09-25 21:00:45 +00004156 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
Chris Lattner15bd0952008-08-29 17:20:18 +00004157 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004158 break;
4159
Devang Patel652203f2008-09-29 20:49:50 +00004160 case 136:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004161#line 1311 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld4980812008-09-02 20:52:40 +00004162 { (yyval.StrVal) = 0; ;}
4163 break;
4164
Devang Patel652203f2008-09-29 20:49:50 +00004165 case 137:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004166#line 1312 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004167 {
4168 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4169 ;}
4170 break;
4171
Devang Patel652203f2008-09-29 20:49:50 +00004172 case 138:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004173#line 1319 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004174 { (yyval.UIntVal) = 0; ;}
4175 break;
4176
Devang Patel652203f2008-09-29 20:49:50 +00004177 case 139:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004178#line 1320 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004179 {
4180 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4181 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004182 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004183 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004184;}
4185 break;
4186
Devang Patel652203f2008-09-29 20:49:50 +00004187 case 140:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004188#line 1326 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004189 { (yyval.UIntVal) = 0; ;}
4190 break;
4191
Devang Patel652203f2008-09-29 20:49:50 +00004192 case 141:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004193#line 1327 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004194 {
4195 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4196 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lambbf3348d2007-12-12 08:45:45 +00004197 GEN_ERROR("Alignment must be a power of two");
4198 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004199;}
4200 break;
4201
Devang Patel652203f2008-09-29 20:49:50 +00004202 case 142:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004203#line 1336 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004204 {
4205 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
4206 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004207 GEN_ERROR("Invalid character in section name");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004208 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004209 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004210;}
4211 break;
4212
Devang Patel652203f2008-09-29 20:49:50 +00004213 case 143:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004214#line 1344 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004215 { (yyval.StrVal) = 0; ;}
4216 break;
4217
Devang Patel652203f2008-09-29 20:49:50 +00004218 case 144:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004219#line 1345 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004220 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4221 break;
4222
Devang Pateld4980812008-09-02 20:52:40 +00004223 case 145:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004224#line 1350 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004225 {;}
4226 break;
4227
Devang Pateld4980812008-09-02 20:52:40 +00004228 case 146:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004229#line 1351 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004230 {;}
4231 break;
4232
4233 case 147:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004234#line 1352 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004235 {
4236 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4237 delete (yyvsp[(1) - (1)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004238 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004239 ;}
4240 break;
4241
Devang Patel652203f2008-09-29 20:49:50 +00004242 case 148:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004243#line 1357 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004244 {
4245 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004246 GEN_ERROR("Alignment must be a power of two");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004247 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004248 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004249 ;}
4250 break;
4251
Devang Patel652203f2008-09-29 20:49:50 +00004252 case 156:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004253#line 1373 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004254 {
4255 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004256 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004257 ;}
4258 break;
4259
Devang Patel652203f2008-09-29 20:49:50 +00004260 case 157:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004261#line 1377 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004262 {
4263 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004264 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004265 ;}
4266 break;
4267
Devang Patel652203f2008-09-29 20:49:50 +00004268 case 158:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004269#line 1381 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004270 { // Pointer type?
4271 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lambbf3348d2007-12-12 08:45:45 +00004272 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004273 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4274 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00004275 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004276 ;}
4277 break;
4278
Devang Patel652203f2008-09-29 20:49:50 +00004279 case 159:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004280#line 1388 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004281 { // Named types are also simple types...
4282 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004283 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004284 (yyval.TypeVal) = new PATypeHolder(tmp);
4285 ;}
4286 break;
4287
Devang Patel652203f2008-09-29 20:49:50 +00004288 case 160:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004289#line 1393 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004290 { // Type UpReference
4291 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004292 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohmanf4423b12008-04-19 00:24:39 +00004293 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4294 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004295 UR_OUT("New Upreference!\n");
4296 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004297 ;}
4298 break;
4299
Devang Patel652203f2008-09-29 20:49:50 +00004300 case 161:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004301#line 1401 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004302 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004303 // Allow but ignore attributes on function types; this permits auto-upgrade.
4304 // FIXME: remove in LLVM 3.0.
Chris Lattnera925a142008-04-23 05:37:08 +00004305 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4306 if (!FunctionType::isValidReturnType(RetTy))
4307 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004308
Reid Spencer41dff5e2007-01-26 08:05:27 +00004309 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004310 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004311 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004312 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004313 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004314 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004315
Reid Spencer41dff5e2007-01-26 08:05:27 +00004316 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4317 if (isVarArg) Params.pop_back();
4318
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004319 for (unsigned i = 0; i != Params.size(); ++i)
4320 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4321 GEN_ERROR("Function arguments must be value types!");
4322
4323 CHECK_FOR_ERROR
4324
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004325 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004326 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4327 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
Eric Christopher2a5196f2008-09-24 04:55:49 +00004328 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004329 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004330 ;}
4331 break;
4332
Devang Patel652203f2008-09-29 20:49:50 +00004333 case 162:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004334#line 1430 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004335 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004336 // Allow but ignore attributes on function types; this permits auto-upgrade.
4337 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004338 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004339 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004340 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004341 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004342 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004343 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004344
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004345 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4346 if (isVarArg) Params.pop_back();
4347
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004348 for (unsigned i = 0; i != Params.size(); ++i)
4349 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4350 GEN_ERROR("Function arguments must be value types!");
4351
4352 CHECK_FOR_ERROR
4353
Dan Gohmanf4423b12008-04-19 00:24:39 +00004354 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
4355 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
Eric Christopher2a5196f2008-09-24 04:55:49 +00004356 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004357 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004358 ;}
4359 break;
4360
Devang Patel652203f2008-09-29 20:49:50 +00004361 case 163:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004362#line 1455 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004363 { // Sized array type?
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004364 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (yyvsp[(2) - (5)].UInt64Val))));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004365 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004366 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004367 ;}
4368 break;
4369
Devang Patel652203f2008-09-29 20:49:50 +00004370 case 164:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004371#line 1460 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004372 { // Vector type?
4373 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4374 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004375 GEN_ERROR("Unsigned result not equal to signed result");
4376 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4377 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004378 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4379 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004380 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004381 ;}
4382 break;
4383
Devang Patel652203f2008-09-29 20:49:50 +00004384 case 165:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004385#line 1470 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004386 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004387 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004388 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4389 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004390 Elements.push_back(*I);
4391
Dan Gohmanf4423b12008-04-19 00:24:39 +00004392 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4393 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004394 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004395 ;}
4396 break;
4397
Devang Patel652203f2008-09-29 20:49:50 +00004398 case 166:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004399#line 1480 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004400 { // Empty structure type?
4401 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004402 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004403 ;}
4404 break;
4405
Devang Patel652203f2008-09-29 20:49:50 +00004406 case 167:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004407#line 1484 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004408 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004409 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004410 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4411 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004412 Elements.push_back(*I);
4413
Dan Gohmanf4423b12008-04-19 00:24:39 +00004414 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4415 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004416 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004417 ;}
4418 break;
4419
Devang Patel652203f2008-09-29 20:49:50 +00004420 case 168:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004421#line 1494 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004422 { // Empty structure type?
4423 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004424 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004425 ;}
4426 break;
4427
Devang Patel652203f2008-09-29 20:49:50 +00004428 case 169:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004429#line 1501 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004430 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004431 // Allow but ignore attributes on function types; this permits auto-upgrade.
4432 // FIXME: remove in LLVM 3.0.
Eric Christopher2a5196f2008-09-24 04:55:49 +00004433 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
Devang Patel05988662008-09-25 21:00:45 +00004434 (yyval.TypeWithAttrs).Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004435 ;}
4436 break;
4437
Devang Patel652203f2008-09-29 20:49:50 +00004438 case 170:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004439#line 1510 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004440 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004441 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004442 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4443 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004444 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004445 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4446 ;}
4447 break;
4448
Devang Patel652203f2008-09-29 20:49:50 +00004449 case 171:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004450#line 1517 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004451 {
4452 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4453 ;}
4454 break;
4455
Devang Patel652203f2008-09-29 20:49:50 +00004456 case 172:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004457#line 1522 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004458 {
4459 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4460 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004461 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004462 ;}
4463 break;
4464
Devang Patel652203f2008-09-29 20:49:50 +00004465 case 173:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004466#line 1527 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004467 {
4468 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004469 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004470 ;}
4471 break;
4472
Devang Patel652203f2008-09-29 20:49:50 +00004473 case 175:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004474#line 1535 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004475 {
4476 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Devang Patel05988662008-09-25 21:00:45 +00004477 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004478 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004479 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004480 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004481 ;}
4482 break;
4483
Devang Patel652203f2008-09-29 20:49:50 +00004484 case 176:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004485#line 1542 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004486 {
4487 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Devang Patel05988662008-09-25 21:00:45 +00004488 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004489 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004490 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004491 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004492 ;}
4493 break;
4494
Devang Patel652203f2008-09-29 20:49:50 +00004495 case 177:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004496#line 1549 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004497 {
4498 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004499 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004500 ;}
4501 break;
4502
Devang Patel652203f2008-09-29 20:49:50 +00004503 case 178:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004504#line 1557 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004505 {
4506 (yyval.TypeList) = new std::list<PATypeHolder>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004507 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004508 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004509 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004510 ;}
4511 break;
4512
Devang Patel652203f2008-09-29 20:49:50 +00004513 case 179:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004514#line 1563 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004515 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00004516 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004517 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004518 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004519 ;}
4520 break;
4521
Devang Patel652203f2008-09-29 20:49:50 +00004522 case 180:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004523#line 1575 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004524 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004525 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004526 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4527 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004528 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004529 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004530 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004531 const Type *ETy = ATy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004532 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004533
4534 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004535 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004536 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004537 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004538 utostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004539
4540 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004541 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4542 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004543 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004544 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004545 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004546 }
4547
Dan Gohmanf4423b12008-04-19 00:24:39 +00004548 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4549 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004550 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004551 ;}
4552 break;
4553
Devang Patel652203f2008-09-29 20:49:50 +00004554 case 181:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004555#line 1603 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004556 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004557 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004558 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4559 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004560 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004561 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004562 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004563
Dan Gohman180c1692008-06-23 18:43:26 +00004564 uint64_t NumElements = ATy->getNumElements();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004565 if (NumElements != uint64_t(-1) && NumElements != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004566 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Mon P Wang28873102008-06-25 08:15:39 +00004567 " arguments, but has size of " + utostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004568 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4569 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004570 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004571 ;}
4572 break;
4573
Devang Patel652203f2008-09-29 20:49:50 +00004574 case 182:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004575#line 1619 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004576 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004577 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004578 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4579 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004580 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004581 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004582 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004583
Dan Gohman180c1692008-06-23 18:43:26 +00004584 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004585 const Type *ETy = ATy->getElementType();
Mon P Wang28873102008-06-25 08:15:39 +00004586 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (3)].StrVal)->length())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004587 GEN_ERROR("Can't build string constant of size " +
Mon P Wang28873102008-06-25 08:15:39 +00004588 utostr((yyvsp[(3) - (3)].StrVal)->length()) +
4589 " when array has size " + utostr(NumElements) + "");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004590 std::vector<Constant*> Vals;
4591 if (ETy == Type::Int8Ty) {
Mon P Wang28873102008-06-25 08:15:39 +00004592 for (uint64_t i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004593 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004594 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004595 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004596 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4597 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004598 delete (yyvsp[(3) - (3)].StrVal);
4599 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4600 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004601 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004602 ;}
4603 break;
4604
Devang Patel652203f2008-09-29 20:49:50 +00004605 case 183:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004606#line 1646 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004607 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004608 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004609 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4610 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004611 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004612 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004613 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004614 const Type *ETy = PTy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004615 unsigned NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004616
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004617 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004618 if (NumElements != unsigned(-1) && NumElements != (unsigned)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004619 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004620 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004621 utostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004622
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004623 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004624 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4625 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004626 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004627 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004628 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004629 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004630
Dan Gohmanf4423b12008-04-19 00:24:39 +00004631 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4632 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004633 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004634 ;}
4635 break;
4636
Devang Patel652203f2008-09-29 20:49:50 +00004637 case 184:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004638#line 1674 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004639 {
4640 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004641 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004642 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004643 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004644
Dan Gohmanf4423b12008-04-19 00:24:39 +00004645 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004646 GEN_ERROR("Illegal number of initializers for structure type");
4647
4648 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004649 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4650 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004651 GEN_ERROR("Expected type '" +
4652 STy->getElementType(i)->getDescription() +
4653 "' for element #" + utostr(i) +
4654 " of structure initializer");
4655
4656 // Check to ensure that Type is not packed
4657 if (STy->isPacked())
4658 GEN_ERROR("Unpacked Initializer to vector type '" +
4659 STy->getDescription() + "'");
4660
Dan Gohmanf4423b12008-04-19 00:24:39 +00004661 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4662 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004663 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004664 ;}
4665 break;
4666
Devang Patel652203f2008-09-29 20:49:50 +00004667 case 185:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004668#line 1700 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004669 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004670 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004671 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4672 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004673 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004674 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004675 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004676
4677 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004678 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004679
4680 // Check to ensure that Type is not packed
4681 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004682 GEN_ERROR("Unpacked Initializer to vector type '" +
4683 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004684
Dan Gohmanf4423b12008-04-19 00:24:39 +00004685 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4686 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004687 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004688 ;}
4689 break;
4690
Devang Patel652203f2008-09-29 20:49:50 +00004691 case 186:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004692#line 1720 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004693 {
4694 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004695 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004696 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004697 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004698
Dan Gohmanf4423b12008-04-19 00:24:39 +00004699 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004700 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004701
4702 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004703 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4704 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004705 GEN_ERROR("Expected type '" +
4706 STy->getElementType(i)->getDescription() +
4707 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004708 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004709
4710 // Check to ensure that Type is packed
4711 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004712 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004713 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004714
Dan Gohmanf4423b12008-04-19 00:24:39 +00004715 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4716 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004717 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004718 ;}
4719 break;
4720
Devang Patel652203f2008-09-29 20:49:50 +00004721 case 187:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004722#line 1746 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004723 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004724 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004725 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4726 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004727 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004728 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004729 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004730
4731 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004732 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004733
4734 // Check to ensure that Type is packed
4735 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004736 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004737 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004738
Dan Gohmanf4423b12008-04-19 00:24:39 +00004739 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4740 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004741 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004742 ;}
4743 break;
4744
Devang Patel652203f2008-09-29 20:49:50 +00004745 case 188:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004746#line 1766 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004747 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004748 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004749 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4750 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004751 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004752 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004753 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004754
Dan Gohmanf4423b12008-04-19 00:24:39 +00004755 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4756 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004757 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004758 ;}
4759 break;
4760
Devang Patel652203f2008-09-29 20:49:50 +00004761 case 189:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004762#line 1778 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004763 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004764 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004765 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4766 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4767 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004768 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004769 ;}
4770 break;
4771
Devang Patel652203f2008-09-29 20:49:50 +00004772 case 190:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004773#line 1785 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004774 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004775 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004776 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4777 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004778 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004779 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004780
4781 // ConstExprs can exist in the body of a function, thus creating
4782 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004783 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004784 // symbol table instead of the module symbol table for the global symbol,
4785 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004786 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004787 //
4788 Function *SavedCurFn = CurFun.CurrentFunction;
4789 CurFun.CurrentFunction = 0;
4790
Dan Gohmanf4423b12008-04-19 00:24:39 +00004791 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004792 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004793
4794 CurFun.CurrentFunction = SavedCurFn;
4795
4796 // If this is an initializer for a constant pointer, which is referencing a
4797 // (currently) undefined variable, create a stub now that shall be replaced
4798 // in the future with the right type of variable.
4799 //
4800 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004801 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004802 const PointerType *PT = cast<PointerType>(Ty);
4803
4804 // First check to see if the forward references value is already created!
4805 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004806 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Eric Christopher2a5196f2008-09-24 04:55:49 +00004807
Reid Spencer68a24bd2005-08-27 18:50:39 +00004808 if (I != CurModule.GlobalRefs.end()) {
4809 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004810 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004811 } else {
4812 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004813 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4814 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4815 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004816 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004817
4818 // Create the forward referenced global.
4819 GlobalValue *GV;
Eric Christopher2a5196f2008-09-24 04:55:49 +00004820 if (const FunctionType *FTy =
Reid Spencer68a24bd2005-08-27 18:50:39 +00004821 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004822 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4823 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004824 } else {
4825 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004826 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004827 Name, CurModule.CurrentModule);
4828 }
4829
4830 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004831 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004832 V = GV;
4833 }
4834 }
4835
Dan Gohmanf4423b12008-04-19 00:24:39 +00004836 (yyval.ConstVal) = cast<GlobalValue>(V);
4837 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004838 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004839 ;}
4840 break;
4841
Devang Patel652203f2008-09-29 20:49:50 +00004842 case 191:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004843#line 1851 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004844 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004845 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004846 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4847 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004848 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004849 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4850 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4851 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004852 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004853 ;}
4854 break;
4855
Devang Patel652203f2008-09-29 20:49:50 +00004856 case 192:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004857#line 1861 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004858 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004859 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004860 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4861 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004862 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4863 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004864 (yyval.ConstVal) = Constant::getNullValue(Ty);
4865 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004866 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004867 ;}
4868 break;
4869
Devang Patel652203f2008-09-29 20:49:50 +00004870 case 193:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004871#line 1871 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004872 { // integral constants
4873 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004874 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004875 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004876 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004877 ;}
4878 break;
4879
Devang Patel652203f2008-09-29 20:49:50 +00004880 case 194:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004881#line 1877 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004882 { // arbitrary precision integer constants
4883 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4884 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004885 GEN_ERROR("Constant value does not fit in type");
4886 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004887 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4888 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4889 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004890 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004891 ;}
4892 break;
4893
Devang Patel652203f2008-09-29 20:49:50 +00004894 case 195:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004895#line 1887 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004896 { // integral constants
4897 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004898 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004899 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004900 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004901 ;}
4902 break;
4903
Devang Patel652203f2008-09-29 20:49:50 +00004904 case 196:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004905#line 1893 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004906 { // arbitrary precision integer constants
4907 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4908 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004909 GEN_ERROR("Constant value does not fit in type");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004910 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004911 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4912 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4913 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004914 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004915 ;}
4916 break;
4917
Devang Patel652203f2008-09-29 20:49:50 +00004918 case 197:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004919#line 1903 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004920 { // Boolean constants
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004921 if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
4922 GEN_ERROR("Constant true must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004923 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004924 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004925 ;}
4926 break;
4927
Devang Patel652203f2008-09-29 20:49:50 +00004928 case 198:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004929#line 1909 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004930 { // Boolean constants
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004931 if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
4932 GEN_ERROR("Constant false must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004933 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004934 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004935 ;}
4936 break;
4937
Devang Patel652203f2008-09-29 20:49:50 +00004938 case 199:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004939#line 1915 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004940 { // Floating point constants
4941 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004942 GEN_ERROR("Floating point constant invalid for type");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004943 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004944 // as double. Fix this here. Long double is done right.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004945 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4946 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004947 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004948 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004949 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004950 ;}
4951 break;
4952
Devang Patel652203f2008-09-29 20:49:50 +00004953 case 200:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004954#line 1928 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004955 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004956 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004957 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4958 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4959 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4960 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004961 GEN_ERROR("invalid cast opcode for cast from '" +
4962 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004963 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004964 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4965 delete (yyvsp[(5) - (6)].TypeVal);
4966 ;}
4967 break;
4968
Devang Patel652203f2008-09-29 20:49:50 +00004969 case 201:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004970#line 1940 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004971 {
4972 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004973 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004974
4975 const Type *IdxTy =
Dan Gohman041e2eb2008-05-15 19:50:34 +00004976 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004977 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004978 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004979
Chris Lattnerf7469af2007-01-31 04:44:08 +00004980 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004981 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4982 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004983 IdxVec.push_back(C);
4984 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004985 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004986
Dan Gohmanf4423b12008-04-19 00:24:39 +00004987 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004988
Dan Gohmanf4423b12008-04-19 00:24:39 +00004989 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004990 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004991 ;}
4992 break;
4993
Devang Patel652203f2008-09-29 20:49:50 +00004994 case 202:
Nuno Lopes191dfb92008-10-03 15:52:39 +00004995#line 1961 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004996 {
4997 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004998 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004999 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005000 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005001 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005002 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005003 ;}
5004 break;
5005
Devang Patel652203f2008-09-29 20:49:50 +00005006 case 203:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005007#line 1969 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005008 {
5009 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005010 GEN_ERROR("Binary operator types must match");
5011 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005012 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
5013 ;}
5014 break;
5015
Devang Patel652203f2008-09-29 20:49:50 +00005016 case 204:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005017#line 1975 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005018 {
5019 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005020 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005021 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005022 if (!isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00005023 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005024 GEN_ERROR("Logical operator requires integral operands");
5025 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005026 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005027 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005028 ;}
5029 break;
5030
Devang Patel652203f2008-09-29 20:49:50 +00005031 case 205:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005032#line 1986 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005033 {
5034 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005035 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005036 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5037 ;}
5038 break;
5039
Devang Patel652203f2008-09-29 20:49:50 +00005040 case 206:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005041#line 1991 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005042 {
5043 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005044 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005045 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5046 ;}
5047 break;
5048
Devang Patel652203f2008-09-29 20:49:50 +00005049 case 207:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005050#line 1996 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005051 {
5052 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5053 GEN_ERROR("vicmp operand types must match");
5054 (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5055 ;}
5056 break;
5057
Devang Patel652203f2008-09-29 20:49:50 +00005058 case 208:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005059#line 2001 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005060 {
5061 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5062 GEN_ERROR("vfcmp operand types must match");
5063 (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5064 ;}
5065 break;
5066
Devang Patel652203f2008-09-29 20:49:50 +00005067 case 209:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005068#line 2006 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005069 {
5070 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005071 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005072 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005073 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005074 ;}
5075 break;
5076
Devang Patel652203f2008-09-29 20:49:50 +00005077 case 210:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005078#line 2012 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005079 {
5080 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005081 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005082 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005083 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005084 ;}
5085 break;
5086
Devang Patel652203f2008-09-29 20:49:50 +00005087 case 211:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005088#line 2018 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005089 {
5090 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005091 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005092 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005093 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005094 ;}
5095 break;
5096
Devang Patel652203f2008-09-29 20:49:50 +00005097 case 212:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005098#line 2024 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005099 {
5100 if (!isa<StructType>((yyvsp[(3) - (5)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (5)].ConstVal)->getType()))
5101 GEN_ERROR("ExtractValue requires an aggregate operand");
5102
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005103 (yyval.ConstVal) = ConstantExpr::getExtractValue((yyvsp[(3) - (5)].ConstVal), &(*(yyvsp[(4) - (5)].ConstantList))[0], (yyvsp[(4) - (5)].ConstantList)->size());
5104 delete (yyvsp[(4) - (5)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005105 CHECK_FOR_ERROR
5106 ;}
5107 break;
5108
Devang Patel652203f2008-09-29 20:49:50 +00005109 case 213:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005110#line 2032 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005111 {
5112 if (!isa<StructType>((yyvsp[(3) - (7)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (7)].ConstVal)->getType()))
5113 GEN_ERROR("InsertValue requires an aggregate operand");
5114
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005115 (yyval.ConstVal) = ConstantExpr::getInsertValue((yyvsp[(3) - (7)].ConstVal), (yyvsp[(5) - (7)].ConstVal), &(*(yyvsp[(6) - (7)].ConstantList))[0], (yyvsp[(6) - (7)].ConstantList)->size());
5116 delete (yyvsp[(6) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005117 CHECK_FOR_ERROR
5118 ;}
5119 break;
5120
Devang Patel652203f2008-09-29 20:49:50 +00005121 case 214:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005122#line 2043 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005123 {
5124 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005125 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005126 ;}
5127 break;
5128
Devang Patel652203f2008-09-29 20:49:50 +00005129 case 215:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005130#line 2047 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005131 {
5132 (yyval.ConstVector) = new std::vector<Constant*>();
5133 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005134 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005135 ;}
5136 break;
5137
Devang Patel652203f2008-09-29 20:49:50 +00005138 case 216:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005139#line 2055 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005140 { (yyval.BoolVal) = false; ;}
Nate Begemanac80ade2008-05-12 19:01:56 +00005141 break;
5142
Devang Pateld4980812008-09-02 20:52:40 +00005143 case 217:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005144#line 2055 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005145 { (yyval.BoolVal) = true; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005146 break;
5147
Devang Pateld4980812008-09-02 20:52:40 +00005148 case 218:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005149#line 2058 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005150 { (yyval.BoolVal) = true; ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00005151 break;
5152
Dale Johannesendfe8c842008-09-26 19:32:34 +00005153 case 219:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005154#line 2058 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005155 { (yyval.BoolVal) = false; ;}
5156 break;
5157
5158 case 220:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005159#line 2061 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005160 {
5161 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
5162 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00005163 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005164 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
5165 if (!Aliasee)
5166 GEN_ERROR("Aliases can be created only to global values");
5167
Dan Gohmanf4423b12008-04-19 00:24:39 +00005168 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005169 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005170 delete (yyvsp[(1) - (2)].TypeVal);
5171 ;}
5172 break;
5173
Devang Patel652203f2008-09-29 20:49:50 +00005174 case 221:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005175#line 2073 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005176 {
5177 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
5178 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
5179 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005180 GEN_ERROR("invalid cast opcode for cast from '" +
5181 Val->getType()->getDescription() + "' to '" +
5182 DestTy->getDescription() + "'");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005183
Dan Gohmanf4423b12008-04-19 00:24:39 +00005184 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005185 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005186 delete (yyvsp[(5) - (6)].TypeVal);
5187 ;}
5188 break;
5189
Devang Pateld4980812008-09-02 20:52:40 +00005190 case 222:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005191#line 2094 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005192 {
5193 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5194 CurModule.ModuleDone();
5195 CHECK_FOR_ERROR;
5196 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005197 break;
5198
Devang Patel652203f2008-09-29 20:49:50 +00005199 case 223:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005200#line 2099 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005201 {
5202 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5203 CurModule.ModuleDone();
5204 CHECK_FOR_ERROR;
5205 ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00005206 break;
5207
Dale Johannesendfe8c842008-09-26 19:32:34 +00005208 case 226:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005209#line 2112 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005210 { CurFun.isDeclare = false; ;}
5211 break;
5212
5213 case 227:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005214#line 2112 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005215 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005216 CurFun.FunctionDone();
5217 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005218 ;}
5219 break;
5220
Devang Patel652203f2008-09-29 20:49:50 +00005221 case 228:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005222#line 2116 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005223 { CurFun.isDeclare = true; ;}
5224 break;
5225
Devang Pateld4980812008-09-02 20:52:40 +00005226 case 229:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005227#line 2116 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005228 {
5229 CHECK_FOR_ERROR
5230 ;}
5231 break;
5232
Devang Pateld4980812008-09-02 20:52:40 +00005233 case 230:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005234#line 2119 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005235 {
5236 CHECK_FOR_ERROR
5237 ;}
5238 break;
5239
5240 case 231:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005241#line 2122 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005242 {
Reid Spencer14310612006-12-31 05:40:51 +00005243 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005244 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005245 // Eagerly resolve types. This is not an optimization, this is a
5246 // requirement that is due to the fact that we could have this:
5247 //
5248 // %list = type { %list * }
5249 // %list = type { %list * } ; repeated type decl
5250 //
5251 // If types are not resolved eagerly, then the two types will not be
5252 // determined to be the same type!
5253 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00005254 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005255
Dan Gohmanf4423b12008-04-19 00:24:39 +00005256 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00005257 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005258 // If this is a named type that is not a redefinition, add it to the slot
5259 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005260 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005261 }
Reid Spencera132e042006-12-03 05:46:11 +00005262
Dan Gohmanf4423b12008-04-19 00:24:39 +00005263 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005264 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005265 ;}
5266 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00005267
Devang Patel652203f2008-09-29 20:49:50 +00005268 case 232:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005269#line 2146 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005270 {
5271 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
5272
5273 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005274 CHECK_FOR_ERROR
5275 // If this is a named type that is not a redefinition, add it to the slot
5276 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005277 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005278 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005279 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005280 ;}
5281 break;
5282
Devang Patel652203f2008-09-29 20:49:50 +00005283 case 233:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005284#line 2158 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005285 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005286 /* "Externally Visible" Linkage */
Eric Christopher2a5196f2008-09-24 04:55:49 +00005287 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005288 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005289 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5290 (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 +00005291 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005292 ;}
5293 break;
5294
Devang Patel652203f2008-09-29 20:49:50 +00005295 case 234:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005296#line 2165 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005297 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005298 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005299 ;}
5300 break;
5301
Devang Patel652203f2008-09-29 20:49:50 +00005302 case 235:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005303#line 2169 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005304 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005305 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005306 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005307 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 +00005308 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005309 ;}
5310 break;
5311
Devang Patel652203f2008-09-29 20:49:50 +00005312 case 236:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005313#line 2174 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005314 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005315 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005316 ;}
5317 break;
5318
Devang Patel652203f2008-09-29 20:49:50 +00005319 case 237:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005320#line 2178 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005321 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005322 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005323 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5324 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 +00005325 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005326 delete (yyvsp[(6) - (7)].TypeVal);
5327 ;}
5328 break;
5329
Devang Patel652203f2008-09-29 20:49:50 +00005330 case 238:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005331#line 2184 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005332 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005333 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005334 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005335 ;}
5336 break;
5337
Devang Patel652203f2008-09-29 20:49:50 +00005338 case 239:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005339#line 2188 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005340 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005341 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005342 if ((yyvsp[(1) - (5)].StrVal)) {
5343 Name = *(yyvsp[(1) - (5)].StrVal);
5344 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005345 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005346 if (Name.empty())
5347 GEN_ERROR("Alias name cannot be empty");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005348
Dan Gohmanf4423b12008-04-19 00:24:39 +00005349 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005350 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005351 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005352
Dan Gohmanf4423b12008-04-19 00:24:39 +00005353 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005354 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005355 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005356 InsertValue(GA, CurModule.Values);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005357
5358
Chris Lattner569f7372007-09-10 23:24:14 +00005359 // If there was a forward reference of this alias, resolve it now.
Eric Christopher2a5196f2008-09-24 04:55:49 +00005360
Chris Lattner569f7372007-09-10 23:24:14 +00005361 ValID ID;
5362 if (!Name.empty())
5363 ID = ValID::createGlobalName(Name);
5364 else
5365 ID = ValID::createGlobalID(CurModule.Values.size()-1);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005366
Chris Lattner569f7372007-09-10 23:24:14 +00005367 if (GlobalValue *FWGV =
5368 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5369 // Replace uses of the fwdref with the actual alias.
5370 FWGV->replaceAllUsesWith(GA);
5371 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5372 GV->eraseFromParent();
5373 else
5374 cast<Function>(FWGV)->eraseFromParent();
5375 }
5376 ID.destroy();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005377
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005378 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005379 ;}
5380 break;
5381
Chris Lattnerccef6b52008-09-23 21:18:31 +00005382 case 240:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005383#line 2228 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005384 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005385 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005386 ;}
5387 break;
5388
Chris Lattnerccef6b52008-09-23 21:18:31 +00005389 case 241:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005390#line 2231 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005391 {
5392 CHECK_FOR_ERROR
5393 ;}
5394 break;
5395
5396 case 242:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005397#line 2237 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005398 {
Chris Lattner66316012006-01-24 04:14:29 +00005399 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005400 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005401 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005402 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005403 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5404 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005405 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005406;}
5407 break;
5408
Devang Patel652203f2008-09-29 20:49:50 +00005409 case 243:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005410#line 2247 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005411 {
5412 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5413 delete (yyvsp[(3) - (3)].StrVal);
5414 ;}
5415 break;
5416
Devang Patel652203f2008-09-29 20:49:50 +00005417 case 244:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005418#line 2251 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005419 {
5420 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5421 delete (yyvsp[(3) - (3)].StrVal);
5422 ;}
5423 break;
5424
Devang Patel652203f2008-09-29 20:49:50 +00005425 case 246:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005426#line 2258 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005427 {
5428 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5429 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005430 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005431 ;}
5432 break;
5433
Devang Patel652203f2008-09-29 20:49:50 +00005434 case 247:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005435#line 2263 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005436 {
5437 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5438 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005439 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005440 ;}
5441 break;
5442
Devang Patel652203f2008-09-29 20:49:50 +00005443 case 248:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005444#line 2268 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005445 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005446 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005447 ;}
5448 break;
5449
Devang Patel652203f2008-09-29 20:49:50 +00005450 case 249:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005451#line 2277 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005452 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005453 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005454 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005455 if (!(*(yyvsp[(3) - (5)].TypeVal))->isFirstClassType())
5456 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005457 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 +00005458 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5459 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005460 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005461 ;}
5462 break;
5463
Devang Patel652203f2008-09-29 20:49:50 +00005464 case 250:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005465#line 2287 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005466 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005467 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005468 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005469 if (!(*(yyvsp[(1) - (3)].TypeVal))->isFirstClassType())
5470 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005471 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 +00005472 (yyval.ArgList) = new ArgListType;
5473 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005474 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005475 ;}
5476 break;
5477
Devang Patel652203f2008-09-29 20:49:50 +00005478 case 251:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005479#line 2298 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005480 {
5481 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005482 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005483 ;}
5484 break;
5485
Devang Patel652203f2008-09-29 20:49:50 +00005486 case 252:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005487#line 2302 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005488 {
5489 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005490 struct ArgListEntry E;
5491 E.Ty = new PATypeHolder(Type::VoidTy);
5492 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005493 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005494 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005495 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005496 ;}
5497 break;
5498
Devang Patel652203f2008-09-29 20:49:50 +00005499 case 253:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005500#line 2311 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005501 {
5502 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005503 struct ArgListEntry E;
5504 E.Ty = new PATypeHolder(Type::VoidTy);
5505 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005506 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005507 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005508 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005509 ;}
5510 break;
5511
Devang Patel652203f2008-09-29 20:49:50 +00005512 case 254:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005513#line 2320 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005514 {
5515 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005516 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005517 ;}
5518 break;
5519
Devang Patel652203f2008-09-29 20:49:50 +00005520 case 255:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005521#line 2326 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005522 {
Devang Patel652203f2008-09-29 20:49:50 +00005523 std::string FunctionName(*(yyvsp[(4) - (11)].StrVal));
5524 delete (yyvsp[(4) - (11)].StrVal); // Free strdup'd memory!
Eric Christopher2a5196f2008-09-24 04:55:49 +00005525
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005526 // Check the function result for abstractness if this is a define. We should
5527 // have no abstract types at this point
Devang Patel652203f2008-09-29 20:49:50 +00005528 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(3) - (11)].TypeVal)))
5529 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(3) - (11)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005530
Devang Patel652203f2008-09-29 20:49:50 +00005531 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (11)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00005532 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005533
Reid Spencer68a24bd2005-08-27 18:50:39 +00005534 std::vector<const Type*> ParamTypeList;
Devang Patel05988662008-09-25 21:00:45 +00005535 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00005536 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
5537 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00005538 Attributes RetAttrs = (yyvsp[(2) - (11)].Attributes);
5539 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None) {
5540 if ((yyvsp[(8) - (11)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005541 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00005542 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005543 }
Devang Patel652203f2008-09-29 20:49:50 +00005544 if ((yyvsp[(8) - (11)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005545 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00005546 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005547 }
Devang Patel652203f2008-09-29 20:49:50 +00005548 if ((yyvsp[(8) - (11)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00005549 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00005550 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00005551 }
Dale Johannesene7261862008-09-26 23:46:20 +00005552 }
Devang Patel652203f2008-09-29 20:49:50 +00005553 if (RetAttrs != Attribute::None)
5554 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
5555 if ((yyvsp[(6) - (11)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005556 unsigned index = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005557 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin(); I != (yyvsp[(6) - (11)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005558 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005559 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5560 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005561 ParamTypeList.push_back(Ty);
Devang Patel05988662008-09-25 21:00:45 +00005562 if (Ty != Type::VoidTy && I->Attrs != Attribute::None)
5563 Attrs.push_back(AttributeWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005564 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005565 }
Devang Patel652203f2008-09-29 20:49:50 +00005566 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None)
5567 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(8) - (11)].Attributes)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005568
5569 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5570 if (isVarArg) ParamTypeList.pop_back();
5571
Devang Patel05988662008-09-25 21:00:45 +00005572 AttrListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005573 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00005574 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005575
Devang Patel652203f2008-09-29 20:49:50 +00005576 FunctionType *FT = FunctionType::get(*(yyvsp[(3) - (11)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005577 const PointerType *PFT = PointerType::getUnqual(FT);
Devang Patel652203f2008-09-29 20:49:50 +00005578 delete (yyvsp[(3) - (11)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005579
5580 ValID ID;
5581 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005582 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005583 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005584 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005585 }
5586
5587 Function *Fn = 0;
5588 // See if this function was forward referenced. If so, recycle the object.
5589 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005590 // Move the function to the end of the list, from whereever it was
Reid Spencer68a24bd2005-08-27 18:50:39 +00005591 // previously inserted.
5592 Fn = cast<Function>(FWRef);
Devang Patel05988662008-09-25 21:00:45 +00005593 assert(Fn->getAttributes().isEmpty() &&
Chris Lattner58d74912008-03-12 17:45:29 +00005594 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005595 CurModule.CurrentModule->getFunctionList().remove(Fn);
5596 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5597 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005598 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005599 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005600 // The existing function doesn't have the same type. This is an overload
5601 // error.
5602 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Devang Patel05988662008-09-25 21:00:45 +00005603 } else if (Fn->getAttributes() != PAL) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005604 // The existing function doesn't have the same parameter attributes.
5605 // This is an overload error.
5606 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005607 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005608 // Neither the existing or the current function is a declaration and they
5609 // have the same name and same type. Clearly this is a redefinition.
5610 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005611 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005612 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005613 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5614 AI != AE; ++AI)
5615 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005616 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005617 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005618 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5619 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005620 InsertValue(Fn, CurModule.Values);
5621 }
5622
Nuno Lopes9e9631d2008-10-03 15:45:58 +00005623 ID.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005624 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005625
5626 if (CurFun.isDeclare) {
5627 // If we have declaration, always overwrite linkage. This will allow us to
5628 // correctly handle cases, when pointer to function is passed as argument to
5629 // another function.
5630 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005631 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005632 }
Devang Pateld4980812008-09-02 20:52:40 +00005633 Fn->setCallingConv((yyvsp[(1) - (11)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00005634 Fn->setAttributes(PAL);
Devang Patel652203f2008-09-29 20:49:50 +00005635 Fn->setAlignment((yyvsp[(10) - (11)].UIntVal));
5636 if ((yyvsp[(9) - (11)].StrVal)) {
5637 Fn->setSection(*(yyvsp[(9) - (11)].StrVal));
5638 delete (yyvsp[(9) - (11)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005639 }
Devang Patel652203f2008-09-29 20:49:50 +00005640 if ((yyvsp[(11) - (11)].StrVal)) {
5641 Fn->setGC((yyvsp[(11) - (11)].StrVal)->c_str());
5642 delete (yyvsp[(11) - (11)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005643 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005644
5645 // Add all of the arguments we parsed to the function...
Devang Patel652203f2008-09-29 20:49:50 +00005646 if ((yyvsp[(6) - (11)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005647 if (isVarArg) { // Nuke the last entry
Devang Patel652203f2008-09-29 20:49:50 +00005648 assert((yyvsp[(6) - (11)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(6) - (11)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005649 "Not a varargs marker!");
Devang Patel652203f2008-09-29 20:49:50 +00005650 delete (yyvsp[(6) - (11)].ArgList)->back().Ty;
5651 (yyvsp[(6) - (11)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005652 }
5653 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005654 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005655 unsigned Idx = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005656 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin();
5657 I != (yyvsp[(6) - (11)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005658 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005659 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005660 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005661 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005662 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005663 }
Reid Spencera132e042006-12-03 05:46:11 +00005664
Devang Patel652203f2008-09-29 20:49:50 +00005665 delete (yyvsp[(6) - (11)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005666 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005667 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005668;}
5669 break;
5670
Devang Patel652203f2008-09-29 20:49:50 +00005671 case 258:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005672#line 2476 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005673 {
5674 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005675
5676 // Make sure that we keep track of the linkage type even if there was a
5677 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005678 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5679 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5680;}
5681 break;
5682
Devang Patel652203f2008-09-29 20:49:50 +00005683 case 261:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005684#line 2487 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005685 {
5686 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005687 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005688;}
5689 break;
5690
Devang Patel652203f2008-09-29 20:49:50 +00005691 case 262:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005692#line 2492 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005693 {
5694 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5695 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5696 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005697 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005698 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005699 ;}
5700 break;
5701
Devang Patel652203f2008-09-29 20:49:50 +00005702 case 263:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005703#line 2504 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005704 {
5705 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005706 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005707 ;}
5708 break;
5709
Devang Patel652203f2008-09-29 20:49:50 +00005710 case 264:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005711#line 2508 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005712 {
5713 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005714 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005715 ;}
5716 break;
5717
Devang Patel652203f2008-09-29 20:49:50 +00005718 case 265:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005719#line 2513 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005720 { // A reference to a direct constant
5721 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005722 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005723 ;}
5724 break;
5725
Devang Patel652203f2008-09-29 20:49:50 +00005726 case 266:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005727#line 2517 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005728 {
5729 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005730 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005731 ;}
5732 break;
5733
Devang Patel652203f2008-09-29 20:49:50 +00005734 case 267:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005735#line 2521 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005736 { // arbitrary precision integer constants
5737 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), true);
5738 delete (yyvsp[(1) - (1)].APIntVal);
5739 CHECK_FOR_ERROR
5740 ;}
5741 break;
5742
Devang Patel652203f2008-09-29 20:49:50 +00005743 case 268:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005744#line 2526 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005745 { // arbitrary precision integer constants
5746 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), false);
5747 delete (yyvsp[(1) - (1)].APIntVal);
5748 CHECK_FOR_ERROR
5749 ;}
5750 break;
5751
Devang Patel652203f2008-09-29 20:49:50 +00005752 case 269:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005753#line 2531 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005754 { // Perhaps it's an FP constant?
5755 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005756 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005757 ;}
5758 break;
5759
Devang Patel652203f2008-09-29 20:49:50 +00005760 case 270:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005761#line 2535 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005762 {
5763 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005764 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005765 ;}
5766 break;
5767
Devang Patel652203f2008-09-29 20:49:50 +00005768 case 271:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005769#line 2539 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005770 {
5771 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005772 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005773 ;}
5774 break;
5775
Devang Patel652203f2008-09-29 20:49:50 +00005776 case 272:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005777#line 2543 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005778 {
5779 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005780 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005781 ;}
5782 break;
5783
Devang Patel652203f2008-09-29 20:49:50 +00005784 case 273:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005785#line 2547 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005786 {
5787 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005788 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005789 ;}
5790 break;
5791
Devang Patel652203f2008-09-29 20:49:50 +00005792 case 274:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005793#line 2551 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005794 { // A vector zero constant.
5795 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005796 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005797 ;}
5798 break;
5799
Devang Patel652203f2008-09-29 20:49:50 +00005800 case 275:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005801#line 2555 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005802 { // Nonempty unsized packed vector
5803 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005804 unsigned NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005805
5806 if (!ETy->isInteger() && !ETy->isFloatingPoint())
5807 GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005808
Reid Spencer9d6565a2007-02-15 02:26:10 +00005809 VectorType* pt = VectorType::get(ETy, NumElements);
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005810 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
Eric Christopher2a5196f2008-09-24 04:55:49 +00005811
Reid Spencer68a24bd2005-08-27 18:50:39 +00005812 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005813 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5814 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005815 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005816 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005817 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005818 }
5819
Dan Gohmanf4423b12008-04-19 00:24:39 +00005820 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5821 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005822 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005823 ;}
5824 break;
5825
Devang Patel652203f2008-09-29 20:49:50 +00005826 case 276:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005827#line 2577 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005828 { // Nonempty unsized arr
5829 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005830 uint64_t NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005831
5832 if (!ETy->isFirstClassType())
5833 GEN_ERROR("Invalid array element type: " + ETy->getDescription());
5834
5835 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5836 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
5837
5838 // Verify all elements are correct type!
5839 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5840 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005841 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005842 ETy->getDescription() +"' as required!\nIt is of type '"+
5843 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
5844 }
5845
5846 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, *(yyvsp[(2) - (3)].ConstVector)));
5847 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5848 CHECK_FOR_ERROR
5849 ;}
5850 break;
5851
Devang Patel652203f2008-09-29 20:49:50 +00005852 case 277:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005853#line 2599 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005854 {
Dan Gohman180c1692008-06-23 18:43:26 +00005855 // Use undef instead of an array because it's inconvenient to determine
5856 // the element type at this point, there being no elements to examine.
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005857 (yyval.ValIDVal) = ValID::createUndef();
5858 CHECK_FOR_ERROR
5859 ;}
5860 break;
5861
Devang Patel652203f2008-09-29 20:49:50 +00005862 case 278:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005863#line 2605 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005864 {
Dan Gohman180c1692008-06-23 18:43:26 +00005865 uint64_t NumElements = (yyvsp[(2) - (2)].StrVal)->length();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005866 const Type *ETy = Type::Int8Ty;
5867
5868 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5869
5870 std::vector<Constant*> Vals;
5871 for (unsigned i = 0; i < (yyvsp[(2) - (2)].StrVal)->length(); ++i)
5872 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(2) - (2)].StrVal))[i]));
5873 delete (yyvsp[(2) - (2)].StrVal);
5874 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, Vals));
5875 CHECK_FOR_ERROR
5876 ;}
5877 break;
5878
Devang Patel652203f2008-09-29 20:49:50 +00005879 case 279:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005880#line 2618 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005881 {
5882 std::vector<const Type*> Elements((yyvsp[(2) - (3)].ConstVector)->size());
5883 for (unsigned i = 0, e = (yyvsp[(2) - (3)].ConstVector)->size(); i != e; ++i)
5884 Elements[i] = (*(yyvsp[(2) - (3)].ConstVector))[i]->getType();
5885
5886 const StructType *STy = StructType::get(Elements);
5887 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5888
5889 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(2) - (3)].ConstVector)));
5890 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5891 CHECK_FOR_ERROR
5892 ;}
5893 break;
5894
Devang Patel652203f2008-09-29 20:49:50 +00005895 case 280:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005896#line 2630 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005897 {
5898 const StructType *STy = StructType::get(std::vector<const Type*>());
5899 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5900 CHECK_FOR_ERROR
5901 ;}
5902 break;
5903
Devang Patel652203f2008-09-29 20:49:50 +00005904 case 281:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005905#line 2635 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005906 {
5907 std::vector<const Type*> Elements((yyvsp[(3) - (5)].ConstVector)->size());
5908 for (unsigned i = 0, e = (yyvsp[(3) - (5)].ConstVector)->size(); i != e; ++i)
5909 Elements[i] = (*(yyvsp[(3) - (5)].ConstVector))[i]->getType();
5910
5911 const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
5912 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5913
5914 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(3) - (5)].ConstVector)));
5915 delete PTy; delete (yyvsp[(3) - (5)].ConstVector);
5916 CHECK_FOR_ERROR
5917 ;}
5918 break;
5919
Devang Patel652203f2008-09-29 20:49:50 +00005920 case 282:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005921#line 2647 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005922 {
5923 const StructType *STy = StructType::get(std::vector<const Type*>(),
5924 /*isPacked=*/true);
5925 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5926 CHECK_FOR_ERROR
5927 ;}
5928 break;
5929
Devang Patel652203f2008-09-29 20:49:50 +00005930 case 283:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005931#line 2653 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005932 {
5933 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005934 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005935 ;}
5936 break;
5937
Devang Patel652203f2008-09-29 20:49:50 +00005938 case 284:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005939#line 2657 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005940 {
5941 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5942 delete (yyvsp[(3) - (5)].StrVal);
5943 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005944 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005945 ;}
5946 break;
5947
Devang Patel652203f2008-09-29 20:49:50 +00005948 case 285:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005949#line 2667 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005950 { // Is it an integer reference...?
5951 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005952 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005953 ;}
5954 break;
5955
Devang Patel652203f2008-09-29 20:49:50 +00005956 case 286:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005957#line 2671 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005958 {
5959 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005960 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005961 ;}
5962 break;
5963
Devang Patel652203f2008-09-29 20:49:50 +00005964 case 287:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005965#line 2675 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005966 { // Is it a named reference...?
5967 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5968 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005969 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005970 ;}
5971 break;
5972
Devang Patel652203f2008-09-29 20:49:50 +00005973 case 288:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005974#line 2680 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005975 { // Is it a named reference...?
5976 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5977 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005978 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005979 ;}
5980 break;
5981
Devang Patel652203f2008-09-29 20:49:50 +00005982 case 291:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005983#line 2693 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005984 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005985 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005986 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005987 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00005988 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005989 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005990 ;}
5991 break;
5992
Devang Patel652203f2008-09-29 20:49:50 +00005993 case 292:
Nuno Lopes191dfb92008-10-03 15:52:39 +00005994#line 2702 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005995 {
5996 (yyval.ValueList) = new std::vector<Value *>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005997 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005998 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005999 ;}
6000 break;
6001
Devang Patel652203f2008-09-29 20:49:50 +00006002 case 293:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006003#line 2707 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006004 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006005 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00006006 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006007 ;}
6008 break;
6009
Devang Patel652203f2008-09-29 20:49:50 +00006010 case 294:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006011#line 2712 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006012 {
6013 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006014 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006015 ;}
6016 break;
6017
Devang Patel652203f2008-09-29 20:49:50 +00006018 case 295:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006019#line 2716 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006020 { // Do not allow functions with 0 basic blocks
Dan Gohmanf4423b12008-04-19 00:24:39 +00006021 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006022 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006023 ;}
6024 break;
6025
Devang Patel652203f2008-09-29 20:49:50 +00006026 case 296:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006027#line 2725 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006028 {
6029 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006030 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006031 InsertValue((yyvsp[(3) - (3)].TermInstVal));
6032 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6033 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006034 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006035 ;}
6036 break;
6037
Devang Patel652203f2008-09-29 20:49:50 +00006038 case 297:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006039#line 2734 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006040 {
6041 CHECK_FOR_ERROR
6042 int ValNum = InsertValue((yyvsp[(3) - (3)].TermInstVal));
6043 if (ValNum != (int)(yyvsp[(2) - (3)].UIntVal))
6044 GEN_ERROR("Result value number %" + utostr((yyvsp[(2) - (3)].UIntVal)) +
6045 " is incorrect, expected %" + utostr((unsigned)ValNum));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006046
Chris Lattner15bd0952008-08-29 17:20:18 +00006047 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6048 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
6049 CHECK_FOR_ERROR
6050;}
6051 break;
6052
Devang Patel652203f2008-09-29 20:49:50 +00006053 case 298:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006054#line 2747 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006055 {
6056 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006057 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
6058 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00006059 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
6060 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
6061 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006062 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006063 ;}
6064 break;
Chris Lattner38905612008-02-19 04:36:25 +00006065
Devang Patel652203f2008-09-29 20:49:50 +00006066 case 299:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006067#line 2756 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006068 { // Empty space between instruction lists
Chris Lattnercc81d152008-05-04 17:18:47 +00006069 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006070 CHECK_FOR_ERROR
6071 ;}
6072 break;
6073
Devang Patel652203f2008-09-29 20:49:50 +00006074 case 300:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006075#line 2760 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnercc81d152008-05-04 17:18:47 +00006076 { // Labelled (named) basic block
6077 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
6078 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006079 CHECK_FOR_ERROR
Chris Lattnercc81d152008-05-04 17:18:47 +00006080
Dan Gohmanf4423b12008-04-19 00:24:39 +00006081 ;}
6082 break;
6083
Devang Patel652203f2008-09-29 20:49:50 +00006084 case 301:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006085#line 2768 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006086 { // Return with a result...
6087 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
6088 assert(!VL.empty() && "Invalid ret operands!");
Dan Gohman1a570242008-07-23 00:54:54 +00006089 const Type *ReturnType = CurFun.CurrentFunction->getReturnType();
6090 if (VL.size() > 1 ||
6091 (isa<StructType>(ReturnType) &&
6092 (VL.empty() || VL[0]->getType() != ReturnType))) {
6093 Value *RV = UndefValue::get(ReturnType);
6094 for (unsigned i = 0, e = VL.size(); i != e; ++i) {
6095 Instruction *I = InsertValueInst::Create(RV, VL[i], i, "mrv");
6096 ((yyvsp[(-1) - (2)].BasicBlockVal))->getInstList().push_back(I);
6097 RV = I;
6098 }
6099 (yyval.TermInstVal) = ReturnInst::Create(RV);
6100 } else {
6101 (yyval.TermInstVal) = ReturnInst::Create(VL[0]);
6102 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006103 delete (yyvsp[(2) - (2)].ValueList);
6104 CHECK_FOR_ERROR
6105 ;}
6106 break;
6107
Devang Patel652203f2008-09-29 20:49:50 +00006108 case 302:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006109#line 2788 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006110 { // Return with no result...
6111 (yyval.TermInstVal) = ReturnInst::Create();
6112 CHECK_FOR_ERROR
6113 ;}
6114 break;
6115
Devang Patel652203f2008-09-29 20:49:50 +00006116 case 303:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006117#line 2792 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006118 { // Unconditional Branch...
6119 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6120 CHECK_FOR_ERROR
6121 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
6122 ;}
6123 break;
6124
Devang Patel652203f2008-09-29 20:49:50 +00006125 case 304:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006126#line 2797 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006127 {
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006128 if (cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() != 1)
6129 GEN_ERROR("Branch condition must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006130 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6131 CHECK_FOR_ERROR
6132 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6133 CHECK_FOR_ERROR
6134 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6135 CHECK_FOR_ERROR
6136 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
6137 ;}
6138 break;
6139
Devang Patel652203f2008-09-29 20:49:50 +00006140 case 305:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006141#line 2808 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006142 {
6143 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
6144 CHECK_FOR_ERROR
6145 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6146 CHECK_FOR_ERROR
6147 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6148 (yyval.TermInstVal) = S;
6149
6150 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6151 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00006152 for (; I != E; ++I) {
6153 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6154 S->addCase(CI, I->second);
6155 else
Reid Spencerb5334b02007-02-05 10:18:06 +00006156 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006157 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006158 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00006159 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006160 ;}
6161 break;
6162
Devang Patel652203f2008-09-29 20:49:50 +00006163 case 306:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006164#line 2827 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006165 {
6166 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006167 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006168 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006169 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00006170 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006171 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006172 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006173 ;}
6174 break;
6175
Devang Patel652203f2008-09-29 20:49:50 +00006176 case 307:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006177#line 2837 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006178 {
Reid Spencer3822ff52006-11-08 06:47:33 +00006179
Reid Spencer14310612006-12-31 05:40:51 +00006180 // Handle the short syntax
6181 const PointerType *PFTy = 0;
6182 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006183 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (15)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00006184 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6185 // Pull out the types of all of the arguments...
6186 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006187 ParamList::iterator I = (yyvsp[(7) - (15)].ParamList)->begin(), E = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006188 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006189 const Type *Ty = I->Val->getType();
6190 if (Ty == Type::VoidTy)
6191 GEN_ERROR("Short call syntax cannot be used with varargs");
6192 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006193 }
Eric Christopher2a5196f2008-09-24 04:55:49 +00006194
Devang Patel652203f2008-09-29 20:49:50 +00006195 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (15)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006196 GEN_ERROR("Invalid result type for LLVM function");
6197
Devang Patel652203f2008-09-29 20:49:50 +00006198 Ty = FunctionType::get((yyvsp[(4) - (15)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006199 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006200 }
6201
Devang Patel652203f2008-09-29 20:49:50 +00006202 delete (yyvsp[(4) - (15)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00006203
Devang Patel652203f2008-09-29 20:49:50 +00006204 Value *V = getVal(PFTy, (yyvsp[(5) - (15)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006205 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006206 BasicBlock *Normal = getBBVal((yyvsp[(12) - (15)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006207 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006208 BasicBlock *Except = getBBVal((yyvsp[(15) - (15)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00006209 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00006210
Devang Patel05988662008-09-25 21:00:45 +00006211 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006212 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6213 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006214 Attributes RetAttrs = (yyvsp[(3) - (15)].Attributes);
6215 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None) {
6216 if ((yyvsp[(9) - (15)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006217 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006218 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006219 }
Devang Patel652203f2008-09-29 20:49:50 +00006220 if ((yyvsp[(9) - (15)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006221 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006222 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006223 }
Devang Patel652203f2008-09-29 20:49:50 +00006224 if ((yyvsp[(9) - (15)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006225 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006226 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006227 }
Dale Johannesene7261862008-09-26 23:46:20 +00006228 }
Devang Patel652203f2008-09-29 20:49:50 +00006229 if (RetAttrs != Attribute::None)
6230 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006231
Reid Spencer14310612006-12-31 05:40:51 +00006232 // Check the arguments
6233 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006234 if ((yyvsp[(7) - (15)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00006235 // Make sure no arguments is a good thing!
6236 if (Ty->getNumParams() != 0)
6237 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006238 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006239 } else { // Has arguments?
6240 // Loop through FunctionType's arguments and ensure they are specified
6241 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00006242 FunctionType::param_iterator I = Ty->param_begin();
6243 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006244 ParamList::iterator ArgI = (yyvsp[(7) - (15)].ParamList)->begin(), ArgE = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006245 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006246
Duncan Sandsdc024672007-11-27 13:23:08 +00006247 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006248 if (ArgI->Val->getType() != *I)
6249 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006250 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006251 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006252 if (ArgI->Attrs != Attribute::None)
6253 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006254 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00006255
Reid Spencer14310612006-12-31 05:40:51 +00006256 if (Ty->isVarArg()) {
6257 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006258 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006259 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006260 if (ArgI->Attrs != Attribute::None)
6261 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006262 }
Reid Spencer14310612006-12-31 05:40:51 +00006263 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006264 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006265 }
Devang Patel652203f2008-09-29 20:49:50 +00006266 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None)
6267 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (15)].Attributes)));
Devang Patel05988662008-09-25 21:00:45 +00006268 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006269 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006270 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006271
Reid Spencer14310612006-12-31 05:40:51 +00006272 // Create the InvokeInst
Dan Gohman041e2eb2008-05-15 19:50:34 +00006273 InvokeInst *II = InvokeInst::Create(V, Normal, Except,
6274 Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006275 II->setCallingConv((yyvsp[(2) - (15)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006276 II->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006277 (yyval.TermInstVal) = II;
Devang Patel652203f2008-09-29 20:49:50 +00006278 delete (yyvsp[(7) - (15)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006279 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006280 ;}
6281 break;
6282
Devang Patel652203f2008-09-29 20:49:50 +00006283 case 308:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006284#line 2940 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006285 {
6286 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006287 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006288 ;}
6289 break;
6290
Devang Patel652203f2008-09-29 20:49:50 +00006291 case 309:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006292#line 2944 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006293 {
6294 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006295 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006296 ;}
6297 break;
6298
Devang Patel652203f2008-09-29 20:49:50 +00006299 case 310:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006300#line 2951 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006301 {
6302 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6303 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006304 CHECK_FOR_ERROR
6305 if (V == 0)
6306 GEN_ERROR("May only switch on a constant pool value");
6307
Dan Gohmanf4423b12008-04-19 00:24:39 +00006308 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006309 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006310 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6311 ;}
6312 break;
6313
Devang Patel652203f2008-09-29 20:49:50 +00006314 case 311:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006315#line 2962 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006316 {
6317 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6318 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006319 CHECK_FOR_ERROR
6320
6321 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00006322 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006323
Dan Gohmanf4423b12008-04-19 00:24:39 +00006324 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006325 CHECK_FOR_ERROR
Eric Christopher2a5196f2008-09-24 04:55:49 +00006326 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006327 ;}
6328 break;
6329
Devang Patel652203f2008-09-29 20:49:50 +00006330 case 312:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006331#line 2975 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006332 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006333 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00006334 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006335 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006336 InsertValue((yyvsp[(2) - (2)].InstVal));
6337 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006338 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006339 ;}
6340 break;
6341
Devang Patel652203f2008-09-29 20:49:50 +00006342 case 313:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006343#line 2984 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006344 {
6345 CHECK_FOR_ERROR
6346 int ValNum = InsertValue((yyvsp[(2) - (2)].InstVal));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006347
Chris Lattner15bd0952008-08-29 17:20:18 +00006348 if (ValNum != (int)(yyvsp[(1) - (2)].UIntVal))
6349 GEN_ERROR("Result value number %" + utostr((yyvsp[(1) - (2)].UIntVal)) +
6350 " is incorrect, expected %" + utostr((unsigned)ValNum));
6351
6352 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6353 CHECK_FOR_ERROR
6354 ;}
6355 break;
6356
Devang Patel652203f2008-09-29 20:49:50 +00006357 case 314:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006358#line 2997 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006359 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006360 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006361 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
6362 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
6363 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00006364 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006365 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006366 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006367 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6368 delete (yyvsp[(1) - (6)].TypeVal);
6369 ;}
6370 break;
6371
Devang Patel652203f2008-09-29 20:49:50 +00006372 case 315:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006373#line 3008 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006374 {
6375 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6376 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006377 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006378 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006379 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006380 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6381 ;}
6382 break;
6383
Devang Patel652203f2008-09-29 20:49:50 +00006384 case 316:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006385#line 3018 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006386 {
Devang Patel05988662008-09-25 21:00:45 +00006387 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006388 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006389 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006390 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00006391 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006392 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 +00006393 (yyval.ParamList)->push_back(E);
6394 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00006395 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006396 ;}
6397 break;
6398
Devang Patel652203f2008-09-29 20:49:50 +00006399 case 317:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006400#line 3029 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006401 {
Devang Patel05988662008-09-25 21:00:45 +00006402 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006403 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00006404 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006405 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 +00006406 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00006407 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006408 ;}
6409 break;
6410
Devang Patel652203f2008-09-29 20:49:50 +00006411 case 318:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006412#line 3037 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006413 {
Devang Patel05988662008-09-25 21:00:45 +00006414 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006415 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006416 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6417 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006418 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 +00006419 (yyval.ParamList)->push_back(E);
6420 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006421 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006422 ;}
6423 break;
6424
Devang Patel652203f2008-09-29 20:49:50 +00006425 case 319:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006426#line 3047 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006427 {
Devang Patel05988662008-09-25 21:00:45 +00006428 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00006429 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006430 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 +00006431 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006432 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006433 ;}
6434 break;
6435
Devang Patel652203f2008-09-29 20:49:50 +00006436 case 320:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006437#line 3054 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006438 { (yyval.ParamList) = new ParamList(); ;}
6439 break;
6440
Devang Patel652203f2008-09-29 20:49:50 +00006441 case 321:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006442#line 3057 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006443 { (yyval.ValueList) = new std::vector<Value*>(); ;}
6444 break;
6445
Devang Patel652203f2008-09-29 20:49:50 +00006446 case 322:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006447#line 3058 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006448 {
6449 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6450 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00006451 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006452 ;}
6453 break;
6454
Devang Patel652203f2008-09-29 20:49:50 +00006455 case 323:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006456#line 3066 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006457 {
6458 (yyval.ConstantList) = new std::vector<unsigned>();
6459 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
6460 GEN_ERROR("Index " + utostr((yyvsp[(2) - (2)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6461 (yyval.ConstantList)->push_back((yyvsp[(2) - (2)].UInt64Val));
6462 ;}
6463 break;
6464
Devang Patel652203f2008-09-29 20:49:50 +00006465 case 324:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006466#line 3072 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006467 {
6468 (yyval.ConstantList) = (yyvsp[(1) - (3)].ConstantList);
6469 if ((unsigned)(yyvsp[(3) - (3)].UInt64Val) != (yyvsp[(3) - (3)].UInt64Val))
6470 GEN_ERROR("Index " + utostr((yyvsp[(3) - (3)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6471 (yyval.ConstantList)->push_back((yyvsp[(3) - (3)].UInt64Val));
6472 CHECK_FOR_ERROR
6473 ;}
6474 break;
6475
Devang Patel652203f2008-09-29 20:49:50 +00006476 case 325:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006477#line 3081 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006478 {
6479 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006480 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006481 ;}
6482 break;
6483
Devang Patel652203f2008-09-29 20:49:50 +00006484 case 326:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006485#line 3085 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006486 {
6487 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006488 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006489 ;}
6490 break;
6491
Devang Patel652203f2008-09-29 20:49:50 +00006492 case 327:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006493#line 3090 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006494 {
Reid Spencer14310612006-12-31 05:40:51 +00006495 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006496 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006497 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
Dan Gohmanf4423b12008-04-19 00:24:39 +00006498 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006499 GEN_ERROR(
6500 "Arithmetic operator requires integer, FP, or packed operands");
Eric Christopher2a5196f2008-09-24 04:55:49 +00006501 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006502 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006503 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006504 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006505 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006506 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006507 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006508 delete (yyvsp[(2) - (5)].TypeVal);
6509 ;}
6510 break;
6511
Devang Patel652203f2008-09-29 20:49:50 +00006512 case 328:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006513#line 3106 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006514 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006515 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006516 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6517 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
Nate Begeman5bc1ea02008-07-29 15:49:41 +00006518 if (!isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00006519 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006520 GEN_ERROR("Logical operator requires integral operands");
6521 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006522 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006523 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006524 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006525 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006526 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006527 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006528 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006529 delete (yyvsp[(2) - (5)].TypeVal);
6530 ;}
6531 break;
6532
Devang Patel652203f2008-09-29 20:49:50 +00006533 case 329:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006534#line 3123 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006535 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006536 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006537 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006538 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006539 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006540 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006541 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006542 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006543 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006544 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006545 delete (yyvsp[(3) - (6)].TypeVal);
6546 ;}
6547 break;
6548
Devang Patel652203f2008-09-29 20:49:50 +00006549 case 330:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006550#line 3135 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006551 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006552 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006553 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006554 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006555 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006556 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006557 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006558 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006559 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006560 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006561 delete (yyvsp[(3) - (6)].TypeVal);
6562 ;}
6563 break;
6564
Devang Patel652203f2008-09-29 20:49:50 +00006565 case 331:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006566#line 3147 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006567 {
6568 if (!UpRefs.empty())
6569 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6570 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6571 GEN_ERROR("Scalar types not supported by vicmp instruction");
6572 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6573 CHECK_FOR_ERROR
6574 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6575 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006576 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006577 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006578 GEN_ERROR("vicmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006579 delete (yyvsp[(3) - (6)].TypeVal);
6580 ;}
6581 break;
6582
Devang Patel652203f2008-09-29 20:49:50 +00006583 case 332:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006584#line 3161 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006585 {
6586 if (!UpRefs.empty())
6587 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6588 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6589 GEN_ERROR("Scalar types not supported by vfcmp instruction");
6590 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6591 CHECK_FOR_ERROR
6592 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6593 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006594 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006595 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006596 GEN_ERROR("vfcmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006597 delete (yyvsp[(3) - (6)].TypeVal);
6598 ;}
6599 break;
6600
Devang Patel652203f2008-09-29 20:49:50 +00006601 case 333:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006602#line 3175 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006603 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006604 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006605 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6606 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6607 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6608 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006609 GEN_ERROR("invalid cast opcode for cast from '" +
6610 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00006611 DestTy->getDescription() + "'");
Dan Gohmane4977cf2008-05-23 01:55:30 +00006612 (yyval.InstVal) = CastInst::Create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006613 delete (yyvsp[(4) - (4)].TypeVal);
6614 ;}
6615 break;
6616
Devang Patel652203f2008-09-29 20:49:50 +00006617 case 334:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006618#line 3187 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006619 {
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006620 if (isa<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType())) {
6621 // vector select
6622 if (!isa<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType())
6623 || !isa<VectorType>((yyvsp[(6) - (6)].ValueVal)->getType()) )
6624 GEN_ERROR("vector select value types must be vector types");
6625 const VectorType* cond_type = cast<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType());
6626 const VectorType* select_type = cast<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType());
6627 if (cond_type->getElementType() != Type::Int1Ty)
6628 GEN_ERROR("vector select condition element type must be boolean");
6629 if (cond_type->getNumElements() != select_type->getNumElements())
6630 GEN_ERROR("vector select number of elements must be the same");
6631 } else {
6632 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
6633 GEN_ERROR("select condition must be boolean");
6634 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006635 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006636 GEN_ERROR("select value types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006637 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006638 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006639 ;}
6640 break;
6641
Devang Patel652203f2008-09-29 20:49:50 +00006642 case 335:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006643#line 3208 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006644 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006645 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006646 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6647 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6648 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006649 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006650 ;}
6651 break;
6652
Devang Patel652203f2008-09-29 20:49:50 +00006653 case 336:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006654#line 3215 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006655 {
6656 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006657 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006658 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006659 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006660 ;}
6661 break;
6662
Devang Patel652203f2008-09-29 20:49:50 +00006663 case 337:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006664#line 3221 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006665 {
6666 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006667 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006668 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006669 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006670 ;}
6671 break;
6672
Devang Patel652203f2008-09-29 20:49:50 +00006673 case 338:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006674#line 3227 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006675 {
6676 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006677 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006678 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006679 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006680 ;}
6681 break;
6682
Devang Patel652203f2008-09-29 20:49:50 +00006683 case 339:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006684#line 3233 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006685 {
6686 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006687 if (!Ty->isFirstClassType())
6688 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006689 (yyval.InstVal) = PHINode::Create(Ty);
6690 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6691 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006692 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006693 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006694 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6695 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006696 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006697 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006698 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006699 ;}
6700 break;
6701
Devang Patel652203f2008-09-29 20:49:50 +00006702 case 340:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006703#line 3249 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006704 {
Reid Spencer14310612006-12-31 05:40:51 +00006705
6706 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006707 const PointerType *PFTy = 0;
6708 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006709 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (9)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006710 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6711 // Pull out the types of all of the arguments...
6712 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006713 ParamList::iterator I = (yyvsp[(7) - (9)].ParamList)->begin(), E = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006714 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006715 const Type *Ty = I->Val->getType();
6716 if (Ty == Type::VoidTy)
6717 GEN_ERROR("Short call syntax cannot be used with varargs");
6718 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006719 }
Chris Lattnera925a142008-04-23 05:37:08 +00006720
Devang Patel652203f2008-09-29 20:49:50 +00006721 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (9)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006722 GEN_ERROR("Invalid result type for LLVM function");
6723
Devang Patel652203f2008-09-29 20:49:50 +00006724 Ty = FunctionType::get((yyvsp[(4) - (9)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006725 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006726 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006727
Devang Patel652203f2008-09-29 20:49:50 +00006728 Value *V = getVal(PFTy, (yyvsp[(5) - (9)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006729 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006730
Reid Spencer7780acb2007-04-16 06:56:07 +00006731 // Check for call to invalid intrinsic to avoid crashing later.
6732 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006733 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006734 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6735 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006736 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6737 theF->getName() + "'");
6738 }
6739
Devang Patel05988662008-09-25 21:00:45 +00006740 // Set up the Attributes for the function
6741 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006742 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6743 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006744 Attributes RetAttrs = (yyvsp[(3) - (9)].Attributes);
6745 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None) {
6746 if ((yyvsp[(9) - (9)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006747 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006748 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006749 }
Devang Patel652203f2008-09-29 20:49:50 +00006750 if ((yyvsp[(9) - (9)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006751 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006752 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006753 }
Devang Patel652203f2008-09-29 20:49:50 +00006754 if ((yyvsp[(9) - (9)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006755 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006756 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006757 }
Dale Johannesene7261862008-09-26 23:46:20 +00006758 }
Devang Patel652203f2008-09-29 20:49:50 +00006759 if (RetAttrs != Attribute::None)
6760 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006761
Eric Christopher2a5196f2008-09-24 04:55:49 +00006762 // Check the arguments
Reid Spencer14310612006-12-31 05:40:51 +00006763 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006764 if ((yyvsp[(7) - (9)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006765 // Make sure no arguments is a good thing!
6766 if (Ty->getNumParams() != 0)
6767 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006768 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006769 } else { // Has arguments?
6770 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006771 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006772 FunctionType::param_iterator I = Ty->param_begin();
6773 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006774 ParamList::iterator ArgI = (yyvsp[(7) - (9)].ParamList)->begin(), ArgE = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006775 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006776
Duncan Sandsdc024672007-11-27 13:23:08 +00006777 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006778 if (ArgI->Val->getType() != *I)
6779 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006780 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006781 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006782 if (ArgI->Attrs != Attribute::None)
6783 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006784 }
6785 if (Ty->isVarArg()) {
6786 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006787 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006788 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006789 if (ArgI->Attrs != Attribute::None)
6790 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006791 }
Reid Spencer14310612006-12-31 05:40:51 +00006792 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006793 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006794 }
Devang Patel652203f2008-09-29 20:49:50 +00006795 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None)
6796 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (9)].Attributes)));
Duncan Sandsdc024672007-11-27 13:23:08 +00006797
Devang Patel05988662008-09-25 21:00:45 +00006798 // Finish off the Attributes and check them
6799 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006800 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006801 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006802
Reid Spencer14310612006-12-31 05:40:51 +00006803 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006804 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006805 CI->setTailCall((yyvsp[(1) - (9)].BoolVal));
6806 CI->setCallingConv((yyvsp[(2) - (9)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006807 CI->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006808 (yyval.InstVal) = CI;
Devang Patel652203f2008-09-29 20:49:50 +00006809 delete (yyvsp[(7) - (9)].ParamList);
6810 delete (yyvsp[(4) - (9)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006811 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006812 ;}
6813 break;
6814
Devang Patel652203f2008-09-29 20:49:50 +00006815 case 341:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006816#line 3358 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006817 {
6818 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006819 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006820 ;}
6821 break;
6822
Devang Patel652203f2008-09-29 20:49:50 +00006823 case 342:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006824#line 3363 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006825 {
6826 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006827 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006828 ;}
6829 break;
6830
Devang Patel652203f2008-09-29 20:49:50 +00006831 case 343:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006832#line 3367 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006833 {
6834 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006835 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006836 ;}
6837 break;
6838
Devang Patel652203f2008-09-29 20:49:50 +00006839 case 344:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006840#line 3374 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006841 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006842 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006843 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6844 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6845 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006846 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006847 ;}
6848 break;
6849
Devang Patel652203f2008-09-29 20:49:50 +00006850 case 345:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006851#line 3381 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006852 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006853 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006854 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006855 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6856 GEN_ERROR("Malloc array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006857 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006858 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006859 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6860 delete (yyvsp[(2) - (6)].TypeVal);
6861 ;}
6862 break;
6863
Devang Patel652203f2008-09-29 20:49:50 +00006864 case 346:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006865#line 3391 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006866 {
Reid Spencer14310612006-12-31 05:40:51 +00006867 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006868 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6869 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6870 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006871 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006872 ;}
6873 break;
6874
Devang Patel652203f2008-09-29 20:49:50 +00006875 case 347:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006876#line 3398 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006877 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006878 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006879 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006880 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6881 GEN_ERROR("Alloca array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006882 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006883 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006884 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6885 delete (yyvsp[(2) - (6)].TypeVal);
6886 ;}
6887 break;
6888
Devang Patel652203f2008-09-29 20:49:50 +00006889 case 348:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006890#line 3408 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006891 {
6892 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Eric Christopher2a5196f2008-09-24 04:55:49 +00006893 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006894 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6895 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006896 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006897 ;}
6898 break;
6899
Devang Patel652203f2008-09-29 20:49:50 +00006900 case 349:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006901#line 3416 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006902 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006903 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006904 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6905 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006906 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006907 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6908 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006909 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006910 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6911 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006912 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006913 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6914 delete (yyvsp[(3) - (5)].TypeVal);
6915 ;}
6916 break;
6917
Devang Patel652203f2008-09-29 20:49:50 +00006918 case 350:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006919#line 3430 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006920 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006921 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006922 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6923 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006924 if (!PT)
6925 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006926 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006927 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006928 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6929 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006930 "' into space of type '" + ElTy->getDescription() + "'");
6931
Dan Gohmanf4423b12008-04-19 00:24:39 +00006932 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006933 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006934 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6935 delete (yyvsp[(5) - (7)].TypeVal);
6936 ;}
6937 break;
6938
Devang Patel652203f2008-09-29 20:49:50 +00006939 case 351:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006940#line 3447 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006941 {
Dan Gohman1a570242008-07-23 00:54:54 +00006942 if (!UpRefs.empty())
6943 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6944 if (!isa<StructType>((yyvsp[(2) - (5)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (5)].TypeVal)->get()))
6945 GEN_ERROR("getresult insn requires an aggregate operand");
6946 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].UInt64Val)))
6947 GEN_ERROR("Invalid getresult index for type '" +
6948 (*(yyvsp[(2) - (5)].TypeVal))->getDescription()+ "'");
6949
6950 Value *tmpVal = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Devang Patel5a970972008-02-19 22:27:01 +00006951 CHECK_FOR_ERROR
Dan Gohman1a570242008-07-23 00:54:54 +00006952 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(5) - (5)].UInt64Val));
6953 delete (yyvsp[(2) - (5)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006954 ;}
6955 break;
6956
Devang Patel652203f2008-09-29 20:49:50 +00006957 case 352:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006958#line 3461 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006959 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006960 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006961 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6962 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006963 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006964
Dan Gohman041e2eb2008-05-15 19:50:34 +00006965 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()))
Reid Spencer61c83e02006-08-18 08:43:06 +00006966 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006967 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6968 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006969 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006970 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006971 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006972 delete (yyvsp[(4) - (4)].ValueList);
6973 ;}
6974 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006975
Devang Patel652203f2008-09-29 20:49:50 +00006976 case 353:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006977#line 3476 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00006978 {
6979 if (!UpRefs.empty())
6980 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6981 if (!isa<StructType>((yyvsp[(2) - (4)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (4)].TypeVal)->get()))
6982 GEN_ERROR("extractvalue insn requires an aggregate operand");
6983
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006984 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end()))
Dan Gohmane4977cf2008-05-23 01:55:30 +00006985 GEN_ERROR("Invalid extractvalue indices for type '" +
6986 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6987 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
6988 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006989 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006990 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006991 delete (yyvsp[(4) - (4)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00006992 ;}
6993 break;
6994
Devang Patel652203f2008-09-29 20:49:50 +00006995 case 354:
Nuno Lopes191dfb92008-10-03 15:52:39 +00006996#line 3491 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00006997 {
6998 if (!UpRefs.empty())
6999 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (7)].TypeVal))->getDescription());
7000 if (!isa<StructType>((yyvsp[(2) - (7)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (7)].TypeVal)->get()))
7001 GEN_ERROR("extractvalue insn requires an aggregate operand");
7002
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007003 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 +00007004 GEN_ERROR("Invalid insertvalue indices for type '" +
7005 (*(yyvsp[(2) - (7)].TypeVal))->getDescription()+ "'");
7006 Value* aggVal = getVal(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(3) - (7)].ValIDVal));
7007 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
7008 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007009 (yyval.InstVal) = InsertValueInst::Create(aggVal, tmpVal, (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00007010 delete (yyvsp[(2) - (7)].TypeVal);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007011 delete (yyvsp[(5) - (7)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007012 delete (yyvsp[(7) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007013 ;}
7014 break;
7015
Dan Gohmanf4423b12008-04-19 00:24:39 +00007016
7017/* Line 1267 of yacc.c. */
Nuno Lopes191dfb92008-10-03 15:52:39 +00007018#line 7019 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00007019 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00007020 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007021 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
7022
7023 YYPOPSTACK (yylen);
7024 yylen = 0;
7025 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007026
7027 *++yyvsp = yyval;
7028
7029
Dan Gohmanf4423b12008-04-19 00:24:39 +00007030 /* Now `shift' the result of the reduction. Determine what state
7031 that goes to, based on the state we popped back to and the rule
7032 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00007033
7034 yyn = yyr1[yyn];
7035
Dan Gohmanf4423b12008-04-19 00:24:39 +00007036 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
7037 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007038 yystate = yytable[yystate];
7039 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00007040 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00007041
7042 goto yynewstate;
7043
7044
Dan Gohmanf4423b12008-04-19 00:24:39 +00007045/*------------------------------------.
7046| yyerrlab -- here on detecting error |
7047`------------------------------------*/
7048yyerrlab:
7049 /* If not already recovering from an error, report this error. */
7050 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007051 {
7052 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007053#if ! YYERROR_VERBOSE
7054 yyerror (YY_("syntax error"));
7055#else
7056 {
7057 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
7058 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
7059 {
7060 YYSIZE_T yyalloc = 2 * yysize;
7061 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
7062 yyalloc = YYSTACK_ALLOC_MAXIMUM;
7063 if (yymsg != yymsgbuf)
7064 YYSTACK_FREE (yymsg);
7065 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
7066 if (yymsg)
7067 yymsg_alloc = yyalloc;
7068 else
7069 {
7070 yymsg = yymsgbuf;
7071 yymsg_alloc = sizeof yymsgbuf;
7072 }
7073 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00007074
Dan Gohmanf4423b12008-04-19 00:24:39 +00007075 if (0 < yysize && yysize <= yymsg_alloc)
7076 {
7077 (void) yysyntax_error (yymsg, yystate, yychar);
7078 yyerror (yymsg);
7079 }
7080 else
7081 {
7082 yyerror (YY_("syntax error"));
7083 if (yysize != 0)
7084 goto yyexhaustedlab;
7085 }
7086 }
7087#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007088 }
7089
Dan Gohmanf4423b12008-04-19 00:24:39 +00007090
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007091
7092 if (yyerrstatus == 3)
7093 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00007094 /* If just tried and failed to reuse look-ahead token after an
7095 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007096
Dan Gohmanf4423b12008-04-19 00:24:39 +00007097 if (yychar <= YYEOF)
7098 {
7099 /* Return failure if at end of input. */
7100 if (yychar == YYEOF)
7101 YYABORT;
7102 }
7103 else
7104 {
7105 yydestruct ("Error: discarding",
7106 yytoken, &yylval);
7107 yychar = YYEMPTY;
7108 }
7109 }
7110
7111 /* Else will try to reuse look-ahead token after shifting the error
7112 token. */
7113 goto yyerrlab1;
7114
7115
7116/*---------------------------------------------------.
7117| yyerrorlab -- error raised explicitly by YYERROR. |
7118`---------------------------------------------------*/
7119yyerrorlab:
7120
7121 /* Pacify compilers like GCC when the user code never invokes
7122 YYERROR and the label yyerrorlab therefore never appears in user
7123 code. */
7124 if (/*CONSTCOND*/ 0)
7125 goto yyerrorlab;
7126
7127 /* Do not reclaim the symbols of the rule which action triggered
7128 this YYERROR. */
7129 YYPOPSTACK (yylen);
7130 yylen = 0;
7131 YY_STACK_PRINT (yyss, yyssp);
7132 yystate = *yyssp;
7133 goto yyerrlab1;
7134
7135
7136/*-------------------------------------------------------------.
7137| yyerrlab1 -- common code for both syntax error and YYERROR. |
7138`-------------------------------------------------------------*/
7139yyerrlab1:
7140 yyerrstatus = 3; /* Each real token shifted decrements this. */
7141
7142 for (;;)
7143 {
7144 yyn = yypact[yystate];
7145 if (yyn != YYPACT_NINF)
7146 {
7147 yyn += YYTERROR;
7148 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7149 {
7150 yyn = yytable[yyn];
7151 if (0 < yyn)
7152 break;
7153 }
7154 }
7155
7156 /* Pop the current state because it cannot handle the error token. */
7157 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007158 YYABORT;
7159
Dale Johannesencdd509a2007-09-07 21:07:57 +00007160
Dan Gohmanf4423b12008-04-19 00:24:39 +00007161 yydestruct ("Error: popping",
7162 yystos[yystate], yyvsp);
7163 YYPOPSTACK (1);
7164 yystate = *yyssp;
7165 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007166 }
7167
7168 if (yyn == YYFINAL)
7169 YYACCEPT;
7170
Reid Spencer68a24bd2005-08-27 18:50:39 +00007171 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007172
7173
7174 /* Shift the error token. */
7175 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00007176
Reid Spencer68a24bd2005-08-27 18:50:39 +00007177 yystate = yyn;
7178 goto yynewstate;
7179
Gabor Greife64d2482008-04-06 23:07:54 +00007180
Dan Gohmanf4423b12008-04-19 00:24:39 +00007181/*-------------------------------------.
7182| yyacceptlab -- YYACCEPT comes here. |
7183`-------------------------------------*/
7184yyacceptlab:
7185 yyresult = 0;
7186 goto yyreturn;
7187
7188/*-----------------------------------.
7189| yyabortlab -- YYABORT comes here. |
7190`-----------------------------------*/
7191yyabortlab:
7192 yyresult = 1;
7193 goto yyreturn;
7194
7195#ifndef yyoverflow
7196/*-------------------------------------------------.
7197| yyexhaustedlab -- memory exhaustion comes here. |
7198`-------------------------------------------------*/
7199yyexhaustedlab:
7200 yyerror (YY_("memory exhausted"));
7201 yyresult = 2;
7202 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00007203#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00007204
7205yyreturn:
7206 if (yychar != YYEOF && yychar != YYEMPTY)
7207 yydestruct ("Cleanup: discarding lookahead",
7208 yytoken, &yylval);
7209 /* Do not reclaim the symbols of the rule which action triggered
7210 this YYABORT or YYACCEPT. */
7211 YYPOPSTACK (yylen);
7212 YY_STACK_PRINT (yyss, yyssp);
7213 while (yyssp != yyss)
7214 {
7215 yydestruct ("Cleanup: popping",
7216 yystos[*yyssp], yyvsp);
7217 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00007218 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007219#ifndef yyoverflow
7220 if (yyss != yyssa)
7221 YYSTACK_FREE (yyss);
7222#endif
7223#if YYERROR_VERBOSE
7224 if (yymsg != yymsgbuf)
7225 YYSTACK_FREE (yymsg);
7226#endif
7227 /* Make sure YYID is used. */
7228 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007229}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007230
7231
Nuno Lopes191dfb92008-10-03 15:52:39 +00007232#line 3510 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00007233
7234
Reid Spencer14310612006-12-31 05:40:51 +00007235// common code from the two 'RunVMAsmParser' functions
7236static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00007237 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00007238 // Check to make sure the parser succeeded
7239 if (yyparse()) {
7240 if (ParserResult)
7241 delete ParserResult;
7242 return 0;
7243 }
7244
Reid Spencer0d60b5a2007-03-30 01:37:39 +00007245 // Emit an error if there are any unresolved types left.
7246 if (!CurModule.LateResolveTypes.empty()) {
7247 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
7248 if (DID.Type == ValID::LocalName) {
7249 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
7250 } else {
7251 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
7252 }
7253 if (ParserResult)
7254 delete ParserResult;
7255 return 0;
7256 }
7257
7258 // Emit an error if there are any unresolved values left.
7259 if (!CurModule.LateResolveValues.empty()) {
7260 Value *V = CurModule.LateResolveValues.back();
7261 std::map<Value*, std::pair<ValID, int> >::iterator I =
7262 CurModule.PlaceHolderInfo.find(V);
7263
7264 if (I != CurModule.PlaceHolderInfo.end()) {
7265 ValID &DID = I->second.first;
7266 if (DID.Type == ValID::LocalName) {
7267 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
7268 } else {
7269 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
7270 }
7271 if (ParserResult)
7272 delete ParserResult;
7273 return 0;
7274 }
7275 }
7276
Reid Spencer14310612006-12-31 05:40:51 +00007277 // Check to make sure that parsing produced a result
7278 if (!ParserResult)
7279 return 0;
7280
7281 // Reset ParserResult variable while saving its value for the result.
7282 Module *Result = ParserResult;
7283 ParserResult = 0;
7284
7285 return Result;
7286}
7287
Reid Spencer61c83e02006-08-18 08:43:06 +00007288void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007289 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00007290 // TODO: column number in exception
7291 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00007292 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00007293 TriggerError = 1;
7294}
Reid Spencer68a24bd2005-08-27 18:50:39 +00007295
7296int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007297 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00007298 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00007299 if (yychar != YYEMPTY && yychar != 0) {
7300 errMsg += " while reading token: '";
Eric Christopher2a5196f2008-09-24 04:55:49 +00007301 errMsg += std::string(LLLgetTokenStart(),
Duncan Sandsdc024672007-11-27 13:23:08 +00007302 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
7303 }
Reid Spencer61c83e02006-08-18 08:43:06 +00007304 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007305 return 0;
7306}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007307