blob: 2faff2d3ea074fd1899307708126991c78b89320 [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,
Nuno Lopes8a88a372008-10-05 16:49:34 +00001902 1393, 1401, 1436, 1467, 1472, 1482, 1492, 1496, 1506, 1513,
1903 1522, 1529, 1534, 1539, 1546, 1547, 1554, 1561, 1569, 1575,
1904 1587, 1615, 1631, 1658, 1686, 1712, 1732, 1758, 1778, 1790,
1905 1797, 1863, 1873, 1883, 1889, 1899, 1905, 1915, 1921, 1927,
1906 1940, 1952, 1973, 1981, 1987, 1998, 2003, 2008, 2013, 2018,
1907 2024, 2030, 2036, 2044, 2055, 2059, 2067, 2067, 2070, 2070,
1908 2073, 2085, 2106, 2111, 2119, 2120, 2124, 2124, 2128, 2128,
1909 2131, 2134, 2158, 2170, 2169, 2181, 2180, 2190, 2189, 2200,
1910 2240, 2243, 2249, 2259, 2263, 2268, 2270, 2275, 2280, 2289,
1911 2299, 2310, 2314, 2323, 2332, 2337, 2486, 2486, 2488, 2497,
1912 2497, 2499, 2504, 2516, 2520, 2525, 2529, 2533, 2538, 2543,
1913 2547, 2551, 2555, 2559, 2563, 2567, 2589, 2611, 2617, 2630,
1914 2642, 2647, 2659, 2665, 2669, 2679, 2683, 2687, 2692, 2699,
1915 2699, 2705, 2714, 2719, 2724, 2728, 2737, 2746, 2759, 2768,
1916 2772, 2780, 2800, 2804, 2809, 2820, 2839, 2848, 2952, 2956,
1917 2963, 2974, 2987, 2996, 3009, 3020, 3030, 3041, 3049, 3059,
1918 3066, 3069, 3070, 3078, 3084, 3093, 3097, 3102, 3118, 3135,
1919 3147, 3159, 3173, 3187, 3199, 3220, 3227, 3233, 3239, 3245,
1920 3260, 3370, 3375, 3379, 3386, 3393, 3403, 3410, 3420, 3428,
1921 3442, 3459, 3473, 3488, 3503
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[(1) - (5)].TypeVal); // Delete the return type handle
Eric Christopher2a5196f2008-09-24 04:55:49 +00004327 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Nuno Lopes8a88a372008-10-05 16:49:34 +00004328
4329 // Delete the argument list
4330 for (I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin() ; I != E; ++I ) {
4331 delete I->Ty;
4332 }
4333 delete (yyvsp[(3) - (5)].TypeWithAttrsList);
4334
Reid Spencere4d87aa2006-12-23 06:05:41 +00004335 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004336 ;}
4337 break;
4338
Devang Patel652203f2008-09-29 20:49:50 +00004339 case 162:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004340#line 1436 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004341 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004342 // Allow but ignore attributes on function types; this permits auto-upgrade.
4343 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004344 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004345 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004346 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004347 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004348 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004349 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004350
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004351 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4352 if (isVarArg) Params.pop_back();
4353
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004354 for (unsigned i = 0; i != Params.size(); ++i)
4355 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4356 GEN_ERROR("Function arguments must be value types!");
4357
4358 CHECK_FOR_ERROR
4359
Dan Gohmanf4423b12008-04-19 00:24:39 +00004360 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
Eric Christopher2a5196f2008-09-24 04:55:49 +00004361 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Nuno Lopes8a88a372008-10-05 16:49:34 +00004362
4363 // Delete the argument list
4364 for (I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin() ; I != E; ++I ) {
4365 delete I->Ty;
4366 }
4367 delete (yyvsp[(3) - (5)].TypeWithAttrsList);
4368
Reid Spencer41dff5e2007-01-26 08:05:27 +00004369 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004370 ;}
4371 break;
4372
Devang Patel652203f2008-09-29 20:49:50 +00004373 case 163:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004374#line 1467 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004375 { // Sized array type?
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004376 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (yyvsp[(2) - (5)].UInt64Val))));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004377 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004378 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004379 ;}
4380 break;
4381
Devang Patel652203f2008-09-29 20:49:50 +00004382 case 164:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004383#line 1472 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004384 { // Vector type?
4385 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4386 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004387 GEN_ERROR("Unsigned result not equal to signed result");
4388 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4389 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004390 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4391 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004392 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004393 ;}
4394 break;
4395
Devang Patel652203f2008-09-29 20:49:50 +00004396 case 165:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004397#line 1482 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004398 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004399 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004400 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4401 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004402 Elements.push_back(*I);
4403
Dan Gohmanf4423b12008-04-19 00:24:39 +00004404 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4405 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004406 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004407 ;}
4408 break;
4409
Devang Patel652203f2008-09-29 20:49:50 +00004410 case 166:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004411#line 1492 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004412 { // Empty structure type?
4413 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004414 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004415 ;}
4416 break;
4417
Devang Patel652203f2008-09-29 20:49:50 +00004418 case 167:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004419#line 1496 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004420 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004421 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004422 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4423 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004424 Elements.push_back(*I);
4425
Dan Gohmanf4423b12008-04-19 00:24:39 +00004426 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4427 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004428 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004429 ;}
4430 break;
4431
Devang Patel652203f2008-09-29 20:49:50 +00004432 case 168:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004433#line 1506 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004434 { // Empty structure type?
4435 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004436 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004437 ;}
4438 break;
4439
Devang Patel652203f2008-09-29 20:49:50 +00004440 case 169:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004441#line 1513 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004442 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004443 // Allow but ignore attributes on function types; this permits auto-upgrade.
4444 // FIXME: remove in LLVM 3.0.
Eric Christopher2a5196f2008-09-24 04:55:49 +00004445 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
Devang Patel05988662008-09-25 21:00:45 +00004446 (yyval.TypeWithAttrs).Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004447 ;}
4448 break;
4449
Devang Patel652203f2008-09-29 20:49:50 +00004450 case 170:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004451#line 1522 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004452 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004453 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004454 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4455 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004456 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004457 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4458 ;}
4459 break;
4460
Devang Patel652203f2008-09-29 20:49:50 +00004461 case 171:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004462#line 1529 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004463 {
4464 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4465 ;}
4466 break;
4467
Devang Patel652203f2008-09-29 20:49:50 +00004468 case 172:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004469#line 1534 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004470 {
4471 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4472 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004473 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004474 ;}
4475 break;
4476
Devang Patel652203f2008-09-29 20:49:50 +00004477 case 173:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004478#line 1539 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004479 {
4480 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004481 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004482 ;}
4483 break;
4484
Devang Patel652203f2008-09-29 20:49:50 +00004485 case 175:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004486#line 1547 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004487 {
4488 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Devang Patel05988662008-09-25 21:00:45 +00004489 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004490 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004491 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004492 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004493 ;}
4494 break;
4495
Devang Patel652203f2008-09-29 20:49:50 +00004496 case 176:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004497#line 1554 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004498 {
4499 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Devang Patel05988662008-09-25 21:00:45 +00004500 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004501 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004502 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004503 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004504 ;}
4505 break;
4506
Devang Patel652203f2008-09-29 20:49:50 +00004507 case 177:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004508#line 1561 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004509 {
4510 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004511 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004512 ;}
4513 break;
4514
Devang Patel652203f2008-09-29 20:49:50 +00004515 case 178:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004516#line 1569 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004517 {
4518 (yyval.TypeList) = new std::list<PATypeHolder>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004519 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004520 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004521 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004522 ;}
4523 break;
4524
Devang Patel652203f2008-09-29 20:49:50 +00004525 case 179:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004526#line 1575 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004527 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00004528 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004529 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004530 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004531 ;}
4532 break;
4533
Devang Patel652203f2008-09-29 20:49:50 +00004534 case 180:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004535#line 1587 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004536 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004537 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004538 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4539 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004540 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004541 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004542 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004543 const Type *ETy = ATy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004544 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004545
4546 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004547 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004548 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004549 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004550 utostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004551
4552 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004553 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4554 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004555 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004556 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004557 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004558 }
4559
Dan Gohmanf4423b12008-04-19 00:24:39 +00004560 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4561 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004562 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004563 ;}
4564 break;
4565
Devang Patel652203f2008-09-29 20:49:50 +00004566 case 181:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004567#line 1615 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004568 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004569 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004570 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4571 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004572 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004573 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004574 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004575
Dan Gohman180c1692008-06-23 18:43:26 +00004576 uint64_t NumElements = ATy->getNumElements();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004577 if (NumElements != uint64_t(-1) && NumElements != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004578 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Mon P Wang28873102008-06-25 08:15:39 +00004579 " arguments, but has size of " + utostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004580 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4581 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004582 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004583 ;}
4584 break;
4585
Devang Patel652203f2008-09-29 20:49:50 +00004586 case 182:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004587#line 1631 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004588 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004589 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004590 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4591 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004592 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004593 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004594 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004595
Dan Gohman180c1692008-06-23 18:43:26 +00004596 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004597 const Type *ETy = ATy->getElementType();
Mon P Wang28873102008-06-25 08:15:39 +00004598 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (3)].StrVal)->length())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004599 GEN_ERROR("Can't build string constant of size " +
Mon P Wang28873102008-06-25 08:15:39 +00004600 utostr((yyvsp[(3) - (3)].StrVal)->length()) +
4601 " when array has size " + utostr(NumElements) + "");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004602 std::vector<Constant*> Vals;
4603 if (ETy == Type::Int8Ty) {
Mon P Wang28873102008-06-25 08:15:39 +00004604 for (uint64_t i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004605 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004606 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004607 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004608 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4609 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004610 delete (yyvsp[(3) - (3)].StrVal);
4611 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4612 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004613 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004614 ;}
4615 break;
4616
Devang Patel652203f2008-09-29 20:49:50 +00004617 case 183:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004618#line 1658 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004619 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004620 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004621 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4622 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004623 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004624 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004625 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004626 const Type *ETy = PTy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004627 unsigned NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004628
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004629 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004630 if (NumElements != unsigned(-1) && NumElements != (unsigned)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004631 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004632 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004633 utostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004634
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004635 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004636 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4637 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004638 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004639 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004640 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004641 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004642
Dan Gohmanf4423b12008-04-19 00:24:39 +00004643 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4644 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004645 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004646 ;}
4647 break;
4648
Devang Patel652203f2008-09-29 20:49:50 +00004649 case 184:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004650#line 1686 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004651 {
4652 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004653 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004654 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004655 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004656
Dan Gohmanf4423b12008-04-19 00:24:39 +00004657 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004658 GEN_ERROR("Illegal number of initializers for structure type");
4659
4660 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004661 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4662 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004663 GEN_ERROR("Expected type '" +
4664 STy->getElementType(i)->getDescription() +
4665 "' for element #" + utostr(i) +
4666 " of structure initializer");
4667
4668 // Check to ensure that Type is not packed
4669 if (STy->isPacked())
4670 GEN_ERROR("Unpacked Initializer to vector type '" +
4671 STy->getDescription() + "'");
4672
Dan Gohmanf4423b12008-04-19 00:24:39 +00004673 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4674 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004675 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004676 ;}
4677 break;
4678
Devang Patel652203f2008-09-29 20:49:50 +00004679 case 185:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004680#line 1712 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004681 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004682 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004683 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4684 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004685 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004686 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004687 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004688
4689 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004690 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004691
4692 // Check to ensure that Type is not packed
4693 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004694 GEN_ERROR("Unpacked Initializer to vector type '" +
4695 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004696
Dan Gohmanf4423b12008-04-19 00:24:39 +00004697 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4698 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004699 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004700 ;}
4701 break;
4702
Devang Patel652203f2008-09-29 20:49:50 +00004703 case 186:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004704#line 1732 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004705 {
4706 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004707 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004708 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004709 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004710
Dan Gohmanf4423b12008-04-19 00:24:39 +00004711 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004712 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004713
4714 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004715 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4716 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004717 GEN_ERROR("Expected type '" +
4718 STy->getElementType(i)->getDescription() +
4719 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004720 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004721
4722 // Check to ensure that Type is packed
4723 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004724 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004725 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004726
Dan Gohmanf4423b12008-04-19 00:24:39 +00004727 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4728 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004729 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004730 ;}
4731 break;
4732
Devang Patel652203f2008-09-29 20:49:50 +00004733 case 187:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004734#line 1758 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004735 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004736 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004737 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4738 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004739 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004740 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004741 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004742
4743 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004744 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004745
4746 // Check to ensure that Type is packed
4747 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004748 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004749 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004750
Dan Gohmanf4423b12008-04-19 00:24:39 +00004751 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4752 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004753 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004754 ;}
4755 break;
4756
Devang Patel652203f2008-09-29 20:49:50 +00004757 case 188:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004758#line 1778 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004759 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004760 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004761 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4762 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004763 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004764 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004765 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004766
Dan Gohmanf4423b12008-04-19 00:24:39 +00004767 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4768 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004769 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004770 ;}
4771 break;
4772
Devang Patel652203f2008-09-29 20:49:50 +00004773 case 189:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004774#line 1790 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004775 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004776 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004777 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4778 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4779 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004780 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004781 ;}
4782 break;
4783
Devang Patel652203f2008-09-29 20:49:50 +00004784 case 190:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004785#line 1797 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004786 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004787 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004788 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4789 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004790 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004791 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004792
4793 // ConstExprs can exist in the body of a function, thus creating
4794 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004795 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004796 // symbol table instead of the module symbol table for the global symbol,
4797 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004798 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004799 //
4800 Function *SavedCurFn = CurFun.CurrentFunction;
4801 CurFun.CurrentFunction = 0;
4802
Dan Gohmanf4423b12008-04-19 00:24:39 +00004803 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004804 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004805
4806 CurFun.CurrentFunction = SavedCurFn;
4807
4808 // If this is an initializer for a constant pointer, which is referencing a
4809 // (currently) undefined variable, create a stub now that shall be replaced
4810 // in the future with the right type of variable.
4811 //
4812 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004813 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004814 const PointerType *PT = cast<PointerType>(Ty);
4815
4816 // First check to see if the forward references value is already created!
4817 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004818 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Eric Christopher2a5196f2008-09-24 04:55:49 +00004819
Reid Spencer68a24bd2005-08-27 18:50:39 +00004820 if (I != CurModule.GlobalRefs.end()) {
4821 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004822 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004823 } else {
4824 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004825 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4826 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4827 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004828 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004829
4830 // Create the forward referenced global.
4831 GlobalValue *GV;
Eric Christopher2a5196f2008-09-24 04:55:49 +00004832 if (const FunctionType *FTy =
Reid Spencer68a24bd2005-08-27 18:50:39 +00004833 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004834 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4835 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004836 } else {
4837 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004838 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004839 Name, CurModule.CurrentModule);
4840 }
4841
4842 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004843 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004844 V = GV;
4845 }
4846 }
4847
Dan Gohmanf4423b12008-04-19 00:24:39 +00004848 (yyval.ConstVal) = cast<GlobalValue>(V);
4849 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004850 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004851 ;}
4852 break;
4853
Devang Patel652203f2008-09-29 20:49:50 +00004854 case 191:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004855#line 1863 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004856 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004857 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004858 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4859 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004860 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004861 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4862 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4863 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004864 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004865 ;}
4866 break;
4867
Devang Patel652203f2008-09-29 20:49:50 +00004868 case 192:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004869#line 1873 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004870 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004871 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004872 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4873 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004874 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4875 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004876 (yyval.ConstVal) = Constant::getNullValue(Ty);
4877 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004878 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004879 ;}
4880 break;
4881
Devang Patel652203f2008-09-29 20:49:50 +00004882 case 193:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004883#line 1883 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004884 { // integral constants
4885 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004886 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004887 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004888 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004889 ;}
4890 break;
4891
Devang Patel652203f2008-09-29 20:49:50 +00004892 case 194:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004893#line 1889 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004894 { // arbitrary precision integer constants
4895 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4896 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004897 GEN_ERROR("Constant value does not fit in type");
4898 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004899 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4900 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4901 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004902 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004903 ;}
4904 break;
4905
Devang Patel652203f2008-09-29 20:49:50 +00004906 case 195:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004907#line 1899 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004908 { // integral constants
4909 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004910 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004911 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004912 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004913 ;}
4914 break;
4915
Devang Patel652203f2008-09-29 20:49:50 +00004916 case 196:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004917#line 1905 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004918 { // arbitrary precision integer constants
4919 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4920 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004921 GEN_ERROR("Constant value does not fit in type");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004922 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004923 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4924 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4925 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004926 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004927 ;}
4928 break;
4929
Devang Patel652203f2008-09-29 20:49:50 +00004930 case 197:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004931#line 1915 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004932 { // Boolean constants
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004933 if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
4934 GEN_ERROR("Constant true must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004935 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004936 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004937 ;}
4938 break;
4939
Devang Patel652203f2008-09-29 20:49:50 +00004940 case 198:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004941#line 1921 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004942 { // Boolean constants
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004943 if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
4944 GEN_ERROR("Constant false must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004945 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004946 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004947 ;}
4948 break;
4949
Devang Patel652203f2008-09-29 20:49:50 +00004950 case 199:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004951#line 1927 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004952 { // Floating point constants
4953 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004954 GEN_ERROR("Floating point constant invalid for type");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004955 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004956 // as double. Fix this here. Long double is done right.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004957 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4958 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004959 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004960 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004961 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004962 ;}
4963 break;
4964
Devang Patel652203f2008-09-29 20:49:50 +00004965 case 200:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004966#line 1940 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004967 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004968 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004969 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4970 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4971 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4972 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004973 GEN_ERROR("invalid cast opcode for cast from '" +
4974 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004975 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004976 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4977 delete (yyvsp[(5) - (6)].TypeVal);
4978 ;}
4979 break;
4980
Devang Patel652203f2008-09-29 20:49:50 +00004981 case 201:
Nuno Lopes8a88a372008-10-05 16:49:34 +00004982#line 1952 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004983 {
4984 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004985 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004986
4987 const Type *IdxTy =
Dan Gohman041e2eb2008-05-15 19:50:34 +00004988 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004989 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004990 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004991
Chris Lattnerf7469af2007-01-31 04:44:08 +00004992 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004993 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4994 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004995 IdxVec.push_back(C);
4996 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004997 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004998
Dan Gohmanf4423b12008-04-19 00:24:39 +00004999 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005000
Dan Gohmanf4423b12008-04-19 00:24:39 +00005001 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00005002 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005003 ;}
5004 break;
5005
Devang Patel652203f2008-09-29 20:49:50 +00005006 case 202:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005007#line 1973 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005008 {
5009 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005010 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005011 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005012 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005013 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005014 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005015 ;}
5016 break;
5017
Devang Patel652203f2008-09-29 20:49:50 +00005018 case 203:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005019#line 1981 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005020 {
5021 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005022 GEN_ERROR("Binary operator types must match");
5023 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005024 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
5025 ;}
5026 break;
5027
Devang Patel652203f2008-09-29 20:49:50 +00005028 case 204:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005029#line 1987 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005030 {
5031 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005032 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005033 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005034 if (!isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00005035 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005036 GEN_ERROR("Logical operator requires integral operands");
5037 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005038 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005039 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005040 ;}
5041 break;
5042
Devang Patel652203f2008-09-29 20:49:50 +00005043 case 205:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005044#line 1998 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005045 {
5046 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005047 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005048 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5049 ;}
5050 break;
5051
Devang Patel652203f2008-09-29 20:49:50 +00005052 case 206:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005053#line 2003 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005054 {
5055 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005056 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005057 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5058 ;}
5059 break;
5060
Devang Patel652203f2008-09-29 20:49:50 +00005061 case 207:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005062#line 2008 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005063 {
5064 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5065 GEN_ERROR("vicmp operand types must match");
5066 (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5067 ;}
5068 break;
5069
Devang Patel652203f2008-09-29 20:49:50 +00005070 case 208:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005071#line 2013 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005072 {
5073 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5074 GEN_ERROR("vfcmp operand types must match");
5075 (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5076 ;}
5077 break;
5078
Devang Patel652203f2008-09-29 20:49:50 +00005079 case 209:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005080#line 2018 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005081 {
5082 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005083 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005084 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005085 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005086 ;}
5087 break;
5088
Devang Patel652203f2008-09-29 20:49:50 +00005089 case 210:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005090#line 2024 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005091 {
5092 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005093 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005094 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005095 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005096 ;}
5097 break;
5098
Devang Patel652203f2008-09-29 20:49:50 +00005099 case 211:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005100#line 2030 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005101 {
5102 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005103 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005104 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005105 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005106 ;}
5107 break;
5108
Devang Patel652203f2008-09-29 20:49:50 +00005109 case 212:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005110#line 2036 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005111 {
5112 if (!isa<StructType>((yyvsp[(3) - (5)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (5)].ConstVal)->getType()))
5113 GEN_ERROR("ExtractValue requires an aggregate operand");
5114
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005115 (yyval.ConstVal) = ConstantExpr::getExtractValue((yyvsp[(3) - (5)].ConstVal), &(*(yyvsp[(4) - (5)].ConstantList))[0], (yyvsp[(4) - (5)].ConstantList)->size());
5116 delete (yyvsp[(4) - (5)].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 213:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005122#line 2044 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005123 {
5124 if (!isa<StructType>((yyvsp[(3) - (7)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (7)].ConstVal)->getType()))
5125 GEN_ERROR("InsertValue requires an aggregate operand");
5126
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005127 (yyval.ConstVal) = ConstantExpr::getInsertValue((yyvsp[(3) - (7)].ConstVal), (yyvsp[(5) - (7)].ConstVal), &(*(yyvsp[(6) - (7)].ConstantList))[0], (yyvsp[(6) - (7)].ConstantList)->size());
5128 delete (yyvsp[(6) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005129 CHECK_FOR_ERROR
5130 ;}
5131 break;
5132
Devang Patel652203f2008-09-29 20:49:50 +00005133 case 214:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005134#line 2055 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005135 {
5136 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005137 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005138 ;}
5139 break;
5140
Devang Patel652203f2008-09-29 20:49:50 +00005141 case 215:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005142#line 2059 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005143 {
5144 (yyval.ConstVector) = new std::vector<Constant*>();
5145 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005146 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005147 ;}
5148 break;
5149
Devang Patel652203f2008-09-29 20:49:50 +00005150 case 216:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005151#line 2067 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005152 { (yyval.BoolVal) = false; ;}
Nate Begemanac80ade2008-05-12 19:01:56 +00005153 break;
5154
Devang Pateld4980812008-09-02 20:52:40 +00005155 case 217:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005156#line 2067 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005157 { (yyval.BoolVal) = true; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005158 break;
5159
Devang Pateld4980812008-09-02 20:52:40 +00005160 case 218:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005161#line 2070 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005162 { (yyval.BoolVal) = true; ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00005163 break;
5164
Dale Johannesendfe8c842008-09-26 19:32:34 +00005165 case 219:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005166#line 2070 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005167 { (yyval.BoolVal) = false; ;}
5168 break;
5169
5170 case 220:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005171#line 2073 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005172 {
5173 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
5174 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00005175 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005176 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
5177 if (!Aliasee)
5178 GEN_ERROR("Aliases can be created only to global values");
5179
Dan Gohmanf4423b12008-04-19 00:24:39 +00005180 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005181 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005182 delete (yyvsp[(1) - (2)].TypeVal);
5183 ;}
5184 break;
5185
Devang Patel652203f2008-09-29 20:49:50 +00005186 case 221:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005187#line 2085 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005188 {
5189 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
5190 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
5191 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005192 GEN_ERROR("invalid cast opcode for cast from '" +
5193 Val->getType()->getDescription() + "' to '" +
5194 DestTy->getDescription() + "'");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005195
Dan Gohmanf4423b12008-04-19 00:24:39 +00005196 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005197 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005198 delete (yyvsp[(5) - (6)].TypeVal);
5199 ;}
5200 break;
5201
Devang Pateld4980812008-09-02 20:52:40 +00005202 case 222:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005203#line 2106 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005204 {
5205 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5206 CurModule.ModuleDone();
5207 CHECK_FOR_ERROR;
5208 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005209 break;
5210
Devang Patel652203f2008-09-29 20:49:50 +00005211 case 223:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005212#line 2111 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005213 {
5214 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5215 CurModule.ModuleDone();
5216 CHECK_FOR_ERROR;
5217 ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00005218 break;
5219
Dale Johannesendfe8c842008-09-26 19:32:34 +00005220 case 226:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005221#line 2124 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005222 { CurFun.isDeclare = false; ;}
5223 break;
5224
5225 case 227:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005226#line 2124 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005227 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005228 CurFun.FunctionDone();
5229 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005230 ;}
5231 break;
5232
Devang Patel652203f2008-09-29 20:49:50 +00005233 case 228:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005234#line 2128 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005235 { CurFun.isDeclare = true; ;}
5236 break;
5237
Devang Pateld4980812008-09-02 20:52:40 +00005238 case 229:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005239#line 2128 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005240 {
5241 CHECK_FOR_ERROR
5242 ;}
5243 break;
5244
Devang Pateld4980812008-09-02 20:52:40 +00005245 case 230:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005246#line 2131 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005247 {
5248 CHECK_FOR_ERROR
5249 ;}
5250 break;
5251
5252 case 231:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005253#line 2134 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005254 {
Reid Spencer14310612006-12-31 05:40:51 +00005255 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005256 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005257 // Eagerly resolve types. This is not an optimization, this is a
5258 // requirement that is due to the fact that we could have this:
5259 //
5260 // %list = type { %list * }
5261 // %list = type { %list * } ; repeated type decl
5262 //
5263 // If types are not resolved eagerly, then the two types will not be
5264 // determined to be the same type!
5265 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00005266 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005267
Dan Gohmanf4423b12008-04-19 00:24:39 +00005268 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00005269 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005270 // If this is a named type that is not a redefinition, add it to the slot
5271 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005272 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005273 }
Reid Spencera132e042006-12-03 05:46:11 +00005274
Dan Gohmanf4423b12008-04-19 00:24:39 +00005275 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005276 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005277 ;}
5278 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00005279
Devang Patel652203f2008-09-29 20:49:50 +00005280 case 232:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005281#line 2158 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005282 {
5283 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
5284
5285 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005286 CHECK_FOR_ERROR
5287 // If this is a named type that is not a redefinition, add it to the slot
5288 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005289 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005290 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005291 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005292 ;}
5293 break;
5294
Devang Patel652203f2008-09-29 20:49:50 +00005295 case 233:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005296#line 2170 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005297 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005298 /* "Externally Visible" Linkage */
Eric Christopher2a5196f2008-09-24 04:55:49 +00005299 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005300 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005301 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5302 (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 +00005303 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005304 ;}
5305 break;
5306
Devang Patel652203f2008-09-29 20:49:50 +00005307 case 234:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005308#line 2177 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005309 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005310 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005311 ;}
5312 break;
5313
Devang Patel652203f2008-09-29 20:49:50 +00005314 case 235:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005315#line 2181 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005316 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005317 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005318 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005319 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 +00005320 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005321 ;}
5322 break;
5323
Devang Patel652203f2008-09-29 20:49:50 +00005324 case 236:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005325#line 2186 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005326 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005327 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005328 ;}
5329 break;
5330
Devang Patel652203f2008-09-29 20:49:50 +00005331 case 237:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005332#line 2190 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005333 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005334 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005335 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5336 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 +00005337 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005338 delete (yyvsp[(6) - (7)].TypeVal);
5339 ;}
5340 break;
5341
Devang Patel652203f2008-09-29 20:49:50 +00005342 case 238:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005343#line 2196 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005344 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005345 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005346 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005347 ;}
5348 break;
5349
Devang Patel652203f2008-09-29 20:49:50 +00005350 case 239:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005351#line 2200 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005352 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005353 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005354 if ((yyvsp[(1) - (5)].StrVal)) {
5355 Name = *(yyvsp[(1) - (5)].StrVal);
5356 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005357 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005358 if (Name.empty())
5359 GEN_ERROR("Alias name cannot be empty");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005360
Dan Gohmanf4423b12008-04-19 00:24:39 +00005361 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005362 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005363 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005364
Dan Gohmanf4423b12008-04-19 00:24:39 +00005365 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005366 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005367 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005368 InsertValue(GA, CurModule.Values);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005369
5370
Chris Lattner569f7372007-09-10 23:24:14 +00005371 // If there was a forward reference of this alias, resolve it now.
Eric Christopher2a5196f2008-09-24 04:55:49 +00005372
Chris Lattner569f7372007-09-10 23:24:14 +00005373 ValID ID;
5374 if (!Name.empty())
5375 ID = ValID::createGlobalName(Name);
5376 else
5377 ID = ValID::createGlobalID(CurModule.Values.size()-1);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005378
Chris Lattner569f7372007-09-10 23:24:14 +00005379 if (GlobalValue *FWGV =
5380 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5381 // Replace uses of the fwdref with the actual alias.
5382 FWGV->replaceAllUsesWith(GA);
5383 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5384 GV->eraseFromParent();
5385 else
5386 cast<Function>(FWGV)->eraseFromParent();
5387 }
5388 ID.destroy();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005389
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005390 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005391 ;}
5392 break;
5393
Chris Lattnerccef6b52008-09-23 21:18:31 +00005394 case 240:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005395#line 2240 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005396 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005397 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005398 ;}
5399 break;
5400
Chris Lattnerccef6b52008-09-23 21:18:31 +00005401 case 241:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005402#line 2243 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005403 {
5404 CHECK_FOR_ERROR
5405 ;}
5406 break;
5407
5408 case 242:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005409#line 2249 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005410 {
Chris Lattner66316012006-01-24 04:14:29 +00005411 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005412 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005413 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005414 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005415 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5416 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005417 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005418;}
5419 break;
5420
Devang Patel652203f2008-09-29 20:49:50 +00005421 case 243:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005422#line 2259 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005423 {
5424 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5425 delete (yyvsp[(3) - (3)].StrVal);
5426 ;}
5427 break;
5428
Devang Patel652203f2008-09-29 20:49:50 +00005429 case 244:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005430#line 2263 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005431 {
5432 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5433 delete (yyvsp[(3) - (3)].StrVal);
5434 ;}
5435 break;
5436
Devang Patel652203f2008-09-29 20:49:50 +00005437 case 246:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005438#line 2270 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005439 {
5440 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5441 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005442 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005443 ;}
5444 break;
5445
Devang Patel652203f2008-09-29 20:49:50 +00005446 case 247:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005447#line 2275 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005448 {
5449 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5450 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005451 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005452 ;}
5453 break;
5454
Devang Patel652203f2008-09-29 20:49:50 +00005455 case 248:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005456#line 2280 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005457 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005458 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005459 ;}
5460 break;
5461
Devang Patel652203f2008-09-29 20:49:50 +00005462 case 249:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005463#line 2289 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005464 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005465 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005466 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005467 if (!(*(yyvsp[(3) - (5)].TypeVal))->isFirstClassType())
5468 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005469 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 +00005470 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5471 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005472 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005473 ;}
5474 break;
5475
Devang Patel652203f2008-09-29 20:49:50 +00005476 case 250:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005477#line 2299 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005478 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005479 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005480 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005481 if (!(*(yyvsp[(1) - (3)].TypeVal))->isFirstClassType())
5482 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005483 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 +00005484 (yyval.ArgList) = new ArgListType;
5485 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005486 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005487 ;}
5488 break;
5489
Devang Patel652203f2008-09-29 20:49:50 +00005490 case 251:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005491#line 2310 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005492 {
5493 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005494 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005495 ;}
5496 break;
5497
Devang Patel652203f2008-09-29 20:49:50 +00005498 case 252:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005499#line 2314 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005500 {
5501 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005502 struct ArgListEntry E;
5503 E.Ty = new PATypeHolder(Type::VoidTy);
5504 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005505 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005506 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005507 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005508 ;}
5509 break;
5510
Devang Patel652203f2008-09-29 20:49:50 +00005511 case 253:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005512#line 2323 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005513 {
5514 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005515 struct ArgListEntry E;
5516 E.Ty = new PATypeHolder(Type::VoidTy);
5517 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005518 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005519 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005520 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005521 ;}
5522 break;
5523
Devang Patel652203f2008-09-29 20:49:50 +00005524 case 254:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005525#line 2332 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005526 {
5527 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005528 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005529 ;}
5530 break;
5531
Devang Patel652203f2008-09-29 20:49:50 +00005532 case 255:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005533#line 2338 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005534 {
Devang Patel652203f2008-09-29 20:49:50 +00005535 std::string FunctionName(*(yyvsp[(4) - (11)].StrVal));
5536 delete (yyvsp[(4) - (11)].StrVal); // Free strdup'd memory!
Eric Christopher2a5196f2008-09-24 04:55:49 +00005537
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005538 // Check the function result for abstractness if this is a define. We should
5539 // have no abstract types at this point
Devang Patel652203f2008-09-29 20:49:50 +00005540 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(3) - (11)].TypeVal)))
5541 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(3) - (11)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005542
Devang Patel652203f2008-09-29 20:49:50 +00005543 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (11)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00005544 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005545
Reid Spencer68a24bd2005-08-27 18:50:39 +00005546 std::vector<const Type*> ParamTypeList;
Devang Patel05988662008-09-25 21:00:45 +00005547 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00005548 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
5549 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00005550 Attributes RetAttrs = (yyvsp[(2) - (11)].Attributes);
5551 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None) {
5552 if ((yyvsp[(8) - (11)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005553 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00005554 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005555 }
Devang Patel652203f2008-09-29 20:49:50 +00005556 if ((yyvsp[(8) - (11)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005557 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00005558 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005559 }
Devang Patel652203f2008-09-29 20:49:50 +00005560 if ((yyvsp[(8) - (11)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00005561 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00005562 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00005563 }
Dale Johannesene7261862008-09-26 23:46:20 +00005564 }
Devang Patel652203f2008-09-29 20:49:50 +00005565 if (RetAttrs != Attribute::None)
5566 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
5567 if ((yyvsp[(6) - (11)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005568 unsigned index = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005569 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin(); I != (yyvsp[(6) - (11)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005570 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005571 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5572 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005573 ParamTypeList.push_back(Ty);
Devang Patel05988662008-09-25 21:00:45 +00005574 if (Ty != Type::VoidTy && I->Attrs != Attribute::None)
5575 Attrs.push_back(AttributeWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005576 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005577 }
Devang Patel652203f2008-09-29 20:49:50 +00005578 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None)
5579 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(8) - (11)].Attributes)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005580
5581 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5582 if (isVarArg) ParamTypeList.pop_back();
5583
Devang Patel05988662008-09-25 21:00:45 +00005584 AttrListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005585 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00005586 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005587
Devang Patel652203f2008-09-29 20:49:50 +00005588 FunctionType *FT = FunctionType::get(*(yyvsp[(3) - (11)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005589 const PointerType *PFT = PointerType::getUnqual(FT);
Devang Patel652203f2008-09-29 20:49:50 +00005590 delete (yyvsp[(3) - (11)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005591
5592 ValID ID;
5593 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005594 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005595 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005596 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005597 }
5598
5599 Function *Fn = 0;
5600 // See if this function was forward referenced. If so, recycle the object.
5601 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005602 // Move the function to the end of the list, from whereever it was
Reid Spencer68a24bd2005-08-27 18:50:39 +00005603 // previously inserted.
5604 Fn = cast<Function>(FWRef);
Devang Patel05988662008-09-25 21:00:45 +00005605 assert(Fn->getAttributes().isEmpty() &&
Chris Lattner58d74912008-03-12 17:45:29 +00005606 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005607 CurModule.CurrentModule->getFunctionList().remove(Fn);
5608 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5609 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005610 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005611 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005612 // The existing function doesn't have the same type. This is an overload
5613 // error.
5614 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Devang Patel05988662008-09-25 21:00:45 +00005615 } else if (Fn->getAttributes() != PAL) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005616 // The existing function doesn't have the same parameter attributes.
5617 // This is an overload error.
5618 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005619 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005620 // Neither the existing or the current function is a declaration and they
5621 // have the same name and same type. Clearly this is a redefinition.
5622 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005623 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005624 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005625 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5626 AI != AE; ++AI)
5627 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005628 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005629 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005630 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5631 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005632 InsertValue(Fn, CurModule.Values);
5633 }
5634
Nuno Lopes9e9631d2008-10-03 15:45:58 +00005635 ID.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005636 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005637
5638 if (CurFun.isDeclare) {
5639 // If we have declaration, always overwrite linkage. This will allow us to
5640 // correctly handle cases, when pointer to function is passed as argument to
5641 // another function.
5642 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005643 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005644 }
Devang Pateld4980812008-09-02 20:52:40 +00005645 Fn->setCallingConv((yyvsp[(1) - (11)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00005646 Fn->setAttributes(PAL);
Devang Patel652203f2008-09-29 20:49:50 +00005647 Fn->setAlignment((yyvsp[(10) - (11)].UIntVal));
5648 if ((yyvsp[(9) - (11)].StrVal)) {
5649 Fn->setSection(*(yyvsp[(9) - (11)].StrVal));
5650 delete (yyvsp[(9) - (11)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005651 }
Devang Patel652203f2008-09-29 20:49:50 +00005652 if ((yyvsp[(11) - (11)].StrVal)) {
5653 Fn->setGC((yyvsp[(11) - (11)].StrVal)->c_str());
5654 delete (yyvsp[(11) - (11)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005655 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005656
5657 // Add all of the arguments we parsed to the function...
Devang Patel652203f2008-09-29 20:49:50 +00005658 if ((yyvsp[(6) - (11)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005659 if (isVarArg) { // Nuke the last entry
Devang Patel652203f2008-09-29 20:49:50 +00005660 assert((yyvsp[(6) - (11)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(6) - (11)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005661 "Not a varargs marker!");
Devang Patel652203f2008-09-29 20:49:50 +00005662 delete (yyvsp[(6) - (11)].ArgList)->back().Ty;
5663 (yyvsp[(6) - (11)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005664 }
5665 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005666 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005667 unsigned Idx = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005668 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin();
5669 I != (yyvsp[(6) - (11)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005670 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005671 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005672 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005673 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005674 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005675 }
Reid Spencera132e042006-12-03 05:46:11 +00005676
Devang Patel652203f2008-09-29 20:49:50 +00005677 delete (yyvsp[(6) - (11)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005678 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005679 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005680;}
5681 break;
5682
Devang Patel652203f2008-09-29 20:49:50 +00005683 case 258:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005684#line 2488 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005685 {
5686 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005687
5688 // Make sure that we keep track of the linkage type even if there was a
5689 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005690 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5691 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5692;}
5693 break;
5694
Devang Patel652203f2008-09-29 20:49:50 +00005695 case 261:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005696#line 2499 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005697 {
5698 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005699 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005700;}
5701 break;
5702
Devang Patel652203f2008-09-29 20:49:50 +00005703 case 262:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005704#line 2504 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005705 {
5706 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5707 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5708 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005709 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005710 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005711 ;}
5712 break;
5713
Devang Patel652203f2008-09-29 20:49:50 +00005714 case 263:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005715#line 2516 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005716 {
5717 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005718 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005719 ;}
5720 break;
5721
Devang Patel652203f2008-09-29 20:49:50 +00005722 case 264:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005723#line 2520 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005724 {
5725 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005726 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005727 ;}
5728 break;
5729
Devang Patel652203f2008-09-29 20:49:50 +00005730 case 265:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005731#line 2525 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005732 { // A reference to a direct constant
5733 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005734 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005735 ;}
5736 break;
5737
Devang Patel652203f2008-09-29 20:49:50 +00005738 case 266:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005739#line 2529 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005740 {
5741 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005742 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005743 ;}
5744 break;
5745
Devang Patel652203f2008-09-29 20:49:50 +00005746 case 267:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005747#line 2533 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005748 { // arbitrary precision integer constants
5749 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), true);
5750 delete (yyvsp[(1) - (1)].APIntVal);
5751 CHECK_FOR_ERROR
5752 ;}
5753 break;
5754
Devang Patel652203f2008-09-29 20:49:50 +00005755 case 268:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005756#line 2538 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005757 { // arbitrary precision integer constants
5758 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), false);
5759 delete (yyvsp[(1) - (1)].APIntVal);
5760 CHECK_FOR_ERROR
5761 ;}
5762 break;
5763
Devang Patel652203f2008-09-29 20:49:50 +00005764 case 269:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005765#line 2543 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005766 { // Perhaps it's an FP constant?
5767 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005768 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005769 ;}
5770 break;
5771
Devang Patel652203f2008-09-29 20:49:50 +00005772 case 270:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005773#line 2547 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005774 {
5775 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005776 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005777 ;}
5778 break;
5779
Devang Patel652203f2008-09-29 20:49:50 +00005780 case 271:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005781#line 2551 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005782 {
5783 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005784 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005785 ;}
5786 break;
5787
Devang Patel652203f2008-09-29 20:49:50 +00005788 case 272:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005789#line 2555 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005790 {
5791 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005792 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005793 ;}
5794 break;
5795
Devang Patel652203f2008-09-29 20:49:50 +00005796 case 273:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005797#line 2559 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005798 {
5799 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005800 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005801 ;}
5802 break;
5803
Devang Patel652203f2008-09-29 20:49:50 +00005804 case 274:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005805#line 2563 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005806 { // A vector zero constant.
5807 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005808 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005809 ;}
5810 break;
5811
Devang Patel652203f2008-09-29 20:49:50 +00005812 case 275:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005813#line 2567 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005814 { // Nonempty unsized packed vector
5815 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005816 unsigned NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005817
5818 if (!ETy->isInteger() && !ETy->isFloatingPoint())
5819 GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005820
Reid Spencer9d6565a2007-02-15 02:26:10 +00005821 VectorType* pt = VectorType::get(ETy, NumElements);
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005822 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
Eric Christopher2a5196f2008-09-24 04:55:49 +00005823
Reid Spencer68a24bd2005-08-27 18:50:39 +00005824 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005825 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5826 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005827 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005828 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005829 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005830 }
5831
Dan Gohmanf4423b12008-04-19 00:24:39 +00005832 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5833 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005834 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005835 ;}
5836 break;
5837
Devang Patel652203f2008-09-29 20:49:50 +00005838 case 276:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005839#line 2589 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005840 { // Nonempty unsized arr
5841 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005842 uint64_t NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005843
5844 if (!ETy->isFirstClassType())
5845 GEN_ERROR("Invalid array element type: " + ETy->getDescription());
5846
5847 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5848 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
5849
5850 // Verify all elements are correct type!
5851 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5852 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005853 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005854 ETy->getDescription() +"' as required!\nIt is of type '"+
5855 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
5856 }
5857
5858 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, *(yyvsp[(2) - (3)].ConstVector)));
5859 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5860 CHECK_FOR_ERROR
5861 ;}
5862 break;
5863
Devang Patel652203f2008-09-29 20:49:50 +00005864 case 277:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005865#line 2611 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005866 {
Dan Gohman180c1692008-06-23 18:43:26 +00005867 // Use undef instead of an array because it's inconvenient to determine
5868 // the element type at this point, there being no elements to examine.
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005869 (yyval.ValIDVal) = ValID::createUndef();
5870 CHECK_FOR_ERROR
5871 ;}
5872 break;
5873
Devang Patel652203f2008-09-29 20:49:50 +00005874 case 278:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005875#line 2617 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005876 {
Dan Gohman180c1692008-06-23 18:43:26 +00005877 uint64_t NumElements = (yyvsp[(2) - (2)].StrVal)->length();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005878 const Type *ETy = Type::Int8Ty;
5879
5880 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5881
5882 std::vector<Constant*> Vals;
5883 for (unsigned i = 0; i < (yyvsp[(2) - (2)].StrVal)->length(); ++i)
5884 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(2) - (2)].StrVal))[i]));
5885 delete (yyvsp[(2) - (2)].StrVal);
5886 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, Vals));
5887 CHECK_FOR_ERROR
5888 ;}
5889 break;
5890
Devang Patel652203f2008-09-29 20:49:50 +00005891 case 279:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005892#line 2630 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005893 {
5894 std::vector<const Type*> Elements((yyvsp[(2) - (3)].ConstVector)->size());
5895 for (unsigned i = 0, e = (yyvsp[(2) - (3)].ConstVector)->size(); i != e; ++i)
5896 Elements[i] = (*(yyvsp[(2) - (3)].ConstVector))[i]->getType();
5897
5898 const StructType *STy = StructType::get(Elements);
5899 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5900
5901 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(2) - (3)].ConstVector)));
5902 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5903 CHECK_FOR_ERROR
5904 ;}
5905 break;
5906
Devang Patel652203f2008-09-29 20:49:50 +00005907 case 280:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005908#line 2642 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005909 {
5910 const StructType *STy = StructType::get(std::vector<const Type*>());
5911 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5912 CHECK_FOR_ERROR
5913 ;}
5914 break;
5915
Devang Patel652203f2008-09-29 20:49:50 +00005916 case 281:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005917#line 2647 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005918 {
5919 std::vector<const Type*> Elements((yyvsp[(3) - (5)].ConstVector)->size());
5920 for (unsigned i = 0, e = (yyvsp[(3) - (5)].ConstVector)->size(); i != e; ++i)
5921 Elements[i] = (*(yyvsp[(3) - (5)].ConstVector))[i]->getType();
5922
5923 const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
5924 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5925
5926 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(3) - (5)].ConstVector)));
5927 delete PTy; delete (yyvsp[(3) - (5)].ConstVector);
5928 CHECK_FOR_ERROR
5929 ;}
5930 break;
5931
Devang Patel652203f2008-09-29 20:49:50 +00005932 case 282:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005933#line 2659 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005934 {
5935 const StructType *STy = StructType::get(std::vector<const Type*>(),
5936 /*isPacked=*/true);
5937 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5938 CHECK_FOR_ERROR
5939 ;}
5940 break;
5941
Devang Patel652203f2008-09-29 20:49:50 +00005942 case 283:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005943#line 2665 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005944 {
5945 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005946 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005947 ;}
5948 break;
5949
Devang Patel652203f2008-09-29 20:49:50 +00005950 case 284:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005951#line 2669 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005952 {
5953 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5954 delete (yyvsp[(3) - (5)].StrVal);
5955 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005956 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005957 ;}
5958 break;
5959
Devang Patel652203f2008-09-29 20:49:50 +00005960 case 285:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005961#line 2679 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005962 { // Is it an integer reference...?
5963 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005964 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005965 ;}
5966 break;
5967
Devang Patel652203f2008-09-29 20:49:50 +00005968 case 286:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005969#line 2683 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005970 {
5971 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005972 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005973 ;}
5974 break;
5975
Devang Patel652203f2008-09-29 20:49:50 +00005976 case 287:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005977#line 2687 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005978 { // Is it a named reference...?
5979 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5980 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005981 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005982 ;}
5983 break;
5984
Devang Patel652203f2008-09-29 20:49:50 +00005985 case 288:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005986#line 2692 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005987 { // Is it a named reference...?
5988 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5989 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005990 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005991 ;}
5992 break;
5993
Devang Patel652203f2008-09-29 20:49:50 +00005994 case 291:
Nuno Lopes8a88a372008-10-05 16:49:34 +00005995#line 2705 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005996 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005997 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005998 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005999 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006000 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00006001 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006002 ;}
6003 break;
6004
Devang Patel652203f2008-09-29 20:49:50 +00006005 case 292:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006006#line 2714 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006007 {
6008 (yyval.ValueList) = new std::vector<Value *>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00006009 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00006010 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006011 ;}
6012 break;
6013
Devang Patel652203f2008-09-29 20:49:50 +00006014 case 293:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006015#line 2719 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006016 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006017 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00006018 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006019 ;}
6020 break;
6021
Devang Patel652203f2008-09-29 20:49:50 +00006022 case 294:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006023#line 2724 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006024 {
6025 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006026 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006027 ;}
6028 break;
6029
Devang Patel652203f2008-09-29 20:49:50 +00006030 case 295:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006031#line 2728 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006032 { // Do not allow functions with 0 basic blocks
Dan Gohmanf4423b12008-04-19 00:24:39 +00006033 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006034 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006035 ;}
6036 break;
6037
Devang Patel652203f2008-09-29 20:49:50 +00006038 case 296:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006039#line 2737 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006040 {
6041 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006042 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006043 InsertValue((yyvsp[(3) - (3)].TermInstVal));
6044 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6045 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006046 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006047 ;}
6048 break;
6049
Devang Patel652203f2008-09-29 20:49:50 +00006050 case 297:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006051#line 2746 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006052 {
6053 CHECK_FOR_ERROR
6054 int ValNum = InsertValue((yyvsp[(3) - (3)].TermInstVal));
6055 if (ValNum != (int)(yyvsp[(2) - (3)].UIntVal))
6056 GEN_ERROR("Result value number %" + utostr((yyvsp[(2) - (3)].UIntVal)) +
6057 " is incorrect, expected %" + utostr((unsigned)ValNum));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006058
Chris Lattner15bd0952008-08-29 17:20:18 +00006059 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6060 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
6061 CHECK_FOR_ERROR
6062;}
6063 break;
6064
Devang Patel652203f2008-09-29 20:49:50 +00006065 case 298:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006066#line 2759 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006067 {
6068 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006069 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
6070 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00006071 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
6072 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
6073 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006074 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006075 ;}
6076 break;
Chris Lattner38905612008-02-19 04:36:25 +00006077
Devang Patel652203f2008-09-29 20:49:50 +00006078 case 299:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006079#line 2768 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006080 { // Empty space between instruction lists
Chris Lattnercc81d152008-05-04 17:18:47 +00006081 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006082 CHECK_FOR_ERROR
6083 ;}
6084 break;
6085
Devang Patel652203f2008-09-29 20:49:50 +00006086 case 300:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006087#line 2772 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnercc81d152008-05-04 17:18:47 +00006088 { // Labelled (named) basic block
6089 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
6090 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006091 CHECK_FOR_ERROR
Chris Lattnercc81d152008-05-04 17:18:47 +00006092
Dan Gohmanf4423b12008-04-19 00:24:39 +00006093 ;}
6094 break;
6095
Devang Patel652203f2008-09-29 20:49:50 +00006096 case 301:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006097#line 2780 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006098 { // Return with a result...
6099 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
6100 assert(!VL.empty() && "Invalid ret operands!");
Dan Gohman1a570242008-07-23 00:54:54 +00006101 const Type *ReturnType = CurFun.CurrentFunction->getReturnType();
6102 if (VL.size() > 1 ||
6103 (isa<StructType>(ReturnType) &&
6104 (VL.empty() || VL[0]->getType() != ReturnType))) {
6105 Value *RV = UndefValue::get(ReturnType);
6106 for (unsigned i = 0, e = VL.size(); i != e; ++i) {
6107 Instruction *I = InsertValueInst::Create(RV, VL[i], i, "mrv");
6108 ((yyvsp[(-1) - (2)].BasicBlockVal))->getInstList().push_back(I);
6109 RV = I;
6110 }
6111 (yyval.TermInstVal) = ReturnInst::Create(RV);
6112 } else {
6113 (yyval.TermInstVal) = ReturnInst::Create(VL[0]);
6114 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006115 delete (yyvsp[(2) - (2)].ValueList);
6116 CHECK_FOR_ERROR
6117 ;}
6118 break;
6119
Devang Patel652203f2008-09-29 20:49:50 +00006120 case 302:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006121#line 2800 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006122 { // Return with no result...
6123 (yyval.TermInstVal) = ReturnInst::Create();
6124 CHECK_FOR_ERROR
6125 ;}
6126 break;
6127
Devang Patel652203f2008-09-29 20:49:50 +00006128 case 303:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006129#line 2804 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006130 { // Unconditional Branch...
6131 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6132 CHECK_FOR_ERROR
6133 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
6134 ;}
6135 break;
6136
Devang Patel652203f2008-09-29 20:49:50 +00006137 case 304:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006138#line 2809 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006139 {
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006140 if (cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() != 1)
6141 GEN_ERROR("Branch condition must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006142 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6143 CHECK_FOR_ERROR
6144 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6145 CHECK_FOR_ERROR
6146 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6147 CHECK_FOR_ERROR
6148 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
6149 ;}
6150 break;
6151
Devang Patel652203f2008-09-29 20:49:50 +00006152 case 305:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006153#line 2820 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006154 {
6155 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
6156 CHECK_FOR_ERROR
6157 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6158 CHECK_FOR_ERROR
6159 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6160 (yyval.TermInstVal) = S;
6161
6162 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6163 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00006164 for (; I != E; ++I) {
6165 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6166 S->addCase(CI, I->second);
6167 else
Reid Spencerb5334b02007-02-05 10:18:06 +00006168 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006169 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006170 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00006171 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006172 ;}
6173 break;
6174
Devang Patel652203f2008-09-29 20:49:50 +00006175 case 306:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006176#line 2839 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006177 {
6178 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006179 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006180 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006181 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00006182 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006183 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006184 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006185 ;}
6186 break;
6187
Devang Patel652203f2008-09-29 20:49:50 +00006188 case 307:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006189#line 2849 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006190 {
Reid Spencer3822ff52006-11-08 06:47:33 +00006191
Reid Spencer14310612006-12-31 05:40:51 +00006192 // Handle the short syntax
6193 const PointerType *PFTy = 0;
6194 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006195 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (15)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00006196 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6197 // Pull out the types of all of the arguments...
6198 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006199 ParamList::iterator I = (yyvsp[(7) - (15)].ParamList)->begin(), E = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006200 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006201 const Type *Ty = I->Val->getType();
6202 if (Ty == Type::VoidTy)
6203 GEN_ERROR("Short call syntax cannot be used with varargs");
6204 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006205 }
Eric Christopher2a5196f2008-09-24 04:55:49 +00006206
Devang Patel652203f2008-09-29 20:49:50 +00006207 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (15)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006208 GEN_ERROR("Invalid result type for LLVM function");
6209
Devang Patel652203f2008-09-29 20:49:50 +00006210 Ty = FunctionType::get((yyvsp[(4) - (15)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006211 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006212 }
6213
Devang Patel652203f2008-09-29 20:49:50 +00006214 delete (yyvsp[(4) - (15)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00006215
Devang Patel652203f2008-09-29 20:49:50 +00006216 Value *V = getVal(PFTy, (yyvsp[(5) - (15)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006217 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006218 BasicBlock *Normal = getBBVal((yyvsp[(12) - (15)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006219 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006220 BasicBlock *Except = getBBVal((yyvsp[(15) - (15)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00006221 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00006222
Devang Patel05988662008-09-25 21:00:45 +00006223 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006224 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6225 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006226 Attributes RetAttrs = (yyvsp[(3) - (15)].Attributes);
6227 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None) {
6228 if ((yyvsp[(9) - (15)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006229 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006230 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006231 }
Devang Patel652203f2008-09-29 20:49:50 +00006232 if ((yyvsp[(9) - (15)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006233 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006234 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006235 }
Devang Patel652203f2008-09-29 20:49:50 +00006236 if ((yyvsp[(9) - (15)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006237 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006238 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006239 }
Dale Johannesene7261862008-09-26 23:46:20 +00006240 }
Devang Patel652203f2008-09-29 20:49:50 +00006241 if (RetAttrs != Attribute::None)
6242 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006243
Reid Spencer14310612006-12-31 05:40:51 +00006244 // Check the arguments
6245 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006246 if ((yyvsp[(7) - (15)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00006247 // Make sure no arguments is a good thing!
6248 if (Ty->getNumParams() != 0)
6249 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006250 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006251 } else { // Has arguments?
6252 // Loop through FunctionType's arguments and ensure they are specified
6253 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00006254 FunctionType::param_iterator I = Ty->param_begin();
6255 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006256 ParamList::iterator ArgI = (yyvsp[(7) - (15)].ParamList)->begin(), ArgE = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006257 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006258
Duncan Sandsdc024672007-11-27 13:23:08 +00006259 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006260 if (ArgI->Val->getType() != *I)
6261 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006262 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006263 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006264 if (ArgI->Attrs != Attribute::None)
6265 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006266 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00006267
Reid Spencer14310612006-12-31 05:40:51 +00006268 if (Ty->isVarArg()) {
6269 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006270 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006271 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006272 if (ArgI->Attrs != Attribute::None)
6273 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006274 }
Reid Spencer14310612006-12-31 05:40:51 +00006275 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006276 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006277 }
Devang Patel652203f2008-09-29 20:49:50 +00006278 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None)
6279 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (15)].Attributes)));
Devang Patel05988662008-09-25 21:00:45 +00006280 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006281 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006282 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006283
Reid Spencer14310612006-12-31 05:40:51 +00006284 // Create the InvokeInst
Dan Gohman041e2eb2008-05-15 19:50:34 +00006285 InvokeInst *II = InvokeInst::Create(V, Normal, Except,
6286 Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006287 II->setCallingConv((yyvsp[(2) - (15)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006288 II->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006289 (yyval.TermInstVal) = II;
Devang Patel652203f2008-09-29 20:49:50 +00006290 delete (yyvsp[(7) - (15)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006291 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006292 ;}
6293 break;
6294
Devang Patel652203f2008-09-29 20:49:50 +00006295 case 308:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006296#line 2952 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006297 {
6298 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006299 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006300 ;}
6301 break;
6302
Devang Patel652203f2008-09-29 20:49:50 +00006303 case 309:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006304#line 2956 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006305 {
6306 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006307 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006308 ;}
6309 break;
6310
Devang Patel652203f2008-09-29 20:49:50 +00006311 case 310:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006312#line 2963 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006313 {
6314 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6315 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006316 CHECK_FOR_ERROR
6317 if (V == 0)
6318 GEN_ERROR("May only switch on a constant pool value");
6319
Dan Gohmanf4423b12008-04-19 00:24:39 +00006320 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006321 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006322 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6323 ;}
6324 break;
6325
Devang Patel652203f2008-09-29 20:49:50 +00006326 case 311:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006327#line 2974 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006328 {
6329 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6330 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006331 CHECK_FOR_ERROR
6332
6333 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00006334 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006335
Dan Gohmanf4423b12008-04-19 00:24:39 +00006336 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006337 CHECK_FOR_ERROR
Eric Christopher2a5196f2008-09-24 04:55:49 +00006338 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006339 ;}
6340 break;
6341
Devang Patel652203f2008-09-29 20:49:50 +00006342 case 312:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006343#line 2987 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006344 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006345 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00006346 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006347 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006348 InsertValue((yyvsp[(2) - (2)].InstVal));
6349 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006350 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006351 ;}
6352 break;
6353
Devang Patel652203f2008-09-29 20:49:50 +00006354 case 313:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006355#line 2996 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006356 {
6357 CHECK_FOR_ERROR
6358 int ValNum = InsertValue((yyvsp[(2) - (2)].InstVal));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006359
Chris Lattner15bd0952008-08-29 17:20:18 +00006360 if (ValNum != (int)(yyvsp[(1) - (2)].UIntVal))
6361 GEN_ERROR("Result value number %" + utostr((yyvsp[(1) - (2)].UIntVal)) +
6362 " is incorrect, expected %" + utostr((unsigned)ValNum));
6363
6364 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6365 CHECK_FOR_ERROR
6366 ;}
6367 break;
6368
Devang Patel652203f2008-09-29 20:49:50 +00006369 case 314:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006370#line 3009 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006371 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006372 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006373 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
6374 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
6375 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00006376 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006377 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006378 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006379 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6380 delete (yyvsp[(1) - (6)].TypeVal);
6381 ;}
6382 break;
6383
Devang Patel652203f2008-09-29 20:49:50 +00006384 case 315:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006385#line 3020 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006386 {
6387 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6388 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006389 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006390 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006391 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006392 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6393 ;}
6394 break;
6395
Devang Patel652203f2008-09-29 20:49:50 +00006396 case 316:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006397#line 3030 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006398 {
Devang Patel05988662008-09-25 21:00:45 +00006399 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006400 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006401 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006402 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00006403 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006404 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 +00006405 (yyval.ParamList)->push_back(E);
6406 delete (yyvsp[(1) - (4)].TypeVal);
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 317:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006412#line 3041 "/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
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006415 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00006416 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006417 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 +00006418 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00006419 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006420 ;}
6421 break;
6422
Devang Patel652203f2008-09-29 20:49:50 +00006423 case 318:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006424#line 3049 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006425 {
Devang Patel05988662008-09-25 21:00:45 +00006426 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006427 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006428 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6429 (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 = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006431 (yyval.ParamList)->push_back(E);
6432 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006433 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006434 ;}
6435 break;
6436
Devang Patel652203f2008-09-29 20:49:50 +00006437 case 319:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006438#line 3059 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006439 {
Devang Patel05988662008-09-25 21:00:45 +00006440 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00006441 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006442 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 +00006443 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006444 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006445 ;}
6446 break;
6447
Devang Patel652203f2008-09-29 20:49:50 +00006448 case 320:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006449#line 3066 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006450 { (yyval.ParamList) = new ParamList(); ;}
6451 break;
6452
Devang Patel652203f2008-09-29 20:49:50 +00006453 case 321:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006454#line 3069 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006455 { (yyval.ValueList) = new std::vector<Value*>(); ;}
6456 break;
6457
Devang Patel652203f2008-09-29 20:49:50 +00006458 case 322:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006459#line 3070 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006460 {
6461 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6462 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00006463 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006464 ;}
6465 break;
6466
Devang Patel652203f2008-09-29 20:49:50 +00006467 case 323:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006468#line 3078 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006469 {
6470 (yyval.ConstantList) = new std::vector<unsigned>();
6471 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
6472 GEN_ERROR("Index " + utostr((yyvsp[(2) - (2)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6473 (yyval.ConstantList)->push_back((yyvsp[(2) - (2)].UInt64Val));
6474 ;}
6475 break;
6476
Devang Patel652203f2008-09-29 20:49:50 +00006477 case 324:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006478#line 3084 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006479 {
6480 (yyval.ConstantList) = (yyvsp[(1) - (3)].ConstantList);
6481 if ((unsigned)(yyvsp[(3) - (3)].UInt64Val) != (yyvsp[(3) - (3)].UInt64Val))
6482 GEN_ERROR("Index " + utostr((yyvsp[(3) - (3)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6483 (yyval.ConstantList)->push_back((yyvsp[(3) - (3)].UInt64Val));
6484 CHECK_FOR_ERROR
6485 ;}
6486 break;
6487
Devang Patel652203f2008-09-29 20:49:50 +00006488 case 325:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006489#line 3093 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006490 {
6491 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006492 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006493 ;}
6494 break;
6495
Devang Patel652203f2008-09-29 20:49:50 +00006496 case 326:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006497#line 3097 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006498 {
6499 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006500 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006501 ;}
6502 break;
6503
Devang Patel652203f2008-09-29 20:49:50 +00006504 case 327:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006505#line 3102 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006506 {
Reid Spencer14310612006-12-31 05:40:51 +00006507 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006508 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006509 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
Dan Gohmanf4423b12008-04-19 00:24:39 +00006510 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006511 GEN_ERROR(
6512 "Arithmetic operator requires integer, FP, or packed operands");
Eric Christopher2a5196f2008-09-24 04:55:49 +00006513 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006514 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006515 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006516 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006517 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006518 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006519 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006520 delete (yyvsp[(2) - (5)].TypeVal);
6521 ;}
6522 break;
6523
Devang Patel652203f2008-09-29 20:49:50 +00006524 case 328:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006525#line 3118 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006526 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006527 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006528 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6529 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
Nate Begeman5bc1ea02008-07-29 15:49:41 +00006530 if (!isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00006531 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006532 GEN_ERROR("Logical operator requires integral operands");
6533 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006534 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006535 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006536 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006537 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006538 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006539 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006540 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006541 delete (yyvsp[(2) - (5)].TypeVal);
6542 ;}
6543 break;
6544
Devang Patel652203f2008-09-29 20:49:50 +00006545 case 329:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006546#line 3135 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006547 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006548 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006549 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006550 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006551 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006552 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006553 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006554 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006555 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006556 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006557 delete (yyvsp[(3) - (6)].TypeVal);
6558 ;}
6559 break;
6560
Devang Patel652203f2008-09-29 20:49:50 +00006561 case 330:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006562#line 3147 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006563 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006564 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006565 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006566 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006567 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006568 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006569 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006570 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006571 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006572 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006573 delete (yyvsp[(3) - (6)].TypeVal);
6574 ;}
6575 break;
6576
Devang Patel652203f2008-09-29 20:49:50 +00006577 case 331:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006578#line 3159 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006579 {
6580 if (!UpRefs.empty())
6581 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6582 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6583 GEN_ERROR("Scalar types not supported by vicmp instruction");
6584 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6585 CHECK_FOR_ERROR
6586 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6587 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006588 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006589 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006590 GEN_ERROR("vicmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006591 delete (yyvsp[(3) - (6)].TypeVal);
6592 ;}
6593 break;
6594
Devang Patel652203f2008-09-29 20:49:50 +00006595 case 332:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006596#line 3173 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006597 {
6598 if (!UpRefs.empty())
6599 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6600 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6601 GEN_ERROR("Scalar types not supported by vfcmp instruction");
6602 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6603 CHECK_FOR_ERROR
6604 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6605 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006606 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006607 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006608 GEN_ERROR("vfcmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006609 delete (yyvsp[(3) - (6)].TypeVal);
6610 ;}
6611 break;
6612
Devang Patel652203f2008-09-29 20:49:50 +00006613 case 333:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006614#line 3187 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006615 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006616 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006617 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6618 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6619 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6620 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006621 GEN_ERROR("invalid cast opcode for cast from '" +
6622 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00006623 DestTy->getDescription() + "'");
Dan Gohmane4977cf2008-05-23 01:55:30 +00006624 (yyval.InstVal) = CastInst::Create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006625 delete (yyvsp[(4) - (4)].TypeVal);
6626 ;}
6627 break;
6628
Devang Patel652203f2008-09-29 20:49:50 +00006629 case 334:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006630#line 3199 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006631 {
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006632 if (isa<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType())) {
6633 // vector select
6634 if (!isa<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType())
6635 || !isa<VectorType>((yyvsp[(6) - (6)].ValueVal)->getType()) )
6636 GEN_ERROR("vector select value types must be vector types");
6637 const VectorType* cond_type = cast<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType());
6638 const VectorType* select_type = cast<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType());
6639 if (cond_type->getElementType() != Type::Int1Ty)
6640 GEN_ERROR("vector select condition element type must be boolean");
6641 if (cond_type->getNumElements() != select_type->getNumElements())
6642 GEN_ERROR("vector select number of elements must be the same");
6643 } else {
6644 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
6645 GEN_ERROR("select condition must be boolean");
6646 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006647 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006648 GEN_ERROR("select value types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006649 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006650 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006651 ;}
6652 break;
6653
Devang Patel652203f2008-09-29 20:49:50 +00006654 case 335:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006655#line 3220 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006656 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006657 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006658 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6659 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6660 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006661 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006662 ;}
6663 break;
6664
Devang Patel652203f2008-09-29 20:49:50 +00006665 case 336:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006666#line 3227 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006667 {
6668 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006669 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006670 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006671 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006672 ;}
6673 break;
6674
Devang Patel652203f2008-09-29 20:49:50 +00006675 case 337:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006676#line 3233 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006677 {
6678 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006679 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006680 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006681 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006682 ;}
6683 break;
6684
Devang Patel652203f2008-09-29 20:49:50 +00006685 case 338:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006686#line 3239 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006687 {
6688 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006689 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006690 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006691 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006692 ;}
6693 break;
6694
Devang Patel652203f2008-09-29 20:49:50 +00006695 case 339:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006696#line 3245 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006697 {
6698 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006699 if (!Ty->isFirstClassType())
6700 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006701 (yyval.InstVal) = PHINode::Create(Ty);
6702 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6703 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006704 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006705 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006706 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6707 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006708 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006709 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006710 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006711 ;}
6712 break;
6713
Devang Patel652203f2008-09-29 20:49:50 +00006714 case 340:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006715#line 3261 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006716 {
Reid Spencer14310612006-12-31 05:40:51 +00006717
6718 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006719 const PointerType *PFTy = 0;
6720 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006721 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (9)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006722 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6723 // Pull out the types of all of the arguments...
6724 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006725 ParamList::iterator I = (yyvsp[(7) - (9)].ParamList)->begin(), E = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006726 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006727 const Type *Ty = I->Val->getType();
6728 if (Ty == Type::VoidTy)
6729 GEN_ERROR("Short call syntax cannot be used with varargs");
6730 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006731 }
Chris Lattnera925a142008-04-23 05:37:08 +00006732
Devang Patel652203f2008-09-29 20:49:50 +00006733 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (9)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006734 GEN_ERROR("Invalid result type for LLVM function");
6735
Devang Patel652203f2008-09-29 20:49:50 +00006736 Ty = FunctionType::get((yyvsp[(4) - (9)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006737 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006738 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006739
Devang Patel652203f2008-09-29 20:49:50 +00006740 Value *V = getVal(PFTy, (yyvsp[(5) - (9)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006741 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006742
Reid Spencer7780acb2007-04-16 06:56:07 +00006743 // Check for call to invalid intrinsic to avoid crashing later.
6744 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006745 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006746 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6747 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006748 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6749 theF->getName() + "'");
6750 }
6751
Devang Patel05988662008-09-25 21:00:45 +00006752 // Set up the Attributes for the function
6753 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006754 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6755 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006756 Attributes RetAttrs = (yyvsp[(3) - (9)].Attributes);
6757 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None) {
6758 if ((yyvsp[(9) - (9)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006759 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006760 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006761 }
Devang Patel652203f2008-09-29 20:49:50 +00006762 if ((yyvsp[(9) - (9)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006763 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006764 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006765 }
Devang Patel652203f2008-09-29 20:49:50 +00006766 if ((yyvsp[(9) - (9)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006767 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006768 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006769 }
Dale Johannesene7261862008-09-26 23:46:20 +00006770 }
Devang Patel652203f2008-09-29 20:49:50 +00006771 if (RetAttrs != Attribute::None)
6772 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006773
Eric Christopher2a5196f2008-09-24 04:55:49 +00006774 // Check the arguments
Reid Spencer14310612006-12-31 05:40:51 +00006775 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006776 if ((yyvsp[(7) - (9)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006777 // Make sure no arguments is a good thing!
6778 if (Ty->getNumParams() != 0)
6779 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006780 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006781 } else { // Has arguments?
6782 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006783 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006784 FunctionType::param_iterator I = Ty->param_begin();
6785 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006786 ParamList::iterator ArgI = (yyvsp[(7) - (9)].ParamList)->begin(), ArgE = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006787 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006788
Duncan Sandsdc024672007-11-27 13:23:08 +00006789 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006790 if (ArgI->Val->getType() != *I)
6791 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006792 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006793 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006794 if (ArgI->Attrs != Attribute::None)
6795 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006796 }
6797 if (Ty->isVarArg()) {
6798 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006799 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006800 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006801 if (ArgI->Attrs != Attribute::None)
6802 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006803 }
Reid Spencer14310612006-12-31 05:40:51 +00006804 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006805 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006806 }
Devang Patel652203f2008-09-29 20:49:50 +00006807 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None)
6808 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (9)].Attributes)));
Duncan Sandsdc024672007-11-27 13:23:08 +00006809
Devang Patel05988662008-09-25 21:00:45 +00006810 // Finish off the Attributes and check them
6811 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006812 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006813 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006814
Reid Spencer14310612006-12-31 05:40:51 +00006815 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006816 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006817 CI->setTailCall((yyvsp[(1) - (9)].BoolVal));
6818 CI->setCallingConv((yyvsp[(2) - (9)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006819 CI->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006820 (yyval.InstVal) = CI;
Devang Patel652203f2008-09-29 20:49:50 +00006821 delete (yyvsp[(7) - (9)].ParamList);
6822 delete (yyvsp[(4) - (9)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006823 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006824 ;}
6825 break;
6826
Devang Patel652203f2008-09-29 20:49:50 +00006827 case 341:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006828#line 3370 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006829 {
6830 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006831 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006832 ;}
6833 break;
6834
Devang Patel652203f2008-09-29 20:49:50 +00006835 case 342:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006836#line 3375 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006837 {
6838 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006839 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006840 ;}
6841 break;
6842
Devang Patel652203f2008-09-29 20:49:50 +00006843 case 343:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006844#line 3379 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006845 {
6846 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006847 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006848 ;}
6849 break;
6850
Devang Patel652203f2008-09-29 20:49:50 +00006851 case 344:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006852#line 3386 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006853 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006854 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006855 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6856 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6857 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006858 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006859 ;}
6860 break;
6861
Devang Patel652203f2008-09-29 20:49:50 +00006862 case 345:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006863#line 3393 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006864 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006865 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006866 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006867 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6868 GEN_ERROR("Malloc array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006869 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006870 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006871 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6872 delete (yyvsp[(2) - (6)].TypeVal);
6873 ;}
6874 break;
6875
Devang Patel652203f2008-09-29 20:49:50 +00006876 case 346:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006877#line 3403 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006878 {
Reid Spencer14310612006-12-31 05:40:51 +00006879 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006880 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6881 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6882 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006883 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006884 ;}
6885 break;
6886
Devang Patel652203f2008-09-29 20:49:50 +00006887 case 347:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006888#line 3410 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006889 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006890 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006891 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006892 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6893 GEN_ERROR("Alloca array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006894 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006895 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006896 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6897 delete (yyvsp[(2) - (6)].TypeVal);
6898 ;}
6899 break;
6900
Devang Patel652203f2008-09-29 20:49:50 +00006901 case 348:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006902#line 3420 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006903 {
6904 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Eric Christopher2a5196f2008-09-24 04:55:49 +00006905 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006906 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6907 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006908 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006909 ;}
6910 break;
6911
Devang Patel652203f2008-09-29 20:49:50 +00006912 case 349:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006913#line 3428 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006914 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006915 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006916 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6917 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006918 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006919 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6920 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006921 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006922 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6923 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006924 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006925 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6926 delete (yyvsp[(3) - (5)].TypeVal);
6927 ;}
6928 break;
6929
Devang Patel652203f2008-09-29 20:49:50 +00006930 case 350:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006931#line 3442 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006932 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006933 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006934 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6935 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006936 if (!PT)
6937 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006938 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006939 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006940 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6941 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006942 "' into space of type '" + ElTy->getDescription() + "'");
6943
Dan Gohmanf4423b12008-04-19 00:24:39 +00006944 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006945 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006946 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6947 delete (yyvsp[(5) - (7)].TypeVal);
6948 ;}
6949 break;
6950
Devang Patel652203f2008-09-29 20:49:50 +00006951 case 351:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006952#line 3459 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006953 {
Dan Gohman1a570242008-07-23 00:54:54 +00006954 if (!UpRefs.empty())
6955 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6956 if (!isa<StructType>((yyvsp[(2) - (5)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (5)].TypeVal)->get()))
6957 GEN_ERROR("getresult insn requires an aggregate operand");
6958 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].UInt64Val)))
6959 GEN_ERROR("Invalid getresult index for type '" +
6960 (*(yyvsp[(2) - (5)].TypeVal))->getDescription()+ "'");
6961
6962 Value *tmpVal = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Devang Patel5a970972008-02-19 22:27:01 +00006963 CHECK_FOR_ERROR
Dan Gohman1a570242008-07-23 00:54:54 +00006964 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(5) - (5)].UInt64Val));
6965 delete (yyvsp[(2) - (5)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006966 ;}
6967 break;
6968
Devang Patel652203f2008-09-29 20:49:50 +00006969 case 352:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006970#line 3473 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006971 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006972 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006973 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6974 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006975 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006976
Dan Gohman041e2eb2008-05-15 19:50:34 +00006977 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()))
Reid Spencer61c83e02006-08-18 08:43:06 +00006978 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006979 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6980 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006981 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006982 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006983 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006984 delete (yyvsp[(4) - (4)].ValueList);
6985 ;}
6986 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006987
Devang Patel652203f2008-09-29 20:49:50 +00006988 case 353:
Nuno Lopes8a88a372008-10-05 16:49:34 +00006989#line 3488 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00006990 {
6991 if (!UpRefs.empty())
6992 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6993 if (!isa<StructType>((yyvsp[(2) - (4)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (4)].TypeVal)->get()))
6994 GEN_ERROR("extractvalue insn requires an aggregate operand");
6995
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006996 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end()))
Dan Gohmane4977cf2008-05-23 01:55:30 +00006997 GEN_ERROR("Invalid extractvalue indices for type '" +
6998 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6999 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
7000 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007001 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00007002 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007003 delete (yyvsp[(4) - (4)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007004 ;}
7005 break;
7006
Devang Patel652203f2008-09-29 20:49:50 +00007007 case 354:
Nuno Lopes8a88a372008-10-05 16:49:34 +00007008#line 3503 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00007009 {
7010 if (!UpRefs.empty())
7011 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (7)].TypeVal))->getDescription());
7012 if (!isa<StructType>((yyvsp[(2) - (7)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (7)].TypeVal)->get()))
7013 GEN_ERROR("extractvalue insn requires an aggregate operand");
7014
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007015 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 +00007016 GEN_ERROR("Invalid insertvalue indices for type '" +
7017 (*(yyvsp[(2) - (7)].TypeVal))->getDescription()+ "'");
7018 Value* aggVal = getVal(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(3) - (7)].ValIDVal));
7019 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
7020 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007021 (yyval.InstVal) = InsertValueInst::Create(aggVal, tmpVal, (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00007022 delete (yyvsp[(2) - (7)].TypeVal);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007023 delete (yyvsp[(5) - (7)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007024 delete (yyvsp[(7) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007025 ;}
7026 break;
7027
Dan Gohmanf4423b12008-04-19 00:24:39 +00007028
7029/* Line 1267 of yacc.c. */
Nuno Lopes8a88a372008-10-05 16:49:34 +00007030#line 7031 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00007031 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00007032 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007033 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
7034
7035 YYPOPSTACK (yylen);
7036 yylen = 0;
7037 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007038
7039 *++yyvsp = yyval;
7040
7041
Dan Gohmanf4423b12008-04-19 00:24:39 +00007042 /* Now `shift' the result of the reduction. Determine what state
7043 that goes to, based on the state we popped back to and the rule
7044 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00007045
7046 yyn = yyr1[yyn];
7047
Dan Gohmanf4423b12008-04-19 00:24:39 +00007048 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
7049 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007050 yystate = yytable[yystate];
7051 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00007052 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00007053
7054 goto yynewstate;
7055
7056
Dan Gohmanf4423b12008-04-19 00:24:39 +00007057/*------------------------------------.
7058| yyerrlab -- here on detecting error |
7059`------------------------------------*/
7060yyerrlab:
7061 /* If not already recovering from an error, report this error. */
7062 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007063 {
7064 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007065#if ! YYERROR_VERBOSE
7066 yyerror (YY_("syntax error"));
7067#else
7068 {
7069 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
7070 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
7071 {
7072 YYSIZE_T yyalloc = 2 * yysize;
7073 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
7074 yyalloc = YYSTACK_ALLOC_MAXIMUM;
7075 if (yymsg != yymsgbuf)
7076 YYSTACK_FREE (yymsg);
7077 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
7078 if (yymsg)
7079 yymsg_alloc = yyalloc;
7080 else
7081 {
7082 yymsg = yymsgbuf;
7083 yymsg_alloc = sizeof yymsgbuf;
7084 }
7085 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00007086
Dan Gohmanf4423b12008-04-19 00:24:39 +00007087 if (0 < yysize && yysize <= yymsg_alloc)
7088 {
7089 (void) yysyntax_error (yymsg, yystate, yychar);
7090 yyerror (yymsg);
7091 }
7092 else
7093 {
7094 yyerror (YY_("syntax error"));
7095 if (yysize != 0)
7096 goto yyexhaustedlab;
7097 }
7098 }
7099#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007100 }
7101
Dan Gohmanf4423b12008-04-19 00:24:39 +00007102
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007103
7104 if (yyerrstatus == 3)
7105 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00007106 /* If just tried and failed to reuse look-ahead token after an
7107 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007108
Dan Gohmanf4423b12008-04-19 00:24:39 +00007109 if (yychar <= YYEOF)
7110 {
7111 /* Return failure if at end of input. */
7112 if (yychar == YYEOF)
7113 YYABORT;
7114 }
7115 else
7116 {
7117 yydestruct ("Error: discarding",
7118 yytoken, &yylval);
7119 yychar = YYEMPTY;
7120 }
7121 }
7122
7123 /* Else will try to reuse look-ahead token after shifting the error
7124 token. */
7125 goto yyerrlab1;
7126
7127
7128/*---------------------------------------------------.
7129| yyerrorlab -- error raised explicitly by YYERROR. |
7130`---------------------------------------------------*/
7131yyerrorlab:
7132
7133 /* Pacify compilers like GCC when the user code never invokes
7134 YYERROR and the label yyerrorlab therefore never appears in user
7135 code. */
7136 if (/*CONSTCOND*/ 0)
7137 goto yyerrorlab;
7138
7139 /* Do not reclaim the symbols of the rule which action triggered
7140 this YYERROR. */
7141 YYPOPSTACK (yylen);
7142 yylen = 0;
7143 YY_STACK_PRINT (yyss, yyssp);
7144 yystate = *yyssp;
7145 goto yyerrlab1;
7146
7147
7148/*-------------------------------------------------------------.
7149| yyerrlab1 -- common code for both syntax error and YYERROR. |
7150`-------------------------------------------------------------*/
7151yyerrlab1:
7152 yyerrstatus = 3; /* Each real token shifted decrements this. */
7153
7154 for (;;)
7155 {
7156 yyn = yypact[yystate];
7157 if (yyn != YYPACT_NINF)
7158 {
7159 yyn += YYTERROR;
7160 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7161 {
7162 yyn = yytable[yyn];
7163 if (0 < yyn)
7164 break;
7165 }
7166 }
7167
7168 /* Pop the current state because it cannot handle the error token. */
7169 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007170 YYABORT;
7171
Dale Johannesencdd509a2007-09-07 21:07:57 +00007172
Dan Gohmanf4423b12008-04-19 00:24:39 +00007173 yydestruct ("Error: popping",
7174 yystos[yystate], yyvsp);
7175 YYPOPSTACK (1);
7176 yystate = *yyssp;
7177 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007178 }
7179
7180 if (yyn == YYFINAL)
7181 YYACCEPT;
7182
Reid Spencer68a24bd2005-08-27 18:50:39 +00007183 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007184
7185
7186 /* Shift the error token. */
7187 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00007188
Reid Spencer68a24bd2005-08-27 18:50:39 +00007189 yystate = yyn;
7190 goto yynewstate;
7191
Gabor Greife64d2482008-04-06 23:07:54 +00007192
Dan Gohmanf4423b12008-04-19 00:24:39 +00007193/*-------------------------------------.
7194| yyacceptlab -- YYACCEPT comes here. |
7195`-------------------------------------*/
7196yyacceptlab:
7197 yyresult = 0;
7198 goto yyreturn;
7199
7200/*-----------------------------------.
7201| yyabortlab -- YYABORT comes here. |
7202`-----------------------------------*/
7203yyabortlab:
7204 yyresult = 1;
7205 goto yyreturn;
7206
7207#ifndef yyoverflow
7208/*-------------------------------------------------.
7209| yyexhaustedlab -- memory exhaustion comes here. |
7210`-------------------------------------------------*/
7211yyexhaustedlab:
7212 yyerror (YY_("memory exhausted"));
7213 yyresult = 2;
7214 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00007215#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00007216
7217yyreturn:
7218 if (yychar != YYEOF && yychar != YYEMPTY)
7219 yydestruct ("Cleanup: discarding lookahead",
7220 yytoken, &yylval);
7221 /* Do not reclaim the symbols of the rule which action triggered
7222 this YYABORT or YYACCEPT. */
7223 YYPOPSTACK (yylen);
7224 YY_STACK_PRINT (yyss, yyssp);
7225 while (yyssp != yyss)
7226 {
7227 yydestruct ("Cleanup: popping",
7228 yystos[*yyssp], yyvsp);
7229 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00007230 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007231#ifndef yyoverflow
7232 if (yyss != yyssa)
7233 YYSTACK_FREE (yyss);
7234#endif
7235#if YYERROR_VERBOSE
7236 if (yymsg != yymsgbuf)
7237 YYSTACK_FREE (yymsg);
7238#endif
7239 /* Make sure YYID is used. */
7240 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007241}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007242
7243
Nuno Lopes8a88a372008-10-05 16:49:34 +00007244#line 3522 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00007245
7246
Reid Spencer14310612006-12-31 05:40:51 +00007247// common code from the two 'RunVMAsmParser' functions
7248static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00007249 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00007250 // Check to make sure the parser succeeded
7251 if (yyparse()) {
7252 if (ParserResult)
7253 delete ParserResult;
7254 return 0;
7255 }
7256
Reid Spencer0d60b5a2007-03-30 01:37:39 +00007257 // Emit an error if there are any unresolved types left.
7258 if (!CurModule.LateResolveTypes.empty()) {
7259 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
7260 if (DID.Type == ValID::LocalName) {
7261 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
7262 } else {
7263 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
7264 }
7265 if (ParserResult)
7266 delete ParserResult;
7267 return 0;
7268 }
7269
7270 // Emit an error if there are any unresolved values left.
7271 if (!CurModule.LateResolveValues.empty()) {
7272 Value *V = CurModule.LateResolveValues.back();
7273 std::map<Value*, std::pair<ValID, int> >::iterator I =
7274 CurModule.PlaceHolderInfo.find(V);
7275
7276 if (I != CurModule.PlaceHolderInfo.end()) {
7277 ValID &DID = I->second.first;
7278 if (DID.Type == ValID::LocalName) {
7279 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
7280 } else {
7281 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
7282 }
7283 if (ParserResult)
7284 delete ParserResult;
7285 return 0;
7286 }
7287 }
7288
Reid Spencer14310612006-12-31 05:40:51 +00007289 // Check to make sure that parsing produced a result
7290 if (!ParserResult)
7291 return 0;
7292
7293 // Reset ParserResult variable while saving its value for the result.
7294 Module *Result = ParserResult;
7295 ParserResult = 0;
7296
7297 return Result;
7298}
7299
Reid Spencer61c83e02006-08-18 08:43:06 +00007300void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007301 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00007302 // TODO: column number in exception
7303 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00007304 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00007305 TriggerError = 1;
7306}
Reid Spencer68a24bd2005-08-27 18:50:39 +00007307
7308int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007309 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00007310 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00007311 if (yychar != YYEMPTY && yychar != 0) {
7312 errMsg += " while reading token: '";
Eric Christopher2a5196f2008-09-24 04:55:49 +00007313 errMsg += std::string(LLLgetTokenStart(),
Duncan Sandsdc024672007-11-27 13:23:08 +00007314 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
7315 }
Reid Spencer61c83e02006-08-18 08:43:06 +00007316 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007317 return 0;
7318}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007319