blob: 733501185c0c422db2b81b1fffba1b0bdecdbe3b [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 Lopes6ec8a252008-10-15 11:11:12 +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 &&
Dale Johannesen236bbd42008-10-09 23:01:34 +0000815 Ty==Type::FloatTy) {
816 bool ignored;
817 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
818 &ignored);
819 }
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000820 return ConstantFP::get(*D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000821
822 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000823 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000824 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000825 return 0;
826 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000827 return ConstantPointerNull::get(cast<PointerType>(Ty));
828
829 case ValID::ConstUndefVal: // Is it an undef value?
830 return UndefValue::get(Ty);
831
Chris Lattner7aa61892005-12-21 17:53:23 +0000832 case ValID::ConstZeroVal: // Is it a zero value?
833 return Constant::getNullValue(Ty);
Eric Christopher2a5196f2008-09-24 04:55:49 +0000834
Reid Spencer68a24bd2005-08-27 18:50:39 +0000835 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000836 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000837 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000838 return 0;
839 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000840 return D.ConstantValue;
841
Chris Lattner0e9c3762006-01-25 22:27:16 +0000842 case ValID::InlineAsmVal: { // Inline asm expression
843 const PointerType *PTy = dyn_cast<PointerType>(Ty);
844 const FunctionType *FTy =
845 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000846 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000847 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000848 return 0;
849 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000850 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
851 D.IAD->HasSideEffects);
852 D.destroy(); // Free InlineAsmDescriptor.
853 return IA;
854 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000855 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000856 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000857 return 0;
858 } // End of switch
859
Reid Spencera9720f52007-02-05 17:04:00 +0000860 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000861 return 0;
862}
863
Reid Spencer93c40032007-03-19 18:40:50 +0000864// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000865// value is not already defined, it "improvises" by creating a placeholder var
866// that looks and acts just like the requested variable. When the value is
867// defined later, all uses of the placeholder variable are replaced with the
868// real thing.
869//
870static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000871 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000872 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000873 return 0;
874 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000875
876 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000877 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000878 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000879 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000880
Reid Spencer5b7e7532006-09-28 19:28:24 +0000881 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Dan Gohmane4977cf2008-05-23 01:55:30 +0000882 GenerateError("Invalid use of a non-first-class type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000883 return 0;
884 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000885
886 // If we reached here, we referenced either a symbol that we don't know about
887 // or an id number that hasn't been read yet. We may be referencing something
888 // forward, so just create an entry to be resolved later and get to it...
889 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000890 switch (ID.Type) {
891 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000892 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000893 const PointerType *PTy = dyn_cast<PointerType>(Ty);
894 if (!PTy) {
895 GenerateError("Invalid type for reference to global" );
896 return 0;
897 }
898 const Type* ElTy = PTy->getElementType();
899 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greife64d2482008-04-06 23:07:54 +0000900 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000901 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000902 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
903 (Module*)0, false, PTy->getAddressSpace());
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000904 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000905 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000906 default:
907 V = new Argument(Ty);
908 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000909
Reid Spencer68a24bd2005-08-27 18:50:39 +0000910 // Remember where this forward reference came from. FIXME, shouldn't we try
911 // to recycle these things??
912 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsdc024672007-11-27 13:23:08 +0000913 LLLgetLineNo())));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000914
915 if (inFunctionScope())
916 InsertValue(V, CurFun.LateResolveValues);
917 else
918 InsertValue(V, CurModule.LateResolveValues);
919 return V;
920}
921
Reid Spencer93c40032007-03-19 18:40:50 +0000922/// defineBBVal - This is a definition of a new basic block with the specified
923/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Chris Lattnercc81d152008-05-04 17:18:47 +0000924static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000925 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000926
Reid Spencer68a24bd2005-08-27 18:50:39 +0000927 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000928
Reid Spencer93c40032007-03-19 18:40:50 +0000929 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000930
Reid Spencer93c40032007-03-19 18:40:50 +0000931 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
932 if (BBI != CurFun.BBForwardRefs.end()) {
933 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000934 // The forward declaration could have been inserted anywhere in the
935 // function: insert it into the correct place now.
936 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
937 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000938
Reid Spencer66728ef2007-03-20 01:13:36 +0000939 // We're about to erase the entry, save the key so we can clean it up.
940 ValID Tmp = BBI->first;
941
Reid Spencer93c40032007-03-19 18:40:50 +0000942 // Erase the forward ref from the map as its no longer "forward"
943 CurFun.BBForwardRefs.erase(ID);
944
Eric Christopher2a5196f2008-09-24 04:55:49 +0000945 // The key has been removed from the map but so we don't want to leave
Reid Spencer66728ef2007-03-20 01:13:36 +0000946 // strdup'd memory around so destroy it too.
947 Tmp.destroy();
948
Reid Spencer93c40032007-03-19 18:40:50 +0000949 // If its a numbered definition, bump the number and set the BB value.
950 if (ID.Type == ValID::LocalID) {
951 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
952 InsertValue(BB);
953 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000954 } else {
955 // We haven't seen this BB before and its first mention is a definition.
Devang Patel67909432008-03-03 18:58:47 +0000956 // Just create it and return it.
957 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greife64d2482008-04-06 23:07:54 +0000958 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel67909432008-03-03 18:58:47 +0000959 if (ID.Type == ValID::LocalID) {
960 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
961 InsertValue(BB);
962 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000963 }
Reid Spencer93c40032007-03-19 18:40:50 +0000964
Devang Patel67909432008-03-03 18:58:47 +0000965 ID.destroy();
Reid Spencer93c40032007-03-19 18:40:50 +0000966 return BB;
967}
968
969/// getBBVal - get an existing BB value or create a forward reference for it.
Eric Christopher2a5196f2008-09-24 04:55:49 +0000970///
Reid Spencer93c40032007-03-19 18:40:50 +0000971static BasicBlock *getBBVal(const ValID &ID) {
972 assert(inFunctionScope() && "Can't get basic block at global scope!");
973
974 BasicBlock *BB = 0;
975
976 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
977 if (BBI != CurFun.BBForwardRefs.end()) {
978 BB = BBI->second;
979 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000980 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000981 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000982 if (N) {
Reid Spencer93c40032007-03-19 18:40:50 +0000983 if (N->getType()->getTypeID() == Type::LabelTyID)
984 BB = cast<BasicBlock>(N);
985 else
986 GenerateError("Reference to label '" + Name + "' is actually of type '"+
987 N->getType()->getDescription() + "'");
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000988 }
Reid Spencer93c40032007-03-19 18:40:50 +0000989 } else if (ID.Type == ValID::LocalID) {
990 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
991 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
992 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
993 else
Eric Christopher2a5196f2008-09-24 04:55:49 +0000994 GenerateError("Reference to label '%" + utostr(ID.Num) +
995 "' is actually of type '"+
Reid Spencer93c40032007-03-19 18:40:50 +0000996 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
997 }
998 } else {
999 GenerateError("Illegal label reference " + ID.getName());
1000 return 0;
1001 }
1002
1003 // If its already been defined, return it now.
1004 if (BB) {
1005 ID.destroy(); // Free strdup'd memory.
1006 return BB;
1007 }
1008
1009 // Otherwise, this block has not been seen before, create it.
1010 std::string Name;
1011 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001012 Name = ID.getName();
Gabor Greife64d2482008-04-06 23:07:54 +00001013 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Reid Spencer93c40032007-03-19 18:40:50 +00001014
1015 // Insert it in the forward refs map.
1016 CurFun.BBForwardRefs[ID] = BB;
1017
Reid Spencer68a24bd2005-08-27 18:50:39 +00001018 return BB;
1019}
1020
1021
1022//===----------------------------------------------------------------------===//
1023// Code to handle forward references in instructions
1024//===----------------------------------------------------------------------===//
1025//
1026// This code handles the late binding needed with statements that reference
1027// values not defined yet... for example, a forward branch, or the PHI node for
1028// a loop body.
1029//
1030// This keeps a table (CurFun.LateResolveValues) of all such forward references
1031// and back patchs after we are done.
1032//
1033
1034// ResolveDefinitions - If we could not resolve some defs at parsing
1035// time (forward branches, phi functions for loops, etc...) resolve the
1036// defs now...
1037//
Eric Christopher2a5196f2008-09-24 04:55:49 +00001038static void
Reid Spencer93c40032007-03-19 18:40:50 +00001039ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001040 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +00001041 while (!LateResolvers.empty()) {
1042 Value *V = LateResolvers.back();
1043 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001044
Reid Spencer93c40032007-03-19 18:40:50 +00001045 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1046 CurModule.PlaceHolderInfo.find(V);
1047 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001048
Reid Spencer93c40032007-03-19 18:40:50 +00001049 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001050
Reid Spencer93c40032007-03-19 18:40:50 +00001051 Value *TheRealValue = getExistingVal(V->getType(), DID);
1052 if (TriggerError)
1053 return;
1054 if (TheRealValue) {
1055 V->replaceAllUsesWith(TheRealValue);
1056 delete V;
1057 CurModule.PlaceHolderInfo.erase(PHI);
1058 } else if (FutureLateResolvers) {
1059 // Functions have their unresolved items forwarded to the module late
1060 // resolver table
1061 InsertValue(V, *FutureLateResolvers);
1062 } else {
1063 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1064 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1065 "' of type '" + V->getType()->getDescription() + "'",
1066 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001067 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001068 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001069 GenerateError("Reference to an invalid definition: #" +
1070 itostr(DID.Num) + " of type '" +
1071 V->getType()->getDescription() + "'",
1072 PHI->second.second);
1073 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001074 }
1075 }
1076 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001077 LateResolvers.clear();
1078}
1079
1080// ResolveTypeTo - A brand new type was just declared. This means that (if
1081// name is not null) things referencing Name can be resolved. Otherwise, things
1082// refering to the number can be resolved. Do this now.
1083//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001084static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001085 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001086 if (Name)
1087 D = ValID::createLocalName(*Name);
Eric Christopher2a5196f2008-09-24 04:55:49 +00001088 else
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001089 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001090
Reid Spencer861d9d62006-11-28 07:29:44 +00001091 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001092 CurModule.LateResolveTypes.find(D);
1093 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001094 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001095 I->first.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001096 CurModule.LateResolveTypes.erase(I);
1097 }
Nuno Lopes191dfb92008-10-03 15:52:39 +00001098 D.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001099}
1100
1101// setValueName - Set the specified value to the name given. The name may be
1102// null potentially, in which case this is a noop. The string passed in is
1103// assumed to be a malloc'd string buffer, and is free'd by this function.
1104//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001105static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001106 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001107 std::string Name(*NameStr); // Copy string
1108 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001109
Reid Spencer41dff5e2007-01-26 08:05:27 +00001110 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001111 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001112 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001113 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001114
Reid Spencera9720f52007-02-05 17:04:00 +00001115 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001116 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1117 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001118 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001119 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001120 return;
1121 }
1122
1123 // Set the name.
1124 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001125}
1126
1127/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1128/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001129static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001130ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001131 GlobalValue::LinkageTypes Linkage,
1132 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001133 bool isConstantGlobal, const Type *Ty,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001134 Constant *Initializer, bool IsThreadLocal,
1135 unsigned AddressSpace = 0) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001136 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001137 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001138 return 0;
1139 }
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001140 if (Ty == Type::LabelTy) {
1141 GenerateError("Cannot declare global vars of label type");
1142 return 0;
1143 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001144
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001145 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001146
1147 std::string Name;
1148 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001149 Name = *NameStr; // Copy string
1150 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001151 }
1152
1153 // See if this global value was forward referenced. If so, recycle the
1154 // object.
1155 ValID ID;
1156 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001157 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001158 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001159 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001160 }
1161
1162 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1163 // Move the global to the end of the list, from whereever it was
1164 // previously inserted.
1165 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1166 CurModule.CurrentModule->getGlobalList().remove(GV);
1167 CurModule.CurrentModule->getGlobalList().push_back(GV);
1168 GV->setInitializer(Initializer);
1169 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001170 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001171 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001172 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001173 InsertValue(GV, CurModule.Values);
Nuno Lopes191dfb92008-10-03 15:52:39 +00001174 ID.destroy();
Chris Lattnerb475c422005-11-12 18:22:38 +00001175 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001176 }
1177
Nuno Lopes191dfb92008-10-03 15:52:39 +00001178 ID.destroy();
1179
Reid Spenceref9b9a72007-02-05 20:47:22 +00001180 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001181 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001182 // if the global we're parsing has an initializer (is a definition) and
1183 // has external linkage.
1184 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1185 // If there is already a global with external linkage with this name
1186 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1187 // If we allow this GVar to get created, it will be renamed in the
1188 // symbol table because it conflicts with an existing GVar. We can't
1189 // allow redefinition of GVars whose linking indicates that their name
1190 // must stay the same. Issue the error.
1191 GenerateError("Redefinition of global variable named '" + Name +
1192 "' of type '" + Ty->getDescription() + "'");
1193 return 0;
1194 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001195 }
1196
1197 // Otherwise there is no existing GV to use, create one now.
1198 GlobalVariable *GV =
1199 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001200 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001201 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001202 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001203 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001204}
1205
1206// setTypeName - Set the specified type to the name given. The name may be
1207// null potentially, in which case this is a noop. The string passed in is
1208// assumed to be a malloc'd string buffer, and is freed by this function.
1209//
1210// This function returns true if the type has already been defined, but is
1211// allowed to be redefined in the specified context. If the name is a new name
1212// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001213static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001214 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001215 if (NameStr == 0) return false;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001216
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001217 std::string Name(*NameStr); // Copy string
1218 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001219
1220 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001221 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001222 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001223 return false;
1224 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001225
1226 // Set the type name, checking for conflicts as we do so.
1227 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1228
1229 if (AlreadyExists) { // Inserting a name that is already defined???
1230 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001231 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001232
1233 // There is only one case where this is allowed: when we are refining an
1234 // opaque type. In this case, Existing will be an opaque type.
1235 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1236 // We ARE replacing an opaque type!
1237 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1238 return true;
1239 }
1240
1241 // Otherwise, this is an attempt to redefine a type. That's okay if
1242 // the redefinition is identical to the original. This will be so if
1243 // Existing and T point to the same Type object. In this one case we
1244 // allow the equivalent redefinition.
1245 if (Existing == T) return true; // Yes, it's equal.
1246
1247 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001248 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001249 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001250 }
1251
1252 return false;
1253}
1254
1255//===----------------------------------------------------------------------===//
1256// Code for handling upreferences in type names...
1257//
1258
1259// TypeContains - Returns true if Ty directly contains E in it.
1260//
1261static bool TypeContains(const Type *Ty, const Type *E) {
1262 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1263 E) != Ty->subtype_end();
1264}
1265
1266namespace {
1267 struct UpRefRecord {
1268 // NestingLevel - The number of nesting levels that need to be popped before
1269 // this type is resolved.
1270 unsigned NestingLevel;
1271
1272 // LastContainedTy - This is the type at the current binding level for the
1273 // type. Every time we reduce the nesting level, this gets updated.
1274 const Type *LastContainedTy;
1275
1276 // UpRefTy - This is the actual opaque type that the upreference is
1277 // represented with.
1278 OpaqueType *UpRefTy;
1279
1280 UpRefRecord(unsigned NL, OpaqueType *URTy)
1281 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1282 };
1283}
1284
1285// UpRefs - A list of the outstanding upreferences that need to be resolved.
1286static std::vector<UpRefRecord> UpRefs;
1287
1288/// HandleUpRefs - Every time we finish a new layer of types, this function is
1289/// called. It loops through the UpRefs vector, which is a list of the
1290/// currently active types. For each type, if the up reference is contained in
1291/// the newly completed type, we decrement the level count. When the level
1292/// count reaches zero, the upreferenced type is the type that is passed in:
1293/// thus we can complete the cycle.
1294///
1295static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001296 // If Ty isn't abstract, or if there are no up-references in it, then there is
1297 // nothing to resolve here.
1298 if (!ty->isAbstract() || UpRefs.empty()) return ty;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001299
Reid Spencer68a24bd2005-08-27 18:50:39 +00001300 PATypeHolder Ty(ty);
1301 UR_OUT("Type '" << Ty->getDescription() <<
1302 "' newly formed. Resolving upreferences.\n" <<
1303 UpRefs.size() << " upreferences active!\n");
1304
1305 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1306 // to zero), we resolve them all together before we resolve them to Ty. At
1307 // the end of the loop, if there is anything to resolve to Ty, it will be in
1308 // this variable.
1309 OpaqueType *TypeToResolve = 0;
1310
1311 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1312 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1313 << UpRefs[i].second->getDescription() << ") = "
1314 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1315 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1316 // Decrement level of upreference
1317 unsigned Level = --UpRefs[i].NestingLevel;
1318 UpRefs[i].LastContainedTy = Ty;
1319 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1320 if (Level == 0) { // Upreference should be resolved!
1321 if (!TypeToResolve) {
1322 TypeToResolve = UpRefs[i].UpRefTy;
1323 } else {
1324 UR_OUT(" * Resolving upreference for "
1325 << UpRefs[i].second->getDescription() << "\n";
1326 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1327 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1328 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1329 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1330 }
1331 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1332 --i; // Do not skip the next element...
1333 }
1334 }
1335 }
1336
1337 if (TypeToResolve) {
1338 UR_OUT(" * Resolving upreference for "
1339 << UpRefs[i].second->getDescription() << "\n";
1340 std::string OldName = TypeToResolve->getDescription());
1341 TypeToResolve->refineAbstractTypeTo(Ty);
1342 }
1343
1344 return Ty;
1345}
1346
Reid Spencer68a24bd2005-08-27 18:50:39 +00001347//===----------------------------------------------------------------------===//
1348// RunVMAsmParser - Define an interface to this parser
1349//===----------------------------------------------------------------------===//
1350//
Reid Spencer14310612006-12-31 05:40:51 +00001351static Module* RunParser(Module * M);
1352
Duncan Sandsdc024672007-11-27 13:23:08 +00001353Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1354 InitLLLexer(MB);
1355 Module *M = RunParser(new Module(LLLgetFilename()));
1356 FreeLexer();
1357 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001358}
1359
1360
Dan Gohmanf4423b12008-04-19 00:24:39 +00001361
1362/* Enabling traces. */
1363#ifndef YYDEBUG
1364# define YYDEBUG 0
1365#endif
1366
1367/* Enabling verbose error messages. */
1368#ifdef YYERROR_VERBOSE
1369# undef YYERROR_VERBOSE
1370# define YYERROR_VERBOSE 1
1371#else
1372# define YYERROR_VERBOSE 0
1373#endif
1374
1375/* Enabling the token table. */
1376#ifndef YYTOKEN_TABLE
1377# define YYTOKEN_TABLE 0
1378#endif
1379
1380#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1381typedef union YYSTYPE
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001382#line 978 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001383{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001384 llvm::Module *ModuleVal;
1385 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001386 llvm::BasicBlock *BasicBlockVal;
1387 llvm::TerminatorInst *TermInstVal;
1388 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001389 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001390
Reid Spencera132e042006-12-03 05:46:11 +00001391 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001392 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001393 llvm::PATypeHolder *TypeVal;
1394 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001395 std::vector<llvm::Value*> *ValueList;
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001396 std::vector<unsigned> *ConstantList;
Reid Spencer14310612006-12-31 05:40:51 +00001397 llvm::ArgListType *ArgList;
1398 llvm::TypeWithAttrs TypeWithAttrs;
1399 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001400 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001401
Reid Spencer68a24bd2005-08-27 18:50:39 +00001402 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001403 std::list<std::pair<llvm::Value*,
1404 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001405 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001406 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001407
1408 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001409 llvm::GlobalValue::VisibilityTypes Visibility;
Devang Patel05988662008-09-25 21:00:45 +00001410 llvm::Attributes Attributes;
Reid Spencer38c91a92007-02-28 02:24:54 +00001411 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001412 int64_t SInt64Val;
1413 uint64_t UInt64Val;
1414 int SIntVal;
1415 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001416 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001417 bool BoolVal;
1418
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001419 std::string *StrVal; // This memory must be deleted
1420 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001421
Reid Spencera132e042006-12-03 05:46:11 +00001422 llvm::Instruction::BinaryOps BinaryOpVal;
1423 llvm::Instruction::TermOps TermOpVal;
1424 llvm::Instruction::MemoryOps MemOpVal;
1425 llvm::Instruction::CastOps CastOpVal;
1426 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001427 llvm::ICmpInst::Predicate IPredicate;
1428 llvm::FCmpInst::Predicate FPredicate;
Dan Gohmanf4423b12008-04-19 00:24:39 +00001429}
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001430/* Line 187 of yacc.c. */
1431#line 1432 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001432 YYSTYPE;
1433# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1434# define YYSTYPE_IS_DECLARED 1
1435# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001436#endif
1437
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001438
Reid Spencer68a24bd2005-08-27 18:50:39 +00001439
Dan Gohmanf4423b12008-04-19 00:24:39 +00001440/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001441
1442
Dan Gohmanf4423b12008-04-19 00:24:39 +00001443/* Line 216 of yacc.c. */
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001444#line 1445 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001445
Dan Gohmanf4423b12008-04-19 00:24:39 +00001446#ifdef short
1447# undef short
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001448#endif
1449
Dan Gohmanf4423b12008-04-19 00:24:39 +00001450#ifdef YYTYPE_UINT8
1451typedef YYTYPE_UINT8 yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001452#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00001453typedef unsigned char yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001454#endif
1455
Dan Gohmanf4423b12008-04-19 00:24:39 +00001456#ifdef YYTYPE_INT8
1457typedef YYTYPE_INT8 yytype_int8;
1458#elif (defined __STDC__ || defined __C99__FUNC__ \
1459 || defined __cplusplus || defined _MSC_VER)
1460typedef signed char yytype_int8;
1461#else
1462typedef short int yytype_int8;
1463#endif
1464
1465#ifdef YYTYPE_UINT16
1466typedef YYTYPE_UINT16 yytype_uint16;
1467#else
1468typedef unsigned short int yytype_uint16;
1469#endif
1470
1471#ifdef YYTYPE_INT16
1472typedef YYTYPE_INT16 yytype_int16;
1473#else
1474typedef short int yytype_int16;
1475#endif
1476
1477#ifndef YYSIZE_T
1478# ifdef __SIZE_TYPE__
1479# define YYSIZE_T __SIZE_TYPE__
1480# elif defined size_t
1481# define YYSIZE_T size_t
1482# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1483 || defined __cplusplus || defined _MSC_VER)
1484# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1485# define YYSIZE_T size_t
1486# else
1487# define YYSIZE_T unsigned int
1488# endif
1489#endif
1490
1491#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1492
1493#ifndef YY_
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001494# if YYENABLE_NLS
Dan Gohmanf4423b12008-04-19 00:24:39 +00001495# if ENABLE_NLS
1496# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1497# define YY_(msgid) dgettext ("bison-runtime", msgid)
1498# endif
1499# endif
1500# ifndef YY_
1501# define YY_(msgid) msgid
1502# endif
1503#endif
1504
1505/* Suppress unused-variable warnings by "using" E. */
1506#if ! defined lint || defined __GNUC__
1507# define YYUSE(e) ((void) (e))
1508#else
1509# define YYUSE(e) /* empty */
1510#endif
1511
1512/* Identity function, used to suppress warnings about constant conditions. */
1513#ifndef lint
1514# define YYID(n) (n)
1515#else
1516#if (defined __STDC__ || defined __C99__FUNC__ \
1517 || defined __cplusplus || defined _MSC_VER)
1518static int
1519YYID (int i)
1520#else
1521static int
1522YYID (i)
1523 int i;
1524#endif
1525{
1526 return i;
1527}
1528#endif
1529
1530#if ! defined yyoverflow || YYERROR_VERBOSE
1531
1532/* The parser invokes alloca or malloc; define the necessary symbols. */
1533
1534# ifdef YYSTACK_USE_ALLOCA
1535# if YYSTACK_USE_ALLOCA
1536# ifdef __GNUC__
1537# define YYSTACK_ALLOC __builtin_alloca
1538# elif defined __BUILTIN_VA_ARG_INCR
1539# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1540# elif defined _AIX
1541# define YYSTACK_ALLOC __alloca
1542# elif defined _MSC_VER
1543# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1544# define alloca _alloca
1545# else
1546# define YYSTACK_ALLOC alloca
1547# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1548 || defined __cplusplus || defined _MSC_VER)
1549# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1550# ifndef _STDLIB_H
1551# define _STDLIB_H 1
1552# endif
1553# endif
1554# endif
1555# endif
1556# endif
1557
1558# ifdef YYSTACK_ALLOC
1559 /* Pacify GCC's `empty if-body' warning. */
1560# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1561# ifndef YYSTACK_ALLOC_MAXIMUM
1562 /* The OS might guarantee only one guard page at the bottom of the stack,
1563 and a page size can be as small as 4096 bytes. So we cannot safely
1564 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1565 to allow for a few compiler-allocated temporary stack slots. */
1566# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1567# endif
1568# else
1569# define YYSTACK_ALLOC YYMALLOC
1570# define YYSTACK_FREE YYFREE
1571# ifndef YYSTACK_ALLOC_MAXIMUM
1572# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1573# endif
1574# if (defined __cplusplus && ! defined _STDLIB_H \
1575 && ! ((defined YYMALLOC || defined malloc) \
1576 && (defined YYFREE || defined free)))
1577# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1578# ifndef _STDLIB_H
1579# define _STDLIB_H 1
1580# endif
1581# endif
1582# ifndef YYMALLOC
1583# define YYMALLOC malloc
1584# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1585 || defined __cplusplus || defined _MSC_VER)
1586void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1587# endif
1588# endif
1589# ifndef YYFREE
1590# define YYFREE free
1591# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1592 || defined __cplusplus || defined _MSC_VER)
1593void free (void *); /* INFRINGES ON USER NAME SPACE */
1594# endif
1595# endif
1596# endif
1597#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1598
1599
1600#if (! defined yyoverflow \
1601 && (! defined __cplusplus \
1602 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1603
1604/* A type that is properly aligned for any stack member. */
1605union yyalloc
1606{
1607 yytype_int16 yyss;
1608 YYSTYPE yyvs;
1609 };
1610
1611/* The size of the maximum gap between one aligned stack and the next. */
1612# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1613
1614/* The size of an array large to enough to hold all stacks, each with
1615 N elements. */
1616# define YYSTACK_BYTES(N) \
1617 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1618 + YYSTACK_GAP_MAXIMUM)
1619
1620/* Copy COUNT objects from FROM to TO. The source and destination do
1621 not overlap. */
1622# ifndef YYCOPY
1623# if defined __GNUC__ && 1 < __GNUC__
1624# define YYCOPY(To, From, Count) \
1625 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1626# else
1627# define YYCOPY(To, From, Count) \
1628 do \
1629 { \
1630 YYSIZE_T yyi; \
1631 for (yyi = 0; yyi < (Count); yyi++) \
1632 (To)[yyi] = (From)[yyi]; \
1633 } \
1634 while (YYID (0))
1635# endif
1636# endif
1637
1638/* Relocate STACK from its old location to the new one. The
1639 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1640 elements in the stack, and YYPTR gives the new location of the
1641 stack. Advance YYPTR to a properly aligned location for the next
1642 stack. */
1643# define YYSTACK_RELOCATE(Stack) \
1644 do \
1645 { \
1646 YYSIZE_T yynewbytes; \
1647 YYCOPY (&yyptr->Stack, Stack, yysize); \
1648 Stack = &yyptr->Stack; \
1649 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1650 yyptr += yynewbytes / sizeof (*yyptr); \
1651 } \
1652 while (YYID (0))
1653
1654#endif
1655
1656/* YYFINAL -- State number of the termination state. */
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001657#define YYFINAL 44
Dan Gohmanf4423b12008-04-19 00:24:39 +00001658/* YYLAST -- Last index in YYTABLE. */
Chris Lattner740e7092008-10-15 06:16:57 +00001659#define YYLAST 2377
Dan Gohmanf4423b12008-04-19 00:24:39 +00001660
1661/* YYNTOKENS -- Number of terminals. */
Devang Patel652203f2008-09-29 20:49:50 +00001662#define YYNTOKENS 173
Dan Gohmanf4423b12008-04-19 00:24:39 +00001663/* YYNNTS -- Number of nonterminals. */
Chris Lattner740e7092008-10-15 06:16:57 +00001664#define YYNNTS 87
Dan Gohmanf4423b12008-04-19 00:24:39 +00001665/* YYNRULES -- Number of rules. */
Chris Lattner740e7092008-10-15 06:16:57 +00001666#define YYNRULES 348
Dan Gohmanf4423b12008-04-19 00:24:39 +00001667/* YYNRULES -- Number of states. */
Chris Lattner740e7092008-10-15 06:16:57 +00001668#define YYNSTATES 708
Dan Gohmanf4423b12008-04-19 00:24:39 +00001669
1670/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1671#define YYUNDEFTOK 2
Devang Patel652203f2008-09-29 20:49:50 +00001672#define YYMAXUTOK 413
Dan Gohmanf4423b12008-04-19 00:24:39 +00001673
1674#define YYTRANSLATE(YYX) \
1675 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1676
1677/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1678static const yytype_uint8 yytranslate[] =
1679{
1680 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1681 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1682 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1683 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001684 159, 160, 163, 2, 162, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001685 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001686 168, 161, 169, 2, 2, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1688 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001689 2, 165, 164, 167, 2, 2, 2, 2, 2, 172,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001690 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1691 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001692 166, 2, 2, 170, 2, 171, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001693 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, 2, 2, 2, 2,
1702 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1703 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1704 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1705 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1706 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1707 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1708 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1709 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1710 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1711 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1712 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1713 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1714 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1715 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1716 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1717 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1718 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1719 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Dan Gohmane4977cf2008-05-23 01:55:30 +00001720 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
Devang Patel652203f2008-09-29 20:49:50 +00001721 155, 156, 157, 158
Dan Gohmanf4423b12008-04-19 00:24:39 +00001722};
1723
1724#if YYDEBUG
1725/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1726 YYRHS. */
1727static const yytype_uint16 yyprhs[] =
1728{
1729 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1730 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1731 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1732 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1733 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1734 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
Chris Lattner740e7092008-10-15 06:16:57 +00001735 118, 123, 124, 127, 128, 131, 133, 135, 137, 138,
1736 141, 143, 145, 147, 149, 151, 153, 155, 157, 159,
1737 160, 162, 164, 166, 167, 169, 171, 172, 174, 176,
1738 178, 180, 181, 183, 185, 186, 188, 190, 192, 194,
1739 196, 199, 201, 203, 205, 207, 209, 211, 213, 215,
1740 217, 220, 221, 224, 226, 228, 230, 231, 234, 236,
1741 238, 240, 242, 244, 246, 248, 250, 252, 254, 255,
1742 258, 259, 262, 263, 266, 267, 271, 274, 275, 277,
1743 278, 282, 284, 287, 289, 291, 293, 295, 297, 299,
1744 301, 303, 305, 309, 311, 314, 320, 326, 332, 338,
1745 342, 345, 351, 356, 359, 361, 363, 365, 369, 371,
1746 375, 377, 378, 380, 384, 389, 393, 397, 402, 407,
1747 411, 418, 424, 427, 430, 433, 436, 439, 442, 445,
1748 448, 451, 454, 457, 460, 467, 473, 482, 489, 496,
1749 504, 512, 520, 528, 535, 544, 553, 559, 567, 571,
1750 573, 575, 577, 579, 580, 583, 590, 592, 593, 595,
1751 598, 599, 603, 604, 608, 612, 616, 620, 621, 630,
1752 631, 641, 642, 652, 658, 661, 665, 667, 671, 675,
1753 679, 683, 685, 686, 692, 696, 698, 702, 704, 705,
1754 717, 719, 721, 726, 728, 730, 733, 737, 738, 740,
1755 742, 744, 746, 748, 750, 752, 754, 756, 758, 760,
1756 764, 768, 771, 774, 778, 781, 787, 792, 794, 800,
1757 802, 804, 806, 808, 810, 812, 815, 817, 821, 824,
1758 827, 831, 835, 838, 839, 841, 844, 847, 851, 861,
1759 871, 880, 896, 898, 900, 907, 913, 916, 919, 926,
1760 934, 939, 944, 951, 958, 959, 960, 964, 967, 971,
1761 974, 976, 982, 988, 995, 1002, 1009, 1016, 1021, 1028,
1762 1033, 1038, 1045, 1052, 1055, 1065, 1067, 1069, 1070, 1074,
1763 1081, 1085, 1092, 1095, 1101, 1109, 1115, 1120, 1125
Dan Gohmanf4423b12008-04-19 00:24:39 +00001764};
1765
1766/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1767static const yytype_int16 yyrhs[] =
1768{
Chris Lattner740e7092008-10-15 06:16:57 +00001769 220, 0, -1, 75, -1, 76, -1, 77, -1, 78,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001770 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
1771 -1, 87, -1, 88, -1, 89, -1, 84, -1, 85,
1772 -1, 86, -1, 120, -1, 121, -1, 122, -1, 123,
1773 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
1774 -1, 129, -1, 130, -1, 131, -1, 94, -1, 95,
1775 -1, 96, -1, 97, -1, 98, -1, 99, -1, 100,
1776 -1, 101, -1, 102, -1, 103, -1, 104, -1, 105,
1777 -1, 106, -1, 107, -1, 108, -1, 109, -1, 110,
1778 -1, 111, -1, 112, -1, 113, -1, 100, -1, 101,
Chris Lattner740e7092008-10-15 06:16:57 +00001779 -1, 102, -1, 103, -1, 26, -1, 27, -1, 19,
1780 -1, 22, -1, 24, -1, 179, -1, -1, 55, 159,
1781 4, 160, -1, -1, 179, 161, -1, -1, 7, 161,
1782 -1, 20, -1, 23, -1, 186, -1, -1, 184, 161,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001783 -1, 42, -1, 44, -1, 43, -1, 45, -1, 47,
1784 -1, 49, -1, 46, -1, 48, -1, 51, -1, -1,
1785 156, -1, 157, -1, 158, -1, -1, 46, -1, 48,
1786 -1, -1, 42, -1, 43, -1, 44, -1, 47, -1,
1787 -1, 44, -1, 42, -1, -1, 63, -1, 64, -1,
1788 65, -1, 66, -1, 67, -1, 62, 4, -1, 142,
1789 -1, 121, -1, 141, -1, 122, -1, 144, -1, 145,
1790 -1, 147, -1, 148, -1, 149, -1, 54, 4, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00001791 -1, 195, 194, -1, 144, -1, 142, -1, 141, -1,
1792 -1, 197, 196, -1, 143, -1, 146, -1, 144, -1,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001793 142, -1, 141, -1, 150, -1, 151, -1, 154, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00001794 155, -1, 153, -1, -1, 199, 198, -1, -1, 152,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001795 22, -1, -1, 54, 4, -1, -1, 162, 54, 4,
Chris Lattner740e7092008-10-15 06:16:57 +00001796 -1, 34, 22, -1, -1, 203, -1, -1, 162, 206,
1797 205, -1, 203, -1, 54, 4, -1, 11, -1, 12,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001798 -1, 13, -1, 16, -1, 15, -1, 14, -1, 17,
Chris Lattner740e7092008-10-15 06:16:57 +00001799 -1, 50, -1, 207, -1, 208, 181, 163, -1, 242,
1800 -1, 164, 4, -1, 208, 159, 212, 160, 199, -1,
1801 10, 159, 212, 160, 199, -1, 165, 4, 166, 208,
1802 167, -1, 168, 4, 166, 208, 169, -1, 170, 213,
1803 171, -1, 170, 171, -1, 168, 170, 213, 171, 169,
1804 -1, 168, 170, 171, 169, -1, 208, 195, -1, 208,
1805 -1, 10, -1, 209, -1, 211, 162, 209, -1, 211,
1806 -1, 211, 162, 39, -1, 39, -1, -1, 208, -1,
1807 213, 162, 208, -1, 208, 165, 216, 167, -1, 208,
1808 165, 167, -1, 208, 172, 22, -1, 208, 168, 216,
1809 169, -1, 208, 170, 216, 171, -1, 208, 170, 171,
1810 -1, 208, 168, 170, 216, 171, 169, -1, 208, 168,
1811 170, 171, 169, -1, 208, 40, -1, 208, 41, -1,
1812 208, 242, -1, 208, 215, -1, 208, 25, -1, 208,
1813 3, -1, 208, 5, -1, 208, 4, -1, 208, 6,
1814 -1, 208, 26, -1, 208, 27, -1, 208, 9, -1,
1815 176, 159, 214, 38, 208, 160, -1, 119, 159, 214,
1816 254, 160, -1, 133, 159, 214, 162, 214, 162, 214,
1817 160, -1, 174, 159, 214, 162, 214, 160, -1, 175,
1818 159, 214, 162, 214, 160, -1, 90, 177, 159, 214,
1819 162, 214, 160, -1, 91, 178, 159, 214, 162, 214,
1820 160, -1, 92, 177, 159, 214, 162, 214, 160, -1,
1821 93, 178, 159, 214, 162, 214, 160, -1, 135, 159,
1822 214, 162, 214, 160, -1, 136, 159, 214, 162, 214,
1823 162, 214, 160, -1, 137, 159, 214, 162, 214, 162,
1824 214, 160, -1, 139, 159, 214, 255, 160, -1, 140,
1825 159, 214, 162, 214, 255, 160, -1, 216, 162, 214,
1826 -1, 214, -1, 32, -1, 33, -1, 37, -1, -1,
1827 210, 242, -1, 125, 159, 219, 38, 208, 160, -1,
1828 221, -1, -1, 222, -1, 221, 222, -1, -1, 31,
1829 223, 238, -1, -1, 30, 224, 239, -1, 60, 59,
1830 228, -1, 182, 18, 208, -1, 182, 18, 10, -1,
1831 -1, 185, 189, 218, 217, 214, 181, 225, 205, -1,
1832 -1, 185, 187, 189, 218, 217, 214, 181, 226, 205,
1833 -1, -1, 185, 188, 189, 218, 217, 208, 181, 227,
1834 205, -1, 185, 189, 35, 192, 219, -1, 52, 229,
1835 -1, 56, 161, 230, -1, 22, -1, 53, 161, 22,
1836 -1, 68, 161, 22, -1, 165, 231, 167, -1, 231,
1837 162, 22, -1, 22, -1, -1, 232, 162, 208, 195,
1838 180, -1, 208, 195, 180, -1, 232, -1, 232, 162,
1839 39, -1, 39, -1, -1, 193, 197, 210, 184, 159,
1840 233, 160, 199, 204, 201, 200, -1, 28, -1, 170,
1841 -1, 191, 189, 234, 235, -1, 29, -1, 171, -1,
1842 246, 237, -1, 190, 189, 234, -1, -1, 61, -1,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001843 3, -1, 4, -1, 5, -1, 6, -1, 9, -1,
1844 26, -1, 27, -1, 40, -1, 41, -1, 25, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00001845 168, 216, 169, -1, 165, 216, 167, -1, 165, 167,
1846 -1, 172, 22, -1, 170, 216, 171, -1, 170, 171,
1847 -1, 168, 170, 216, 171, 169, -1, 168, 170, 171,
1848 169, -1, 215, -1, 59, 240, 22, 162, 22, -1,
1849 7, -1, 8, -1, 179, -1, 184, -1, 242, -1,
1850 241, -1, 208, 243, -1, 244, -1, 245, 162, 244,
1851 -1, 246, 247, -1, 236, 247, -1, 248, 182, 249,
1852 -1, 248, 183, 249, -1, 248, 251, -1, -1, 21,
1853 -1, 69, 245, -1, 69, 10, -1, 70, 17, 243,
1854 -1, 70, 11, 243, 162, 17, 243, 162, 17, 243,
1855 -1, 71, 11, 243, 162, 17, 243, 165, 250, 167,
1856 -1, 71, 11, 243, 162, 17, 243, 165, 167, -1,
1857 72, 193, 197, 210, 243, 159, 253, 160, 199, 38,
1858 17, 243, 73, 17, 243, -1, 73, -1, 74, -1,
1859 250, 11, 241, 162, 17, 243, -1, 11, 241, 162,
1860 17, 243, -1, 182, 257, -1, 183, 257, -1, 208,
1861 165, 243, 162, 243, 167, -1, 252, 162, 165, 243,
1862 162, 243, 167, -1, 208, 195, 243, 195, -1, 17,
1863 195, 243, 195, -1, 253, 162, 208, 195, 243, 195,
1864 -1, 253, 162, 17, 195, 243, 195, -1, -1, -1,
1865 254, 162, 244, -1, 162, 4, -1, 255, 162, 4,
1866 -1, 58, 57, -1, 57, -1, 174, 208, 243, 162,
1867 243, -1, 175, 208, 243, 162, 243, -1, 90, 177,
1868 208, 243, 162, 243, -1, 91, 178, 208, 243, 162,
1869 243, -1, 92, 177, 208, 243, 162, 243, -1, 93,
1870 178, 208, 243, 162, 243, -1, 176, 244, 38, 208,
1871 -1, 133, 244, 162, 244, 162, 244, -1, 134, 244,
1872 162, 208, -1, 135, 244, 162, 244, -1, 136, 244,
1873 162, 244, 162, 244, -1, 137, 244, 162, 244, 162,
1874 244, -1, 132, 252, -1, 256, 193, 197, 210, 243,
1875 159, 253, 160, 199, -1, 259, -1, 36, -1, -1,
1876 114, 208, 202, -1, 114, 208, 162, 11, 243, 202,
1877 -1, 115, 208, 202, -1, 115, 208, 162, 11, 243,
1878 202, -1, 116, 244, -1, 258, 117, 208, 243, 202,
1879 -1, 258, 118, 244, 162, 208, 243, 202, -1, 138,
1880 208, 243, 162, 4, -1, 119, 208, 243, 254, -1,
1881 139, 208, 243, 255, -1, 140, 208, 243, 162, 208,
1882 243, 255, -1
Dan Gohmanf4423b12008-04-19 00:24:39 +00001883};
1884
1885/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1886static const yytype_uint16 yyrline[] =
1887{
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001888 0, 1144, 1144, 1144, 1144, 1144, 1144, 1144, 1144, 1144,
1889 1144, 1145, 1145, 1145, 1145, 1145, 1145, 1146, 1146, 1146,
1890 1146, 1146, 1146, 1147, 1147, 1147, 1147, 1147, 1147, 1150,
1891 1150, 1151, 1151, 1152, 1152, 1153, 1153, 1154, 1154, 1158,
1892 1158, 1159, 1159, 1160, 1160, 1161, 1161, 1162, 1162, 1163,
1893 1163, 1164, 1164, 1165, 1166, 1169, 1169, 1169, 1170, 1170,
1894 1172, 1173, 1177, 1181, 1186, 1192, 1192, 1194, 1195, 1200,
1895 1206, 1207, 1208, 1209, 1210, 1211, 1215, 1216, 1217, 1221,
1896 1222, 1223, 1224, 1228, 1229, 1230, 1234, 1235, 1236, 1237,
1897 1238, 1242, 1243, 1244, 1247, 1248, 1249, 1250, 1251, 1252,
1898 1253, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268,
1899 1269, 1273, 1274, 1279, 1280, 1281, 1284, 1285, 1291, 1292,
1900 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1303, 1304,
1901 1310, 1311, 1318, 1319, 1325, 1326, 1335, 1343, 1344, 1349,
1902 1350, 1351, 1356, 1369, 1369, 1369, 1369, 1369, 1369, 1369,
1903 1372, 1376, 1380, 1387, 1392, 1400, 1435, 1466, 1471, 1481,
1904 1491, 1495, 1505, 1512, 1521, 1528, 1533, 1538, 1545, 1546,
1905 1553, 1560, 1568, 1574, 1586, 1614, 1630, 1657, 1685, 1711,
1906 1731, 1757, 1777, 1789, 1796, 1862, 1872, 1882, 1893, 1906,
1907 1917, 1931, 1938, 1945, 1963, 1975, 1996, 2004, 2010, 2021,
1908 2026, 2031, 2036, 2041, 2047, 2053, 2059, 2067, 2078, 2082,
1909 2090, 2090, 2093, 2093, 2096, 2108, 2129, 2134, 2142, 2143,
1910 2147, 2147, 2151, 2151, 2154, 2157, 2181, 2193, 2192, 2204,
1911 2203, 2213, 2212, 2223, 2263, 2266, 2272, 2282, 2286, 2291,
1912 2293, 2298, 2303, 2312, 2322, 2333, 2337, 2346, 2355, 2360,
1913 2509, 2509, 2511, 2520, 2520, 2522, 2527, 2539, 2543, 2548,
1914 2552, 2556, 2561, 2566, 2570, 2574, 2578, 2582, 2586, 2590,
1915 2612, 2634, 2640, 2653, 2665, 2670, 2682, 2688, 2692, 2702,
1916 2706, 2710, 2715, 2722, 2722, 2728, 2737, 2742, 2747, 2751,
1917 2760, 2769, 2782, 2791, 2795, 2803, 2823, 2827, 2832, 2843,
1918 2862, 2871, 2975, 2979, 2986, 2997, 3010, 3019, 3032, 3043,
1919 3053, 3064, 3072, 3082, 3089, 3092, 3093, 3101, 3107, 3116,
1920 3120, 3125, 3141, 3158, 3170, 3182, 3196, 3210, 3222, 3243,
1921 3250, 3256, 3262, 3268, 3283, 3393, 3398, 3402, 3409, 3416,
1922 3426, 3433, 3443, 3451, 3465, 3482, 3496, 3511, 3526
Dan Gohmanf4423b12008-04-19 00:24:39 +00001923};
1924#endif
1925
1926#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1927/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1928 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1929static const char *const yytname[] =
1930{
1931 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1932 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1933 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1934 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1935 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1936 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1937 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1938 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001939 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "COMMON", "OPAQUE",
Dan Gohmanf4423b12008-04-19 00:24:39 +00001940 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1941 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1942 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Dale Johannesendfe8c842008-09-26 19:32:34 +00001943 "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
1944 "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
1945 "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "VICMP",
1946 "VFCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1947 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1948 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1949 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1950 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1951 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1952 "GETRESULT", "EXTRACTVALUE", "INSERTVALUE", "SIGNEXT", "ZEROEXT",
1953 "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST",
Devang Patel652203f2008-09-29 20:49:50 +00001954 "READNONE", "READONLY", "GC", "OPTSIZE", "NOINLINE", "ALWAYSINLINE",
1955 "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'",
1956 "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'",
1957 "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates",
Chris Lattner740e7092008-10-15 06:16:57 +00001958 "FPredicates", "LocalName", "OptLocalName", "OptAddrSpace",
Chris Lattnerf9078f92008-10-15 06:03:48 +00001959 "OptLocalAssign", "LocalNumber", "GlobalName", "OptGlobalAssign",
1960 "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1961 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1962 "AliasLinkage", "OptCallingConv", "Attribute", "OptAttributes",
1963 "RetAttr", "OptRetAttrs", "FuncAttr", "OptFuncAttrs", "OptGC",
1964 "OptAlign", "OptCAlign", "SectionString", "OptSection",
Devang Patel652203f2008-09-29 20:49:50 +00001965 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1966 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1967 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "ThreadLocal",
1968 "AliaseeRef", "Module", "DefinitionList", "Definition", "@1", "@2", "@3",
1969 "@4", "@5", "AsmBlock", "TargetDefinition", "LibrariesDefinition",
1970 "LibList", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1971 "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect",
1972 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1973 "ReturnedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1974 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ParamList",
1975 "IndexList", "ConstantIndexList", "OptTailCall", "InstVal",
Chris Lattner15bd0952008-08-29 17:20:18 +00001976 "OptVolatile", "MemoryInst", 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00001977};
1978#endif
1979
1980# ifdef YYPRINT
1981/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1982 token YYLEX-NUM. */
1983static const yytype_uint16 yytoknum[] =
1984{
1985 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1986 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1987 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1988 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1989 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1990 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1991 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1992 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1993 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1994 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1995 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1996 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1997 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1998 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1999 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Devang Patel652203f2008-09-29 20:49:50 +00002000 405, 406, 407, 408, 409, 410, 411, 412, 413, 40,
2001 41, 61, 44, 42, 92, 91, 120, 93, 60, 62,
2002 123, 125, 99
Dan Gohmanf4423b12008-04-19 00:24:39 +00002003};
2004# endif
2005
2006/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002007static const yytype_uint16 yyr1[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002008{
Devang Patel652203f2008-09-29 20:49:50 +00002009 0, 173, 174, 174, 174, 174, 174, 174, 174, 174,
2010 174, 175, 175, 175, 175, 175, 175, 176, 176, 176,
2011 176, 176, 176, 176, 176, 176, 176, 176, 176, 177,
2012 177, 177, 177, 177, 177, 177, 177, 177, 177, 178,
2013 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
Chris Lattner740e7092008-10-15 06:16:57 +00002014 178, 178, 178, 178, 178, 179, 179, 179, 180, 180,
2015 181, 181, 182, 182, 183, 184, 184, 185, 185, 186,
2016 187, 187, 187, 187, 187, 187, 188, 188, 188, 189,
2017 189, 189, 189, 190, 190, 190, 191, 191, 191, 191,
2018 191, 192, 192, 192, 193, 193, 193, 193, 193, 193,
2019 193, 194, 194, 194, 194, 194, 194, 194, 194, 194,
2020 194, 195, 195, 196, 196, 196, 197, 197, 198, 198,
2021 198, 198, 198, 198, 198, 198, 198, 198, 199, 199,
2022 200, 200, 201, 201, 202, 202, 203, 204, 204, 205,
2023 205, 206, 206, 207, 207, 207, 207, 207, 207, 207,
2024 208, 208, 208, 208, 208, 208, 208, 208, 208, 208,
2025 208, 208, 208, 209, 210, 210, 211, 211, 212, 212,
2026 212, 212, 213, 213, 214, 214, 214, 214, 214, 214,
2027 214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
2028 214, 214, 214, 214, 215, 215, 215, 215, 215, 215,
2029 215, 215, 215, 215, 215, 215, 215, 215, 216, 216,
2030 217, 217, 218, 218, 219, 219, 220, 220, 221, 221,
2031 223, 222, 224, 222, 222, 222, 222, 225, 222, 226,
2032 222, 227, 222, 222, 222, 222, 228, 229, 229, 230,
2033 231, 231, 231, 232, 232, 233, 233, 233, 233, 234,
2034 235, 235, 236, 237, 237, 238, 239, 240, 240, 241,
2035 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2036 241, 241, 241, 241, 241, 241, 241, 241, 241, 242,
2037 242, 242, 242, 243, 243, 244, 245, 245, 246, 246,
2038 247, 247, 248, 248, 248, 249, 249, 249, 249, 249,
2039 249, 249, 249, 249, 250, 250, 251, 251, 252, 252,
2040 253, 253, 253, 253, 253, 254, 254, 255, 255, 256,
2041 256, 257, 257, 257, 257, 257, 257, 257, 257, 257,
2042 257, 257, 257, 257, 257, 257, 258, 258, 259, 259,
2043 259, 259, 259, 259, 259, 259, 259, 259, 259
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,
Chris Lattner740e7092008-10-15 06:16:57 +00002054 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
2055 4, 0, 2, 0, 2, 1, 1, 1, 0, 2,
2056 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
2057 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
2058 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
2059 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2060 2, 0, 2, 1, 1, 1, 0, 2, 1, 1,
2061 1, 1, 1, 1, 1, 1, 1, 1, 0, 2,
2062 0, 2, 0, 2, 0, 3, 2, 0, 1, 0,
2063 3, 1, 2, 1, 1, 1, 1, 1, 1, 1,
2064 1, 1, 3, 1, 2, 5, 5, 5, 5, 3,
2065 2, 5, 4, 2, 1, 1, 1, 3, 1, 3,
2066 1, 0, 1, 3, 4, 3, 3, 4, 4, 3,
2067 6, 5, 2, 2, 2, 2, 2, 2, 2, 2,
2068 2, 2, 2, 2, 6, 5, 8, 6, 6, 7,
2069 7, 7, 7, 6, 8, 8, 5, 7, 3, 1,
2070 1, 1, 1, 0, 2, 6, 1, 0, 1, 2,
2071 0, 3, 0, 3, 3, 3, 3, 0, 8, 0,
2072 9, 0, 9, 5, 2, 3, 1, 3, 3, 3,
2073 3, 1, 0, 5, 3, 1, 3, 1, 0, 11,
2074 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
2075 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
2076 3, 2, 2, 3, 2, 5, 4, 1, 5, 1,
2077 1, 1, 1, 1, 1, 2, 1, 3, 2, 2,
2078 3, 3, 2, 0, 1, 2, 2, 3, 9, 9,
2079 8, 15, 1, 1, 6, 5, 2, 2, 6, 7,
2080 4, 4, 6, 6, 0, 0, 3, 2, 3, 2,
2081 1, 5, 5, 6, 6, 6, 6, 4, 6, 4,
2082 4, 6, 6, 2, 9, 1, 1, 0, 3, 6,
2083 3, 6, 2, 5, 7, 5, 4, 4, 7
Dan Gohmanf4423b12008-04-19 00:24:39 +00002084};
2085
2086/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2087 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2088 means the default is an error. */
2089static const yytype_uint16 yydefact[] =
2090{
Chris Lattner740e7092008-10-15 06:16:57 +00002091 68, 55, 65, 56, 66, 57, 222, 220, 0, 0,
2092 0, 0, 0, 0, 79, 67, 0, 68, 218, 83,
2093 86, 0, 0, 234, 0, 0, 62, 0, 69, 70,
2094 72, 71, 73, 76, 74, 77, 75, 78, 80, 81,
2095 82, 79, 79, 213, 1, 219, 84, 85, 79, 223,
2096 87, 88, 89, 90, 79, 293, 221, 293, 0, 0,
2097 242, 235, 236, 224, 279, 280, 226, 143, 144, 145,
2098 148, 147, 146, 149, 150, 0, 0, 0, 0, 281,
2099 282, 151, 225, 153, 213, 213, 91, 212, 0, 94,
2100 94, 294, 289, 63, 253, 254, 255, 288, 237, 238,
2101 241, 0, 171, 154, 0, 0, 0, 0, 160, 172,
2102 0, 0, 171, 0, 0, 0, 93, 92, 0, 210,
2103 211, 0, 0, 95, 96, 97, 98, 99, 116, 256,
2104 0, 0, 337, 337, 292, 0, 239, 170, 111, 166,
2105 168, 0, 0, 0, 0, 0, 0, 159, 0, 0,
2106 152, 0, 0, 165, 0, 164, 0, 233, 61, 61,
2107 100, 0, 250, 251, 252, 64, 336, 320, 0, 0,
2108 0, 0, 94, 302, 303, 2, 3, 4, 5, 6,
2109 7, 8, 9, 10, 14, 15, 16, 11, 12, 13,
2110 0, 0, 0, 0, 0, 0, 0, 0, 17, 18,
2111 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
Nate Begemanac80ade2008-05-12 19:01:56 +00002112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002113 0, 0, 290, 94, 306, 0, 335, 291, 307, 240,
2114 163, 0, 128, 61, 61, 162, 0, 173, 0, 128,
2115 61, 61, 0, 214, 187, 189, 188, 190, 193, 186,
2116 191, 192, 182, 183, 0, 0, 0, 0, 0, 0,
2117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2118 0, 0, 185, 184, 227, 115, 114, 113, 117, 0,
2119 319, 296, 61, 286, 295, 0, 0, 0, 116, 29,
2120 30, 31, 32, 33, 34, 35, 36, 37, 38, 0,
2121 53, 54, 49, 50, 51, 52, 39, 40, 41, 42,
2122 43, 44, 45, 46, 47, 48, 0, 0, 0, 134,
2123 134, 342, 61, 61, 333, 0, 0, 0, 0, 0,
2124 61, 61, 61, 61, 61, 0, 116, 0, 0, 0,
2125 102, 104, 103, 101, 105, 106, 107, 108, 109, 112,
2126 169, 167, 156, 157, 158, 161, 60, 155, 229, 231,
2127 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2128 0, 0, 175, 209, 0, 0, 0, 179, 0, 176,
2129 0, 0, 0, 139, 0, 259, 260, 261, 262, 263,
2130 268, 264, 265, 266, 267, 257, 0, 0, 0, 0,
2131 277, 284, 283, 285, 0, 0, 297, 0, 0, 61,
2132 61, 61, 61, 0, 338, 0, 340, 315, 0, 0,
2133 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2134 0, 0, 61, 0, 110, 122, 121, 118, 120, 119,
2135 123, 124, 127, 125, 126, 129, 139, 139, 0, 0,
2136 0, 0, 0, 315, 0, 0, 0, 0, 0, 0,
2137 0, 174, 160, 172, 0, 177, 178, 0, 0, 0,
2138 0, 228, 248, 258, 0, 271, 0, 0, 0, 274,
2139 0, 272, 287, 0, 0, 0, 0, 0, 0, 0,
2140 0, 0, 0, 346, 0, 0, 0, 329, 330, 0,
2141 0, 0, 0, 347, 0, 0, 0, 327, 0, 134,
2142 0, 230, 232, 61, 0, 0, 0, 0, 0, 0,
2143 0, 0, 0, 0, 0, 208, 181, 0, 0, 0,
2144 0, 0, 0, 141, 139, 247, 111, 245, 0, 0,
2145 270, 160, 0, 269, 273, 0, 0, 0, 0, 0,
2146 0, 0, 134, 135, 134, 0, 0, 0, 0, 0,
2147 0, 345, 317, 0, 61, 321, 322, 0, 0, 343,
2148 61, 215, 0, 0, 0, 0, 195, 0, 0, 0,
2149 0, 206, 0, 180, 0, 0, 61, 136, 142, 140,
2150 59, 0, 128, 0, 276, 0, 0, 0, 314, 323,
2151 324, 325, 326, 339, 341, 316, 0, 0, 328, 331,
2152 332, 318, 0, 314, 134, 0, 0, 0, 0, 0,
2153 203, 0, 0, 0, 197, 198, 194, 58, 244, 246,
2154 111, 137, 278, 275, 0, 0, 111, 111, 0, 308,
2155 0, 348, 0, 344, 199, 200, 201, 202, 0, 0,
2156 0, 207, 59, 138, 132, 0, 0, 300, 0, 0,
2157 0, 128, 0, 309, 128, 196, 204, 205, 243, 0,
2158 130, 298, 0, 0, 299, 102, 104, 111, 111, 0,
2159 111, 111, 334, 133, 0, 249, 0, 0, 311, 310,
2160 0, 0, 0, 131, 0, 0, 0, 111, 111, 305,
2161 0, 0, 313, 312, 304, 0, 0, 301
Dan Gohmanf4423b12008-04-19 00:24:39 +00002162};
2163
2164/* YYDEFGOTO[NTERM-NUM]. */
2165static const yytype_int16 yydefgoto[] =
2166{
Chris Lattner740e7092008-10-15 06:16:57 +00002167 -1, 269, 270, 271, 299, 316, 79, 628, 113, 12,
2168 133, 80, 14, 15, 41, 42, 43, 48, 54, 118,
2169 128, 349, 230, 278, 161, 445, 352, 685, 670, 414,
2170 533, 654, 471, 534, 81, 158, 139, 156, 140, 141,
2171 110, 373, 400, 374, 121, 88, 157, 16, 17, 18,
2172 20, 19, 383, 446, 447, 63, 23, 61, 101, 537,
2173 538, 129, 164, 55, 96, 56, 49, 474, 401, 83,
2174 403, 283, 284, 57, 92, 93, 222, 658, 134, 324,
2175 638, 493, 503, 223, 224, 225, 226
Dan Gohmanf4423b12008-04-19 00:24:39 +00002176};
2177
2178/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2179 STATE-NUM. */
Chris Lattner740e7092008-10-15 06:16:57 +00002180#define YYPACT_NINF -624
Dan Gohmanf4423b12008-04-19 00:24:39 +00002181static const yytype_int16 yypact[] =
2182{
Chris Lattner740e7092008-10-15 06:16:57 +00002183 815, -624, -624, -624, -624, -624, -624, -624, 14, -114,
2184 16, -73, 78, -31, 299, -624, 163, 2187, -624, 164,
2185 80, 19, 22, -624, 2, 179, -624, 1912, -624, -624,
2186 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2187 -624, 68, 68, 201, -624, -624, -624, -624, 68, -624,
2188 -624, -624, -624, -624, 68, 200, -624, 5, 215, 222,
2189 225, -624, -624, -624, -624, -624, 117, -624, -624, -624,
2190 -624, -624, -624, -624, -624, 264, 277, 7, 49, -624,
2191 -624, -624, -12, -624, 252, 252, 198, -624, 79, 231,
2192 231, -624, -624, 83, -624, -624, -624, -624, -624, -624,
2193 -624, -21, 649, -624, 138, 149, 627, 117, -624, -12,
2194 -120, 159, 649, 158, 79, 79, -624, -624, 1557, -624,
2195 -624, 2012, 320, -624, -624, -624, -624, -624, -624, -624,
2196 -13, 173, 2237, 2237, -624, 313, -624, -624, -12, -624,
2197 174, 177, 2012, 2012, 169, -118, 2012, -624, 336, 191,
2198 -624, 2012, 2012, 117, 193, -12, 226, -624, 1296, 308,
2199 -624, 1516, -624, -624, -624, -624, -624, -624, 307, 2031,
2200 108, 357, 231, -624, -624, -624, -624, -624, -624, -624,
2201 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2202 454, 958, 454, 958, 2012, 2012, 2012, 2012, -624, -624,
2203 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2204 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2205 2012, 2012, -624, 231, -624, 55, -624, -624, -624, -624,
2206 161, 1748, -624, -23, -41, -624, 203, -12, 214, -624,
2207 308, -20, 1557, -624, -624, -624, -624, -624, -624, -624,
2208 -624, -624, -624, -624, 454, 958, 454, 958, 216, 217,
2209 218, 220, 221, 224, 227, 1789, 2076, 732, 351, 228,
2210 229, 230, -624, -624, -624, -624, -624, -624, -624, 109,
2211 -624, 117, 956, -624, 219, 1466, 1466, 1466, -624, -624,
2212 -624, -624, -624, -624, -624, -624, -624, -624, -624, 2012,
2213 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2214 -624, -624, -624, -624, -624, -624, 2012, 2012, 2012, -10,
2215 3, -624, 956, -17, 223, 237, 238, 239, 240, 241,
2216 956, 956, 956, 956, 956, 352, -624, 2012, 2012, 387,
2217 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2218 -624, -624, 539, -624, -624, -624, -624, 539, -624, 158,
2219 354, 234, 248, 249, 250, 2012, 2012, 2012, 2012, 2012,
2220 2012, 2012, -624, -624, 42, 1006, -121, -624, -116, -624,
2221 2012, 2012, 2012, 253, 251, -624, -624, -624, -624, -624,
2222 -624, -624, -624, -624, -624, 353, 1807, 2094, 1175, 390,
2223 -624, -624, -624, -624, 2012, 255, -624, 256, 1516, 956,
2224 956, 956, 956, 20, -624, 29, -624, -624, 1466, 254,
2225 2012, 2012, 2012, 2012, 2012, 258, 259, 261, 262, 263,
2226 2012, 1516, 956, 266, -624, -624, -624, -624, -624, -624,
2227 -624, -624, -624, -624, -624, -624, 253, 253, 2012, 2012,
2228 2012, 2012, 2012, -624, 269, 270, 272, 273, 259, 274,
2229 2012, -624, 268, 1126, -84, -624, -624, 280, 281, 406,
2230 -5, -624, 1830, -624, 423, -624, 61, 1345, -56, -624,
2231 -77, -624, -624, 430, 431, 1466, 288, 290, 291, 292,
2232 1466, 455, 1466, 296, 298, 1466, 300, -12, -624, 301,
2233 302, 457, 461, 306, 2012, 1466, 1466, -12, 1466, 311,
2234 2012, -624, -624, -1, 312, 314, 317, 319, 101, 2012,
2235 2012, 2012, 2012, 112, 2012, -624, -624, 318, 2012, 2012,
2236 2012, 453, 478, -624, 253, -624, -12, 321, 326, 327,
2237 -624, 323, -67, -624, -624, 1466, 1466, 329, 1466, 1466,
2238 1466, 1466, 311, -624, 311, 2012, 1466, 328, 2012, 2012,
2239 2012, -624, -624, 489, 956, -624, -624, 335, 441, -624,
2240 956, -624, 2012, 2012, 2012, 2012, -624, 334, 337, 339,
2241 340, -624, 259, -624, 343, 345, 15, -624, -624, -624,
2242 178, 1848, -624, 484, -624, 338, 350, 349, 2117, -624,
2243 -624, -624, -624, -624, -624, -624, 348, 1466, -624, -624,
2244 -624, -624, 259, 2117, 311, 356, 359, 360, 361, 2012,
2245 -624, 2012, 2012, 115, -624, -624, -624, -624, -624, -624,
2246 -12, 116, -624, -624, 505, -7, 59, -12, 118, -624,
2247 358, 306, 124, -624, -624, -624, -624, -624, 363, 364,
2248 366, -624, 178, -624, 473, 1466, 1614, -624, -6, 802,
2249 802, -624, 2135, -624, -624, -624, -624, -624, -624, 526,
2250 379, -624, 374, 1614, -624, 378, 380, -624, -624, 442,
2251 59, -12, 539, -624, 516, -624, 523, 396, 161, 161,
2252 524, 802, 802, -624, 1466, 525, 1466, -624, -624, -624,
2253 1466, 486, 161, 161, -624, 543, 1466, -624
Dan Gohmanf4423b12008-04-19 00:24:39 +00002254};
2255
2256/* YYPGOTO[NTERM-NUM]. */
2257static const yytype_int16 yypgoto[] =
2258{
Chris Lattner740e7092008-10-15 06:16:57 +00002259 -624, 132, 155, 181, -165, -154, 0, -86, -143, 474,
2260 -624, 6, -624, -624, -624, -624, 67, -624, -624, -624,
2261 -142, -624, -499, -624, -252, -624, -231, -624, -624, -313,
2262 -63, -624, -434, -624, -624, -26, 342, -152, -624, 458,
2263 463, -11, -156, -242, 202, 244, 332, -624, -624, 554,
2264 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2265 -624, 485, -624, -624, -624, -624, -624, -624, -623, -79,
2266 213, -193, -624, -624, 520, -624, 445, -624, -624, -624,
2267 -34, 129, -448, -624, 456, -624, -624
Dan Gohmanf4423b12008-04-19 00:24:39 +00002268};
2269
2270/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2271 positive, shift that token. If negative, reduce the rule which
2272 number is the opposite. If zero, do what YYDEFACT says.
2273 If YYTABLE_NINF, syntax error. */
Chris Lattner740e7092008-10-15 06:16:57 +00002274#define YYTABLE_NINF -218
Dan Gohmanf4423b12008-04-19 00:24:39 +00002275static const yytype_int16 yytable[] =
2276{
Chris Lattner740e7092008-10-15 06:16:57 +00002277 11, 82, 272, 321, 656, 673, 13, 416, 357, 279,
2278 523, 105, 511, 512, 111, 162, 274, 11, 325, 326,
2279 327, 328, 329, 13, 376, 378, 91, 317, 335, 531,
2280 288, 490, 111, 672, 94, 111, 408, 590, 111, 318,
2281 492, 460, 146, 111, 146, 111, 460, 24, 465, 532,
2282 687, 147, 109, 236, 111, 466, 64, 65, 111, 107,
2283 67, 68, 69, 70, 71, 72, 73, 21, 1, 2,
2284 111, 3, 4, 5, 491, 25, 138, 243, 460, 273,
2285 109, 336, 22, 491, 431, 460, 138, 527, 26, 361,
2286 131, 363, 155, 11, 544, 460, 27, 358, 359, 74,
2287 589, 362, 1, 364, 595, 3, 460, 5, 84, 85,
2288 159, 119, 120, 543, -149, 89, 233, 234, 112, 285,
2289 237, 90, 50, 51, 52, 286, 241, 53, 354, 2,
2290 28, 652, 4, 464, 623, 155, 112, 659, 660, 112,
2291 240, 135, 112, 282, 353, 433, 136, 112, 418, 112,
2292 531, -61, 413, -61, 476, 478, 480, 163, 112, 571,
2293 657, 674, 112, 44, 641, 415, -61, 60, 319, 320,
2294 282, 322, 337, 338, 112, 626, 95, 106, 688, 689,
2295 58, 691, 692, 59, 323, 282, 282, 282, 282, 282,
2296 330, 331, 332, 333, 334, 282, 569, 1, 702, 703,
2297 3, 62, 5, 402, 460, 138, 402, 402, 402, 461,
2298 46, 482, 47, 75, 76, 339, 155, 77, -149, 78,
2299 108, 91, -149, 460, 38, 39, 40, 496, 540, 498,
2300 499, 500, 339, 64, 65, 542, 86, 98, 87, 603,
2301 116, 604, 117, 402, 99, 1, 2, 100, 3, 4,
2302 5, 402, 402, 402, 402, 402, 485, 435, 436, 437,
2303 438, 576, 439, 555, 219, 219, 440, 441, 103, 442,
2304 443, 444, 581, 409, 563, 651, 102, 563, 661, 508,
2305 662, 104, 340, 341, 664, 384, 662, 220, 220, 87,
2306 410, 411, 412, 122, 123, 124, 125, 126, 127, 340,
2307 341, 643, 342, 343, 142, 344, 345, 272, 346, 347,
2308 348, 432, 282, 221, 221, 143, 151, 152, 148, 342,
2309 343, 150, 344, 345, 160, 346, 347, 348, 114, 115,
2310 402, 402, 402, 402, 165, 229, 231, 232, 235, 402,
2311 238, 29, 30, 31, 32, 33, 34, 35, 36, 463,
2312 37, 239, 242, 402, 453, 454, 455, 456, 457, 458,
2313 459, 631, 605, 111, 280, 608, 609, 610, 287, 467,
2314 468, 469, 355, 379, 356, 365, 366, 367, 282, 368,
2315 369, 404, 155, 370, 273, 419, 371, 380, 381, 382,
2316 430, 434, 448, 449, 282, 497, 282, 282, 282, 420,
2317 421, 422, 423, 424, 507, 155, 402, 450, 451, 452,
2318 472, 402, 481, 402, 473, 470, 402, 483, 484, 495,
2319 501, 502, 513, 504, 505, 506, 402, 402, 510, 402,
2320 679, 519, 520, 682, 521, 522, 524, 526, 514, 515,
2321 516, 517, 528, 529, 530, 539, 536, 545, 546, 525,
2322 548, 463, 549, 550, 551, 38, 39, 40, 555, 553,
2323 556, 561, 558, 559, 560, 562, 402, 402, 563, 402,
2324 402, 402, 402, 568, 572, 587, 573, 402, 564, 574,
2325 690, 575, 588, 591, 570, 402, 592, 583, 598, 593,
2326 607, 402, 594, 611, 613, 491, 619, 620, 405, 406,
2327 407, 621, 622, 624, 586, 625, 632, 633, 577, 578,
2328 579, 580, 634, 582, 635, 639, 644, 584, 585, 645,
2329 646, 647, 655, 665, 666, 663, 667, 669, 402, 282,
2330 683, 684, 282, 282, 282, 417, 686, -18, 693, -19,
2331 694, 696, 700, 425, 426, 427, 428, 429, 289, 290,
2332 291, 292, 293, 294, 295, 296, 297, 298, 695, 705,
2333 706, 615, 616, 617, 618, 630, 668, 132, 653, 145,
2334 149, 45, 637, 351, 360, 130, 402, 97, 227, 642,
2335 402, 402, 518, 435, 436, 437, 438, 637, 439, 228,
2336 627, 0, 440, 441, 0, 442, 443, 444, 0, 0,
2337 0, 0, 0, 0, 0, 0, 0, 0, 648, 0,
2338 649, 650, 402, 402, 0, 402, 0, 402, 0, 0,
2339 0, 402, 486, 487, 488, 489, 0, 402, 0, 0,
2340 0, 494, 0, 0, 64, 65, 681, 107, 67, 68,
2341 69, 70, 71, 72, 73, 509, 1, 2, 0, 3,
2342 4, 5, 627, 0, 0, 0, 64, 65, 0, 107,
2343 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2344 0, 3, 4, 5, 0, 0, 0, 74, 0, 0,
2345 435, 436, 437, 438, 0, 439, 0, 0, 137, 440,
2346 441, 0, 442, 443, 444, 0, 0, 0, 547, 74,
2347 0, 0, 0, 552, 0, 554, 0, 0, 557, 0,
2348 0, 0, 0, 0, 0, 0, 0, 0, 565, 566,
2349 0, 567, 0, 0, 0, 0, 0, 0, 0, 0,
2350 0, 0, 0, 0, 0, 0, 0, 0, 0, 64,
2351 65, 0, 107, 67, 68, 69, 70, 71, 72, 73,
2352 0, 1, 2, 0, 3, 4, 5, 0, 596, 597,
2353 0, 599, 600, 601, 602, 0, 0, 0, 0, 606,
2354 0, 0, 0, 0, 0, 0, 0, 612, 0, 0,
2355 0, 0, 74, 614, 0, 0, 0, 0, 0, 0,
2356 0, 75, 76, 0, 0, 77, 0, 78, 144, 0,
2357 0, 0, 0, 0, 0, 385, 386, 387, 388, 64,
2358 65, 389, 0, 75, 76, -217, 0, 77, 0, 78,
2359 640, 1, 2, 0, 3, 4, 5, 390, 391, 392,
2360 0, 0, 0, -63, 1, 2, 0, 3, 4, 5,
2361 0, 0, 393, 394, 0, 6, 7, 0, 0, 0,
2362 0, 0, 0, 0, 0, 0, 339, 0, 0, 0,
2363 0, 395, 0, 0, 0, 0, 0, 8, 671, 0,
2364 0, 9, 677, 678, 0, 10, 0, 175, 176, 177,
2365 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2366 188, 189, 254, 255, 256, 257, 75, 76, 0, 0,
2367 77, 0, 78, 377, 697, 698, 0, 699, 0, 701,
2368 0, 0, 0, 704, 0, 0, 0, 0, 0, 707,
2369 0, 258, 198, 675, 676, 201, 202, 203, 204, 205,
2370 206, 207, 208, 209, 0, 259, 0, 260, 261, 262,
2371 0, 263, 264, 342, 343, 0, 344, 345, 0, 346,
2372 347, 348, 0, 0, 0, 0, 0, 0, 0, 385,
2373 386, 387, 388, 64, 65, 389, 0, 396, 0, 0,
2374 397, 0, 398, 0, 399, 1, 2, 0, 3, 4,
2375 5, 390, 391, 392, 300, 301, 0, 0, 0, 0,
2376 0, 0, 0, 0, 0, 0, 393, 394, 0, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002377 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002378 0, 111, 0, 64, 65, 395, 107, 67, 68, 69,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002379 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
Chris Lattner740e7092008-10-15 06:16:57 +00002380 5, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2381 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2382 0, 0, 0, 0, 0, 0, 74, 0, 302, 303,
2383 304, 305, 306, 307, 308, 309, 310, 311, 312, 313,
2384 314, 315, 0, 0, 0, 258, 198, 199, 200, 201,
2385 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2386 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002387 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002388 0, 0, 0, 0, 0, 112, 0, 0, 0, 0,
2389 0, 396, 0, 0, 397, 0, 398, 0, 399, 244,
2390 245, 246, 247, 64, 65, 248, 0, 0, 0, 0,
2391 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2392 5, 249, 250, 251, 0, 0, 0, 0, 0, 0,
2393 0, 0, 0, 0, 0, 0, 252, 253, 0, 0,
2394 75, 76, 0, 0, 77, 0, 78, 462, 0, 0,
2395 0, 111, 64, 65, 0, 107, 67, 68, 69, 70,
2396 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2397 0, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2398 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2399 0, 0, 0, 0, 0, 74, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002400 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002401 0, 0, 0, 0, 0, 258, 198, 199, 200, 201,
2402 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2403 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002404 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002405 0, 0, 0, 0, 0, 112, 0, 0, 0, -61,
2406 0, 265, 0, 0, 266, 0, 267, 0, 268, 244,
2407 245, 246, 247, 64, 65, 248, 0, 0, 0, 0,
2408 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2409 5, 249, 250, 251, 0, 0, 0, 0, 0, 0,
2410 0, 0, 0, 0, 0, 0, 252, 253, 0, 75,
2411 76, 0, 0, 77, 0, 78, 479, 0, 0, 0,
2412 0, 111, 64, 65, 0, 107, 67, 68, 69, 70,
2413 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2414 0, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2415 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2416 0, 0, 0, 0, 0, 74, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002417 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002418 0, 0, 0, 0, 0, 258, 198, 199, 200, 201,
2419 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2420 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
2421 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2422 0, 0, 0, 0, 0, 112, 0, 0, 0, 0,
2423 0, 265, 0, 0, 266, 0, 267, 0, 268, 385,
2424 386, 387, 388, 64, 65, 389, 0, 0, 0, 0,
2425 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2426 5, 390, 391, 392, 0, 0, 0, 0, 0, 0,
2427 0, 0, 0, 0, 0, 0, 393, 394, 0, 75,
2428 76, 0, 0, 77, 0, 78, 541, 0, 0, 0,
2429 0, 0, 0, 64, 65, 395, 153, 67, 68, 69,
2430 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
2431 5, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2432 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2433 0, 0, 0, 0, 64, 65, 74, 153, 67, 68,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002434 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
Chris Lattner740e7092008-10-15 06:16:57 +00002435 4, 5, 0, 0, 0, 258, 198, 199, 200, 201,
2436 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2437 0, 260, 261, 262, 0, 263, 264, 74, 0, 0,
2438 0, 0, 0, 0, 0, 0, 0, 385, 386, 387,
2439 388, 0, 0, 389, 0, 0, 0, 0, 0, 0,
2440 0, 396, 0, 0, 397, 0, 398, 0, 399, 390,
2441 391, 392, 0, 0, 0, 0, 0, 0, 0, 0,
2442 0, 0, 0, 0, 393, 394, 0, 275, 276, 0,
2443 277, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2444 0, 0, 0, 395, 0, 0, 0, 0, 0, 0,
2445 75, 76, 154, 0, 77, 0, 78, 0, 0, 175,
2446 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2447 186, 187, 188, 189, 254, 255, 256, 257, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002448 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002449 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002450 0, 0, 0, 258, 198, 199, 200, 201, 202, 203,
2451 204, 205, 206, 207, 208, 209, 0, 259, 0, 260,
2452 261, 262, 0, 263, 264, 64, 65, 0, 107, 67,
2453 68, 69, 70, 71, 72, 73, 0, 1, 2, 0,
2454 3, 4, 5, 0, 0, 0, 0, 0, 0, 396,
2455 0, 0, 397, 0, 398, 0, 399, 350, 0, 0,
2456 0, 0, 0, 0, 0, 0, 64, 65, 74, 107,
2457 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2458 0, 3, 4, 5, 64, 65, 0, 107, 67, 68,
2459 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
2460 4, 5, 0, 0, 0, 0, 0, 64, 65, 74,
2461 107, 67, 68, 69, 70, 71, 72, 73, 0, 1,
2462 2, 0, 3, 4, 5, 64, 65, 74, 107, 67,
2463 68, 69, 70, 71, 72, 73, 0, 1, 2, 535,
2464 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2465 74, 0, 0, 0, 0, 0, 0, 629, 0, 0,
2466 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002467 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002468 0, 0, 75, 76, 0, 0, 77, 0, 78, 64,
2469 65, 0, 66, 67, 68, 69, 70, 71, 72, 73,
2470 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2471 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2472 0, 0, 0, 75, 76, 0, 372, 77, 0, 78,
2473 0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
2474 0, 75, 76, 0, 475, 77, 0, 78, 0, 0,
2475 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2476 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2477 78, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2478 0, 0, 75, 76, 0, 0, 77, 0, 78, 64,
2479 65, 0, 107, 67, 68, 69, 70, 71, 72, 73,
2480 0, 1, 2, 0, 3, 4, 5, 0, 64, 65,
2481 0, 281, 67, 68, 69, 70, 71, 72, 73, 0,
2482 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2483 0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
2484 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2485 77, 74, 78, 64, 65, 0, 107, 67, 68, 69,
2486 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
2487 5, 64, 65, 0, 107, 67, 68, 69, 70, 71,
2488 72, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2489 0, 0, 0, 0, 64, 65, 74, 107, 67, 68,
2490 69, 70, 71, 72, 636, 0, 1, 2, 0, 3,
2491 4, 5, 64, 65, 74, 107, 67, 68, 69, 70,
2492 71, 72, 680, 0, 1, 2, 0, 3, 4, 5,
2493 0, 0, 0, 0, 0, 0, 0, 74, 0, 0,
2494 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2495 77, 0, 78, 0, 0, 74, 0, -216, 0, 0,
2496 0, 0, 0, 0, 0, 75, 76, 0, 0, 77,
2497 0, 78, 0, 0, 0, -63, 1, 2, 0, 3,
2498 4, 5, 0, 0, 0, 0, 0, 6, 7, 0,
2499 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2500 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
2501 75, 76, 0, 9, 77, 0, 375, 10, 0, 0,
2502 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2503 0, 0, 77, 0, 477, 0, 0, 0, 0, 0,
2504 0, 0, 0, 166, 0, 0, 0, 0, 0, 0,
2505 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
2506 0, 0, 0, 0, 167, 168, 0, 0, 0, 75,
2507 76, 0, 0, 77, 0, 78, 169, 170, 171, 172,
2508 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002509 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
Chris Lattner740e7092008-10-15 06:16:57 +00002510 193, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2511 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2512 0, 194, 195, 196, 0, 0, 197, 198, 199, 200,
2513 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
2514 211, 212, 213, 214, 215, 216, 217, 218
Dan Gohmanf4423b12008-04-19 00:24:39 +00002515};
2516
2517static const yytype_int16 yycheck[] =
2518{
Chris Lattner740e7092008-10-15 06:16:57 +00002519 0, 27, 158, 196, 11, 11, 0, 320, 239, 161,
2520 458, 4, 446, 447, 55, 28, 159, 17, 211, 212,
2521 213, 214, 215, 17, 266, 267, 21, 192, 221, 34,
2522 172, 11, 55, 656, 29, 55, 288, 536, 55, 193,
2523 11, 162, 162, 55, 162, 55, 162, 161, 169, 54,
2524 673, 171, 78, 171, 55, 171, 7, 8, 55, 10,
2525 11, 12, 13, 14, 15, 16, 17, 53, 19, 20,
2526 55, 22, 23, 24, 54, 59, 102, 156, 162, 158,
2527 106, 223, 68, 54, 336, 162, 112, 171, 161, 254,
2528 7, 256, 118, 93, 171, 162, 18, 240, 241, 50,
2529 534, 255, 19, 257, 171, 22, 162, 24, 41, 42,
2530 121, 32, 33, 169, 55, 48, 142, 143, 159, 11,
2531 146, 54, 42, 43, 44, 17, 152, 47, 169, 20,
2532 161, 630, 23, 375, 582, 161, 159, 636, 637, 159,
2533 151, 162, 159, 169, 167, 338, 167, 159, 165, 159,
2534 34, 163, 162, 163, 396, 397, 398, 170, 159, 160,
2535 167, 167, 159, 0, 612, 162, 163, 165, 194, 195,
2536 196, 197, 117, 118, 159, 160, 171, 170, 677, 678,
2537 161, 680, 681, 161, 210, 211, 212, 213, 214, 215,
2538 216, 217, 218, 219, 220, 221, 509, 19, 697, 698,
2539 22, 22, 24, 282, 162, 231, 285, 286, 287, 167,
2540 46, 404, 48, 164, 165, 54, 242, 168, 159, 170,
2541 171, 21, 163, 162, 156, 157, 158, 420, 167, 422,
2542 423, 424, 54, 7, 8, 477, 35, 22, 37, 552,
2543 42, 554, 44, 322, 22, 19, 20, 22, 22, 23,
2544 24, 330, 331, 332, 333, 334, 408, 141, 142, 143,
2545 144, 160, 146, 162, 132, 133, 150, 151, 4, 153,
2546 154, 155, 160, 299, 162, 160, 159, 162, 160, 431,
2547 162, 4, 121, 122, 160, 279, 162, 132, 133, 37,
2548 316, 317, 318, 62, 63, 64, 65, 66, 67, 121,
2549 122, 614, 141, 142, 166, 144, 145, 463, 147, 148,
2550 149, 337, 338, 132, 133, 166, 114, 115, 159, 141,
2551 142, 163, 144, 145, 4, 147, 148, 149, 84, 85,
2552 409, 410, 411, 412, 161, 22, 162, 160, 169, 418,
2553 4, 42, 43, 44, 45, 46, 47, 48, 49, 375,
2554 51, 160, 159, 432, 365, 366, 367, 368, 369, 370,
2555 371, 592, 555, 55, 57, 558, 559, 560, 11, 380,
2556 381, 382, 169, 22, 160, 159, 159, 159, 404, 159,
2557 159, 162, 408, 159, 463, 162, 159, 159, 159, 159,
2558 38, 4, 38, 159, 420, 421, 422, 423, 424, 162,
2559 162, 162, 162, 162, 430, 431, 485, 159, 159, 159,
2560 159, 490, 22, 492, 61, 162, 495, 162, 162, 165,
2561 162, 162, 448, 162, 162, 162, 505, 506, 162, 508,
2562 661, 162, 162, 664, 162, 162, 162, 169, 449, 450,
2563 451, 452, 162, 162, 38, 22, 472, 17, 17, 460,
2564 162, 477, 162, 162, 162, 156, 157, 158, 162, 4,
2565 162, 4, 162, 162, 162, 4, 545, 546, 162, 548,
2566 549, 550, 551, 162, 162, 22, 162, 556, 504, 162,
2567 38, 162, 4, 162, 510, 564, 160, 169, 159, 162,
2568 162, 570, 169, 4, 159, 54, 162, 160, 285, 286,
2569 287, 162, 162, 160, 530, 160, 22, 169, 519, 520,
2570 521, 522, 162, 524, 165, 167, 160, 528, 529, 160,
2571 160, 160, 17, 160, 160, 167, 160, 54, 607, 555,
2572 4, 152, 558, 559, 560, 322, 162, 159, 22, 159,
2573 17, 17, 17, 330, 331, 332, 333, 334, 94, 95,
2574 96, 97, 98, 99, 100, 101, 102, 103, 162, 73,
2575 17, 572, 573, 574, 575, 591, 652, 93, 631, 106,
2576 112, 17, 598, 231, 242, 90, 655, 57, 133, 613,
2577 659, 660, 453, 141, 142, 143, 144, 613, 146, 133,
2578 590, -1, 150, 151, -1, 153, 154, 155, -1, -1,
2579 -1, -1, -1, -1, -1, -1, -1, -1, 619, -1,
2580 621, 622, 691, 692, -1, 694, -1, 696, -1, -1,
2581 -1, 700, 409, 410, 411, 412, -1, 706, -1, -1,
2582 -1, 418, -1, -1, 7, 8, 662, 10, 11, 12,
2583 13, 14, 15, 16, 17, 432, 19, 20, -1, 22,
2584 23, 24, 652, -1, -1, -1, 7, 8, -1, 10,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002585 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Chris Lattner740e7092008-10-15 06:16:57 +00002586 -1, 22, 23, 24, -1, -1, -1, 50, -1, -1,
2587 141, 142, 143, 144, -1, 146, -1, -1, 39, 150,
2588 151, -1, 153, 154, 155, -1, -1, -1, 485, 50,
2589 -1, -1, -1, 490, -1, 492, -1, -1, 495, -1,
2590 -1, -1, -1, -1, -1, -1, -1, -1, 505, 506,
2591 -1, 508, -1, -1, -1, -1, -1, -1, -1, -1,
2592 -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
Devang Patel652203f2008-09-29 20:49:50 +00002593 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
Chris Lattner740e7092008-10-15 06:16:57 +00002594 -1, 19, 20, -1, 22, 23, 24, -1, 545, 546,
2595 -1, 548, 549, 550, 551, -1, -1, -1, -1, 556,
2596 -1, -1, -1, -1, -1, -1, -1, 564, -1, -1,
2597 -1, -1, 50, 570, -1, -1, -1, -1, -1, -1,
2598 -1, 164, 165, -1, -1, 168, -1, 170, 171, -1,
2599 -1, -1, -1, -1, -1, 3, 4, 5, 6, 7,
2600 8, 9, -1, 164, 165, 0, -1, 168, -1, 170,
2601 607, 19, 20, -1, 22, 23, 24, 25, 26, 27,
2602 -1, -1, -1, 18, 19, 20, -1, 22, 23, 24,
2603 -1, -1, 40, 41, -1, 30, 31, -1, -1, -1,
2604 -1, -1, -1, -1, -1, -1, 54, -1, -1, -1,
2605 -1, 59, -1, -1, -1, -1, -1, 52, 655, -1,
2606 -1, 56, 659, 660, -1, 60, -1, 75, 76, 77,
2607 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
2608 88, 89, 90, 91, 92, 93, 164, 165, -1, -1,
2609 168, -1, 170, 171, 691, 692, -1, 694, -1, 696,
2610 -1, -1, -1, 700, -1, -1, -1, -1, -1, 706,
2611 -1, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2612 128, 129, 130, 131, -1, 133, -1, 135, 136, 137,
2613 -1, 139, 140, 141, 142, -1, 144, 145, -1, 147,
2614 148, 149, -1, -1, -1, -1, -1, -1, -1, 3,
2615 4, 5, 6, 7, 8, 9, -1, 165, -1, -1,
2616 168, -1, 170, -1, 172, 19, 20, -1, 22, 23,
2617 24, 25, 26, 27, 26, 27, -1, -1, -1, -1,
2618 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002619 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002620 -1, 55, -1, 7, 8, 59, 10, 11, 12, 13,
2621 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2622 24, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2623 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2624 -1, -1, -1, -1, -1, -1, 50, -1, 100, 101,
2625 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
2626 112, 113, -1, -1, -1, 119, 120, 121, 122, 123,
2627 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2628 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
2629 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2630 -1, -1, -1, -1, -1, 159, -1, -1, -1, -1,
2631 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2632 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2633 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2634 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2635 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
2636 164, 165, -1, -1, 168, -1, 170, 171, -1, -1,
2637 -1, 55, 7, 8, -1, 10, 11, 12, 13, 14,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002638 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
Chris Lattner740e7092008-10-15 06:16:57 +00002639 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2640 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2641 -1, -1, -1, -1, -1, 50, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002642 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002643 -1, -1, -1, -1, -1, 119, 120, 121, 122, 123,
2644 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2645 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002646 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002647 -1, -1, -1, -1, -1, 159, -1, -1, -1, 163,
2648 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2649 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2650 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2651 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2652 -1, -1, -1, -1, -1, -1, 40, 41, -1, 164,
2653 165, -1, -1, 168, -1, 170, 171, -1, -1, -1,
2654 -1, 55, 7, 8, -1, 10, 11, 12, 13, 14,
2655 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2656 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2657 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2658 -1, -1, -1, -1, -1, 50, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002659 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002660 -1, -1, -1, -1, -1, 119, 120, 121, 122, 123,
2661 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2662 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
2663 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2664 -1, -1, -1, -1, -1, 159, -1, -1, -1, -1,
2665 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2666 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2667 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2668 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2669 -1, -1, -1, -1, -1, -1, 40, 41, -1, 164,
2670 165, -1, -1, 168, -1, 170, 171, -1, -1, -1,
2671 -1, -1, -1, 7, 8, 59, 10, 11, 12, 13,
2672 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2673 24, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2674 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2675 -1, -1, -1, -1, 7, 8, 50, 10, 11, 12,
2676 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2677 23, 24, -1, -1, -1, 119, 120, 121, 122, 123,
2678 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2679 -1, 135, 136, 137, -1, 139, 140, 50, -1, -1,
2680 -1, -1, -1, -1, -1, -1, -1, 3, 4, 5,
2681 6, -1, -1, 9, -1, -1, -1, -1, -1, -1,
2682 -1, 165, -1, -1, 168, -1, 170, -1, 172, 25,
2683 26, 27, -1, -1, -1, -1, -1, -1, -1, -1,
2684 -1, -1, -1, -1, 40, 41, -1, 141, 142, -1,
2685 144, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2686 -1, -1, -1, 59, -1, -1, -1, -1, -1, -1,
2687 164, 165, 125, -1, 168, -1, 170, -1, -1, 75,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002688 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2689 86, 87, 88, 89, 90, 91, 92, 93, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002690 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2691 -1, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2692 -1, -1, -1, 119, 120, 121, 122, 123, 124, 125,
2693 126, 127, 128, 129, 130, 131, -1, 133, -1, 135,
2694 136, 137, -1, 139, 140, 7, 8, -1, 10, 11,
2695 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2696 22, 23, 24, -1, -1, -1, -1, -1, -1, 165,
2697 -1, -1, 168, -1, 170, -1, 172, 39, -1, -1,
2698 -1, -1, -1, -1, -1, -1, 7, 8, 50, 10,
2699 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2700 -1, 22, 23, 24, 7, 8, -1, 10, 11, 12,
2701 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2702 23, 24, -1, -1, -1, -1, -1, 7, 8, 50,
2703 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2704 20, -1, 22, 23, 24, 7, 8, 50, 10, 11,
2705 12, 13, 14, 15, 16, 17, -1, 19, 20, 39,
2706 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2707 50, -1, -1, -1, -1, -1, -1, 39, -1, -1,
2708 -1, -1, -1, -1, -1, -1, -1, -1, 50, -1,
2709 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2710 -1, -1, 164, 165, -1, -1, 168, -1, 170, 7,
2711 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2712 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2713 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2714 -1, -1, -1, 164, 165, -1, 167, 168, -1, 170,
2715 -1, -1, 50, -1, -1, -1, -1, -1, -1, -1,
2716 -1, 164, 165, -1, 167, 168, -1, 170, -1, -1,
2717 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2718 -1, -1, -1, -1, 164, 165, -1, -1, 168, -1,
2719 170, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2720 -1, -1, 164, 165, -1, -1, 168, -1, 170, 7,
2721 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2722 -1, 19, 20, -1, 22, 23, 24, -1, 7, 8,
2723 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2724 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2725 -1, -1, 50, -1, -1, -1, -1, -1, -1, -1,
2726 -1, -1, -1, -1, -1, -1, 164, 165, -1, -1,
2727 168, 50, 170, 7, 8, -1, 10, 11, 12, 13,
2728 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2729 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2730 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2731 -1, -1, -1, -1, 7, 8, 50, 10, 11, 12,
2732 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2733 23, 24, 7, 8, 50, 10, 11, 12, 13, 14,
2734 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2735 -1, -1, -1, -1, -1, -1, -1, 50, -1, -1,
2736 -1, -1, -1, -1, -1, -1, 164, 165, -1, -1,
2737 168, -1, 170, -1, -1, 50, -1, 0, -1, -1,
2738 -1, -1, -1, -1, -1, 164, 165, -1, -1, 168,
2739 -1, 170, -1, -1, -1, 18, 19, 20, -1, 22,
2740 23, 24, -1, -1, -1, -1, -1, 30, 31, -1,
2741 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2742 -1, -1, -1, -1, -1, -1, -1, -1, -1, 52,
2743 164, 165, -1, 56, 168, -1, 170, 60, -1, -1,
2744 -1, -1, -1, -1, -1, -1, -1, -1, 164, 165,
2745 -1, -1, 168, -1, 170, -1, -1, -1, -1, -1,
2746 -1, -1, -1, 36, -1, -1, -1, -1, -1, -1,
2747 -1, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2748 -1, -1, -1, -1, 57, 58, -1, -1, -1, 164,
2749 165, -1, -1, 168, -1, 170, 69, 70, 71, 72,
2750 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2751 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2752 93, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2753 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2754 -1, 114, 115, 116, -1, -1, 119, 120, 121, 122,
2755 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
2756 133, 134, 135, 136, 137, 138, 139, 140
Dan Gohmanf4423b12008-04-19 00:24:39 +00002757};
2758
2759/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2760 symbol of state STATE-NUM. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002761static const yytype_uint16 yystos[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002762{
Dale Johannesenc7071cc2008-05-14 20:13:36 +00002763 0, 19, 20, 22, 23, 24, 30, 31, 52, 56,
Chris Lattner740e7092008-10-15 06:16:57 +00002764 60, 179, 182, 184, 185, 186, 220, 221, 222, 224,
2765 223, 53, 68, 229, 161, 59, 161, 18, 161, 42,
Devang Patel652203f2008-09-29 20:49:50 +00002766 43, 44, 45, 46, 47, 48, 49, 51, 156, 157,
Chris Lattner740e7092008-10-15 06:16:57 +00002767 158, 187, 188, 189, 0, 222, 46, 48, 190, 239,
2768 42, 43, 44, 47, 191, 236, 238, 246, 161, 161,
2769 165, 230, 22, 228, 7, 8, 10, 11, 12, 13,
2770 14, 15, 16, 17, 50, 164, 165, 168, 170, 179,
2771 184, 207, 208, 242, 189, 189, 35, 37, 218, 189,
2772 189, 21, 247, 248, 29, 171, 237, 247, 22, 22,
2773 22, 231, 159, 4, 4, 4, 170, 10, 171, 208,
2774 213, 55, 159, 181, 218, 218, 42, 44, 192, 32,
2775 33, 217, 62, 63, 64, 65, 66, 67, 193, 234,
2776 234, 7, 182, 183, 251, 162, 167, 39, 208, 209,
2777 211, 212, 166, 166, 171, 213, 162, 171, 159, 212,
2778 163, 217, 217, 10, 125, 208, 210, 219, 208, 214,
2779 4, 197, 28, 170, 235, 161, 36, 57, 58, 69,
2780 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2781 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2782 90, 91, 92, 93, 114, 115, 116, 119, 120, 121,
2783 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
2784 132, 133, 134, 135, 136, 137, 138, 139, 140, 174,
2785 175, 176, 249, 256, 257, 258, 259, 249, 257, 22,
2786 195, 162, 160, 208, 208, 169, 171, 208, 4, 160,
2787 214, 208, 159, 242, 3, 4, 5, 6, 9, 25,
2788 26, 27, 40, 41, 90, 91, 92, 93, 119, 133,
2789 135, 136, 137, 139, 140, 165, 168, 170, 172, 174,
2790 175, 176, 215, 242, 181, 141, 142, 144, 196, 210,
2791 57, 10, 208, 244, 245, 11, 17, 11, 193, 94,
2792 95, 96, 97, 98, 99, 100, 101, 102, 103, 177,
2793 26, 27, 100, 101, 102, 103, 104, 105, 106, 107,
2794 108, 109, 110, 111, 112, 113, 178, 177, 178, 208,
2795 208, 244, 208, 208, 252, 244, 244, 244, 244, 244,
2796 208, 208, 208, 208, 208, 244, 193, 117, 118, 54,
2797 121, 122, 141, 142, 144, 145, 147, 148, 149, 194,
2798 39, 209, 199, 167, 169, 169, 160, 199, 181, 181,
2799 219, 177, 178, 177, 178, 159, 159, 159, 159, 159,
2800 159, 159, 167, 214, 216, 170, 216, 171, 216, 22,
2801 159, 159, 159, 225, 184, 3, 4, 5, 6, 9,
2802 25, 26, 27, 40, 41, 59, 165, 168, 170, 172,
2803 215, 241, 242, 243, 162, 243, 243, 243, 197, 208,
2804 208, 208, 208, 162, 202, 162, 202, 243, 165, 162,
2805 162, 162, 162, 162, 162, 243, 243, 243, 243, 243,
2806 38, 197, 208, 244, 4, 141, 142, 143, 144, 146,
2807 150, 151, 153, 154, 155, 198, 226, 227, 38, 159,
2808 159, 159, 159, 214, 214, 214, 214, 214, 214, 214,
2809 162, 167, 171, 208, 216, 169, 171, 214, 214, 214,
2810 162, 205, 159, 61, 240, 167, 216, 170, 216, 171,
2811 216, 22, 244, 162, 162, 210, 243, 243, 243, 243,
2812 11, 54, 11, 254, 243, 165, 244, 208, 244, 244,
2813 244, 162, 162, 255, 162, 162, 162, 208, 210, 243,
2814 162, 205, 205, 208, 214, 214, 214, 214, 254, 162,
2815 162, 162, 162, 255, 162, 214, 169, 171, 162, 162,
2816 38, 34, 54, 203, 206, 39, 208, 232, 233, 22,
2817 167, 171, 216, 169, 171, 17, 17, 243, 162, 162,
2818 162, 162, 243, 4, 243, 162, 162, 243, 162, 162,
2819 162, 4, 4, 162, 208, 243, 243, 243, 162, 202,
2820 208, 160, 162, 162, 162, 162, 160, 214, 214, 214,
2821 214, 160, 214, 169, 214, 214, 208, 22, 4, 205,
2822 195, 162, 160, 162, 169, 171, 243, 243, 159, 243,
2823 243, 243, 243, 202, 202, 244, 243, 162, 244, 244,
2824 244, 4, 243, 159, 243, 214, 214, 214, 214, 162,
2825 160, 162, 162, 255, 160, 160, 160, 179, 180, 39,
2826 208, 199, 22, 169, 162, 165, 17, 208, 253, 167,
2827 243, 255, 253, 202, 160, 160, 160, 160, 214, 214,
2828 214, 160, 195, 203, 204, 17, 11, 167, 250, 195,
2829 195, 160, 162, 167, 160, 160, 160, 160, 180, 54,
2830 201, 243, 241, 11, 167, 121, 122, 243, 243, 199,
2831 17, 208, 199, 4, 152, 200, 162, 241, 195, 195,
2832 38, 195, 195, 22, 17, 162, 17, 243, 243, 243,
2833 17, 243, 195, 195, 243, 73, 17, 243
Dan Gohmanf4423b12008-04-19 00:24:39 +00002834};
David Greene718fda32007-08-01 03:59:32 +00002835
Reid Spencer68a24bd2005-08-27 18:50:39 +00002836#define yyerrok (yyerrstatus = 0)
2837#define yyclearin (yychar = YYEMPTY)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002838#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002839#define YYEOF 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00002840
Reid Spencer68a24bd2005-08-27 18:50:39 +00002841#define YYACCEPT goto yyacceptlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002842#define YYABORT goto yyabortlab
2843#define YYERROR goto yyerrorlab
2844
2845
2846/* Like YYERROR except do call yyerror. This remains here temporarily
2847 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002848 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00002849
Reid Spencer68a24bd2005-08-27 18:50:39 +00002850#define YYFAIL goto yyerrlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002851
Reid Spencer68a24bd2005-08-27 18:50:39 +00002852#define YYRECOVERING() (!!yyerrstatus)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002853
2854#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002855do \
2856 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002857 { \
2858 yychar = (Token); \
2859 yylval = (Value); \
2860 yytoken = YYTRANSLATE (yychar); \
2861 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002862 goto yybackup; \
2863 } \
2864 else \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002865 { \
2866 yyerror (YY_("syntax error: cannot back up")); \
2867 YYERROR; \
2868 } \
2869while (YYID (0))
2870
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002871
Reid Spencer68a24bd2005-08-27 18:50:39 +00002872#define YYTERROR 1
2873#define YYERRCODE 256
2874
Dan Gohmanf4423b12008-04-19 00:24:39 +00002875
2876/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2877 If N is 0, then set CURRENT to the empty location which ends
2878 the previous symbol: RHS[0] (always defined). */
2879
2880#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2881#ifndef YYLLOC_DEFAULT
2882# define YYLLOC_DEFAULT(Current, Rhs, N) \
2883 do \
2884 if (YYID (N)) \
2885 { \
2886 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2887 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2888 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2889 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2890 } \
2891 else \
2892 { \
2893 (Current).first_line = (Current).last_line = \
2894 YYRHSLOC (Rhs, 0).last_line; \
2895 (Current).first_column = (Current).last_column = \
2896 YYRHSLOC (Rhs, 0).last_column; \
2897 } \
2898 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002899#endif
2900
Dan Gohmanf4423b12008-04-19 00:24:39 +00002901
2902/* YY_LOCATION_PRINT -- Print the location on the stream.
2903 This macro was not mandated originally: define only if we know
2904 we won't break user code: when these are the locations we know. */
2905
2906#ifndef YY_LOCATION_PRINT
Nuno Lopes6ec8a252008-10-15 11:11:12 +00002907# if YYLTYPE_IS_TRIVIAL
Dan Gohmanf4423b12008-04-19 00:24:39 +00002908# define YY_LOCATION_PRINT(File, Loc) \
2909 fprintf (File, "%d.%d-%d.%d", \
2910 (Loc).first_line, (Loc).first_column, \
2911 (Loc).last_line, (Loc).last_column)
2912# else
2913# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2914# endif
2915#endif
2916
2917
2918/* YYLEX -- calling `yylex' with the right arguments. */
2919
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002920#ifdef YYLEX_PARAM
Dan Gohmanf4423b12008-04-19 00:24:39 +00002921# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002922#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002923# define YYLEX yylex ()
Gabor Greife64d2482008-04-06 23:07:54 +00002924#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002925
2926/* Enable debugging if requested. */
2927#if YYDEBUG
2928
2929# ifndef YYFPRINTF
2930# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2931# define YYFPRINTF fprintf
2932# endif
2933
2934# define YYDPRINTF(Args) \
2935do { \
2936 if (yydebug) \
2937 YYFPRINTF Args; \
2938} while (YYID (0))
2939
2940# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2941do { \
2942 if (yydebug) \
2943 { \
2944 YYFPRINTF (stderr, "%s ", Title); \
2945 yy_symbol_print (stderr, \
2946 Type, Value); \
2947 YYFPRINTF (stderr, "\n"); \
2948 } \
2949} while (YYID (0))
2950
2951
2952/*--------------------------------.
2953| Print this symbol on YYOUTPUT. |
2954`--------------------------------*/
2955
2956/*ARGSUSED*/
2957#if (defined __STDC__ || defined __C99__FUNC__ \
2958 || defined __cplusplus || defined _MSC_VER)
2959static void
2960yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greife64d2482008-04-06 23:07:54 +00002961#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002962static void
2963yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2964 FILE *yyoutput;
2965 int yytype;
2966 YYSTYPE const * const yyvaluep;
Gabor Greife64d2482008-04-06 23:07:54 +00002967#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002968{
2969 if (!yyvaluep)
2970 return;
2971# ifdef YYPRINT
2972 if (yytype < YYNTOKENS)
2973 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2974# else
2975 YYUSE (yyoutput);
2976# endif
2977 switch (yytype)
2978 {
2979 default:
2980 break;
2981 }
2982}
2983
2984
2985/*--------------------------------.
2986| Print this symbol on YYOUTPUT. |
2987`--------------------------------*/
2988
2989#if (defined __STDC__ || defined __C99__FUNC__ \
2990 || defined __cplusplus || defined _MSC_VER)
2991static void
2992yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2993#else
2994static void
2995yy_symbol_print (yyoutput, yytype, yyvaluep)
2996 FILE *yyoutput;
2997 int yytype;
2998 YYSTYPE const * const yyvaluep;
Scott Michel15dcd8e2008-01-30 03:10:00 +00002999#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003000{
3001 if (yytype < YYNTOKENS)
3002 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3003 else
3004 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner38905612008-02-19 04:36:25 +00003005
Dan Gohmanf4423b12008-04-19 00:24:39 +00003006 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3007 YYFPRINTF (yyoutput, ")");
3008}
Chris Lattner38905612008-02-19 04:36:25 +00003009
Dan Gohmanf4423b12008-04-19 00:24:39 +00003010/*------------------------------------------------------------------.
3011| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3012| TOP (included). |
3013`------------------------------------------------------------------*/
Chris Lattner38905612008-02-19 04:36:25 +00003014
Dan Gohmanf4423b12008-04-19 00:24:39 +00003015#if (defined __STDC__ || defined __C99__FUNC__ \
3016 || defined __cplusplus || defined _MSC_VER)
3017static void
3018yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3019#else
3020static void
3021yy_stack_print (bottom, top)
3022 yytype_int16 *bottom;
3023 yytype_int16 *top;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003024#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003025{
3026 YYFPRINTF (stderr, "Stack now");
3027 for (; bottom <= top; ++bottom)
3028 YYFPRINTF (stderr, " %d", *bottom);
3029 YYFPRINTF (stderr, "\n");
3030}
Chris Lattner38905612008-02-19 04:36:25 +00003031
Dan Gohmanf4423b12008-04-19 00:24:39 +00003032# define YY_STACK_PRINT(Bottom, Top) \
3033do { \
3034 if (yydebug) \
3035 yy_stack_print ((Bottom), (Top)); \
3036} while (YYID (0))
Chris Lattner38905612008-02-19 04:36:25 +00003037
Dan Gohmanf4423b12008-04-19 00:24:39 +00003038
3039/*------------------------------------------------.
3040| Report that the YYRULE is going to be reduced. |
3041`------------------------------------------------*/
3042
3043#if (defined __STDC__ || defined __C99__FUNC__ \
3044 || defined __cplusplus || defined _MSC_VER)
3045static void
3046yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3047#else
3048static void
3049yy_reduce_print (yyvsp, yyrule)
3050 YYSTYPE *yyvsp;
3051 int yyrule;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003052#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003053{
3054 int yynrhs = yyr2[yyrule];
3055 int yyi;
3056 unsigned long int yylno = yyrline[yyrule];
3057 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3058 yyrule - 1, yylno);
3059 /* The symbols being reduced. */
3060 for (yyi = 0; yyi < yynrhs; yyi++)
3061 {
3062 fprintf (stderr, " $%d = ", yyi + 1);
3063 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3064 &(yyvsp[(yyi + 1) - (yynrhs)])
3065 );
3066 fprintf (stderr, "\n");
3067 }
3068}
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003069
Dan Gohmanf4423b12008-04-19 00:24:39 +00003070# define YY_REDUCE_PRINT(Rule) \
3071do { \
3072 if (yydebug) \
3073 yy_reduce_print (yyvsp, Rule); \
3074} while (YYID (0))
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003075
Dan Gohmanf4423b12008-04-19 00:24:39 +00003076/* Nonzero means print parse trace. It is left uninitialized so that
3077 multiple parsers can coexist. */
3078int yydebug;
3079#else /* !YYDEBUG */
3080# define YYDPRINTF(Args)
3081# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3082# define YY_STACK_PRINT(Bottom, Top)
3083# define YY_REDUCE_PRINT(Rule)
3084#endif /* !YYDEBUG */
3085
3086
3087/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003088#ifndef YYINITDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003089# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00003090#endif
3091
Dan Gohmanf4423b12008-04-19 00:24:39 +00003092/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3093 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00003094
Dan Gohmanf4423b12008-04-19 00:24:39 +00003095 Do not make this value too large; the results are undefined if
3096 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3097 evaluated with infinite-precision integer arithmetic. */
David Greene718fda32007-08-01 03:59:32 +00003098
Reid Spencer68a24bd2005-08-27 18:50:39 +00003099#ifndef YYMAXDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003100# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00003101#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003102
Reid Spencer68a24bd2005-08-27 18:50:39 +00003103
3104
Dan Gohmanf4423b12008-04-19 00:24:39 +00003105#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00003106
Dan Gohmanf4423b12008-04-19 00:24:39 +00003107# ifndef yystrlen
3108# if defined __GLIBC__ && defined _STRING_H
3109# define yystrlen strlen
3110# else
3111/* Return the length of YYSTR. */
3112#if (defined __STDC__ || defined __C99__FUNC__ \
3113 || defined __cplusplus || defined _MSC_VER)
3114static YYSIZE_T
3115yystrlen (const char *yystr)
Chris Lattner38905612008-02-19 04:36:25 +00003116#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003117static YYSIZE_T
3118yystrlen (yystr)
3119 const char *yystr;
3120#endif
3121{
3122 YYSIZE_T yylen;
3123 for (yylen = 0; yystr[yylen]; yylen++)
3124 continue;
3125 return yylen;
3126}
3127# endif
3128# endif
3129
3130# ifndef yystpcpy
3131# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3132# define yystpcpy stpcpy
3133# else
3134/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3135 YYDEST. */
3136#if (defined __STDC__ || defined __C99__FUNC__ \
3137 || defined __cplusplus || defined _MSC_VER)
3138static char *
3139yystpcpy (char *yydest, const char *yysrc)
3140#else
3141static char *
3142yystpcpy (yydest, yysrc)
3143 char *yydest;
3144 const char *yysrc;
3145#endif
3146{
3147 char *yyd = yydest;
3148 const char *yys = yysrc;
3149
3150 while ((*yyd++ = *yys++) != '\0')
3151 continue;
3152
3153 return yyd - 1;
3154}
3155# endif
3156# endif
3157
3158# ifndef yytnamerr
3159/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3160 quotes and backslashes, so that it's suitable for yyerror. The
3161 heuristic is that double-quoting is unnecessary unless the string
3162 contains an apostrophe, a comma, or backslash (other than
3163 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3164 null, do not copy; instead, return the length of what the result
3165 would have been. */
3166static YYSIZE_T
3167yytnamerr (char *yyres, const char *yystr)
3168{
3169 if (*yystr == '"')
3170 {
3171 YYSIZE_T yyn = 0;
3172 char const *yyp = yystr;
3173
3174 for (;;)
3175 switch (*++yyp)
3176 {
3177 case '\'':
3178 case ',':
3179 goto do_not_strip_quotes;
3180
3181 case '\\':
3182 if (*++yyp != '\\')
3183 goto do_not_strip_quotes;
3184 /* Fall through. */
3185 default:
3186 if (yyres)
3187 yyres[yyn] = *yyp;
3188 yyn++;
3189 break;
3190
3191 case '"':
3192 if (yyres)
3193 yyres[yyn] = '\0';
3194 return yyn;
3195 }
3196 do_not_strip_quotes: ;
3197 }
3198
3199 if (! yyres)
3200 return yystrlen (yystr);
3201
3202 return yystpcpy (yyres, yystr) - yyres;
3203}
3204# endif
3205
3206/* Copy into YYRESULT an error message about the unexpected token
3207 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3208 including the terminating null byte. If YYRESULT is null, do not
3209 copy anything; just return the number of bytes that would be
3210 copied. As a special case, return 0 if an ordinary "syntax error"
3211 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3212 size calculation. */
3213static YYSIZE_T
3214yysyntax_error (char *yyresult, int yystate, int yychar)
3215{
3216 int yyn = yypact[yystate];
3217
3218 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3219 return 0;
3220 else
3221 {
3222 int yytype = YYTRANSLATE (yychar);
3223 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3224 YYSIZE_T yysize = yysize0;
3225 YYSIZE_T yysize1;
3226 int yysize_overflow = 0;
3227 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3228 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3229 int yyx;
3230
3231# if 0
3232 /* This is so xgettext sees the translatable formats that are
3233 constructed on the fly. */
3234 YY_("syntax error, unexpected %s");
3235 YY_("syntax error, unexpected %s, expecting %s");
3236 YY_("syntax error, unexpected %s, expecting %s or %s");
3237 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3238 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3239# endif
3240 char *yyfmt;
3241 char const *yyf;
3242 static char const yyunexpected[] = "syntax error, unexpected %s";
3243 static char const yyexpecting[] = ", expecting %s";
3244 static char const yyor[] = " or %s";
3245 char yyformat[sizeof yyunexpected
3246 + sizeof yyexpecting - 1
3247 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3248 * (sizeof yyor - 1))];
3249 char const *yyprefix = yyexpecting;
3250
3251 /* Start YYX at -YYN if negative to avoid negative indexes in
3252 YYCHECK. */
3253 int yyxbegin = yyn < 0 ? -yyn : 0;
3254
3255 /* Stay within bounds of both yycheck and yytname. */
3256 int yychecklim = YYLAST - yyn + 1;
3257 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3258 int yycount = 1;
3259
3260 yyarg[0] = yytname[yytype];
3261 yyfmt = yystpcpy (yyformat, yyunexpected);
3262
3263 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3264 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3265 {
3266 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3267 {
3268 yycount = 1;
3269 yysize = yysize0;
3270 yyformat[sizeof yyunexpected - 1] = '\0';
3271 break;
3272 }
3273 yyarg[yycount++] = yytname[yyx];
3274 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3275 yysize_overflow |= (yysize1 < yysize);
3276 yysize = yysize1;
3277 yyfmt = yystpcpy (yyfmt, yyprefix);
3278 yyprefix = yyor;
3279 }
3280
3281 yyf = YY_(yyformat);
3282 yysize1 = yysize + yystrlen (yyf);
3283 yysize_overflow |= (yysize1 < yysize);
3284 yysize = yysize1;
3285
3286 if (yysize_overflow)
3287 return YYSIZE_MAXIMUM;
3288
3289 if (yyresult)
3290 {
3291 /* Avoid sprintf, as that infringes on the user's name space.
3292 Don't have undefined behavior even if the translation
3293 produced a string with the wrong number of "%s"s. */
3294 char *yyp = yyresult;
3295 int yyi = 0;
3296 while ((*yyp = *yyf) != '\0')
3297 {
3298 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3299 {
3300 yyp += yytnamerr (yyp, yyarg[yyi++]);
3301 yyf += 2;
3302 }
3303 else
3304 {
3305 yyp++;
3306 yyf++;
3307 }
3308 }
3309 }
3310 return yysize;
3311 }
3312}
3313#endif /* YYERROR_VERBOSE */
3314
3315
3316/*-----------------------------------------------.
3317| Release the memory associated to this symbol. |
3318`-----------------------------------------------*/
3319
3320/*ARGSUSED*/
3321#if (defined __STDC__ || defined __C99__FUNC__ \
3322 || defined __cplusplus || defined _MSC_VER)
3323static void
3324yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3325#else
3326static void
3327yydestruct (yymsg, yytype, yyvaluep)
3328 const char *yymsg;
3329 int yytype;
3330 YYSTYPE *yyvaluep;
3331#endif
3332{
3333 YYUSE (yyvaluep);
3334
3335 if (!yymsg)
3336 yymsg = "Deleting";
3337 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3338
3339 switch (yytype)
3340 {
3341
3342 default:
3343 break;
3344 }
3345}
3346
3347
3348/* Prevent warnings from -Wmissing-prototypes. */
3349
3350#ifdef YYPARSE_PARAM
3351#if defined __STDC__ || defined __cplusplus
3352int yyparse (void *YYPARSE_PARAM);
3353#else
3354int yyparse ();
3355#endif
3356#else /* ! YYPARSE_PARAM */
3357#if defined __STDC__ || defined __cplusplus
David Greene5fd22a82007-09-04 18:46:50 +00003358int yyparse (void);
Gabor Greife64d2482008-04-06 23:07:54 +00003359#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003360int yyparse ();
Scott Michel15dcd8e2008-01-30 03:10:00 +00003361#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003362#endif /* ! YYPARSE_PARAM */
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003363
Chris Lattner38905612008-02-19 04:36:25 +00003364
Dan Gohmanf4423b12008-04-19 00:24:39 +00003365
3366/* The look-ahead symbol. */
3367int yychar;
3368
3369/* The semantic value of the look-ahead symbol. */
3370YYSTYPE yylval;
3371
3372/* Number of syntax errors so far. */
3373int yynerrs;
3374
3375
3376
3377/*----------.
3378| yyparse. |
3379`----------*/
3380
3381#ifdef YYPARSE_PARAM
3382#if (defined __STDC__ || defined __C99__FUNC__ \
3383 || defined __cplusplus || defined _MSC_VER)
3384int
3385yyparse (void *YYPARSE_PARAM)
3386#else
3387int
3388yyparse (YYPARSE_PARAM)
3389 void *YYPARSE_PARAM;
3390#endif
3391#else /* ! YYPARSE_PARAM */
3392#if (defined __STDC__ || defined __C99__FUNC__ \
3393 || defined __cplusplus || defined _MSC_VER)
3394int
3395yyparse (void)
3396#else
3397int
3398yyparse ()
3399
Gabor Greife64d2482008-04-06 23:07:54 +00003400#endif
3401#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003402{
3403
3404 int yystate;
3405 int yyn;
3406 int yyresult;
3407 /* Number of tokens to shift before error messages enabled. */
3408 int yyerrstatus;
3409 /* Look-ahead token as an internal (translated) token number. */
3410 int yytoken = 0;
3411#if YYERROR_VERBOSE
3412 /* Buffer for error messages, and its allocated size. */
3413 char yymsgbuf[128];
3414 char *yymsg = yymsgbuf;
3415 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greife64d2482008-04-06 23:07:54 +00003416#endif
Chris Lattner38905612008-02-19 04:36:25 +00003417
Dan Gohmanf4423b12008-04-19 00:24:39 +00003418 /* Three stacks and their tools:
3419 `yyss': related to states,
3420 `yyvs': related to semantic values,
3421 `yyls': related to locations.
3422
3423 Refer to the stacks thru separate pointers, to allow yyoverflow
3424 to reallocate them elsewhere. */
3425
3426 /* The state stack. */
3427 yytype_int16 yyssa[YYINITDEPTH];
3428 yytype_int16 *yyss = yyssa;
3429 yytype_int16 *yyssp;
3430
3431 /* The semantic value stack. */
3432 YYSTYPE yyvsa[YYINITDEPTH];
3433 YYSTYPE *yyvs = yyvsa;
3434 YYSTYPE *yyvsp;
3435
3436
3437
3438#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3439
3440 YYSIZE_T yystacksize = YYINITDEPTH;
3441
3442 /* The variables used to return semantic value and location from the
3443 action routines. */
3444 YYSTYPE yyval;
3445
3446
3447 /* The number of symbols on the RHS of the reduced rule.
3448 Keep to zero when no symbol should be popped. */
3449 int yylen = 0;
3450
3451 YYDPRINTF ((stderr, "Starting parse\n"));
3452
Reid Spencer68a24bd2005-08-27 18:50:39 +00003453 yystate = 0;
3454 yyerrstatus = 0;
3455 yynerrs = 0;
3456 yychar = YYEMPTY; /* Cause a token to be read. */
3457
3458 /* Initialize stack pointers.
3459 Waste one element of value and location stack
3460 so that they stay on the same level as the state stack.
3461 The wasted elements are never initialized. */
3462
Dan Gohmanf4423b12008-04-19 00:24:39 +00003463 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003464 yyvsp = yyvs;
3465
Dan Gohmanf4423b12008-04-19 00:24:39 +00003466 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003467
Dan Gohmanf4423b12008-04-19 00:24:39 +00003468/*------------------------------------------------------------.
3469| yynewstate -- Push a new state, which is found in yystate. |
3470`------------------------------------------------------------*/
3471 yynewstate:
3472 /* In all cases, when you get here, the value and location stacks
3473 have just been pushed. So pushing a state here evens the stacks. */
3474 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003475
Dan Gohmanf4423b12008-04-19 00:24:39 +00003476 yysetstate:
3477 *yyssp = yystate;
3478
3479 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003480 {
3481 /* Get the current used size of the three stacks, in elements. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003482 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003483
3484#ifdef yyoverflow
Dan Gohmanf4423b12008-04-19 00:24:39 +00003485 {
3486 /* Give user a chance to reallocate the stack. Use copies of
3487 these so that the &'s don't force the real ones into
3488 memory. */
3489 YYSTYPE *yyvs1 = yyvs;
3490 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003491
Dan Gohmanf4423b12008-04-19 00:24:39 +00003492
3493 /* Each stack pointer address is followed by the size of the
3494 data in use in that stack, in bytes. This used to be a
3495 conditional around just the two extra args, but that might
3496 be undefined if yyoverflow is a macro. */
3497 yyoverflow (YY_("memory exhausted"),
3498 &yyss1, yysize * sizeof (*yyssp),
3499 &yyvs1, yysize * sizeof (*yyvsp),
3500
3501 &yystacksize);
3502
3503 yyss = yyss1;
3504 yyvs = yyvs1;
3505 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003506#else /* no yyoverflow */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003507# ifndef YYSTACK_RELOCATE
3508 goto yyexhaustedlab;
3509# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003510 /* Extend the stack our own way. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003511 if (YYMAXDEPTH <= yystacksize)
3512 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003513 yystacksize *= 2;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003514 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003515 yystacksize = YYMAXDEPTH;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003516
3517 {
3518 yytype_int16 *yyss1 = yyss;
3519 union yyalloc *yyptr =
3520 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3521 if (! yyptr)
3522 goto yyexhaustedlab;
3523 YYSTACK_RELOCATE (yyss);
3524 YYSTACK_RELOCATE (yyvs);
3525
3526# undef YYSTACK_RELOCATE
3527 if (yyss1 != yyssa)
3528 YYSTACK_FREE (yyss1);
3529 }
3530# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003531#endif /* no yyoverflow */
3532
Dan Gohmanf4423b12008-04-19 00:24:39 +00003533 yyssp = yyss + yysize - 1;
3534 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003535
3536
Dan Gohmanf4423b12008-04-19 00:24:39 +00003537 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3538 (unsigned long int) yystacksize));
3539
3540 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003541 YYABORT;
3542 }
3543
Dan Gohmanf4423b12008-04-19 00:24:39 +00003544 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003545
3546 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003547
Dan Gohmanf4423b12008-04-19 00:24:39 +00003548/*-----------.
3549| yybackup. |
3550`-----------*/
3551yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003552
Dan Gohmanf4423b12008-04-19 00:24:39 +00003553 /* Do appropriate processing given the current state. Read a
3554 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003555
Dan Gohmanf4423b12008-04-19 00:24:39 +00003556 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003557 yyn = yypact[yystate];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003558 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003559 goto yydefault;
3560
Dan Gohmanf4423b12008-04-19 00:24:39 +00003561 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003562
Dan Gohmanf4423b12008-04-19 00:24:39 +00003563 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003564 if (yychar == YYEMPTY)
3565 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003566 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003567 yychar = YYLEX;
3568 }
3569
Dan Gohmanf4423b12008-04-19 00:24:39 +00003570 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003571 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003572 yychar = yytoken = YYEOF;
3573 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003574 }
3575 else
3576 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003577 yytoken = YYTRANSLATE (yychar);
3578 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003579 }
3580
Dan Gohmanf4423b12008-04-19 00:24:39 +00003581 /* If the proper action on seeing token YYTOKEN is to reduce or to
3582 detect an error, take that action. */
3583 yyn += yytoken;
3584 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003585 goto yydefault;
3586 yyn = yytable[yyn];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003587 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003588 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003589 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003590 goto yyerrlab;
3591 yyn = -yyn;
3592 goto yyreduce;
3593 }
3594
3595 if (yyn == YYFINAL)
3596 YYACCEPT;
3597
Dan Gohmanf4423b12008-04-19 00:24:39 +00003598 /* Count tokens shifted since error; after three, turn off error
3599 status. */
3600 if (yyerrstatus)
3601 yyerrstatus--;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003602
Dan Gohmanf4423b12008-04-19 00:24:39 +00003603 /* Shift the look-ahead token. */
3604 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003605
Dan Gohmanf4423b12008-04-19 00:24:39 +00003606 /* Discard the shifted token unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003607 if (yychar != YYEOF)
3608 yychar = YYEMPTY;
3609
Gabor Greife64d2482008-04-06 23:07:54 +00003610 yystate = yyn;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003611 *++yyvsp = yylval;
3612
Reid Spencer68a24bd2005-08-27 18:50:39 +00003613 goto yynewstate;
3614
Gabor Greife64d2482008-04-06 23:07:54 +00003615
Dan Gohmanf4423b12008-04-19 00:24:39 +00003616/*-----------------------------------------------------------.
3617| yydefault -- do the default action for the current state. |
3618`-----------------------------------------------------------*/
3619yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003620 yyn = yydefact[yystate];
3621 if (yyn == 0)
3622 goto yyerrlab;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003623 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003624
Dan Gohmanf4423b12008-04-19 00:24:39 +00003625
3626/*-----------------------------.
3627| yyreduce -- Do a reduction. |
3628`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003629yyreduce:
Dan Gohmanf4423b12008-04-19 00:24:39 +00003630 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003631 yylen = yyr2[yyn];
3632
Dan Gohmanf4423b12008-04-19 00:24:39 +00003633 /* If YYLEN is nonzero, implement the default value of the action:
3634 `$$ = $1'.
3635
3636 Otherwise, the following line sets YYVAL to garbage.
3637 This behavior is undocumented and Bison
3638 users should not rely upon it. Assigning to YYVAL
3639 unconditionally makes the parser a bit smaller, and it avoids a
3640 GCC warning that YYVAL may be used uninitialized. */
3641 yyval = yyvsp[1-yylen];
3642
3643
3644 YY_REDUCE_PRINT (yyn);
3645 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003646 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003647 case 29:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003648#line 1150 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003649 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3650 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003651
Dan Gohmanf4423b12008-04-19 00:24:39 +00003652 case 30:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003653#line 1150 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003654 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3655 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003656
Dan Gohmanf4423b12008-04-19 00:24:39 +00003657 case 31:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003658#line 1151 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003659 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3660 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003661
Dan Gohmanf4423b12008-04-19 00:24:39 +00003662 case 32:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003663#line 1151 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003664 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3665 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003666
Dan Gohmanf4423b12008-04-19 00:24:39 +00003667 case 33:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003668#line 1152 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003669 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3670 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003671
Dan Gohmanf4423b12008-04-19 00:24:39 +00003672 case 34:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003673#line 1152 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003674 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3675 break;
3676
3677 case 35:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003678#line 1153 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003679 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3680 break;
3681
3682 case 36:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003683#line 1153 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003684 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3685 break;
3686
3687 case 37:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003688#line 1154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003689 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3690 break;
3691
3692 case 38:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003693#line 1154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003694 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3695 break;
3696
3697 case 39:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003698#line 1158 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003699 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3700 break;
3701
3702 case 40:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003703#line 1158 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003704 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3705 break;
3706
3707 case 41:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003708#line 1159 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003709 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3710 break;
3711
3712 case 42:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003713#line 1159 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003714 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3715 break;
3716
3717 case 43:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003718#line 1160 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003719 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3720 break;
3721
3722 case 44:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003723#line 1160 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003724 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3725 break;
3726
3727 case 45:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003728#line 1161 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003729 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3730 break;
3731
3732 case 46:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003733#line 1161 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003734 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3735 break;
3736
3737 case 47:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003738#line 1162 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003739 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3740 break;
3741
3742 case 48:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003743#line 1162 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003744 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3745 break;
3746
3747 case 49:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003748#line 1163 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003749 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3750 break;
3751
3752 case 50:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003753#line 1163 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003754 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3755 break;
3756
3757 case 51:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003758#line 1164 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003759 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3760 break;
3761
3762 case 52:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003763#line 1164 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003764 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3765 break;
3766
3767 case 53:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003768#line 1165 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003769 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3770 break;
3771
3772 case 54:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003773#line 1166 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003774 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3775 break;
3776
Chris Lattner740e7092008-10-15 06:16:57 +00003777 case 59:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003778#line 1170 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003779 { (yyval.StrVal) = 0; ;}
3780 break;
3781
Chris Lattner740e7092008-10-15 06:16:57 +00003782 case 60:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003783#line 1172 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003784 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3785 break;
3786
Chris Lattner740e7092008-10-15 06:16:57 +00003787 case 61:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003788#line 1173 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003789 { (yyval.UIntVal)=0; ;}
3790 break;
3791
Chris Lattner740e7092008-10-15 06:16:57 +00003792 case 62:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003793#line 1177 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003794 {
3795 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003796 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003797 ;}
3798 break;
3799
Chris Lattner740e7092008-10-15 06:16:57 +00003800 case 63:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003801#line 1181 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003802 {
3803 (yyval.StrVal) = 0;
3804 CHECK_FOR_ERROR
3805 ;}
3806 break;
3807
3808 case 64:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003809#line 1186 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003810 {
3811 (yyval.UIntVal) = (yyvsp[(1) - (2)].UIntVal);
3812 CHECK_FOR_ERROR
3813;}
3814 break;
3815
Chris Lattnerf9078f92008-10-15 06:03:48 +00003816 case 68:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003817#line 1195 "/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 Lattnerf9078f92008-10-15 06:03:48 +00003824 case 69:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003825#line 1200 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003826 {
3827 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00003828 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003829 ;}
3830 break;
3831
Chris Lattner740e7092008-10-15 06:16:57 +00003832 case 70:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003833#line 1206 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003834 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3835 break;
3836
Chris Lattner740e7092008-10-15 06:16:57 +00003837 case 71:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003838#line 1207 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003839 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3840 break;
3841
Chris Lattner740e7092008-10-15 06:16:57 +00003842 case 72:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003843#line 1208 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003844 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3845 break;
3846
Chris Lattner740e7092008-10-15 06:16:57 +00003847 case 73:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003848#line 1209 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003849 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3850 break;
3851
Chris Lattner740e7092008-10-15 06:16:57 +00003852 case 74:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003853#line 1210 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003854 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3855 break;
3856
Chris Lattner740e7092008-10-15 06:16:57 +00003857 case 75:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003858#line 1211 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003859 { (yyval.Linkage) = GlobalValue::CommonLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003860 break;
3861
Chris Lattner740e7092008-10-15 06:16:57 +00003862 case 76:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003863#line 1215 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003864 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003865 break;
3866
Chris Lattner740e7092008-10-15 06:16:57 +00003867 case 77:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003868#line 1216 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003869 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003870 break;
3871
Chris Lattner740e7092008-10-15 06:16:57 +00003872 case 78:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003873#line 1217 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003874 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3875 break;
3876
3877 case 79:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003878#line 1221 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003879 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3880 break;
3881
3882 case 80:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003883#line 1222 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003884 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3885 break;
3886
3887 case 81:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003888#line 1223 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003889 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3890 break;
3891
3892 case 82:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003893#line 1224 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003894 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3895 break;
3896
3897 case 83:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003898#line 1228 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003899 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003900 break;
3901
Chris Lattnerf9078f92008-10-15 06:03:48 +00003902 case 84:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003903#line 1229 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003904 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003905 break;
3906
Chris Lattner740e7092008-10-15 06:16:57 +00003907 case 85:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003908#line 1230 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003909 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003910 break;
3911
Chris Lattner740e7092008-10-15 06:16:57 +00003912 case 86:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003913#line 1234 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003914 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3915 break;
3916
3917 case 87:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003918#line 1235 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003919 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3920 break;
3921
3922 case 88:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003923#line 1236 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003924 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3925 break;
3926
3927 case 89:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003928#line 1237 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003929 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3930 break;
3931
3932 case 90:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003933#line 1238 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003934 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3935 break;
3936
3937 case 91:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003938#line 1242 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003939 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3940 break;
3941
Chris Lattnerf9078f92008-10-15 06:03:48 +00003942 case 92:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003943#line 1243 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003944 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Chris Lattnerf9078f92008-10-15 06:03:48 +00003945 break;
3946
Chris Lattner15bd0952008-08-29 17:20:18 +00003947 case 93:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003948#line 1244 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003949 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003950 break;
3951
Chris Lattner740e7092008-10-15 06:16:57 +00003952 case 94:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003953#line 1247 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00003954 { (yyval.UIntVal) = CallingConv::C; ;}
3955 break;
3956
Chris Lattner740e7092008-10-15 06:16:57 +00003957 case 95:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003958#line 1248 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003959 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003960 break;
3961
Chris Lattner740e7092008-10-15 06:16:57 +00003962 case 96:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003963#line 1249 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003964 { (yyval.UIntVal) = CallingConv::Fast; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003965 break;
3966
Chris Lattner740e7092008-10-15 06:16:57 +00003967 case 97:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003968#line 1250 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003969 { (yyval.UIntVal) = CallingConv::Cold; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003970 break;
3971
Chris Lattner740e7092008-10-15 06:16:57 +00003972 case 98:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003973#line 1251 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003974 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003975 break;
3976
Chris Lattner740e7092008-10-15 06:16:57 +00003977 case 99:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003978#line 1252 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003979 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00003980 break;
3981
Chris Lattner740e7092008-10-15 06:16:57 +00003982 case 100:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003983#line 1253 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003984 {
3985 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003986 GEN_ERROR("Calling conv too large");
Dan Gohmanf4423b12008-04-19 00:24:39 +00003987 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003988 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003989 ;}
3990 break;
3991
Chris Lattner740e7092008-10-15 06:16:57 +00003992 case 101:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003993#line 1260 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003994 { (yyval.Attributes) = Attribute::ZExt; ;}
3995 break;
3996
3997 case 102:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00003998#line 1261 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003999 { (yyval.Attributes) = Attribute::ZExt; ;}
4000 break;
4001
4002 case 103:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004003#line 1262 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004004 { (yyval.Attributes) = Attribute::SExt; ;}
4005 break;
4006
4007 case 104:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004008#line 1263 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004009 { (yyval.Attributes) = Attribute::SExt; ;}
4010 break;
4011
4012 case 105:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004013#line 1264 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004014 { (yyval.Attributes) = Attribute::InReg; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004015 break;
4016
Chris Lattner740e7092008-10-15 06:16:57 +00004017 case 106:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004018#line 1265 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004019 { (yyval.Attributes) = Attribute::StructRet; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004020 break;
4021
Chris Lattner740e7092008-10-15 06:16:57 +00004022 case 107:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004023#line 1266 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004024 { (yyval.Attributes) = Attribute::NoAlias; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004025 break;
4026
Chris Lattner740e7092008-10-15 06:16:57 +00004027 case 108:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004028#line 1267 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004029 { (yyval.Attributes) = Attribute::ByVal; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004030 break;
4031
Chris Lattner740e7092008-10-15 06:16:57 +00004032 case 109:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004033#line 1268 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004034 { (yyval.Attributes) = Attribute::Nest; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004035 break;
4036
Chris Lattner740e7092008-10-15 06:16:57 +00004037 case 110:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004038#line 1269 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004039 { (yyval.Attributes) =
4040 Attribute::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004041 break;
4042
Chris Lattner740e7092008-10-15 06:16:57 +00004043 case 111:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004044#line 1273 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004045 { (yyval.Attributes) = Attribute::None; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004046 break;
4047
Chris Lattner740e7092008-10-15 06:16:57 +00004048 case 112:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004049#line 1274 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesendfe8c842008-09-26 19:32:34 +00004050 {
4051 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4052 ;}
4053 break;
4054
Chris Lattner740e7092008-10-15 06:16:57 +00004055 case 113:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004056#line 1279 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004057 { (yyval.Attributes) = Attribute::InReg; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004058 break;
4059
Chris Lattner740e7092008-10-15 06:16:57 +00004060 case 114:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004061#line 1280 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004062 { (yyval.Attributes) = Attribute::ZExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004063 break;
4064
Chris Lattner740e7092008-10-15 06:16:57 +00004065 case 115:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004066#line 1281 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004067 { (yyval.Attributes) = Attribute::SExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004068 break;
4069
Chris Lattner740e7092008-10-15 06:16:57 +00004070 case 116:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004071#line 1284 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004072 { (yyval.Attributes) = Attribute::None; ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00004073 break;
4074
Chris Lattner740e7092008-10-15 06:16:57 +00004075 case 117:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004076#line 1285 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004077 {
4078 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4079 ;}
4080 break;
4081
Chris Lattner740e7092008-10-15 06:16:57 +00004082 case 118:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004083#line 1291 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004084 { (yyval.Attributes) = Attribute::NoReturn; ;}
4085 break;
4086
Chris Lattner740e7092008-10-15 06:16:57 +00004087 case 119:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004088#line 1292 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004089 { (yyval.Attributes) = Attribute::NoUnwind; ;}
4090 break;
4091
Chris Lattner740e7092008-10-15 06:16:57 +00004092 case 120:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004093#line 1293 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004094 { (yyval.Attributes) = Attribute::InReg; ;}
4095 break;
4096
Chris Lattner740e7092008-10-15 06:16:57 +00004097 case 121:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004098#line 1294 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004099 { (yyval.Attributes) = Attribute::ZExt; ;}
4100 break;
4101
Chris Lattner740e7092008-10-15 06:16:57 +00004102 case 122:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004103#line 1295 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004104 { (yyval.Attributes) = Attribute::SExt; ;}
4105 break;
4106
Chris Lattner740e7092008-10-15 06:16:57 +00004107 case 123:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004108#line 1296 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004109 { (yyval.Attributes) = Attribute::ReadNone; ;}
4110 break;
4111
Chris Lattner740e7092008-10-15 06:16:57 +00004112 case 124:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004113#line 1297 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004114 { (yyval.Attributes) = Attribute::ReadOnly; ;}
4115 break;
4116
Chris Lattner740e7092008-10-15 06:16:57 +00004117 case 125:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004118#line 1298 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner9fc4da42008-10-08 06:44:45 +00004119 { (yyval.Attributes) = Attribute::NoInline; ;}
Devang Patel652203f2008-09-29 20:49:50 +00004120 break;
4121
Chris Lattner740e7092008-10-15 06:16:57 +00004122 case 126:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004123#line 1299 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner9fc4da42008-10-08 06:44:45 +00004124 { (yyval.Attributes) = Attribute::AlwaysInline; ;}
Devang Patel652203f2008-09-29 20:49:50 +00004125 break;
4126
Chris Lattner740e7092008-10-15 06:16:57 +00004127 case 127:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004128#line 1300 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner9fc4da42008-10-08 06:44:45 +00004129 { (yyval.Attributes) = Attribute::OptimizeForSize; ;}
Devang Patel652203f2008-09-29 20:49:50 +00004130 break;
4131
Chris Lattner740e7092008-10-15 06:16:57 +00004132 case 128:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004133#line 1303 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004134 { (yyval.Attributes) = Attribute::None; ;}
4135 break;
4136
Chris Lattner740e7092008-10-15 06:16:57 +00004137 case 129:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004138#line 1304 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004139 {
Devang Patel05988662008-09-25 21:00:45 +00004140 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
Chris Lattner15bd0952008-08-29 17:20:18 +00004141 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004142 break;
4143
Chris Lattner740e7092008-10-15 06:16:57 +00004144 case 130:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004145#line 1310 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld4980812008-09-02 20:52:40 +00004146 { (yyval.StrVal) = 0; ;}
4147 break;
4148
Chris Lattner740e7092008-10-15 06:16:57 +00004149 case 131:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004150#line 1311 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004151 {
4152 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4153 ;}
4154 break;
4155
Chris Lattner740e7092008-10-15 06:16:57 +00004156 case 132:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004157#line 1318 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004158 { (yyval.UIntVal) = 0; ;}
4159 break;
4160
Chris Lattner740e7092008-10-15 06:16:57 +00004161 case 133:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004162#line 1319 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004163 {
4164 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4165 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004166 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004167 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004168;}
4169 break;
4170
Chris Lattner740e7092008-10-15 06:16:57 +00004171 case 134:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004172#line 1325 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004173 { (yyval.UIntVal) = 0; ;}
4174 break;
4175
Chris Lattner740e7092008-10-15 06:16:57 +00004176 case 135:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004177#line 1326 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004178 {
4179 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4180 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lambbf3348d2007-12-12 08:45:45 +00004181 GEN_ERROR("Alignment must be a power of two");
4182 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004183;}
4184 break;
4185
Chris Lattner740e7092008-10-15 06:16:57 +00004186 case 136:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004187#line 1335 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004188 {
4189 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
4190 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004191 GEN_ERROR("Invalid character in section name");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004192 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004193 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004194;}
4195 break;
4196
Chris Lattner740e7092008-10-15 06:16:57 +00004197 case 137:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004198#line 1343 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004199 { (yyval.StrVal) = 0; ;}
4200 break;
4201
Chris Lattner740e7092008-10-15 06:16:57 +00004202 case 138:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004203#line 1344 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004204 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4205 break;
4206
Chris Lattner740e7092008-10-15 06:16:57 +00004207 case 139:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004208#line 1349 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00004209 {;}
4210 break;
4211
Chris Lattner740e7092008-10-15 06:16:57 +00004212 case 140:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004213#line 1350 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004214 {;}
4215 break;
4216
Chris Lattner740e7092008-10-15 06:16:57 +00004217 case 141:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004218#line 1351 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004219 {
4220 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4221 delete (yyvsp[(1) - (1)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004222 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004223 ;}
4224 break;
4225
Chris Lattner740e7092008-10-15 06:16:57 +00004226 case 142:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004227#line 1356 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004228 {
4229 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004230 GEN_ERROR("Alignment must be a power of two");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004231 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004232 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004233 ;}
4234 break;
4235
Chris Lattner740e7092008-10-15 06:16:57 +00004236 case 150:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004237#line 1372 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004238 {
4239 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004240 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004241 ;}
4242 break;
4243
Chris Lattner740e7092008-10-15 06:16:57 +00004244 case 151:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004245#line 1376 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004246 {
4247 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004248 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004249 ;}
4250 break;
4251
Chris Lattner740e7092008-10-15 06:16:57 +00004252 case 152:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004253#line 1380 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004254 { // Pointer type?
4255 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lambbf3348d2007-12-12 08:45:45 +00004256 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004257 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4258 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00004259 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004260 ;}
4261 break;
4262
Chris Lattner740e7092008-10-15 06:16:57 +00004263 case 153:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004264#line 1387 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004265 { // Named types are also simple types...
4266 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004267 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004268 (yyval.TypeVal) = new PATypeHolder(tmp);
4269 ;}
4270 break;
4271
Chris Lattner740e7092008-10-15 06:16:57 +00004272 case 154:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004273#line 1392 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004274 { // Type UpReference
4275 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004276 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohmanf4423b12008-04-19 00:24:39 +00004277 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4278 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004279 UR_OUT("New Upreference!\n");
4280 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004281 ;}
4282 break;
4283
Chris Lattner740e7092008-10-15 06:16:57 +00004284 case 155:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004285#line 1400 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004286 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004287 // Allow but ignore attributes on function types; this permits auto-upgrade.
4288 // FIXME: remove in LLVM 3.0.
Chris Lattnera925a142008-04-23 05:37:08 +00004289 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4290 if (!FunctionType::isValidReturnType(RetTy))
4291 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004292
Reid Spencer41dff5e2007-01-26 08:05:27 +00004293 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004294 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004295 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004296 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004297 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004298 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004299
Reid Spencer41dff5e2007-01-26 08:05:27 +00004300 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4301 if (isVarArg) Params.pop_back();
4302
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004303 for (unsigned i = 0; i != Params.size(); ++i)
4304 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4305 GEN_ERROR("Function arguments must be value types!");
4306
4307 CHECK_FOR_ERROR
4308
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004309 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004310 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
Eric Christopher2a5196f2008-09-24 04:55:49 +00004311 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Nuno Lopes8a88a372008-10-05 16:49:34 +00004312
4313 // Delete the argument list
4314 for (I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin() ; I != E; ++I ) {
4315 delete I->Ty;
4316 }
4317 delete (yyvsp[(3) - (5)].TypeWithAttrsList);
4318
Reid Spencere4d87aa2006-12-23 06:05:41 +00004319 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004320 ;}
4321 break;
4322
Chris Lattner740e7092008-10-15 06:16:57 +00004323 case 156:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004324#line 1435 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004325 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004326 // Allow but ignore attributes on function types; this permits auto-upgrade.
4327 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004328 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004329 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004330 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004331 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004332 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004333 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004334
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004335 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4336 if (isVarArg) Params.pop_back();
4337
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004338 for (unsigned i = 0; i != Params.size(); ++i)
4339 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4340 GEN_ERROR("Function arguments must be value types!");
4341
4342 CHECK_FOR_ERROR
4343
Dan Gohmanf4423b12008-04-19 00:24:39 +00004344 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
Eric Christopher2a5196f2008-09-24 04:55:49 +00004345 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Nuno Lopes8a88a372008-10-05 16:49:34 +00004346
4347 // Delete the argument list
4348 for (I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin() ; I != E; ++I ) {
4349 delete I->Ty;
4350 }
4351 delete (yyvsp[(3) - (5)].TypeWithAttrsList);
4352
Reid Spencer41dff5e2007-01-26 08:05:27 +00004353 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004354 ;}
4355 break;
4356
Chris Lattner740e7092008-10-15 06:16:57 +00004357 case 157:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004358#line 1466 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004359 { // Sized array type?
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004360 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (yyvsp[(2) - (5)].UInt64Val))));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004361 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004362 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004363 ;}
4364 break;
4365
Chris Lattner740e7092008-10-15 06:16:57 +00004366 case 158:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004367#line 1471 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004368 { // Vector type?
4369 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4370 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004371 GEN_ERROR("Unsigned result not equal to signed result");
4372 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4373 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004374 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4375 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004376 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004377 ;}
4378 break;
4379
Chris Lattner740e7092008-10-15 06:16:57 +00004380 case 159:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004381#line 1481 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004382 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004383 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004384 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4385 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004386 Elements.push_back(*I);
4387
Dan Gohmanf4423b12008-04-19 00:24:39 +00004388 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4389 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004390 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004391 ;}
4392 break;
4393
Chris Lattner740e7092008-10-15 06:16:57 +00004394 case 160:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004395#line 1491 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004396 { // Empty structure type?
4397 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004398 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004399 ;}
4400 break;
4401
Chris Lattner740e7092008-10-15 06:16:57 +00004402 case 161:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004403#line 1495 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004404 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004405 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004406 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4407 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004408 Elements.push_back(*I);
4409
Dan Gohmanf4423b12008-04-19 00:24:39 +00004410 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4411 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004412 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004413 ;}
4414 break;
4415
Chris Lattner740e7092008-10-15 06:16:57 +00004416 case 162:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004417#line 1505 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004418 { // Empty structure type?
4419 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004420 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004421 ;}
4422 break;
4423
Chris Lattner740e7092008-10-15 06:16:57 +00004424 case 163:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004425#line 1512 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004426 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004427 // Allow but ignore attributes on function types; this permits auto-upgrade.
4428 // FIXME: remove in LLVM 3.0.
Eric Christopher2a5196f2008-09-24 04:55:49 +00004429 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
Devang Patel05988662008-09-25 21:00:45 +00004430 (yyval.TypeWithAttrs).Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004431 ;}
4432 break;
4433
Chris Lattner740e7092008-10-15 06:16:57 +00004434 case 164:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004435#line 1521 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004436 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004437 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004438 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4439 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004440 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004441 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4442 ;}
4443 break;
4444
Chris Lattner740e7092008-10-15 06:16:57 +00004445 case 165:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004446#line 1528 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004447 {
4448 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4449 ;}
4450 break;
4451
Chris Lattner740e7092008-10-15 06:16:57 +00004452 case 166:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004453#line 1533 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004454 {
4455 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4456 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004457 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004458 ;}
4459 break;
4460
Chris Lattner740e7092008-10-15 06:16:57 +00004461 case 167:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004462#line 1538 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004463 {
4464 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004465 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004466 ;}
4467 break;
4468
Chris Lattner740e7092008-10-15 06:16:57 +00004469 case 169:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004470#line 1546 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004471 {
4472 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Devang Patel05988662008-09-25 21:00:45 +00004473 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004474 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004475 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004476 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004477 ;}
4478 break;
4479
Chris Lattner740e7092008-10-15 06:16:57 +00004480 case 170:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004481#line 1553 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004482 {
4483 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Devang Patel05988662008-09-25 21:00:45 +00004484 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004485 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004486 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004487 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004488 ;}
4489 break;
4490
Chris Lattner740e7092008-10-15 06:16:57 +00004491 case 171:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004492#line 1560 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004493 {
4494 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004495 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004496 ;}
4497 break;
4498
Chris Lattner740e7092008-10-15 06:16:57 +00004499 case 172:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004500#line 1568 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004501 {
4502 (yyval.TypeList) = new std::list<PATypeHolder>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004503 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004504 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004505 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004506 ;}
4507 break;
4508
Chris Lattner740e7092008-10-15 06:16:57 +00004509 case 173:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004510#line 1574 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004511 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00004512 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004513 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004514 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004515 ;}
4516 break;
4517
Chris Lattner740e7092008-10-15 06:16:57 +00004518 case 174:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004519#line 1586 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004520 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004521 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004522 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4523 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004524 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004525 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004526 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004527 const Type *ETy = ATy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004528 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004529
4530 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004531 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004532 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004533 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004534 utostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004535
4536 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004537 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4538 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004539 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004540 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004541 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004542 }
4543
Dan Gohmanf4423b12008-04-19 00:24:39 +00004544 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4545 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004546 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004547 ;}
4548 break;
4549
Chris Lattner740e7092008-10-15 06:16:57 +00004550 case 175:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004551#line 1614 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004552 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004553 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004554 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4555 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004556 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004557 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004558 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004559
Dan Gohman180c1692008-06-23 18:43:26 +00004560 uint64_t NumElements = ATy->getNumElements();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004561 if (NumElements != uint64_t(-1) && NumElements != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004562 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Mon P Wang28873102008-06-25 08:15:39 +00004563 " arguments, but has size of " + utostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004564 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4565 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004566 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004567 ;}
4568 break;
4569
Chris Lattner740e7092008-10-15 06:16:57 +00004570 case 176:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004571#line 1630 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004572 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004573 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004574 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4575 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004576 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004577 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004578 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004579
Dan Gohman180c1692008-06-23 18:43:26 +00004580 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004581 const Type *ETy = ATy->getElementType();
Mon P Wang28873102008-06-25 08:15:39 +00004582 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (3)].StrVal)->length())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004583 GEN_ERROR("Can't build string constant of size " +
Mon P Wang28873102008-06-25 08:15:39 +00004584 utostr((yyvsp[(3) - (3)].StrVal)->length()) +
4585 " when array has size " + utostr(NumElements) + "");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004586 std::vector<Constant*> Vals;
4587 if (ETy == Type::Int8Ty) {
Mon P Wang28873102008-06-25 08:15:39 +00004588 for (uint64_t i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004589 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004590 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004591 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004592 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4593 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004594 delete (yyvsp[(3) - (3)].StrVal);
4595 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4596 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004597 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004598 ;}
4599 break;
4600
Chris Lattner740e7092008-10-15 06:16:57 +00004601 case 177:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004602#line 1657 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004603 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004604 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004605 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4606 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004607 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004608 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004609 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004610 const Type *ETy = PTy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004611 unsigned NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004612
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004613 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004614 if (NumElements != unsigned(-1) && NumElements != (unsigned)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004615 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004616 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004617 utostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004618
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004619 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004620 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4621 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004622 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004623 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004624 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004625 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004626
Dan Gohmanf4423b12008-04-19 00:24:39 +00004627 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4628 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004629 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004630 ;}
4631 break;
4632
Chris Lattner740e7092008-10-15 06:16:57 +00004633 case 178:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004634#line 1685 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004635 {
4636 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004637 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004638 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004639 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004640
Dan Gohmanf4423b12008-04-19 00:24:39 +00004641 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004642 GEN_ERROR("Illegal number of initializers for structure type");
4643
4644 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004645 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4646 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004647 GEN_ERROR("Expected type '" +
4648 STy->getElementType(i)->getDescription() +
4649 "' for element #" + utostr(i) +
4650 " of structure initializer");
4651
4652 // Check to ensure that Type is not packed
4653 if (STy->isPacked())
4654 GEN_ERROR("Unpacked Initializer to vector type '" +
4655 STy->getDescription() + "'");
4656
Dan Gohmanf4423b12008-04-19 00:24:39 +00004657 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4658 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004659 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004660 ;}
4661 break;
4662
Chris Lattner740e7092008-10-15 06:16:57 +00004663 case 179:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004664#line 1711 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004665 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004666 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004667 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4668 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004669 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004670 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004671 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004672
4673 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004674 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004675
4676 // Check to ensure that Type is not packed
4677 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004678 GEN_ERROR("Unpacked Initializer to vector type '" +
4679 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004680
Dan Gohmanf4423b12008-04-19 00:24:39 +00004681 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4682 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004683 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004684 ;}
4685 break;
4686
Chris Lattner740e7092008-10-15 06:16:57 +00004687 case 180:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004688#line 1731 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004689 {
4690 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004691 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004692 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004693 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004694
Dan Gohmanf4423b12008-04-19 00:24:39 +00004695 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004696 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004697
4698 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004699 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4700 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004701 GEN_ERROR("Expected type '" +
4702 STy->getElementType(i)->getDescription() +
4703 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004704 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004705
4706 // Check to ensure that Type is packed
4707 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004708 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004709 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004710
Dan Gohmanf4423b12008-04-19 00:24:39 +00004711 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4712 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004713 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004714 ;}
4715 break;
4716
Chris Lattner740e7092008-10-15 06:16:57 +00004717 case 181:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004718#line 1757 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004719 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004720 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004721 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4722 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004723 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004724 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004725 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004726
4727 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004728 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004729
4730 // Check to ensure that Type is packed
4731 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004732 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004733 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004734
Dan Gohmanf4423b12008-04-19 00:24:39 +00004735 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4736 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004737 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004738 ;}
4739 break;
4740
Chris Lattner740e7092008-10-15 06:16:57 +00004741 case 182:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004742#line 1777 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004743 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004744 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004745 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4746 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004747 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004748 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004749 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004750
Dan Gohmanf4423b12008-04-19 00:24:39 +00004751 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4752 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004753 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004754 ;}
4755 break;
4756
Chris Lattner740e7092008-10-15 06:16:57 +00004757 case 183:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004758#line 1789 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004759 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004760 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004761 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4762 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4763 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004764 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004765 ;}
4766 break;
4767
Chris Lattner740e7092008-10-15 06:16:57 +00004768 case 184:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004769#line 1796 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004770 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004771 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004772 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4773 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004774 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004775 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004776
4777 // ConstExprs can exist in the body of a function, thus creating
4778 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004779 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004780 // symbol table instead of the module symbol table for the global symbol,
4781 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004782 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004783 //
4784 Function *SavedCurFn = CurFun.CurrentFunction;
4785 CurFun.CurrentFunction = 0;
4786
Dan Gohmanf4423b12008-04-19 00:24:39 +00004787 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004788 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004789
4790 CurFun.CurrentFunction = SavedCurFn;
4791
4792 // If this is an initializer for a constant pointer, which is referencing a
4793 // (currently) undefined variable, create a stub now that shall be replaced
4794 // in the future with the right type of variable.
4795 //
4796 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004797 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004798 const PointerType *PT = cast<PointerType>(Ty);
4799
4800 // First check to see if the forward references value is already created!
4801 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004802 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Eric Christopher2a5196f2008-09-24 04:55:49 +00004803
Reid Spencer68a24bd2005-08-27 18:50:39 +00004804 if (I != CurModule.GlobalRefs.end()) {
4805 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004806 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004807 } else {
4808 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004809 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4810 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4811 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004812 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004813
4814 // Create the forward referenced global.
4815 GlobalValue *GV;
Eric Christopher2a5196f2008-09-24 04:55:49 +00004816 if (const FunctionType *FTy =
Reid Spencer68a24bd2005-08-27 18:50:39 +00004817 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004818 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4819 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004820 } else {
4821 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004822 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004823 Name, CurModule.CurrentModule);
4824 }
4825
4826 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004827 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004828 V = GV;
4829 }
4830 }
4831
Dan Gohmanf4423b12008-04-19 00:24:39 +00004832 (yyval.ConstVal) = cast<GlobalValue>(V);
4833 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004834 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004835 ;}
4836 break;
4837
Chris Lattner740e7092008-10-15 06:16:57 +00004838 case 185:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004839#line 1862 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004840 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004841 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004842 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4843 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004844 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004845 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4846 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4847 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004848 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004849 ;}
4850 break;
4851
Chris Lattner740e7092008-10-15 06:16:57 +00004852 case 186:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004853#line 1872 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004854 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004855 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004856 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4857 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004858 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4859 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004860 (yyval.ConstVal) = Constant::getNullValue(Ty);
4861 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004862 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004863 ;}
4864 break;
4865
Chris Lattner740e7092008-10-15 06:16:57 +00004866 case 187:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004867#line 1882 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004868 { // integral constants
Chris Lattner740e7092008-10-15 06:16:57 +00004869 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4870 if (!ConstantInt::isValueValidForType(IT, (yyvsp[(2) - (2)].SInt64Val)))
4871 GEN_ERROR("Constant value doesn't fit in type");
4872 (yyval.ConstVal) = ConstantInt::get(IT, (yyvsp[(2) - (2)].SInt64Val), true);
4873 } else {
4874 GEN_ERROR("integer constant must have integer type");
4875 }
4876 delete (yyvsp[(1) - (2)].TypeVal);
4877 CHECK_FOR_ERROR
4878 ;}
4879 break;
4880
4881 case 188:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004882#line 1893 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004883 { // arbitrary precision integer constants
4884 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4885 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > IT->getBitWidth())
4886 GEN_ERROR("Constant value does not fit in type");
4887 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(IT->getBitWidth());
4888 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4889 } else {
4890 GEN_ERROR("integer constant must have integer type");
4891 }
4892 delete (yyvsp[(1) - (2)].TypeVal);
4893 delete (yyvsp[(2) - (2)].APIntVal);
4894 CHECK_FOR_ERROR
4895 ;}
4896 break;
4897
4898 case 189:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004899#line 1906 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004900 { // integral constants
4901 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4902 if (!ConstantInt::isValueValidForType(IT, (yyvsp[(2) - (2)].UInt64Val)))
4903 GEN_ERROR("Constant value doesn't fit in type");
4904 (yyval.ConstVal) = ConstantInt::get(IT, (yyvsp[(2) - (2)].UInt64Val), false);
4905 } else {
4906 GEN_ERROR("integer constant must have integer type");
4907 }
4908 delete (yyvsp[(1) - (2)].TypeVal);
4909 CHECK_FOR_ERROR
4910 ;}
4911 break;
4912
4913 case 190:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004914#line 1917 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004915 { // arbitrary precision integer constants
4916 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4917 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > IT->getBitWidth())
4918 GEN_ERROR("Constant value does not fit in type");
4919 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(IT->getBitWidth());
4920 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4921 } else {
4922 GEN_ERROR("integer constant must have integer type");
4923 }
4924
4925 delete (yyvsp[(2) - (2)].APIntVal);
4926 delete (yyvsp[(1) - (2)].TypeVal);
4927 CHECK_FOR_ERROR
4928 ;}
4929 break;
4930
4931 case 191:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004932#line 1931 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004933 { // Boolean constants
4934 if ((yyvsp[(1) - (2)].TypeVal)->get() != Type::Int1Ty)
4935 GEN_ERROR("Constant true must have type i1");
4936 (yyval.ConstVal) = ConstantInt::getTrue();
4937 delete (yyvsp[(1) - (2)].TypeVal);
4938 CHECK_FOR_ERROR
4939 ;}
4940 break;
4941
4942 case 192:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004943#line 1938 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004944 { // Boolean constants
4945 if ((yyvsp[(1) - (2)].TypeVal)->get() != Type::Int1Ty)
4946 GEN_ERROR("Constant false must have type i1");
4947 (yyval.ConstVal) = ConstantInt::getFalse();
4948 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00004949 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004950 ;}
4951 break;
4952
Chris Lattnerf9078f92008-10-15 06:03:48 +00004953 case 193:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004954#line 1945 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004955 { // Floating point constants
Chris Lattner740e7092008-10-15 06:16:57 +00004956 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].TypeVal)->get(), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004957 GEN_ERROR("Floating point constant invalid for type");
Chris Lattner740e7092008-10-15 06:16:57 +00004958
Eric Christopher2a5196f2008-09-24 04:55:49 +00004959 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004960 // as double. Fix this here. Long double is done right.
Chris Lattner740e7092008-10-15 06:16:57 +00004961 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].TypeVal)->get()==Type::FloatTy) {
Dale Johannesen236bbd42008-10-09 23:01:34 +00004962 bool ignored;
4963 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
4964 &ignored);
4965 }
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004966 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Chris Lattner740e7092008-10-15 06:16:57 +00004967 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004968 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004969 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004970 ;}
4971 break;
4972
Chris Lattner740e7092008-10-15 06:16:57 +00004973 case 194:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004974#line 1963 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004975 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004976 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004977 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4978 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4979 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4980 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004981 GEN_ERROR("invalid cast opcode for cast from '" +
4982 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004983 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004984 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4985 delete (yyvsp[(5) - (6)].TypeVal);
4986 ;}
4987 break;
4988
Chris Lattner740e7092008-10-15 06:16:57 +00004989 case 195:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00004990#line 1975 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004991 {
4992 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004993 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004994
4995 const Type *IdxTy =
Dan Gohman041e2eb2008-05-15 19:50:34 +00004996 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004997 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004998 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004999
Chris Lattnerf7469af2007-01-31 04:44:08 +00005000 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005001 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
5002 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005003 IdxVec.push_back(C);
5004 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005005 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005006
Dan Gohmanf4423b12008-04-19 00:24:39 +00005007 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005008
Dan Gohmanf4423b12008-04-19 00:24:39 +00005009 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00005010 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005011 ;}
5012 break;
5013
Chris Lattner740e7092008-10-15 06:16:57 +00005014 case 196:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005015#line 1996 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005016 {
5017 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005018 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005019 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005020 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005021 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005022 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005023 ;}
5024 break;
5025
Chris Lattner740e7092008-10-15 06:16:57 +00005026 case 197:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005027#line 2004 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005028 {
5029 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005030 GEN_ERROR("Binary operator types must match");
5031 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005032 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
5033 ;}
5034 break;
5035
Chris Lattner740e7092008-10-15 06:16:57 +00005036 case 198:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005037#line 2010 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005038 {
5039 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005040 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005041 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005042 if (!isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00005043 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005044 GEN_ERROR("Logical operator requires integral operands");
5045 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005046 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005047 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005048 ;}
5049 break;
5050
Chris Lattner740e7092008-10-15 06:16:57 +00005051 case 199:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005052#line 2021 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005053 {
5054 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005055 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005056 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5057 ;}
5058 break;
5059
Chris Lattner740e7092008-10-15 06:16:57 +00005060 case 200:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005061#line 2026 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005062 {
5063 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005064 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005065 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5066 ;}
5067 break;
5068
Chris Lattner740e7092008-10-15 06:16:57 +00005069 case 201:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005070#line 2031 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005071 {
5072 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5073 GEN_ERROR("vicmp operand types must match");
5074 (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5075 ;}
5076 break;
5077
Chris Lattner740e7092008-10-15 06:16:57 +00005078 case 202:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005079#line 2036 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005080 {
5081 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5082 GEN_ERROR("vfcmp operand types must match");
5083 (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5084 ;}
5085 break;
5086
Chris Lattner740e7092008-10-15 06:16:57 +00005087 case 203:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005088#line 2041 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005089 {
5090 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005091 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005092 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005093 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005094 ;}
5095 break;
5096
Chris Lattner740e7092008-10-15 06:16:57 +00005097 case 204:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005098#line 2047 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005099 {
5100 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005101 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005102 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005103 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005104 ;}
5105 break;
5106
Chris Lattner740e7092008-10-15 06:16:57 +00005107 case 205:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005108#line 2053 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005109 {
5110 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005111 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005112 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005113 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005114 ;}
5115 break;
5116
Chris Lattner740e7092008-10-15 06:16:57 +00005117 case 206:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005118#line 2059 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005119 {
5120 if (!isa<StructType>((yyvsp[(3) - (5)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (5)].ConstVal)->getType()))
5121 GEN_ERROR("ExtractValue requires an aggregate operand");
5122
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005123 (yyval.ConstVal) = ConstantExpr::getExtractValue((yyvsp[(3) - (5)].ConstVal), &(*(yyvsp[(4) - (5)].ConstantList))[0], (yyvsp[(4) - (5)].ConstantList)->size());
5124 delete (yyvsp[(4) - (5)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005125 CHECK_FOR_ERROR
5126 ;}
5127 break;
5128
Chris Lattner740e7092008-10-15 06:16:57 +00005129 case 207:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005130#line 2067 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005131 {
5132 if (!isa<StructType>((yyvsp[(3) - (7)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (7)].ConstVal)->getType()))
5133 GEN_ERROR("InsertValue requires an aggregate operand");
5134
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005135 (yyval.ConstVal) = ConstantExpr::getInsertValue((yyvsp[(3) - (7)].ConstVal), (yyvsp[(5) - (7)].ConstVal), &(*(yyvsp[(6) - (7)].ConstantList))[0], (yyvsp[(6) - (7)].ConstantList)->size());
5136 delete (yyvsp[(6) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005137 CHECK_FOR_ERROR
5138 ;}
5139 break;
5140
Chris Lattner740e7092008-10-15 06:16:57 +00005141 case 208:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005142#line 2078 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005143 {
5144 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005145 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005146 ;}
5147 break;
5148
Chris Lattner740e7092008-10-15 06:16:57 +00005149 case 209:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005150#line 2082 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005151 {
5152 (yyval.ConstVector) = new std::vector<Constant*>();
5153 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005154 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005155 ;}
5156 break;
5157
Chris Lattner740e7092008-10-15 06:16:57 +00005158 case 210:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005159#line 2090 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005160 { (yyval.BoolVal) = false; ;}
Nate Begemanac80ade2008-05-12 19:01:56 +00005161 break;
5162
Chris Lattner740e7092008-10-15 06:16:57 +00005163 case 211:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005164#line 2090 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005165 { (yyval.BoolVal) = true; ;}
5166 break;
5167
Chris Lattner740e7092008-10-15 06:16:57 +00005168 case 212:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005169#line 2093 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005170 { (yyval.BoolVal) = true; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005171 break;
5172
Chris Lattner740e7092008-10-15 06:16:57 +00005173 case 213:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005174#line 2093 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005175 { (yyval.BoolVal) = false; ;}
5176 break;
5177
Chris Lattner740e7092008-10-15 06:16:57 +00005178 case 214:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005179#line 2096 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005180 {
5181 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
5182 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00005183 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005184 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
5185 if (!Aliasee)
5186 GEN_ERROR("Aliases can be created only to global values");
5187
Dan Gohmanf4423b12008-04-19 00:24:39 +00005188 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005189 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005190 delete (yyvsp[(1) - (2)].TypeVal);
5191 ;}
5192 break;
5193
Chris Lattner740e7092008-10-15 06:16:57 +00005194 case 215:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005195#line 2108 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005196 {
5197 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
5198 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
5199 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005200 GEN_ERROR("invalid cast opcode for cast from '" +
5201 Val->getType()->getDescription() + "' to '" +
5202 DestTy->getDescription() + "'");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005203
Dan Gohmanf4423b12008-04-19 00:24:39 +00005204 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005205 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005206 delete (yyvsp[(5) - (6)].TypeVal);
5207 ;}
5208 break;
5209
Chris Lattner740e7092008-10-15 06:16:57 +00005210 case 216:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005211#line 2129 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005212 {
5213 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5214 CurModule.ModuleDone();
5215 CHECK_FOR_ERROR;
5216 ;}
5217 break;
5218
Chris Lattner740e7092008-10-15 06:16:57 +00005219 case 217:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005220#line 2134 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005221 {
5222 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5223 CurModule.ModuleDone();
5224 CHECK_FOR_ERROR;
5225 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005226 break;
5227
Chris Lattner740e7092008-10-15 06:16:57 +00005228 case 220:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005229#line 2147 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005230 { CurFun.isDeclare = false; ;}
5231 break;
5232
Chris Lattner740e7092008-10-15 06:16:57 +00005233 case 221:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005234#line 2147 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005235 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005236 CurFun.FunctionDone();
5237 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005238 ;}
5239 break;
5240
Chris Lattner740e7092008-10-15 06:16:57 +00005241 case 222:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005242#line 2151 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005243 { CurFun.isDeclare = true; ;}
5244 break;
5245
Chris Lattner740e7092008-10-15 06:16:57 +00005246 case 223:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005247#line 2151 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005248 {
5249 CHECK_FOR_ERROR
5250 ;}
5251 break;
5252
Chris Lattner740e7092008-10-15 06:16:57 +00005253 case 224:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005254#line 2154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005255 {
5256 CHECK_FOR_ERROR
5257 ;}
5258 break;
5259
Chris Lattner740e7092008-10-15 06:16:57 +00005260 case 225:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005261#line 2157 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005262 {
Reid Spencer14310612006-12-31 05:40:51 +00005263 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005264 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005265 // Eagerly resolve types. This is not an optimization, this is a
5266 // requirement that is due to the fact that we could have this:
5267 //
5268 // %list = type { %list * }
5269 // %list = type { %list * } ; repeated type decl
5270 //
5271 // If types are not resolved eagerly, then the two types will not be
5272 // determined to be the same type!
5273 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00005274 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005275
Dan Gohmanf4423b12008-04-19 00:24:39 +00005276 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00005277 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005278 // If this is a named type that is not a redefinition, add it to the slot
5279 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005280 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005281 }
Reid Spencera132e042006-12-03 05:46:11 +00005282
Dan Gohmanf4423b12008-04-19 00:24:39 +00005283 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005284 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005285 ;}
5286 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00005287
Chris Lattner740e7092008-10-15 06:16:57 +00005288 case 226:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005289#line 2181 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005290 {
5291 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
5292
5293 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005294 CHECK_FOR_ERROR
5295 // If this is a named type that is not a redefinition, add it to the slot
5296 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005297 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005298 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005299 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005300 ;}
5301 break;
5302
Chris Lattner740e7092008-10-15 06:16:57 +00005303 case 227:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005304#line 2193 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005305 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005306 /* "Externally Visible" Linkage */
Eric Christopher2a5196f2008-09-24 04:55:49 +00005307 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005308 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005309 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5310 (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 +00005311 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005312 ;}
5313 break;
5314
Chris Lattner740e7092008-10-15 06:16:57 +00005315 case 228:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005316#line 2200 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005317 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005318 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005319 ;}
5320 break;
5321
Chris Lattner740e7092008-10-15 06:16:57 +00005322 case 229:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005323#line 2204 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005324 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005325 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005326 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005327 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 +00005328 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005329 ;}
5330 break;
5331
Chris Lattner740e7092008-10-15 06:16:57 +00005332 case 230:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005333#line 2209 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005334 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005335 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005336 ;}
5337 break;
5338
Chris Lattner740e7092008-10-15 06:16:57 +00005339 case 231:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005340#line 2213 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005341 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005342 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005343 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5344 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 +00005345 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005346 delete (yyvsp[(6) - (7)].TypeVal);
5347 ;}
5348 break;
5349
Chris Lattner740e7092008-10-15 06:16:57 +00005350 case 232:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005351#line 2219 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005352 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005353 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005354 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005355 ;}
5356 break;
5357
Chris Lattner740e7092008-10-15 06:16:57 +00005358 case 233:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005359#line 2223 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005360 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005361 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005362 if ((yyvsp[(1) - (5)].StrVal)) {
5363 Name = *(yyvsp[(1) - (5)].StrVal);
5364 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005365 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005366 if (Name.empty())
5367 GEN_ERROR("Alias name cannot be empty");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005368
Dan Gohmanf4423b12008-04-19 00:24:39 +00005369 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005370 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005371 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005372
Dan Gohmanf4423b12008-04-19 00:24:39 +00005373 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005374 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005375 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005376 InsertValue(GA, CurModule.Values);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005377
5378
Chris Lattner569f7372007-09-10 23:24:14 +00005379 // If there was a forward reference of this alias, resolve it now.
Eric Christopher2a5196f2008-09-24 04:55:49 +00005380
Chris Lattner569f7372007-09-10 23:24:14 +00005381 ValID ID;
5382 if (!Name.empty())
5383 ID = ValID::createGlobalName(Name);
5384 else
5385 ID = ValID::createGlobalID(CurModule.Values.size()-1);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005386
Chris Lattner569f7372007-09-10 23:24:14 +00005387 if (GlobalValue *FWGV =
5388 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5389 // Replace uses of the fwdref with the actual alias.
5390 FWGV->replaceAllUsesWith(GA);
5391 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5392 GV->eraseFromParent();
5393 else
5394 cast<Function>(FWGV)->eraseFromParent();
5395 }
5396 ID.destroy();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005397
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005398 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005399 ;}
5400 break;
5401
Chris Lattner740e7092008-10-15 06:16:57 +00005402 case 234:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005403#line 2263 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005404 {
5405 CHECK_FOR_ERROR
5406 ;}
5407 break;
5408
Chris Lattner740e7092008-10-15 06:16:57 +00005409 case 235:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005410#line 2266 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005411 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005412 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005413 ;}
5414 break;
5415
Chris Lattner740e7092008-10-15 06:16:57 +00005416 case 236:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005417#line 2272 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005418 {
Chris Lattner66316012006-01-24 04:14:29 +00005419 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005420 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005421 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005422 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005423 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5424 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005425 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005426;}
5427 break;
5428
Chris Lattner740e7092008-10-15 06:16:57 +00005429 case 237:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005430#line 2282 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005431 {
5432 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5433 delete (yyvsp[(3) - (3)].StrVal);
5434 ;}
5435 break;
5436
Chris Lattner740e7092008-10-15 06:16:57 +00005437 case 238:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005438#line 2286 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005439 {
5440 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5441 delete (yyvsp[(3) - (3)].StrVal);
5442 ;}
5443 break;
5444
Chris Lattner740e7092008-10-15 06:16:57 +00005445 case 240:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005446#line 2293 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005447 {
5448 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5449 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005450 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005451 ;}
5452 break;
5453
Chris Lattner740e7092008-10-15 06:16:57 +00005454 case 241:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005455#line 2298 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005456 {
5457 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5458 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005459 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005460 ;}
5461 break;
5462
Chris Lattner740e7092008-10-15 06:16:57 +00005463 case 242:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005464#line 2303 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005465 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005466 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005467 ;}
5468 break;
5469
Chris Lattner740e7092008-10-15 06:16:57 +00005470 case 243:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005471#line 2312 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005472 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005473 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005474 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005475 if (!(*(yyvsp[(3) - (5)].TypeVal))->isFirstClassType())
5476 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005477 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 +00005478 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5479 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005480 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005481 ;}
5482 break;
5483
Chris Lattner740e7092008-10-15 06:16:57 +00005484 case 244:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005485#line 2322 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005486 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005487 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005488 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005489 if (!(*(yyvsp[(1) - (3)].TypeVal))->isFirstClassType())
5490 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005491 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 +00005492 (yyval.ArgList) = new ArgListType;
5493 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005494 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005495 ;}
5496 break;
5497
Chris Lattner740e7092008-10-15 06:16:57 +00005498 case 245:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005499#line 2333 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005500 {
5501 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005502 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005503 ;}
5504 break;
5505
Chris Lattner740e7092008-10-15 06:16:57 +00005506 case 246:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005507#line 2337 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005508 {
5509 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005510 struct ArgListEntry E;
5511 E.Ty = new PATypeHolder(Type::VoidTy);
5512 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005513 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005514 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005515 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005516 ;}
5517 break;
5518
Chris Lattner740e7092008-10-15 06:16:57 +00005519 case 247:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005520#line 2346 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005521 {
5522 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005523 struct ArgListEntry E;
5524 E.Ty = new PATypeHolder(Type::VoidTy);
5525 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005526 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005527 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005528 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005529 ;}
5530 break;
5531
Chris Lattner740e7092008-10-15 06:16:57 +00005532 case 248:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005533#line 2355 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005534 {
5535 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005536 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005537 ;}
5538 break;
5539
Chris Lattner740e7092008-10-15 06:16:57 +00005540 case 249:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005541#line 2361 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005542 {
Devang Patel652203f2008-09-29 20:49:50 +00005543 std::string FunctionName(*(yyvsp[(4) - (11)].StrVal));
5544 delete (yyvsp[(4) - (11)].StrVal); // Free strdup'd memory!
Eric Christopher2a5196f2008-09-24 04:55:49 +00005545
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005546 // Check the function result for abstractness if this is a define. We should
5547 // have no abstract types at this point
Devang Patel652203f2008-09-29 20:49:50 +00005548 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(3) - (11)].TypeVal)))
5549 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(3) - (11)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005550
Devang Patel652203f2008-09-29 20:49:50 +00005551 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (11)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00005552 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005553
Reid Spencer68a24bd2005-08-27 18:50:39 +00005554 std::vector<const Type*> ParamTypeList;
Devang Patel05988662008-09-25 21:00:45 +00005555 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00005556 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
5557 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00005558 Attributes RetAttrs = (yyvsp[(2) - (11)].Attributes);
5559 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None) {
5560 if ((yyvsp[(8) - (11)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005561 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00005562 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005563 }
Devang Patel652203f2008-09-29 20:49:50 +00005564 if ((yyvsp[(8) - (11)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005565 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00005566 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005567 }
Devang Patel652203f2008-09-29 20:49:50 +00005568 if ((yyvsp[(8) - (11)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00005569 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00005570 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00005571 }
Dale Johannesene7261862008-09-26 23:46:20 +00005572 }
Devang Patel652203f2008-09-29 20:49:50 +00005573 if (RetAttrs != Attribute::None)
5574 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
5575 if ((yyvsp[(6) - (11)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005576 unsigned index = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005577 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin(); I != (yyvsp[(6) - (11)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005578 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005579 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5580 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005581 ParamTypeList.push_back(Ty);
Devang Patel05988662008-09-25 21:00:45 +00005582 if (Ty != Type::VoidTy && I->Attrs != Attribute::None)
5583 Attrs.push_back(AttributeWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005584 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005585 }
Devang Patel652203f2008-09-29 20:49:50 +00005586 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None)
5587 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(8) - (11)].Attributes)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005588
5589 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5590 if (isVarArg) ParamTypeList.pop_back();
5591
Devang Patel05988662008-09-25 21:00:45 +00005592 AttrListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005593 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00005594 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005595
Devang Patel652203f2008-09-29 20:49:50 +00005596 FunctionType *FT = FunctionType::get(*(yyvsp[(3) - (11)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005597 const PointerType *PFT = PointerType::getUnqual(FT);
Devang Patel652203f2008-09-29 20:49:50 +00005598 delete (yyvsp[(3) - (11)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005599
5600 ValID ID;
5601 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005602 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005603 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005604 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005605 }
5606
5607 Function *Fn = 0;
5608 // See if this function was forward referenced. If so, recycle the object.
5609 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005610 // Move the function to the end of the list, from whereever it was
Reid Spencer68a24bd2005-08-27 18:50:39 +00005611 // previously inserted.
5612 Fn = cast<Function>(FWRef);
Devang Patel05988662008-09-25 21:00:45 +00005613 assert(Fn->getAttributes().isEmpty() &&
Chris Lattner58d74912008-03-12 17:45:29 +00005614 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005615 CurModule.CurrentModule->getFunctionList().remove(Fn);
5616 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5617 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005618 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005619 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005620 // The existing function doesn't have the same type. This is an overload
5621 // error.
5622 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Devang Patel05988662008-09-25 21:00:45 +00005623 } else if (Fn->getAttributes() != PAL) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005624 // The existing function doesn't have the same parameter attributes.
5625 // This is an overload error.
5626 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005627 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005628 // Neither the existing or the current function is a declaration and they
5629 // have the same name and same type. Clearly this is a redefinition.
5630 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005631 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005632 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005633 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5634 AI != AE; ++AI)
5635 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005636 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005637 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005638 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5639 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005640 InsertValue(Fn, CurModule.Values);
5641 }
5642
Nuno Lopes9e9631d2008-10-03 15:45:58 +00005643 ID.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005644 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005645
5646 if (CurFun.isDeclare) {
5647 // If we have declaration, always overwrite linkage. This will allow us to
5648 // correctly handle cases, when pointer to function is passed as argument to
5649 // another function.
5650 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005651 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005652 }
Devang Pateld4980812008-09-02 20:52:40 +00005653 Fn->setCallingConv((yyvsp[(1) - (11)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00005654 Fn->setAttributes(PAL);
Devang Patel652203f2008-09-29 20:49:50 +00005655 Fn->setAlignment((yyvsp[(10) - (11)].UIntVal));
5656 if ((yyvsp[(9) - (11)].StrVal)) {
5657 Fn->setSection(*(yyvsp[(9) - (11)].StrVal));
5658 delete (yyvsp[(9) - (11)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005659 }
Devang Patel652203f2008-09-29 20:49:50 +00005660 if ((yyvsp[(11) - (11)].StrVal)) {
5661 Fn->setGC((yyvsp[(11) - (11)].StrVal)->c_str());
5662 delete (yyvsp[(11) - (11)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005663 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005664
5665 // Add all of the arguments we parsed to the function...
Devang Patel652203f2008-09-29 20:49:50 +00005666 if ((yyvsp[(6) - (11)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005667 if (isVarArg) { // Nuke the last entry
Devang Patel652203f2008-09-29 20:49:50 +00005668 assert((yyvsp[(6) - (11)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(6) - (11)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005669 "Not a varargs marker!");
Devang Patel652203f2008-09-29 20:49:50 +00005670 delete (yyvsp[(6) - (11)].ArgList)->back().Ty;
5671 (yyvsp[(6) - (11)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005672 }
5673 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005674 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005675 unsigned Idx = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005676 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin();
5677 I != (yyvsp[(6) - (11)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005678 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005679 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005680 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005681 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005682 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005683 }
Reid Spencera132e042006-12-03 05:46:11 +00005684
Devang Patel652203f2008-09-29 20:49:50 +00005685 delete (yyvsp[(6) - (11)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005686 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005687 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005688;}
5689 break;
5690
Chris Lattner740e7092008-10-15 06:16:57 +00005691 case 252:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005692#line 2511 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005693 {
5694 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005695
5696 // Make sure that we keep track of the linkage type even if there was a
5697 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005698 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5699 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5700;}
5701 break;
5702
Chris Lattner740e7092008-10-15 06:16:57 +00005703 case 255:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005704#line 2522 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005705 {
5706 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005707 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005708;}
5709 break;
5710
Chris Lattner740e7092008-10-15 06:16:57 +00005711 case 256:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005712#line 2527 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005713 {
5714 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5715 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5716 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005717 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005718 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005719 ;}
5720 break;
5721
Chris Lattner740e7092008-10-15 06:16:57 +00005722 case 257:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005723#line 2539 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005724 {
5725 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005726 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005727 ;}
5728 break;
5729
Chris Lattner740e7092008-10-15 06:16:57 +00005730 case 258:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005731#line 2543 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005732 {
5733 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005734 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005735 ;}
5736 break;
5737
Chris Lattner740e7092008-10-15 06:16:57 +00005738 case 259:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005739#line 2548 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005740 { // A reference to a direct constant
5741 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005742 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005743 ;}
5744 break;
5745
Chris Lattner740e7092008-10-15 06:16:57 +00005746 case 260:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005747#line 2552 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005748 {
5749 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005750 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005751 ;}
5752 break;
5753
Chris Lattner740e7092008-10-15 06:16:57 +00005754 case 261:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005755#line 2556 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005756 { // arbitrary precision integer constants
5757 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), true);
5758 delete (yyvsp[(1) - (1)].APIntVal);
5759 CHECK_FOR_ERROR
5760 ;}
5761 break;
5762
Chris Lattner740e7092008-10-15 06:16:57 +00005763 case 262:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005764#line 2561 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005765 { // arbitrary precision integer constants
5766 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), false);
5767 delete (yyvsp[(1) - (1)].APIntVal);
5768 CHECK_FOR_ERROR
5769 ;}
5770 break;
5771
Chris Lattner740e7092008-10-15 06:16:57 +00005772 case 263:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005773#line 2566 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005774 { // Perhaps it's an FP constant?
5775 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005776 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005777 ;}
5778 break;
5779
Chris Lattner740e7092008-10-15 06:16:57 +00005780 case 264:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005781#line 2570 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005782 {
5783 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005784 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005785 ;}
5786 break;
5787
Chris Lattner740e7092008-10-15 06:16:57 +00005788 case 265:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005789#line 2574 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005790 {
5791 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005792 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005793 ;}
5794 break;
5795
Chris Lattner740e7092008-10-15 06:16:57 +00005796 case 266:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005797#line 2578 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005798 {
5799 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005800 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005801 ;}
5802 break;
5803
Chris Lattner740e7092008-10-15 06:16:57 +00005804 case 267:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005805#line 2582 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005806 {
5807 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005808 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005809 ;}
5810 break;
5811
Chris Lattner740e7092008-10-15 06:16:57 +00005812 case 268:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005813#line 2586 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005814 { // A vector zero constant.
5815 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005816 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005817 ;}
5818 break;
5819
Chris Lattner740e7092008-10-15 06:16:57 +00005820 case 269:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005821#line 2590 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005822 { // Nonempty unsized packed vector
5823 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005824 unsigned NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005825
5826 if (!ETy->isInteger() && !ETy->isFloatingPoint())
5827 GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005828
Reid Spencer9d6565a2007-02-15 02:26:10 +00005829 VectorType* pt = VectorType::get(ETy, NumElements);
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005830 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
Eric Christopher2a5196f2008-09-24 04:55:49 +00005831
Reid Spencer68a24bd2005-08-27 18:50:39 +00005832 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005833 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5834 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005835 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005836 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005837 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005838 }
5839
Dan Gohmanf4423b12008-04-19 00:24:39 +00005840 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5841 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005842 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005843 ;}
5844 break;
5845
Chris Lattner740e7092008-10-15 06:16:57 +00005846 case 270:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005847#line 2612 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005848 { // Nonempty unsized arr
5849 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005850 uint64_t NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005851
5852 if (!ETy->isFirstClassType())
5853 GEN_ERROR("Invalid array element type: " + ETy->getDescription());
5854
5855 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5856 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
5857
5858 // Verify all elements are correct type!
5859 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5860 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005861 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005862 ETy->getDescription() +"' as required!\nIt is of type '"+
5863 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
5864 }
5865
5866 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, *(yyvsp[(2) - (3)].ConstVector)));
5867 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5868 CHECK_FOR_ERROR
5869 ;}
5870 break;
5871
Chris Lattner740e7092008-10-15 06:16:57 +00005872 case 271:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005873#line 2634 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005874 {
Dan Gohman180c1692008-06-23 18:43:26 +00005875 // Use undef instead of an array because it's inconvenient to determine
5876 // the element type at this point, there being no elements to examine.
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005877 (yyval.ValIDVal) = ValID::createUndef();
5878 CHECK_FOR_ERROR
5879 ;}
5880 break;
5881
Chris Lattner740e7092008-10-15 06:16:57 +00005882 case 272:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005883#line 2640 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005884 {
Dan Gohman180c1692008-06-23 18:43:26 +00005885 uint64_t NumElements = (yyvsp[(2) - (2)].StrVal)->length();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005886 const Type *ETy = Type::Int8Ty;
5887
5888 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5889
5890 std::vector<Constant*> Vals;
5891 for (unsigned i = 0; i < (yyvsp[(2) - (2)].StrVal)->length(); ++i)
5892 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(2) - (2)].StrVal))[i]));
5893 delete (yyvsp[(2) - (2)].StrVal);
5894 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, Vals));
5895 CHECK_FOR_ERROR
5896 ;}
5897 break;
5898
Chris Lattner740e7092008-10-15 06:16:57 +00005899 case 273:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005900#line 2653 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005901 {
5902 std::vector<const Type*> Elements((yyvsp[(2) - (3)].ConstVector)->size());
5903 for (unsigned i = 0, e = (yyvsp[(2) - (3)].ConstVector)->size(); i != e; ++i)
5904 Elements[i] = (*(yyvsp[(2) - (3)].ConstVector))[i]->getType();
5905
5906 const StructType *STy = StructType::get(Elements);
5907 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5908
5909 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(2) - (3)].ConstVector)));
5910 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5911 CHECK_FOR_ERROR
5912 ;}
5913 break;
5914
Chris Lattner740e7092008-10-15 06:16:57 +00005915 case 274:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005916#line 2665 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005917 {
5918 const StructType *STy = StructType::get(std::vector<const Type*>());
5919 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5920 CHECK_FOR_ERROR
5921 ;}
5922 break;
5923
Chris Lattner740e7092008-10-15 06:16:57 +00005924 case 275:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005925#line 2670 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005926 {
5927 std::vector<const Type*> Elements((yyvsp[(3) - (5)].ConstVector)->size());
5928 for (unsigned i = 0, e = (yyvsp[(3) - (5)].ConstVector)->size(); i != e; ++i)
5929 Elements[i] = (*(yyvsp[(3) - (5)].ConstVector))[i]->getType();
5930
5931 const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
5932 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5933
5934 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(3) - (5)].ConstVector)));
5935 delete PTy; delete (yyvsp[(3) - (5)].ConstVector);
5936 CHECK_FOR_ERROR
5937 ;}
5938 break;
5939
Chris Lattner740e7092008-10-15 06:16:57 +00005940 case 276:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005941#line 2682 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005942 {
5943 const StructType *STy = StructType::get(std::vector<const Type*>(),
5944 /*isPacked=*/true);
5945 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5946 CHECK_FOR_ERROR
5947 ;}
5948 break;
5949
Chris Lattner740e7092008-10-15 06:16:57 +00005950 case 277:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005951#line 2688 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005952 {
5953 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005954 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005955 ;}
5956 break;
5957
Chris Lattner740e7092008-10-15 06:16:57 +00005958 case 278:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005959#line 2692 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005960 {
5961 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5962 delete (yyvsp[(3) - (5)].StrVal);
5963 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005964 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005965 ;}
5966 break;
5967
Chris Lattner740e7092008-10-15 06:16:57 +00005968 case 279:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005969#line 2702 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005970 { // Is it an integer reference...?
5971 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005972 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005973 ;}
5974 break;
5975
Chris Lattner740e7092008-10-15 06:16:57 +00005976 case 280:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005977#line 2706 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005978 {
5979 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005980 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005981 ;}
5982 break;
5983
Chris Lattner740e7092008-10-15 06:16:57 +00005984 case 281:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005985#line 2710 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005986 { // Is it a named reference...?
5987 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5988 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005989 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005990 ;}
5991 break;
5992
Chris Lattner740e7092008-10-15 06:16:57 +00005993 case 282:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00005994#line 2715 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005995 { // Is it a named reference...?
5996 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5997 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005998 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005999 ;}
6000 break;
6001
Chris Lattner740e7092008-10-15 06:16:57 +00006002 case 285:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006003#line 2728 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006004 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006005 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006006 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006007 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006008 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00006009 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006010 ;}
6011 break;
6012
Chris Lattner740e7092008-10-15 06:16:57 +00006013 case 286:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006014#line 2737 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006015 {
6016 (yyval.ValueList) = new std::vector<Value *>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00006017 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00006018 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006019 ;}
6020 break;
6021
Chris Lattner740e7092008-10-15 06:16:57 +00006022 case 287:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006023#line 2742 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006024 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006025 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00006026 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006027 ;}
6028 break;
6029
Chris Lattner740e7092008-10-15 06:16:57 +00006030 case 288:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006031#line 2747 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006032 {
6033 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006034 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006035 ;}
6036 break;
6037
Chris Lattner740e7092008-10-15 06:16:57 +00006038 case 289:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006039#line 2751 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006040 { // Do not allow functions with 0 basic blocks
Dan Gohmanf4423b12008-04-19 00:24:39 +00006041 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006042 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006043 ;}
6044 break;
6045
Chris Lattner740e7092008-10-15 06:16:57 +00006046 case 290:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006047#line 2760 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006048 {
6049 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006050 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006051 InsertValue((yyvsp[(3) - (3)].TermInstVal));
6052 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6053 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006054 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006055 ;}
6056 break;
6057
Chris Lattner740e7092008-10-15 06:16:57 +00006058 case 291:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006059#line 2769 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006060 {
6061 CHECK_FOR_ERROR
6062 int ValNum = InsertValue((yyvsp[(3) - (3)].TermInstVal));
6063 if (ValNum != (int)(yyvsp[(2) - (3)].UIntVal))
6064 GEN_ERROR("Result value number %" + utostr((yyvsp[(2) - (3)].UIntVal)) +
6065 " is incorrect, expected %" + utostr((unsigned)ValNum));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006066
Chris Lattner15bd0952008-08-29 17:20:18 +00006067 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6068 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
6069 CHECK_FOR_ERROR
6070;}
6071 break;
6072
Chris Lattner740e7092008-10-15 06:16:57 +00006073 case 292:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006074#line 2782 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006075 {
6076 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006077 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
6078 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00006079 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
6080 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
6081 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006082 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006083 ;}
6084 break;
Chris Lattner38905612008-02-19 04:36:25 +00006085
Chris Lattner740e7092008-10-15 06:16:57 +00006086 case 293:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006087#line 2791 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006088 { // Empty space between instruction lists
Chris Lattnercc81d152008-05-04 17:18:47 +00006089 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006090 CHECK_FOR_ERROR
6091 ;}
6092 break;
6093
Chris Lattner740e7092008-10-15 06:16:57 +00006094 case 294:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006095#line 2795 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnercc81d152008-05-04 17:18:47 +00006096 { // Labelled (named) basic block
6097 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
6098 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006099 CHECK_FOR_ERROR
Chris Lattnercc81d152008-05-04 17:18:47 +00006100
Dan Gohmanf4423b12008-04-19 00:24:39 +00006101 ;}
6102 break;
6103
Chris Lattner740e7092008-10-15 06:16:57 +00006104 case 295:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006105#line 2803 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006106 { // Return with a result...
6107 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
6108 assert(!VL.empty() && "Invalid ret operands!");
Dan Gohman1a570242008-07-23 00:54:54 +00006109 const Type *ReturnType = CurFun.CurrentFunction->getReturnType();
6110 if (VL.size() > 1 ||
6111 (isa<StructType>(ReturnType) &&
6112 (VL.empty() || VL[0]->getType() != ReturnType))) {
6113 Value *RV = UndefValue::get(ReturnType);
6114 for (unsigned i = 0, e = VL.size(); i != e; ++i) {
6115 Instruction *I = InsertValueInst::Create(RV, VL[i], i, "mrv");
6116 ((yyvsp[(-1) - (2)].BasicBlockVal))->getInstList().push_back(I);
6117 RV = I;
6118 }
6119 (yyval.TermInstVal) = ReturnInst::Create(RV);
6120 } else {
6121 (yyval.TermInstVal) = ReturnInst::Create(VL[0]);
6122 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006123 delete (yyvsp[(2) - (2)].ValueList);
6124 CHECK_FOR_ERROR
6125 ;}
6126 break;
6127
Chris Lattner740e7092008-10-15 06:16:57 +00006128 case 296:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006129#line 2823 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006130 { // Return with no result...
6131 (yyval.TermInstVal) = ReturnInst::Create();
6132 CHECK_FOR_ERROR
6133 ;}
6134 break;
6135
Chris Lattner740e7092008-10-15 06:16:57 +00006136 case 297:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006137#line 2827 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006138 { // Unconditional Branch...
6139 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6140 CHECK_FOR_ERROR
6141 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
6142 ;}
6143 break;
6144
Chris Lattner740e7092008-10-15 06:16:57 +00006145 case 298:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006146#line 2832 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006147 {
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006148 if (cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() != 1)
6149 GEN_ERROR("Branch condition must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006150 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6151 CHECK_FOR_ERROR
6152 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6153 CHECK_FOR_ERROR
6154 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6155 CHECK_FOR_ERROR
6156 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
6157 ;}
6158 break;
6159
Chris Lattner740e7092008-10-15 06:16:57 +00006160 case 299:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006161#line 2843 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006162 {
6163 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
6164 CHECK_FOR_ERROR
6165 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6166 CHECK_FOR_ERROR
6167 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6168 (yyval.TermInstVal) = S;
6169
6170 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6171 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00006172 for (; I != E; ++I) {
6173 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6174 S->addCase(CI, I->second);
6175 else
Reid Spencerb5334b02007-02-05 10:18:06 +00006176 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006177 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006178 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00006179 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006180 ;}
6181 break;
6182
Chris Lattner740e7092008-10-15 06:16:57 +00006183 case 300:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006184#line 2862 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006185 {
6186 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006187 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006188 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006189 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00006190 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006191 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006192 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006193 ;}
6194 break;
6195
Chris Lattner740e7092008-10-15 06:16:57 +00006196 case 301:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006197#line 2872 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006198 {
Reid Spencer3822ff52006-11-08 06:47:33 +00006199
Reid Spencer14310612006-12-31 05:40:51 +00006200 // Handle the short syntax
6201 const PointerType *PFTy = 0;
6202 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006203 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (15)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00006204 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6205 // Pull out the types of all of the arguments...
6206 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006207 ParamList::iterator I = (yyvsp[(7) - (15)].ParamList)->begin(), E = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006208 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006209 const Type *Ty = I->Val->getType();
6210 if (Ty == Type::VoidTy)
6211 GEN_ERROR("Short call syntax cannot be used with varargs");
6212 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006213 }
Eric Christopher2a5196f2008-09-24 04:55:49 +00006214
Devang Patel652203f2008-09-29 20:49:50 +00006215 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (15)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006216 GEN_ERROR("Invalid result type for LLVM function");
6217
Devang Patel652203f2008-09-29 20:49:50 +00006218 Ty = FunctionType::get((yyvsp[(4) - (15)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006219 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006220 }
6221
Devang Patel652203f2008-09-29 20:49:50 +00006222 delete (yyvsp[(4) - (15)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00006223
Devang Patel652203f2008-09-29 20:49:50 +00006224 Value *V = getVal(PFTy, (yyvsp[(5) - (15)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006225 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006226 BasicBlock *Normal = getBBVal((yyvsp[(12) - (15)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006227 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006228 BasicBlock *Except = getBBVal((yyvsp[(15) - (15)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00006229 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00006230
Devang Patel05988662008-09-25 21:00:45 +00006231 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006232 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6233 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006234 Attributes RetAttrs = (yyvsp[(3) - (15)].Attributes);
6235 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None) {
6236 if ((yyvsp[(9) - (15)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006237 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006238 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006239 }
Devang Patel652203f2008-09-29 20:49:50 +00006240 if ((yyvsp[(9) - (15)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006241 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006242 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006243 }
Devang Patel652203f2008-09-29 20:49:50 +00006244 if ((yyvsp[(9) - (15)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006245 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006246 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006247 }
Dale Johannesene7261862008-09-26 23:46:20 +00006248 }
Devang Patel652203f2008-09-29 20:49:50 +00006249 if (RetAttrs != Attribute::None)
6250 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006251
Reid Spencer14310612006-12-31 05:40:51 +00006252 // Check the arguments
6253 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006254 if ((yyvsp[(7) - (15)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00006255 // Make sure no arguments is a good thing!
6256 if (Ty->getNumParams() != 0)
6257 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006258 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006259 } else { // Has arguments?
6260 // Loop through FunctionType's arguments and ensure they are specified
6261 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00006262 FunctionType::param_iterator I = Ty->param_begin();
6263 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006264 ParamList::iterator ArgI = (yyvsp[(7) - (15)].ParamList)->begin(), ArgE = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006265 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006266
Duncan Sandsdc024672007-11-27 13:23:08 +00006267 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006268 if (ArgI->Val->getType() != *I)
6269 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006270 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006271 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006272 if (ArgI->Attrs != Attribute::None)
6273 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006274 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00006275
Reid Spencer14310612006-12-31 05:40:51 +00006276 if (Ty->isVarArg()) {
6277 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006278 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006279 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006280 if (ArgI->Attrs != Attribute::None)
6281 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006282 }
Reid Spencer14310612006-12-31 05:40:51 +00006283 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006284 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006285 }
Devang Patel652203f2008-09-29 20:49:50 +00006286 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None)
6287 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (15)].Attributes)));
Devang Patel05988662008-09-25 21:00:45 +00006288 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006289 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006290 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006291
Reid Spencer14310612006-12-31 05:40:51 +00006292 // Create the InvokeInst
Dan Gohman041e2eb2008-05-15 19:50:34 +00006293 InvokeInst *II = InvokeInst::Create(V, Normal, Except,
6294 Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006295 II->setCallingConv((yyvsp[(2) - (15)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006296 II->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006297 (yyval.TermInstVal) = II;
Devang Patel652203f2008-09-29 20:49:50 +00006298 delete (yyvsp[(7) - (15)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006299 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006300 ;}
6301 break;
6302
Chris Lattner740e7092008-10-15 06:16:57 +00006303 case 302:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006304#line 2975 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006305 {
6306 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006307 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006308 ;}
6309 break;
6310
Chris Lattner740e7092008-10-15 06:16:57 +00006311 case 303:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006312#line 2979 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006313 {
6314 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006315 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006316 ;}
6317 break;
6318
Chris Lattner740e7092008-10-15 06:16:57 +00006319 case 304:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006320#line 2986 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006321 {
6322 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6323 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006324 CHECK_FOR_ERROR
6325 if (V == 0)
6326 GEN_ERROR("May only switch on a constant pool value");
6327
Dan Gohmanf4423b12008-04-19 00:24:39 +00006328 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006329 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006330 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6331 ;}
6332 break;
6333
Chris Lattner740e7092008-10-15 06:16:57 +00006334 case 305:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006335#line 2997 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006336 {
6337 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6338 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006339 CHECK_FOR_ERROR
6340
6341 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00006342 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006343
Dan Gohmanf4423b12008-04-19 00:24:39 +00006344 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006345 CHECK_FOR_ERROR
Eric Christopher2a5196f2008-09-24 04:55:49 +00006346 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006347 ;}
6348 break;
6349
Chris Lattner740e7092008-10-15 06:16:57 +00006350 case 306:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006351#line 3010 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006352 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006353 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00006354 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006355 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006356 InsertValue((yyvsp[(2) - (2)].InstVal));
6357 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006358 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006359 ;}
6360 break;
6361
Chris Lattner740e7092008-10-15 06:16:57 +00006362 case 307:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006363#line 3019 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006364 {
6365 CHECK_FOR_ERROR
6366 int ValNum = InsertValue((yyvsp[(2) - (2)].InstVal));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006367
Chris Lattner15bd0952008-08-29 17:20:18 +00006368 if (ValNum != (int)(yyvsp[(1) - (2)].UIntVal))
6369 GEN_ERROR("Result value number %" + utostr((yyvsp[(1) - (2)].UIntVal)) +
6370 " is incorrect, expected %" + utostr((unsigned)ValNum));
6371
6372 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6373 CHECK_FOR_ERROR
6374 ;}
6375 break;
6376
Chris Lattner740e7092008-10-15 06:16:57 +00006377 case 308:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006378#line 3032 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006379 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006380 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006381 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
6382 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
6383 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00006384 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006385 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006386 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006387 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6388 delete (yyvsp[(1) - (6)].TypeVal);
6389 ;}
6390 break;
6391
Chris Lattner740e7092008-10-15 06:16:57 +00006392 case 309:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006393#line 3043 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006394 {
6395 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6396 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006397 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006398 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006399 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006400 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6401 ;}
6402 break;
6403
Chris Lattner740e7092008-10-15 06:16:57 +00006404 case 310:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006405#line 3053 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006406 {
Devang Patel05988662008-09-25 21:00:45 +00006407 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006408 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006409 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006410 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00006411 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006412 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 +00006413 (yyval.ParamList)->push_back(E);
6414 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00006415 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006416 ;}
6417 break;
6418
Chris Lattner740e7092008-10-15 06:16:57 +00006419 case 311:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006420#line 3064 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006421 {
Devang Patel05988662008-09-25 21:00:45 +00006422 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006423 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00006424 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006425 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 +00006426 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00006427 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006428 ;}
6429 break;
6430
Chris Lattner740e7092008-10-15 06:16:57 +00006431 case 312:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006432#line 3072 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006433 {
Devang Patel05988662008-09-25 21:00:45 +00006434 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006435 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006436 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6437 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006438 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 +00006439 (yyval.ParamList)->push_back(E);
6440 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006441 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006442 ;}
6443 break;
6444
Chris Lattner740e7092008-10-15 06:16:57 +00006445 case 313:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006446#line 3082 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006447 {
Devang Patel05988662008-09-25 21:00:45 +00006448 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00006449 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006450 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 +00006451 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006452 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006453 ;}
6454 break;
6455
Chris Lattner740e7092008-10-15 06:16:57 +00006456 case 314:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006457#line 3089 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006458 { (yyval.ParamList) = new ParamList(); ;}
6459 break;
6460
Chris Lattner740e7092008-10-15 06:16:57 +00006461 case 315:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006462#line 3092 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006463 { (yyval.ValueList) = new std::vector<Value*>(); ;}
6464 break;
6465
Chris Lattner740e7092008-10-15 06:16:57 +00006466 case 316:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006467#line 3093 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006468 {
6469 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6470 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00006471 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006472 ;}
6473 break;
6474
Chris Lattner740e7092008-10-15 06:16:57 +00006475 case 317:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006476#line 3101 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006477 {
6478 (yyval.ConstantList) = new std::vector<unsigned>();
6479 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
6480 GEN_ERROR("Index " + utostr((yyvsp[(2) - (2)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6481 (yyval.ConstantList)->push_back((yyvsp[(2) - (2)].UInt64Val));
6482 ;}
6483 break;
6484
Chris Lattner740e7092008-10-15 06:16:57 +00006485 case 318:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006486#line 3107 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006487 {
6488 (yyval.ConstantList) = (yyvsp[(1) - (3)].ConstantList);
6489 if ((unsigned)(yyvsp[(3) - (3)].UInt64Val) != (yyvsp[(3) - (3)].UInt64Val))
6490 GEN_ERROR("Index " + utostr((yyvsp[(3) - (3)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6491 (yyval.ConstantList)->push_back((yyvsp[(3) - (3)].UInt64Val));
6492 CHECK_FOR_ERROR
6493 ;}
6494 break;
6495
Chris Lattner740e7092008-10-15 06:16:57 +00006496 case 319:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006497#line 3116 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006498 {
6499 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006500 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006501 ;}
6502 break;
6503
Chris Lattner740e7092008-10-15 06:16:57 +00006504 case 320:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006505#line 3120 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006506 {
6507 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006508 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006509 ;}
6510 break;
6511
Chris Lattner740e7092008-10-15 06:16:57 +00006512 case 321:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006513#line 3125 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006514 {
Reid Spencer14310612006-12-31 05:40:51 +00006515 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006516 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006517 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
Dan Gohmanf4423b12008-04-19 00:24:39 +00006518 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006519 GEN_ERROR(
6520 "Arithmetic operator requires integer, FP, or packed operands");
Eric Christopher2a5196f2008-09-24 04:55:49 +00006521 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006522 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006523 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006524 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006525 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006526 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006527 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006528 delete (yyvsp[(2) - (5)].TypeVal);
6529 ;}
6530 break;
6531
Chris Lattner740e7092008-10-15 06:16:57 +00006532 case 322:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006533#line 3141 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006534 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006535 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006536 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6537 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
Nate Begeman5bc1ea02008-07-29 15:49:41 +00006538 if (!isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00006539 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006540 GEN_ERROR("Logical operator requires integral operands");
6541 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006542 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006543 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006544 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006545 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006546 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006547 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006548 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006549 delete (yyvsp[(2) - (5)].TypeVal);
6550 ;}
6551 break;
6552
Chris Lattner740e7092008-10-15 06:16:57 +00006553 case 323:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006554#line 3158 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006555 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006556 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006557 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006558 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006559 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006560 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006561 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006562 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006563 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006564 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006565 delete (yyvsp[(3) - (6)].TypeVal);
6566 ;}
6567 break;
6568
Chris Lattner740e7092008-10-15 06:16:57 +00006569 case 324:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006570#line 3170 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006571 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006572 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006573 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006574 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006575 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006576 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006577 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006578 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006579 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006580 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006581 delete (yyvsp[(3) - (6)].TypeVal);
6582 ;}
6583 break;
6584
Chris Lattner740e7092008-10-15 06:16:57 +00006585 case 325:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006586#line 3182 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006587 {
6588 if (!UpRefs.empty())
6589 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6590 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6591 GEN_ERROR("Scalar types not supported by vicmp instruction");
6592 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6593 CHECK_FOR_ERROR
6594 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6595 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006596 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006597 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006598 GEN_ERROR("vicmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006599 delete (yyvsp[(3) - (6)].TypeVal);
6600 ;}
6601 break;
6602
Chris Lattner740e7092008-10-15 06:16:57 +00006603 case 326:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006604#line 3196 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006605 {
6606 if (!UpRefs.empty())
6607 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6608 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6609 GEN_ERROR("Scalar types not supported by vfcmp instruction");
6610 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6611 CHECK_FOR_ERROR
6612 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6613 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006614 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006615 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006616 GEN_ERROR("vfcmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006617 delete (yyvsp[(3) - (6)].TypeVal);
6618 ;}
6619 break;
6620
Chris Lattner740e7092008-10-15 06:16:57 +00006621 case 327:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006622#line 3210 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006623 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006624 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006625 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6626 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6627 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6628 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006629 GEN_ERROR("invalid cast opcode for cast from '" +
6630 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00006631 DestTy->getDescription() + "'");
Dan Gohmane4977cf2008-05-23 01:55:30 +00006632 (yyval.InstVal) = CastInst::Create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006633 delete (yyvsp[(4) - (4)].TypeVal);
6634 ;}
6635 break;
6636
Chris Lattner740e7092008-10-15 06:16:57 +00006637 case 328:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006638#line 3222 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006639 {
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006640 if (isa<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType())) {
6641 // vector select
6642 if (!isa<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType())
6643 || !isa<VectorType>((yyvsp[(6) - (6)].ValueVal)->getType()) )
6644 GEN_ERROR("vector select value types must be vector types");
6645 const VectorType* cond_type = cast<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType());
6646 const VectorType* select_type = cast<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType());
6647 if (cond_type->getElementType() != Type::Int1Ty)
6648 GEN_ERROR("vector select condition element type must be boolean");
6649 if (cond_type->getNumElements() != select_type->getNumElements())
6650 GEN_ERROR("vector select number of elements must be the same");
6651 } else {
6652 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
6653 GEN_ERROR("select condition must be boolean");
6654 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006655 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006656 GEN_ERROR("select value types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006657 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006658 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006659 ;}
6660 break;
6661
Chris Lattner740e7092008-10-15 06:16:57 +00006662 case 329:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006663#line 3243 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006664 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006665 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006666 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6667 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6668 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006669 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006670 ;}
6671 break;
6672
Chris Lattner740e7092008-10-15 06:16:57 +00006673 case 330:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006674#line 3250 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006675 {
6676 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006677 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006678 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006679 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006680 ;}
6681 break;
6682
Chris Lattner740e7092008-10-15 06:16:57 +00006683 case 331:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006684#line 3256 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006685 {
6686 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006687 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006688 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006689 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006690 ;}
6691 break;
6692
Chris Lattner740e7092008-10-15 06:16:57 +00006693 case 332:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006694#line 3262 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006695 {
6696 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006697 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006698 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006699 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006700 ;}
6701 break;
6702
Chris Lattner740e7092008-10-15 06:16:57 +00006703 case 333:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006704#line 3268 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006705 {
6706 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006707 if (!Ty->isFirstClassType())
6708 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006709 (yyval.InstVal) = PHINode::Create(Ty);
6710 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6711 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006712 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006713 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006714 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6715 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006716 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006717 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006718 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006719 ;}
6720 break;
6721
Chris Lattner740e7092008-10-15 06:16:57 +00006722 case 334:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006723#line 3284 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006724 {
Reid Spencer14310612006-12-31 05:40:51 +00006725
6726 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006727 const PointerType *PFTy = 0;
6728 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006729 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (9)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006730 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6731 // Pull out the types of all of the arguments...
6732 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006733 ParamList::iterator I = (yyvsp[(7) - (9)].ParamList)->begin(), E = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006734 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006735 const Type *Ty = I->Val->getType();
6736 if (Ty == Type::VoidTy)
6737 GEN_ERROR("Short call syntax cannot be used with varargs");
6738 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006739 }
Chris Lattnera925a142008-04-23 05:37:08 +00006740
Devang Patel652203f2008-09-29 20:49:50 +00006741 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (9)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006742 GEN_ERROR("Invalid result type for LLVM function");
6743
Devang Patel652203f2008-09-29 20:49:50 +00006744 Ty = FunctionType::get((yyvsp[(4) - (9)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006745 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006746 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006747
Devang Patel652203f2008-09-29 20:49:50 +00006748 Value *V = getVal(PFTy, (yyvsp[(5) - (9)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006749 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006750
Reid Spencer7780acb2007-04-16 06:56:07 +00006751 // Check for call to invalid intrinsic to avoid crashing later.
6752 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006753 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006754 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6755 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006756 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6757 theF->getName() + "'");
6758 }
6759
Devang Patel05988662008-09-25 21:00:45 +00006760 // Set up the Attributes for the function
6761 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006762 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6763 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006764 Attributes RetAttrs = (yyvsp[(3) - (9)].Attributes);
6765 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None) {
6766 if ((yyvsp[(9) - (9)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006767 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006768 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006769 }
Devang Patel652203f2008-09-29 20:49:50 +00006770 if ((yyvsp[(9) - (9)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006771 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006772 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006773 }
Devang Patel652203f2008-09-29 20:49:50 +00006774 if ((yyvsp[(9) - (9)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006775 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006776 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006777 }
Dale Johannesene7261862008-09-26 23:46:20 +00006778 }
Devang Patel652203f2008-09-29 20:49:50 +00006779 if (RetAttrs != Attribute::None)
6780 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006781
Eric Christopher2a5196f2008-09-24 04:55:49 +00006782 // Check the arguments
Reid Spencer14310612006-12-31 05:40:51 +00006783 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006784 if ((yyvsp[(7) - (9)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006785 // Make sure no arguments is a good thing!
6786 if (Ty->getNumParams() != 0)
6787 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006788 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006789 } else { // Has arguments?
6790 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006791 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006792 FunctionType::param_iterator I = Ty->param_begin();
6793 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006794 ParamList::iterator ArgI = (yyvsp[(7) - (9)].ParamList)->begin(), ArgE = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006795 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006796
Duncan Sandsdc024672007-11-27 13:23:08 +00006797 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006798 if (ArgI->Val->getType() != *I)
6799 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006800 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006801 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006802 if (ArgI->Attrs != Attribute::None)
6803 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006804 }
6805 if (Ty->isVarArg()) {
6806 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006807 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006808 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006809 if (ArgI->Attrs != Attribute::None)
6810 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006811 }
Reid Spencer14310612006-12-31 05:40:51 +00006812 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006813 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006814 }
Devang Patel652203f2008-09-29 20:49:50 +00006815 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None)
6816 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (9)].Attributes)));
Duncan Sandsdc024672007-11-27 13:23:08 +00006817
Devang Patel05988662008-09-25 21:00:45 +00006818 // Finish off the Attributes and check them
6819 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006820 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006821 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006822
Reid Spencer14310612006-12-31 05:40:51 +00006823 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006824 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006825 CI->setTailCall((yyvsp[(1) - (9)].BoolVal));
6826 CI->setCallingConv((yyvsp[(2) - (9)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006827 CI->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006828 (yyval.InstVal) = CI;
Devang Patel652203f2008-09-29 20:49:50 +00006829 delete (yyvsp[(7) - (9)].ParamList);
6830 delete (yyvsp[(4) - (9)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006831 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006832 ;}
6833 break;
6834
Chris Lattner740e7092008-10-15 06:16:57 +00006835 case 335:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006836#line 3393 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006837 {
6838 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006839 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006840 ;}
6841 break;
6842
Chris Lattner740e7092008-10-15 06:16:57 +00006843 case 336:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006844#line 3398 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006845 {
6846 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006847 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006848 ;}
6849 break;
6850
Chris Lattner740e7092008-10-15 06:16:57 +00006851 case 337:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006852#line 3402 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006853 {
6854 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006855 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006856 ;}
6857 break;
6858
Chris Lattner740e7092008-10-15 06:16:57 +00006859 case 338:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006860#line 3409 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006861 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006862 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006863 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6864 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6865 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006866 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006867 ;}
6868 break;
6869
Chris Lattner740e7092008-10-15 06:16:57 +00006870 case 339:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006871#line 3416 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006872 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006873 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006874 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006875 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6876 GEN_ERROR("Malloc array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006877 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006878 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006879 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6880 delete (yyvsp[(2) - (6)].TypeVal);
6881 ;}
6882 break;
6883
Chris Lattner740e7092008-10-15 06:16:57 +00006884 case 340:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006885#line 3426 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006886 {
Reid Spencer14310612006-12-31 05:40:51 +00006887 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006888 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6889 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6890 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006891 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006892 ;}
6893 break;
6894
Chris Lattner740e7092008-10-15 06:16:57 +00006895 case 341:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006896#line 3433 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006897 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006898 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006899 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006900 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6901 GEN_ERROR("Alloca array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006902 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006903 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006904 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6905 delete (yyvsp[(2) - (6)].TypeVal);
6906 ;}
6907 break;
6908
Chris Lattner740e7092008-10-15 06:16:57 +00006909 case 342:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006910#line 3443 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006911 {
6912 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Eric Christopher2a5196f2008-09-24 04:55:49 +00006913 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006914 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6915 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006916 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006917 ;}
6918 break;
6919
Chris Lattner740e7092008-10-15 06:16:57 +00006920 case 343:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006921#line 3451 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006922 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006923 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006924 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6925 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006926 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006927 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6928 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006929 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006930 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6931 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006932 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006933 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6934 delete (yyvsp[(3) - (5)].TypeVal);
6935 ;}
6936 break;
6937
Chris Lattner740e7092008-10-15 06:16:57 +00006938 case 344:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006939#line 3465 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006940 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006941 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006942 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6943 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006944 if (!PT)
6945 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006946 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006947 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006948 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6949 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006950 "' into space of type '" + ElTy->getDescription() + "'");
6951
Dan Gohmanf4423b12008-04-19 00:24:39 +00006952 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006953 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006954 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6955 delete (yyvsp[(5) - (7)].TypeVal);
6956 ;}
6957 break;
6958
Chris Lattner740e7092008-10-15 06:16:57 +00006959 case 345:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006960#line 3482 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006961 {
Dan Gohman1a570242008-07-23 00:54:54 +00006962 if (!UpRefs.empty())
6963 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6964 if (!isa<StructType>((yyvsp[(2) - (5)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (5)].TypeVal)->get()))
6965 GEN_ERROR("getresult insn requires an aggregate operand");
6966 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].UInt64Val)))
6967 GEN_ERROR("Invalid getresult index for type '" +
6968 (*(yyvsp[(2) - (5)].TypeVal))->getDescription()+ "'");
6969
6970 Value *tmpVal = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Devang Patel5a970972008-02-19 22:27:01 +00006971 CHECK_FOR_ERROR
Dan Gohman1a570242008-07-23 00:54:54 +00006972 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(5) - (5)].UInt64Val));
6973 delete (yyvsp[(2) - (5)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006974 ;}
6975 break;
6976
Chris Lattner740e7092008-10-15 06:16:57 +00006977 case 346:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006978#line 3496 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006979 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006980 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006981 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6982 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006983 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006984
Dan Gohman041e2eb2008-05-15 19:50:34 +00006985 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()))
Reid Spencer61c83e02006-08-18 08:43:06 +00006986 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006987 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6988 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006989 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006990 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006991 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006992 delete (yyvsp[(4) - (4)].ValueList);
6993 ;}
6994 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006995
Chris Lattner740e7092008-10-15 06:16:57 +00006996 case 347:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00006997#line 3511 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00006998 {
6999 if (!UpRefs.empty())
7000 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
7001 if (!isa<StructType>((yyvsp[(2) - (4)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (4)].TypeVal)->get()))
7002 GEN_ERROR("extractvalue insn requires an aggregate operand");
7003
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007004 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end()))
Dan Gohmane4977cf2008-05-23 01:55:30 +00007005 GEN_ERROR("Invalid extractvalue indices for type '" +
7006 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
7007 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
7008 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007009 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00007010 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007011 delete (yyvsp[(4) - (4)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007012 ;}
7013 break;
7014
Chris Lattner740e7092008-10-15 06:16:57 +00007015 case 348:
Nuno Lopes6ec8a252008-10-15 11:11:12 +00007016#line 3526 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00007017 {
7018 if (!UpRefs.empty())
7019 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (7)].TypeVal))->getDescription());
7020 if (!isa<StructType>((yyvsp[(2) - (7)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (7)].TypeVal)->get()))
7021 GEN_ERROR("extractvalue insn requires an aggregate operand");
7022
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007023 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 +00007024 GEN_ERROR("Invalid insertvalue indices for type '" +
7025 (*(yyvsp[(2) - (7)].TypeVal))->getDescription()+ "'");
7026 Value* aggVal = getVal(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(3) - (7)].ValIDVal));
7027 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
7028 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007029 (yyval.InstVal) = InsertValueInst::Create(aggVal, tmpVal, (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00007030 delete (yyvsp[(2) - (7)].TypeVal);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007031 delete (yyvsp[(5) - (7)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007032 delete (yyvsp[(7) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007033 ;}
7034 break;
7035
Dan Gohmanf4423b12008-04-19 00:24:39 +00007036
7037/* Line 1267 of yacc.c. */
Nuno Lopes6ec8a252008-10-15 11:11:12 +00007038#line 7039 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00007039 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00007040 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007041 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
7042
7043 YYPOPSTACK (yylen);
7044 yylen = 0;
7045 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007046
7047 *++yyvsp = yyval;
7048
7049
Dan Gohmanf4423b12008-04-19 00:24:39 +00007050 /* Now `shift' the result of the reduction. Determine what state
7051 that goes to, based on the state we popped back to and the rule
7052 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00007053
7054 yyn = yyr1[yyn];
7055
Dan Gohmanf4423b12008-04-19 00:24:39 +00007056 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
7057 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007058 yystate = yytable[yystate];
7059 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00007060 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00007061
7062 goto yynewstate;
7063
7064
Dan Gohmanf4423b12008-04-19 00:24:39 +00007065/*------------------------------------.
7066| yyerrlab -- here on detecting error |
7067`------------------------------------*/
7068yyerrlab:
7069 /* If not already recovering from an error, report this error. */
7070 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007071 {
7072 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007073#if ! YYERROR_VERBOSE
7074 yyerror (YY_("syntax error"));
7075#else
7076 {
7077 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
7078 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
7079 {
7080 YYSIZE_T yyalloc = 2 * yysize;
7081 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
7082 yyalloc = YYSTACK_ALLOC_MAXIMUM;
7083 if (yymsg != yymsgbuf)
7084 YYSTACK_FREE (yymsg);
7085 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
7086 if (yymsg)
7087 yymsg_alloc = yyalloc;
7088 else
7089 {
7090 yymsg = yymsgbuf;
7091 yymsg_alloc = sizeof yymsgbuf;
7092 }
7093 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00007094
Dan Gohmanf4423b12008-04-19 00:24:39 +00007095 if (0 < yysize && yysize <= yymsg_alloc)
7096 {
7097 (void) yysyntax_error (yymsg, yystate, yychar);
7098 yyerror (yymsg);
7099 }
7100 else
7101 {
7102 yyerror (YY_("syntax error"));
7103 if (yysize != 0)
7104 goto yyexhaustedlab;
7105 }
7106 }
7107#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007108 }
7109
Dan Gohmanf4423b12008-04-19 00:24:39 +00007110
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007111
7112 if (yyerrstatus == 3)
7113 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00007114 /* If just tried and failed to reuse look-ahead token after an
7115 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007116
Dan Gohmanf4423b12008-04-19 00:24:39 +00007117 if (yychar <= YYEOF)
7118 {
7119 /* Return failure if at end of input. */
7120 if (yychar == YYEOF)
7121 YYABORT;
7122 }
7123 else
7124 {
7125 yydestruct ("Error: discarding",
7126 yytoken, &yylval);
7127 yychar = YYEMPTY;
7128 }
7129 }
7130
7131 /* Else will try to reuse look-ahead token after shifting the error
7132 token. */
7133 goto yyerrlab1;
7134
7135
7136/*---------------------------------------------------.
7137| yyerrorlab -- error raised explicitly by YYERROR. |
7138`---------------------------------------------------*/
7139yyerrorlab:
7140
7141 /* Pacify compilers like GCC when the user code never invokes
7142 YYERROR and the label yyerrorlab therefore never appears in user
7143 code. */
7144 if (/*CONSTCOND*/ 0)
7145 goto yyerrorlab;
7146
7147 /* Do not reclaim the symbols of the rule which action triggered
7148 this YYERROR. */
7149 YYPOPSTACK (yylen);
7150 yylen = 0;
7151 YY_STACK_PRINT (yyss, yyssp);
7152 yystate = *yyssp;
7153 goto yyerrlab1;
7154
7155
7156/*-------------------------------------------------------------.
7157| yyerrlab1 -- common code for both syntax error and YYERROR. |
7158`-------------------------------------------------------------*/
7159yyerrlab1:
7160 yyerrstatus = 3; /* Each real token shifted decrements this. */
7161
7162 for (;;)
7163 {
7164 yyn = yypact[yystate];
7165 if (yyn != YYPACT_NINF)
7166 {
7167 yyn += YYTERROR;
7168 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7169 {
7170 yyn = yytable[yyn];
7171 if (0 < yyn)
7172 break;
7173 }
7174 }
7175
7176 /* Pop the current state because it cannot handle the error token. */
7177 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007178 YYABORT;
7179
Dale Johannesencdd509a2007-09-07 21:07:57 +00007180
Dan Gohmanf4423b12008-04-19 00:24:39 +00007181 yydestruct ("Error: popping",
7182 yystos[yystate], yyvsp);
7183 YYPOPSTACK (1);
7184 yystate = *yyssp;
7185 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007186 }
7187
7188 if (yyn == YYFINAL)
7189 YYACCEPT;
7190
Reid Spencer68a24bd2005-08-27 18:50:39 +00007191 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007192
7193
7194 /* Shift the error token. */
7195 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00007196
Reid Spencer68a24bd2005-08-27 18:50:39 +00007197 yystate = yyn;
7198 goto yynewstate;
7199
Gabor Greife64d2482008-04-06 23:07:54 +00007200
Dan Gohmanf4423b12008-04-19 00:24:39 +00007201/*-------------------------------------.
7202| yyacceptlab -- YYACCEPT comes here. |
7203`-------------------------------------*/
7204yyacceptlab:
7205 yyresult = 0;
7206 goto yyreturn;
7207
7208/*-----------------------------------.
7209| yyabortlab -- YYABORT comes here. |
7210`-----------------------------------*/
7211yyabortlab:
7212 yyresult = 1;
7213 goto yyreturn;
7214
7215#ifndef yyoverflow
7216/*-------------------------------------------------.
7217| yyexhaustedlab -- memory exhaustion comes here. |
7218`-------------------------------------------------*/
7219yyexhaustedlab:
7220 yyerror (YY_("memory exhausted"));
7221 yyresult = 2;
7222 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00007223#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00007224
7225yyreturn:
7226 if (yychar != YYEOF && yychar != YYEMPTY)
7227 yydestruct ("Cleanup: discarding lookahead",
7228 yytoken, &yylval);
7229 /* Do not reclaim the symbols of the rule which action triggered
7230 this YYABORT or YYACCEPT. */
7231 YYPOPSTACK (yylen);
7232 YY_STACK_PRINT (yyss, yyssp);
7233 while (yyssp != yyss)
7234 {
7235 yydestruct ("Cleanup: popping",
7236 yystos[*yyssp], yyvsp);
7237 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00007238 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007239#ifndef yyoverflow
7240 if (yyss != yyssa)
7241 YYSTACK_FREE (yyss);
7242#endif
7243#if YYERROR_VERBOSE
7244 if (yymsg != yymsgbuf)
7245 YYSTACK_FREE (yymsg);
7246#endif
7247 /* Make sure YYID is used. */
7248 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007249}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007250
7251
Nuno Lopes6ec8a252008-10-15 11:11:12 +00007252#line 3545 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00007253
7254
Reid Spencer14310612006-12-31 05:40:51 +00007255// common code from the two 'RunVMAsmParser' functions
7256static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00007257 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00007258 // Check to make sure the parser succeeded
7259 if (yyparse()) {
7260 if (ParserResult)
7261 delete ParserResult;
7262 return 0;
7263 }
7264
Reid Spencer0d60b5a2007-03-30 01:37:39 +00007265 // Emit an error if there are any unresolved types left.
7266 if (!CurModule.LateResolveTypes.empty()) {
7267 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
7268 if (DID.Type == ValID::LocalName) {
7269 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
7270 } else {
7271 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
7272 }
7273 if (ParserResult)
7274 delete ParserResult;
7275 return 0;
7276 }
7277
7278 // Emit an error if there are any unresolved values left.
7279 if (!CurModule.LateResolveValues.empty()) {
7280 Value *V = CurModule.LateResolveValues.back();
7281 std::map<Value*, std::pair<ValID, int> >::iterator I =
7282 CurModule.PlaceHolderInfo.find(V);
7283
7284 if (I != CurModule.PlaceHolderInfo.end()) {
7285 ValID &DID = I->second.first;
7286 if (DID.Type == ValID::LocalName) {
7287 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
7288 } else {
7289 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
7290 }
7291 if (ParserResult)
7292 delete ParserResult;
7293 return 0;
7294 }
7295 }
7296
Reid Spencer14310612006-12-31 05:40:51 +00007297 // Check to make sure that parsing produced a result
7298 if (!ParserResult)
7299 return 0;
7300
7301 // Reset ParserResult variable while saving its value for the result.
7302 Module *Result = ParserResult;
7303 ParserResult = 0;
7304
7305 return Result;
7306}
7307
Reid Spencer61c83e02006-08-18 08:43:06 +00007308void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007309 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00007310 // TODO: column number in exception
7311 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00007312 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00007313 TriggerError = 1;
7314}
Reid Spencer68a24bd2005-08-27 18:50:39 +00007315
7316int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007317 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00007318 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00007319 if (yychar != YYEMPTY && yychar != 0) {
7320 errMsg += " while reading token: '";
Eric Christopher2a5196f2008-09-24 04:55:49 +00007321 errMsg += std::string(LLLgetTokenStart(),
Duncan Sandsdc024672007-11-27 13:23:08 +00007322 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
7323 }
Reid Spencer61c83e02006-08-18 08:43:06 +00007324 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007325 return 0;
7326}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007327