blob: d7d5cda6b35020e1032a1eb803e1ef59f4c52277 [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;
Nuno Lopes8a5f3472008-10-15 12:05:02 +0000527 I->first.second.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000528 GlobalRefs.erase(I);
529 }
530 return Ret;
531 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000532
533 bool TypeIsUnresolved(PATypeHolder* PATy) {
534 // If it isn't abstract, its resolved
535 const Type* Ty = PATy->get();
536 if (!Ty->isAbstract())
537 return false;
538 // Traverse the type looking for abstract types. If it isn't abstract then
Eric Christopher2a5196f2008-09-24 04:55:49 +0000539 // we don't need to traverse that leg of the type.
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000540 std::vector<const Type*> WorkList, SeenList;
541 WorkList.push_back(Ty);
542 while (!WorkList.empty()) {
543 const Type* Ty = WorkList.back();
544 SeenList.push_back(Ty);
545 WorkList.pop_back();
546 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
547 // Check to see if this is an unresolved type
548 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
549 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
550 for ( ; I != E; ++I) {
551 if (I->second.get() == OpTy)
552 return true;
553 }
554 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
555 const Type* TheTy = SeqTy->getElementType();
556 if (TheTy->isAbstract() && TheTy != Ty) {
Eric Christopher2a5196f2008-09-24 04:55:49 +0000557 std::vector<const Type*>::iterator I = SeenList.begin(),
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000558 E = SeenList.end();
559 for ( ; I != E; ++I)
560 if (*I == TheTy)
561 break;
562 if (I == E)
563 WorkList.push_back(TheTy);
564 }
565 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
566 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
567 const Type* TheTy = StrTy->getElementType(i);
568 if (TheTy->isAbstract() && TheTy != Ty) {
Eric Christopher2a5196f2008-09-24 04:55:49 +0000569 std::vector<const Type*>::iterator I = SeenList.begin(),
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000570 E = SeenList.end();
571 for ( ; I != E; ++I)
572 if (*I == TheTy)
573 break;
574 if (I == E)
575 WorkList.push_back(TheTy);
576 }
577 }
578 }
579 }
580 return false;
581 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000582} CurModule;
583
584static struct PerFunctionInfo {
585 Function *CurrentFunction; // Pointer to current function being created
586
Reid Spencer93c40032007-03-19 18:40:50 +0000587 ValueList Values; // Keep track of #'d definitions
588 unsigned NextValNum;
589 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000590 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000591 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000592 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000593
594 /// BBForwardRefs - When we see forward references to basic blocks, keep
595 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000596 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000597
598 inline PerFunctionInfo() {
599 CurrentFunction = 0;
600 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000601 Linkage = GlobalValue::ExternalLinkage;
602 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000603 }
604
605 inline void FunctionStart(Function *M) {
606 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000607 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000608 }
609
610 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000612 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000613 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000614 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000615 return;
616 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000617
618 // Resolve all forward references now.
619 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
620
621 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000622 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000623 CurrentFunction = 0;
624 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000625 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000626 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000627 }
628} CurFun; // Info for the current function...
629
630static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
631
632
633//===----------------------------------------------------------------------===//
634// Code to handle definitions of all the types
635//===----------------------------------------------------------------------===//
636
Chris Lattner15bd0952008-08-29 17:20:18 +0000637/// InsertValue - Insert a value into the value table. If it is named, this
638/// returns -1, otherwise it returns the slot number for the value.
639static int InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
Reid Spencer93c40032007-03-19 18:40:50 +0000640 // Things that have names or are void typed don't get slot numbers
641 if (V->hasName() || (V->getType() == Type::VoidTy))
Chris Lattner15bd0952008-08-29 17:20:18 +0000642 return -1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000643
Reid Spencer93c40032007-03-19 18:40:50 +0000644 // In the case of function values, we have to allow for the forward reference
645 // of basic blocks, which are included in the numbering. Consequently, we keep
Eric Christopher2a5196f2008-09-24 04:55:49 +0000646 // track of the next insertion location with NextValNum. When a BB gets
Reid Spencer93c40032007-03-19 18:40:50 +0000647 // inserted, it could change the size of the CurFun.Values vector.
648 if (&ValueTab == &CurFun.Values) {
649 if (ValueTab.size() <= CurFun.NextValNum)
650 ValueTab.resize(CurFun.NextValNum+1);
651 ValueTab[CurFun.NextValNum++] = V;
Chris Lattner15bd0952008-08-29 17:20:18 +0000652 return CurFun.NextValNum-1;
Eric Christopher2a5196f2008-09-24 04:55:49 +0000653 }
Reid Spencer93c40032007-03-19 18:40:50 +0000654 // For all other lists, its okay to just tack it on the back of the vector.
655 ValueTab.push_back(V);
Chris Lattner15bd0952008-08-29 17:20:18 +0000656 return ValueTab.size()-1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657}
658
659static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
660 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000661 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000662 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000663 if (D.Num < CurModule.Types.size())
664 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000665 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000666 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000667 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000668 D.destroy(); // Free old strdup'd memory...
669 return N;
670 }
671 break;
672 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000673 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000674 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000675 }
676
677 // If we reached here, we referenced either a symbol that we don't know about
678 // or an id number that hasn't been read yet. We may be referencing something
679 // forward, so just create an entry to be resolved later and get to it...
680 //
681 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
682
683
684 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000685 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000686 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000687 return 0;
688 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000689 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000690 return 0;
691 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000692 }
693
Reid Spencer861d9d62006-11-28 07:29:44 +0000694 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Nuno Lopesf05ff662008-10-15 11:20:21 +0000695 if (I != CurModule.LateResolveTypes.end()) {
696 D.destroy();
Reid Spencer861d9d62006-11-28 07:29:44 +0000697 return I->second;
Nuno Lopesf05ff662008-10-15 11:20:21 +0000698 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000699
Reid Spencer861d9d62006-11-28 07:29:44 +0000700 Type *Typ = OpaqueType::get();
701 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
702 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000703 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000704
Reid Spencer93c40032007-03-19 18:40:50 +0000705// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000706// the provided ValID. If the value exists and has already been defined, return
707// it. Otherwise return null.
708//
Reid Spencer93c40032007-03-19 18:40:50 +0000709static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000710 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000711 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000712 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000713 return 0;
714 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000715
716 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000717 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000718 // Check that the number is within bounds.
Eric Christopher2a5196f2008-09-24 04:55:49 +0000719 if (D.Num >= CurFun.Values.size())
Reid Spencer93c40032007-03-19 18:40:50 +0000720 return 0;
721 Value *Result = CurFun.Values[D.Num];
722 if (Ty != Result->getType()) {
723 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +0000724 Result->getType()->getDescription() + "' does not match "
Reid Spencer93c40032007-03-19 18:40:50 +0000725 "expected type, '" + Ty->getDescription() + "'");
726 return 0;
727 }
728 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000729 }
730 case ValID::GlobalID: { // Is it a numbered definition?
Eric Christopher2a5196f2008-09-24 04:55:49 +0000731 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000732 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000733 Value *Result = CurModule.Values[D.Num];
734 if (Ty != Result->getType()) {
735 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +0000736 Result->getType()->getDescription() + "' does not match "
Reid Spencer93c40032007-03-19 18:40:50 +0000737 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000738 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000739 }
740 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000741 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000742
Reid Spencer41dff5e2007-01-26 08:05:27 +0000743 case ValID::LocalName: { // Is it a named definition?
Eric Christopher2a5196f2008-09-24 04:55:49 +0000744 if (!inFunctionScope())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000745 return 0;
746 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000747 Value *N = SymTab.lookup(D.getName());
Eric Christopher2a5196f2008-09-24 04:55:49 +0000748 if (N == 0)
Reid Spenceref9b9a72007-02-05 20:47:22 +0000749 return 0;
750 if (N->getType() != Ty)
751 return 0;
Eric Christopher2a5196f2008-09-24 04:55:49 +0000752
Reid Spencer41dff5e2007-01-26 08:05:27 +0000753 D.destroy(); // Free old strdup'd memory...
754 return N;
755 }
756 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000757 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000758 Value *N = SymTab.lookup(D.getName());
Eric Christopher2a5196f2008-09-24 04:55:49 +0000759 if (N == 0)
Reid Spenceref9b9a72007-02-05 20:47:22 +0000760 return 0;
761 if (N->getType() != Ty)
762 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000763
764 D.destroy(); // Free old strdup'd memory...
765 return N;
766 }
767
768 // Check to make sure that "Ty" is an integral type, and that our
769 // value will fit into the specified type...
770 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner38905612008-02-19 04:36:25 +0000771 if (!isa<IntegerType>(Ty) ||
772 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000773 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000774 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000775 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000776 return 0;
777 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000778 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000779
780 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000781 if (isa<IntegerType>(Ty) &&
782 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Reid Spencerb83eb642006-10-20 07:07:24 +0000783 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner38905612008-02-19 04:36:25 +0000784
785 if (!isa<IntegerType>(Ty) ||
786 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
787 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
788 "' is invalid or out of range for type '" +
789 Ty->getDescription() + "'");
790 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000791 }
Chris Lattner38905612008-02-19 04:36:25 +0000792 // This is really a signed reference. Transmogrify.
793 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794
Chris Lattner1913b942008-07-11 00:30:39 +0000795 case ValID::ConstAPInt: // Is it an unsigned const pool reference?
796 if (!isa<IntegerType>(Ty)) {
797 GenerateError("Integral constant '" + D.getName() +
798 "' is invalid or out of range for type '" +
799 Ty->getDescription() + "'");
800 return 0;
801 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000802
Chris Lattner1913b942008-07-11 00:30:39 +0000803 {
804 APSInt Tmp = *D.ConstPoolInt;
805 Tmp.extOrTrunc(Ty->getPrimitiveSizeInBits());
806 return ConstantInt::get(Tmp);
807 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000808
Reid Spencer68a24bd2005-08-27 18:50:39 +0000809 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000810 if (!Ty->isFloatingPoint() ||
811 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000812 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000813 return 0;
814 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000815 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +0000816 // as double. Fix this here. Long double does not need this.
817 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
Dale Johannesen236bbd42008-10-09 23:01:34 +0000818 Ty==Type::FloatTy) {
819 bool ignored;
820 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
821 &ignored);
822 }
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000823 return ConstantFP::get(*D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000824
825 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000826 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000827 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000828 return 0;
829 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000830 return ConstantPointerNull::get(cast<PointerType>(Ty));
831
832 case ValID::ConstUndefVal: // Is it an undef value?
833 return UndefValue::get(Ty);
834
Chris Lattner7aa61892005-12-21 17:53:23 +0000835 case ValID::ConstZeroVal: // Is it a zero value?
836 return Constant::getNullValue(Ty);
Eric Christopher2a5196f2008-09-24 04:55:49 +0000837
Reid Spencer68a24bd2005-08-27 18:50:39 +0000838 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000839 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000840 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000841 return 0;
842 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000843 return D.ConstantValue;
844
Chris Lattner0e9c3762006-01-25 22:27:16 +0000845 case ValID::InlineAsmVal: { // Inline asm expression
846 const PointerType *PTy = dyn_cast<PointerType>(Ty);
847 const FunctionType *FTy =
848 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000849 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000850 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000851 return 0;
852 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000853 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
854 D.IAD->HasSideEffects);
855 D.destroy(); // Free InlineAsmDescriptor.
856 return IA;
857 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000858 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000859 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000860 return 0;
861 } // End of switch
862
Reid Spencera9720f52007-02-05 17:04:00 +0000863 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000864 return 0;
865}
866
Reid Spencer93c40032007-03-19 18:40:50 +0000867// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000868// value is not already defined, it "improvises" by creating a placeholder var
869// that looks and acts just like the requested variable. When the value is
870// defined later, all uses of the placeholder variable are replaced with the
871// real thing.
872//
873static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000874 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000875 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000876 return 0;
877 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000878
879 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000880 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000881 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000882 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000883
Reid Spencer5b7e7532006-09-28 19:28:24 +0000884 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Dan Gohmane4977cf2008-05-23 01:55:30 +0000885 GenerateError("Invalid use of a non-first-class type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000886 return 0;
887 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000888
889 // If we reached here, we referenced either a symbol that we don't know about
890 // or an id number that hasn't been read yet. We may be referencing something
891 // forward, so just create an entry to be resolved later and get to it...
892 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000893 switch (ID.Type) {
894 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000895 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000896 const PointerType *PTy = dyn_cast<PointerType>(Ty);
897 if (!PTy) {
898 GenerateError("Invalid type for reference to global" );
899 return 0;
900 }
901 const Type* ElTy = PTy->getElementType();
902 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greife64d2482008-04-06 23:07:54 +0000903 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000904 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000905 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
906 (Module*)0, false, PTy->getAddressSpace());
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000907 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000908 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000909 default:
910 V = new Argument(Ty);
911 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000912
Reid Spencer68a24bd2005-08-27 18:50:39 +0000913 // Remember where this forward reference came from. FIXME, shouldn't we try
914 // to recycle these things??
915 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsdc024672007-11-27 13:23:08 +0000916 LLLgetLineNo())));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000917
918 if (inFunctionScope())
919 InsertValue(V, CurFun.LateResolveValues);
920 else
921 InsertValue(V, CurModule.LateResolveValues);
922 return V;
923}
924
Reid Spencer93c40032007-03-19 18:40:50 +0000925/// defineBBVal - This is a definition of a new basic block with the specified
926/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Chris Lattnercc81d152008-05-04 17:18:47 +0000927static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000928 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000929
Reid Spencer68a24bd2005-08-27 18:50:39 +0000930 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000931
Reid Spencer93c40032007-03-19 18:40:50 +0000932 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000933
Reid Spencer93c40032007-03-19 18:40:50 +0000934 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
935 if (BBI != CurFun.BBForwardRefs.end()) {
936 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000937 // The forward declaration could have been inserted anywhere in the
938 // function: insert it into the correct place now.
939 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
940 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000941
Reid Spencer66728ef2007-03-20 01:13:36 +0000942 // We're about to erase the entry, save the key so we can clean it up.
943 ValID Tmp = BBI->first;
944
Reid Spencer93c40032007-03-19 18:40:50 +0000945 // Erase the forward ref from the map as its no longer "forward"
946 CurFun.BBForwardRefs.erase(ID);
947
Eric Christopher2a5196f2008-09-24 04:55:49 +0000948 // The key has been removed from the map but so we don't want to leave
Reid Spencer66728ef2007-03-20 01:13:36 +0000949 // strdup'd memory around so destroy it too.
950 Tmp.destroy();
951
Reid Spencer93c40032007-03-19 18:40:50 +0000952 // If its a numbered definition, bump the number and set the BB value.
953 if (ID.Type == ValID::LocalID) {
954 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
955 InsertValue(BB);
956 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000957 } else {
958 // We haven't seen this BB before and its first mention is a definition.
Devang Patel67909432008-03-03 18:58:47 +0000959 // Just create it and return it.
960 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greife64d2482008-04-06 23:07:54 +0000961 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel67909432008-03-03 18:58:47 +0000962 if (ID.Type == ValID::LocalID) {
963 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
964 InsertValue(BB);
965 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000966 }
Reid Spencer93c40032007-03-19 18:40:50 +0000967
Devang Patel67909432008-03-03 18:58:47 +0000968 ID.destroy();
Reid Spencer93c40032007-03-19 18:40:50 +0000969 return BB;
970}
971
972/// getBBVal - get an existing BB value or create a forward reference for it.
Eric Christopher2a5196f2008-09-24 04:55:49 +0000973///
Reid Spencer93c40032007-03-19 18:40:50 +0000974static BasicBlock *getBBVal(const ValID &ID) {
975 assert(inFunctionScope() && "Can't get basic block at global scope!");
976
977 BasicBlock *BB = 0;
978
979 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
980 if (BBI != CurFun.BBForwardRefs.end()) {
981 BB = BBI->second;
982 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000983 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000984 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000985 if (N) {
Reid Spencer93c40032007-03-19 18:40:50 +0000986 if (N->getType()->getTypeID() == Type::LabelTyID)
987 BB = cast<BasicBlock>(N);
988 else
989 GenerateError("Reference to label '" + Name + "' is actually of type '"+
990 N->getType()->getDescription() + "'");
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000991 }
Reid Spencer93c40032007-03-19 18:40:50 +0000992 } else if (ID.Type == ValID::LocalID) {
993 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
994 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
995 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
996 else
Eric Christopher2a5196f2008-09-24 04:55:49 +0000997 GenerateError("Reference to label '%" + utostr(ID.Num) +
998 "' is actually of type '"+
Reid Spencer93c40032007-03-19 18:40:50 +0000999 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
1000 }
1001 } else {
1002 GenerateError("Illegal label reference " + ID.getName());
1003 return 0;
1004 }
1005
1006 // If its already been defined, return it now.
1007 if (BB) {
1008 ID.destroy(); // Free strdup'd memory.
1009 return BB;
1010 }
1011
1012 // Otherwise, this block has not been seen before, create it.
1013 std::string Name;
1014 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001015 Name = ID.getName();
Gabor Greife64d2482008-04-06 23:07:54 +00001016 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Reid Spencer93c40032007-03-19 18:40:50 +00001017
1018 // Insert it in the forward refs map.
1019 CurFun.BBForwardRefs[ID] = BB;
1020
Reid Spencer68a24bd2005-08-27 18:50:39 +00001021 return BB;
1022}
1023
1024
1025//===----------------------------------------------------------------------===//
1026// Code to handle forward references in instructions
1027//===----------------------------------------------------------------------===//
1028//
1029// This code handles the late binding needed with statements that reference
1030// values not defined yet... for example, a forward branch, or the PHI node for
1031// a loop body.
1032//
1033// This keeps a table (CurFun.LateResolveValues) of all such forward references
1034// and back patchs after we are done.
1035//
1036
1037// ResolveDefinitions - If we could not resolve some defs at parsing
1038// time (forward branches, phi functions for loops, etc...) resolve the
1039// defs now...
1040//
Eric Christopher2a5196f2008-09-24 04:55:49 +00001041static void
Reid Spencer93c40032007-03-19 18:40:50 +00001042ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001043 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +00001044 while (!LateResolvers.empty()) {
1045 Value *V = LateResolvers.back();
1046 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001047
Reid Spencer93c40032007-03-19 18:40:50 +00001048 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1049 CurModule.PlaceHolderInfo.find(V);
1050 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001051
Reid Spencer93c40032007-03-19 18:40:50 +00001052 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001053
Reid Spencer93c40032007-03-19 18:40:50 +00001054 Value *TheRealValue = getExistingVal(V->getType(), DID);
1055 if (TriggerError)
1056 return;
1057 if (TheRealValue) {
1058 V->replaceAllUsesWith(TheRealValue);
1059 delete V;
1060 CurModule.PlaceHolderInfo.erase(PHI);
1061 } else if (FutureLateResolvers) {
1062 // Functions have their unresolved items forwarded to the module late
1063 // resolver table
1064 InsertValue(V, *FutureLateResolvers);
1065 } else {
1066 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1067 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1068 "' of type '" + V->getType()->getDescription() + "'",
1069 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001070 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001071 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001072 GenerateError("Reference to an invalid definition: #" +
1073 itostr(DID.Num) + " of type '" +
1074 V->getType()->getDescription() + "'",
1075 PHI->second.second);
1076 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001077 }
1078 }
1079 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001080 LateResolvers.clear();
1081}
1082
1083// ResolveTypeTo - A brand new type was just declared. This means that (if
1084// name is not null) things referencing Name can be resolved. Otherwise, things
1085// refering to the number can be resolved. Do this now.
1086//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001087static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001088 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001089 if (Name)
1090 D = ValID::createLocalName(*Name);
Eric Christopher2a5196f2008-09-24 04:55:49 +00001091 else
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001092 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001093
Reid Spencer861d9d62006-11-28 07:29:44 +00001094 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001095 CurModule.LateResolveTypes.find(D);
1096 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001097 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001098 I->first.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001099 CurModule.LateResolveTypes.erase(I);
1100 }
Nuno Lopes191dfb92008-10-03 15:52:39 +00001101 D.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001102}
1103
1104// setValueName - Set the specified value to the name given. The name may be
1105// null potentially, in which case this is a noop. The string passed in is
1106// assumed to be a malloc'd string buffer, and is free'd by this function.
1107//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001108static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001109 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001110 std::string Name(*NameStr); // Copy string
1111 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001112
Reid Spencer41dff5e2007-01-26 08:05:27 +00001113 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001114 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001115 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001116 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001117
Reid Spencera9720f52007-02-05 17:04:00 +00001118 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001119 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1120 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001121 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001122 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001123 return;
1124 }
1125
1126 // Set the name.
1127 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001128}
1129
1130/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1131/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001132static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001133ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001134 GlobalValue::LinkageTypes Linkage,
1135 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001136 bool isConstantGlobal, const Type *Ty,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001137 Constant *Initializer, bool IsThreadLocal,
1138 unsigned AddressSpace = 0) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001139 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001140 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001141 return 0;
1142 }
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001143 if (Ty == Type::LabelTy) {
1144 GenerateError("Cannot declare global vars of label type");
1145 return 0;
1146 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001147
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001148 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001149
1150 std::string Name;
1151 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001152 Name = *NameStr; // Copy string
1153 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001154 }
1155
1156 // See if this global value was forward referenced. If so, recycle the
1157 // object.
1158 ValID ID;
1159 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001160 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001161 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001162 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001163 }
1164
1165 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1166 // Move the global to the end of the list, from whereever it was
1167 // previously inserted.
1168 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1169 CurModule.CurrentModule->getGlobalList().remove(GV);
1170 CurModule.CurrentModule->getGlobalList().push_back(GV);
1171 GV->setInitializer(Initializer);
1172 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001173 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001174 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001175 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001176 InsertValue(GV, CurModule.Values);
Nuno Lopes191dfb92008-10-03 15:52:39 +00001177 ID.destroy();
Chris Lattnerb475c422005-11-12 18:22:38 +00001178 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001179 }
1180
Nuno Lopes191dfb92008-10-03 15:52:39 +00001181 ID.destroy();
1182
Reid Spenceref9b9a72007-02-05 20:47:22 +00001183 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001184 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001185 // if the global we're parsing has an initializer (is a definition) and
1186 // has external linkage.
1187 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1188 // If there is already a global with external linkage with this name
1189 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1190 // If we allow this GVar to get created, it will be renamed in the
1191 // symbol table because it conflicts with an existing GVar. We can't
1192 // allow redefinition of GVars whose linking indicates that their name
1193 // must stay the same. Issue the error.
1194 GenerateError("Redefinition of global variable named '" + Name +
1195 "' of type '" + Ty->getDescription() + "'");
1196 return 0;
1197 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001198 }
1199
1200 // Otherwise there is no existing GV to use, create one now.
1201 GlobalVariable *GV =
1202 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001203 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001204 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001205 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001206 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001207}
1208
1209// setTypeName - Set the specified type to the name given. The name may be
1210// null potentially, in which case this is a noop. The string passed in is
1211// assumed to be a malloc'd string buffer, and is freed by this function.
1212//
1213// This function returns true if the type has already been defined, but is
1214// allowed to be redefined in the specified context. If the name is a new name
1215// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001216static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001217 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001218 if (NameStr == 0) return false;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001219
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001220 std::string Name(*NameStr); // Copy string
1221 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001222
1223 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001224 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001225 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001226 return false;
1227 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001228
1229 // Set the type name, checking for conflicts as we do so.
1230 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1231
1232 if (AlreadyExists) { // Inserting a name that is already defined???
1233 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001234 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001235
1236 // There is only one case where this is allowed: when we are refining an
1237 // opaque type. In this case, Existing will be an opaque type.
1238 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1239 // We ARE replacing an opaque type!
1240 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1241 return true;
1242 }
1243
1244 // Otherwise, this is an attempt to redefine a type. That's okay if
1245 // the redefinition is identical to the original. This will be so if
1246 // Existing and T point to the same Type object. In this one case we
1247 // allow the equivalent redefinition.
1248 if (Existing == T) return true; // Yes, it's equal.
1249
1250 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001251 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001252 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001253 }
1254
1255 return false;
1256}
1257
1258//===----------------------------------------------------------------------===//
1259// Code for handling upreferences in type names...
1260//
1261
1262// TypeContains - Returns true if Ty directly contains E in it.
1263//
1264static bool TypeContains(const Type *Ty, const Type *E) {
1265 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1266 E) != Ty->subtype_end();
1267}
1268
1269namespace {
1270 struct UpRefRecord {
1271 // NestingLevel - The number of nesting levels that need to be popped before
1272 // this type is resolved.
1273 unsigned NestingLevel;
1274
1275 // LastContainedTy - This is the type at the current binding level for the
1276 // type. Every time we reduce the nesting level, this gets updated.
1277 const Type *LastContainedTy;
1278
1279 // UpRefTy - This is the actual opaque type that the upreference is
1280 // represented with.
1281 OpaqueType *UpRefTy;
1282
1283 UpRefRecord(unsigned NL, OpaqueType *URTy)
1284 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1285 };
1286}
1287
1288// UpRefs - A list of the outstanding upreferences that need to be resolved.
1289static std::vector<UpRefRecord> UpRefs;
1290
1291/// HandleUpRefs - Every time we finish a new layer of types, this function is
1292/// called. It loops through the UpRefs vector, which is a list of the
1293/// currently active types. For each type, if the up reference is contained in
1294/// the newly completed type, we decrement the level count. When the level
1295/// count reaches zero, the upreferenced type is the type that is passed in:
1296/// thus we can complete the cycle.
1297///
1298static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001299 // If Ty isn't abstract, or if there are no up-references in it, then there is
1300 // nothing to resolve here.
1301 if (!ty->isAbstract() || UpRefs.empty()) return ty;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001302
Reid Spencer68a24bd2005-08-27 18:50:39 +00001303 PATypeHolder Ty(ty);
1304 UR_OUT("Type '" << Ty->getDescription() <<
1305 "' newly formed. Resolving upreferences.\n" <<
1306 UpRefs.size() << " upreferences active!\n");
1307
1308 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1309 // to zero), we resolve them all together before we resolve them to Ty. At
1310 // the end of the loop, if there is anything to resolve to Ty, it will be in
1311 // this variable.
1312 OpaqueType *TypeToResolve = 0;
1313
1314 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1315 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1316 << UpRefs[i].second->getDescription() << ") = "
1317 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1318 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1319 // Decrement level of upreference
1320 unsigned Level = --UpRefs[i].NestingLevel;
1321 UpRefs[i].LastContainedTy = Ty;
1322 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1323 if (Level == 0) { // Upreference should be resolved!
1324 if (!TypeToResolve) {
1325 TypeToResolve = UpRefs[i].UpRefTy;
1326 } else {
1327 UR_OUT(" * Resolving upreference for "
1328 << UpRefs[i].second->getDescription() << "\n";
1329 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1330 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1331 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1332 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1333 }
1334 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1335 --i; // Do not skip the next element...
1336 }
1337 }
1338 }
1339
1340 if (TypeToResolve) {
1341 UR_OUT(" * Resolving upreference for "
1342 << UpRefs[i].second->getDescription() << "\n";
1343 std::string OldName = TypeToResolve->getDescription());
1344 TypeToResolve->refineAbstractTypeTo(Ty);
1345 }
1346
1347 return Ty;
1348}
1349
Reid Spencer68a24bd2005-08-27 18:50:39 +00001350//===----------------------------------------------------------------------===//
1351// RunVMAsmParser - Define an interface to this parser
1352//===----------------------------------------------------------------------===//
1353//
Reid Spencer14310612006-12-31 05:40:51 +00001354static Module* RunParser(Module * M);
1355
Duncan Sandsdc024672007-11-27 13:23:08 +00001356Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1357 InitLLLexer(MB);
1358 Module *M = RunParser(new Module(LLLgetFilename()));
1359 FreeLexer();
1360 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001361}
1362
1363
Dan Gohmanf4423b12008-04-19 00:24:39 +00001364
1365/* Enabling traces. */
1366#ifndef YYDEBUG
1367# define YYDEBUG 0
1368#endif
1369
1370/* Enabling verbose error messages. */
1371#ifdef YYERROR_VERBOSE
1372# undef YYERROR_VERBOSE
1373# define YYERROR_VERBOSE 1
1374#else
1375# define YYERROR_VERBOSE 0
1376#endif
1377
1378/* Enabling the token table. */
1379#ifndef YYTOKEN_TABLE
1380# define YYTOKEN_TABLE 0
1381#endif
1382
1383#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1384typedef union YYSTYPE
Nuno Lopes8a5f3472008-10-15 12:05:02 +00001385#line 981 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001386{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001387 llvm::Module *ModuleVal;
1388 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001389 llvm::BasicBlock *BasicBlockVal;
1390 llvm::TerminatorInst *TermInstVal;
1391 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001392 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001393
Reid Spencera132e042006-12-03 05:46:11 +00001394 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001395 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001396 llvm::PATypeHolder *TypeVal;
1397 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001398 std::vector<llvm::Value*> *ValueList;
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001399 std::vector<unsigned> *ConstantList;
Reid Spencer14310612006-12-31 05:40:51 +00001400 llvm::ArgListType *ArgList;
1401 llvm::TypeWithAttrs TypeWithAttrs;
1402 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001403 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001404
Reid Spencer68a24bd2005-08-27 18:50:39 +00001405 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001406 std::list<std::pair<llvm::Value*,
1407 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001408 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001409 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001410
1411 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001412 llvm::GlobalValue::VisibilityTypes Visibility;
Devang Patel05988662008-09-25 21:00:45 +00001413 llvm::Attributes Attributes;
Reid Spencer38c91a92007-02-28 02:24:54 +00001414 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001415 int64_t SInt64Val;
1416 uint64_t UInt64Val;
1417 int SIntVal;
1418 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001419 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001420 bool BoolVal;
1421
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001422 std::string *StrVal; // This memory must be deleted
1423 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001424
Reid Spencera132e042006-12-03 05:46:11 +00001425 llvm::Instruction::BinaryOps BinaryOpVal;
1426 llvm::Instruction::TermOps TermOpVal;
1427 llvm::Instruction::MemoryOps MemOpVal;
1428 llvm::Instruction::CastOps CastOpVal;
1429 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001430 llvm::ICmpInst::Predicate IPredicate;
1431 llvm::FCmpInst::Predicate FPredicate;
Dan Gohmanf4423b12008-04-19 00:24:39 +00001432}
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001433/* Line 187 of yacc.c. */
Nuno Lopes8a5f3472008-10-15 12:05:02 +00001434#line 1435 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001435 YYSTYPE;
1436# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1437# define YYSTYPE_IS_DECLARED 1
1438# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001439#endif
1440
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001441
Reid Spencer68a24bd2005-08-27 18:50:39 +00001442
Dan Gohmanf4423b12008-04-19 00:24:39 +00001443/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001444
1445
Dan Gohmanf4423b12008-04-19 00:24:39 +00001446/* Line 216 of yacc.c. */
Nuno Lopes8a5f3472008-10-15 12:05:02 +00001447#line 1448 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001448
Dan Gohmanf4423b12008-04-19 00:24:39 +00001449#ifdef short
1450# undef short
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001451#endif
1452
Dan Gohmanf4423b12008-04-19 00:24:39 +00001453#ifdef YYTYPE_UINT8
1454typedef YYTYPE_UINT8 yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001455#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00001456typedef unsigned char yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001457#endif
1458
Dan Gohmanf4423b12008-04-19 00:24:39 +00001459#ifdef YYTYPE_INT8
1460typedef YYTYPE_INT8 yytype_int8;
1461#elif (defined __STDC__ || defined __C99__FUNC__ \
1462 || defined __cplusplus || defined _MSC_VER)
1463typedef signed char yytype_int8;
1464#else
1465typedef short int yytype_int8;
1466#endif
1467
1468#ifdef YYTYPE_UINT16
1469typedef YYTYPE_UINT16 yytype_uint16;
1470#else
1471typedef unsigned short int yytype_uint16;
1472#endif
1473
1474#ifdef YYTYPE_INT16
1475typedef YYTYPE_INT16 yytype_int16;
1476#else
1477typedef short int yytype_int16;
1478#endif
1479
1480#ifndef YYSIZE_T
1481# ifdef __SIZE_TYPE__
1482# define YYSIZE_T __SIZE_TYPE__
1483# elif defined size_t
1484# define YYSIZE_T size_t
1485# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1486 || defined __cplusplus || defined _MSC_VER)
1487# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1488# define YYSIZE_T size_t
1489# else
1490# define YYSIZE_T unsigned int
1491# endif
1492#endif
1493
1494#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1495
1496#ifndef YY_
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001497# if YYENABLE_NLS
Dan Gohmanf4423b12008-04-19 00:24:39 +00001498# if ENABLE_NLS
1499# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1500# define YY_(msgid) dgettext ("bison-runtime", msgid)
1501# endif
1502# endif
1503# ifndef YY_
1504# define YY_(msgid) msgid
1505# endif
1506#endif
1507
1508/* Suppress unused-variable warnings by "using" E. */
1509#if ! defined lint || defined __GNUC__
1510# define YYUSE(e) ((void) (e))
1511#else
1512# define YYUSE(e) /* empty */
1513#endif
1514
1515/* Identity function, used to suppress warnings about constant conditions. */
1516#ifndef lint
1517# define YYID(n) (n)
1518#else
1519#if (defined __STDC__ || defined __C99__FUNC__ \
1520 || defined __cplusplus || defined _MSC_VER)
1521static int
1522YYID (int i)
1523#else
1524static int
1525YYID (i)
1526 int i;
1527#endif
1528{
1529 return i;
1530}
1531#endif
1532
1533#if ! defined yyoverflow || YYERROR_VERBOSE
1534
1535/* The parser invokes alloca or malloc; define the necessary symbols. */
1536
1537# ifdef YYSTACK_USE_ALLOCA
1538# if YYSTACK_USE_ALLOCA
1539# ifdef __GNUC__
1540# define YYSTACK_ALLOC __builtin_alloca
1541# elif defined __BUILTIN_VA_ARG_INCR
1542# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1543# elif defined _AIX
1544# define YYSTACK_ALLOC __alloca
1545# elif defined _MSC_VER
1546# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1547# define alloca _alloca
1548# else
1549# define YYSTACK_ALLOC alloca
1550# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1551 || defined __cplusplus || defined _MSC_VER)
1552# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1553# ifndef _STDLIB_H
1554# define _STDLIB_H 1
1555# endif
1556# endif
1557# endif
1558# endif
1559# endif
1560
1561# ifdef YYSTACK_ALLOC
1562 /* Pacify GCC's `empty if-body' warning. */
1563# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1564# ifndef YYSTACK_ALLOC_MAXIMUM
1565 /* The OS might guarantee only one guard page at the bottom of the stack,
1566 and a page size can be as small as 4096 bytes. So we cannot safely
1567 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1568 to allow for a few compiler-allocated temporary stack slots. */
1569# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1570# endif
1571# else
1572# define YYSTACK_ALLOC YYMALLOC
1573# define YYSTACK_FREE YYFREE
1574# ifndef YYSTACK_ALLOC_MAXIMUM
1575# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1576# endif
1577# if (defined __cplusplus && ! defined _STDLIB_H \
1578 && ! ((defined YYMALLOC || defined malloc) \
1579 && (defined YYFREE || defined free)))
1580# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1581# ifndef _STDLIB_H
1582# define _STDLIB_H 1
1583# endif
1584# endif
1585# ifndef YYMALLOC
1586# define YYMALLOC malloc
1587# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1588 || defined __cplusplus || defined _MSC_VER)
1589void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1590# endif
1591# endif
1592# ifndef YYFREE
1593# define YYFREE free
1594# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1595 || defined __cplusplus || defined _MSC_VER)
1596void free (void *); /* INFRINGES ON USER NAME SPACE */
1597# endif
1598# endif
1599# endif
1600#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1601
1602
1603#if (! defined yyoverflow \
1604 && (! defined __cplusplus \
1605 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1606
1607/* A type that is properly aligned for any stack member. */
1608union yyalloc
1609{
1610 yytype_int16 yyss;
1611 YYSTYPE yyvs;
1612 };
1613
1614/* The size of the maximum gap between one aligned stack and the next. */
1615# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1616
1617/* The size of an array large to enough to hold all stacks, each with
1618 N elements. */
1619# define YYSTACK_BYTES(N) \
1620 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1621 + YYSTACK_GAP_MAXIMUM)
1622
1623/* Copy COUNT objects from FROM to TO. The source and destination do
1624 not overlap. */
1625# ifndef YYCOPY
1626# if defined __GNUC__ && 1 < __GNUC__
1627# define YYCOPY(To, From, Count) \
1628 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1629# else
1630# define YYCOPY(To, From, Count) \
1631 do \
1632 { \
1633 YYSIZE_T yyi; \
1634 for (yyi = 0; yyi < (Count); yyi++) \
1635 (To)[yyi] = (From)[yyi]; \
1636 } \
1637 while (YYID (0))
1638# endif
1639# endif
1640
1641/* Relocate STACK from its old location to the new one. The
1642 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1643 elements in the stack, and YYPTR gives the new location of the
1644 stack. Advance YYPTR to a properly aligned location for the next
1645 stack. */
1646# define YYSTACK_RELOCATE(Stack) \
1647 do \
1648 { \
1649 YYSIZE_T yynewbytes; \
1650 YYCOPY (&yyptr->Stack, Stack, yysize); \
1651 Stack = &yyptr->Stack; \
1652 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1653 yyptr += yynewbytes / sizeof (*yyptr); \
1654 } \
1655 while (YYID (0))
1656
1657#endif
1658
1659/* YYFINAL -- State number of the termination state. */
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001660#define YYFINAL 44
Dan Gohmanf4423b12008-04-19 00:24:39 +00001661/* YYLAST -- Last index in YYTABLE. */
Chris Lattner740e7092008-10-15 06:16:57 +00001662#define YYLAST 2377
Dan Gohmanf4423b12008-04-19 00:24:39 +00001663
1664/* YYNTOKENS -- Number of terminals. */
Devang Patel652203f2008-09-29 20:49:50 +00001665#define YYNTOKENS 173
Dan Gohmanf4423b12008-04-19 00:24:39 +00001666/* YYNNTS -- Number of nonterminals. */
Chris Lattner740e7092008-10-15 06:16:57 +00001667#define YYNNTS 87
Dan Gohmanf4423b12008-04-19 00:24:39 +00001668/* YYNRULES -- Number of rules. */
Chris Lattner740e7092008-10-15 06:16:57 +00001669#define YYNRULES 348
Dan Gohmanf4423b12008-04-19 00:24:39 +00001670/* YYNRULES -- Number of states. */
Chris Lattner740e7092008-10-15 06:16:57 +00001671#define YYNSTATES 708
Dan Gohmanf4423b12008-04-19 00:24:39 +00001672
1673/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1674#define YYUNDEFTOK 2
Devang Patel652203f2008-09-29 20:49:50 +00001675#define YYMAXUTOK 413
Dan Gohmanf4423b12008-04-19 00:24:39 +00001676
1677#define YYTRANSLATE(YYX) \
1678 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1679
1680/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1681static const yytype_uint8 yytranslate[] =
1682{
1683 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1684 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1685 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1686 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001687 159, 160, 163, 2, 162, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001688 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001689 168, 161, 169, 2, 2, 2, 2, 2, 2, 2,
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 2, 165, 164, 167, 2, 2, 2, 2, 2, 172,
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,
Devang Patel652203f2008-09-29 20:49:50 +00001695 166, 2, 2, 170, 2, 171, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001696 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, 2, 2, 2, 2,
1706 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1707 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1708 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1709 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1710 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1711 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1712 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1713 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1714 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1715 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1716 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1717 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1718 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1719 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1720 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1721 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1722 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Dan Gohmane4977cf2008-05-23 01:55:30 +00001723 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
Devang Patel652203f2008-09-29 20:49:50 +00001724 155, 156, 157, 158
Dan Gohmanf4423b12008-04-19 00:24:39 +00001725};
1726
1727#if YYDEBUG
1728/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1729 YYRHS. */
1730static const yytype_uint16 yyprhs[] =
1731{
1732 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1733 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1734 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1735 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1736 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1737 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
Chris Lattner740e7092008-10-15 06:16:57 +00001738 118, 123, 124, 127, 128, 131, 133, 135, 137, 138,
1739 141, 143, 145, 147, 149, 151, 153, 155, 157, 159,
1740 160, 162, 164, 166, 167, 169, 171, 172, 174, 176,
1741 178, 180, 181, 183, 185, 186, 188, 190, 192, 194,
1742 196, 199, 201, 203, 205, 207, 209, 211, 213, 215,
1743 217, 220, 221, 224, 226, 228, 230, 231, 234, 236,
1744 238, 240, 242, 244, 246, 248, 250, 252, 254, 255,
1745 258, 259, 262, 263, 266, 267, 271, 274, 275, 277,
1746 278, 282, 284, 287, 289, 291, 293, 295, 297, 299,
1747 301, 303, 305, 309, 311, 314, 320, 326, 332, 338,
1748 342, 345, 351, 356, 359, 361, 363, 365, 369, 371,
1749 375, 377, 378, 380, 384, 389, 393, 397, 402, 407,
1750 411, 418, 424, 427, 430, 433, 436, 439, 442, 445,
1751 448, 451, 454, 457, 460, 467, 473, 482, 489, 496,
1752 504, 512, 520, 528, 535, 544, 553, 559, 567, 571,
1753 573, 575, 577, 579, 580, 583, 590, 592, 593, 595,
1754 598, 599, 603, 604, 608, 612, 616, 620, 621, 630,
1755 631, 641, 642, 652, 658, 661, 665, 667, 671, 675,
1756 679, 683, 685, 686, 692, 696, 698, 702, 704, 705,
1757 717, 719, 721, 726, 728, 730, 733, 737, 738, 740,
1758 742, 744, 746, 748, 750, 752, 754, 756, 758, 760,
1759 764, 768, 771, 774, 778, 781, 787, 792, 794, 800,
1760 802, 804, 806, 808, 810, 812, 815, 817, 821, 824,
1761 827, 831, 835, 838, 839, 841, 844, 847, 851, 861,
1762 871, 880, 896, 898, 900, 907, 913, 916, 919, 926,
1763 934, 939, 944, 951, 958, 959, 960, 964, 967, 971,
1764 974, 976, 982, 988, 995, 1002, 1009, 1016, 1021, 1028,
1765 1033, 1038, 1045, 1052, 1055, 1065, 1067, 1069, 1070, 1074,
1766 1081, 1085, 1092, 1095, 1101, 1109, 1115, 1120, 1125
Dan Gohmanf4423b12008-04-19 00:24:39 +00001767};
1768
1769/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1770static const yytype_int16 yyrhs[] =
1771{
Chris Lattner740e7092008-10-15 06:16:57 +00001772 220, 0, -1, 75, -1, 76, -1, 77, -1, 78,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001773 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
1774 -1, 87, -1, 88, -1, 89, -1, 84, -1, 85,
1775 -1, 86, -1, 120, -1, 121, -1, 122, -1, 123,
1776 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
1777 -1, 129, -1, 130, -1, 131, -1, 94, -1, 95,
1778 -1, 96, -1, 97, -1, 98, -1, 99, -1, 100,
1779 -1, 101, -1, 102, -1, 103, -1, 104, -1, 105,
1780 -1, 106, -1, 107, -1, 108, -1, 109, -1, 110,
1781 -1, 111, -1, 112, -1, 113, -1, 100, -1, 101,
Chris Lattner740e7092008-10-15 06:16:57 +00001782 -1, 102, -1, 103, -1, 26, -1, 27, -1, 19,
1783 -1, 22, -1, 24, -1, 179, -1, -1, 55, 159,
1784 4, 160, -1, -1, 179, 161, -1, -1, 7, 161,
1785 -1, 20, -1, 23, -1, 186, -1, -1, 184, 161,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001786 -1, 42, -1, 44, -1, 43, -1, 45, -1, 47,
1787 -1, 49, -1, 46, -1, 48, -1, 51, -1, -1,
1788 156, -1, 157, -1, 158, -1, -1, 46, -1, 48,
1789 -1, -1, 42, -1, 43, -1, 44, -1, 47, -1,
1790 -1, 44, -1, 42, -1, -1, 63, -1, 64, -1,
1791 65, -1, 66, -1, 67, -1, 62, 4, -1, 142,
1792 -1, 121, -1, 141, -1, 122, -1, 144, -1, 145,
1793 -1, 147, -1, 148, -1, 149, -1, 54, 4, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00001794 -1, 195, 194, -1, 144, -1, 142, -1, 141, -1,
1795 -1, 197, 196, -1, 143, -1, 146, -1, 144, -1,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001796 142, -1, 141, -1, 150, -1, 151, -1, 154, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00001797 155, -1, 153, -1, -1, 199, 198, -1, -1, 152,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001798 22, -1, -1, 54, 4, -1, -1, 162, 54, 4,
Chris Lattner740e7092008-10-15 06:16:57 +00001799 -1, 34, 22, -1, -1, 203, -1, -1, 162, 206,
1800 205, -1, 203, -1, 54, 4, -1, 11, -1, 12,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001801 -1, 13, -1, 16, -1, 15, -1, 14, -1, 17,
Chris Lattner740e7092008-10-15 06:16:57 +00001802 -1, 50, -1, 207, -1, 208, 181, 163, -1, 242,
1803 -1, 164, 4, -1, 208, 159, 212, 160, 199, -1,
1804 10, 159, 212, 160, 199, -1, 165, 4, 166, 208,
1805 167, -1, 168, 4, 166, 208, 169, -1, 170, 213,
1806 171, -1, 170, 171, -1, 168, 170, 213, 171, 169,
1807 -1, 168, 170, 171, 169, -1, 208, 195, -1, 208,
1808 -1, 10, -1, 209, -1, 211, 162, 209, -1, 211,
1809 -1, 211, 162, 39, -1, 39, -1, -1, 208, -1,
1810 213, 162, 208, -1, 208, 165, 216, 167, -1, 208,
1811 165, 167, -1, 208, 172, 22, -1, 208, 168, 216,
1812 169, -1, 208, 170, 216, 171, -1, 208, 170, 171,
1813 -1, 208, 168, 170, 216, 171, 169, -1, 208, 168,
1814 170, 171, 169, -1, 208, 40, -1, 208, 41, -1,
1815 208, 242, -1, 208, 215, -1, 208, 25, -1, 208,
1816 3, -1, 208, 5, -1, 208, 4, -1, 208, 6,
1817 -1, 208, 26, -1, 208, 27, -1, 208, 9, -1,
1818 176, 159, 214, 38, 208, 160, -1, 119, 159, 214,
1819 254, 160, -1, 133, 159, 214, 162, 214, 162, 214,
1820 160, -1, 174, 159, 214, 162, 214, 160, -1, 175,
1821 159, 214, 162, 214, 160, -1, 90, 177, 159, 214,
1822 162, 214, 160, -1, 91, 178, 159, 214, 162, 214,
1823 160, -1, 92, 177, 159, 214, 162, 214, 160, -1,
1824 93, 178, 159, 214, 162, 214, 160, -1, 135, 159,
1825 214, 162, 214, 160, -1, 136, 159, 214, 162, 214,
1826 162, 214, 160, -1, 137, 159, 214, 162, 214, 162,
1827 214, 160, -1, 139, 159, 214, 255, 160, -1, 140,
1828 159, 214, 162, 214, 255, 160, -1, 216, 162, 214,
1829 -1, 214, -1, 32, -1, 33, -1, 37, -1, -1,
1830 210, 242, -1, 125, 159, 219, 38, 208, 160, -1,
1831 221, -1, -1, 222, -1, 221, 222, -1, -1, 31,
1832 223, 238, -1, -1, 30, 224, 239, -1, 60, 59,
1833 228, -1, 182, 18, 208, -1, 182, 18, 10, -1,
1834 -1, 185, 189, 218, 217, 214, 181, 225, 205, -1,
1835 -1, 185, 187, 189, 218, 217, 214, 181, 226, 205,
1836 -1, -1, 185, 188, 189, 218, 217, 208, 181, 227,
1837 205, -1, 185, 189, 35, 192, 219, -1, 52, 229,
1838 -1, 56, 161, 230, -1, 22, -1, 53, 161, 22,
1839 -1, 68, 161, 22, -1, 165, 231, 167, -1, 231,
1840 162, 22, -1, 22, -1, -1, 232, 162, 208, 195,
1841 180, -1, 208, 195, 180, -1, 232, -1, 232, 162,
1842 39, -1, 39, -1, -1, 193, 197, 210, 184, 159,
1843 233, 160, 199, 204, 201, 200, -1, 28, -1, 170,
1844 -1, 191, 189, 234, 235, -1, 29, -1, 171, -1,
1845 246, 237, -1, 190, 189, 234, -1, -1, 61, -1,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001846 3, -1, 4, -1, 5, -1, 6, -1, 9, -1,
1847 26, -1, 27, -1, 40, -1, 41, -1, 25, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00001848 168, 216, 169, -1, 165, 216, 167, -1, 165, 167,
1849 -1, 172, 22, -1, 170, 216, 171, -1, 170, 171,
1850 -1, 168, 170, 216, 171, 169, -1, 168, 170, 171,
1851 169, -1, 215, -1, 59, 240, 22, 162, 22, -1,
1852 7, -1, 8, -1, 179, -1, 184, -1, 242, -1,
1853 241, -1, 208, 243, -1, 244, -1, 245, 162, 244,
1854 -1, 246, 247, -1, 236, 247, -1, 248, 182, 249,
1855 -1, 248, 183, 249, -1, 248, 251, -1, -1, 21,
1856 -1, 69, 245, -1, 69, 10, -1, 70, 17, 243,
1857 -1, 70, 11, 243, 162, 17, 243, 162, 17, 243,
1858 -1, 71, 11, 243, 162, 17, 243, 165, 250, 167,
1859 -1, 71, 11, 243, 162, 17, 243, 165, 167, -1,
1860 72, 193, 197, 210, 243, 159, 253, 160, 199, 38,
1861 17, 243, 73, 17, 243, -1, 73, -1, 74, -1,
1862 250, 11, 241, 162, 17, 243, -1, 11, 241, 162,
1863 17, 243, -1, 182, 257, -1, 183, 257, -1, 208,
1864 165, 243, 162, 243, 167, -1, 252, 162, 165, 243,
1865 162, 243, 167, -1, 208, 195, 243, 195, -1, 17,
1866 195, 243, 195, -1, 253, 162, 208, 195, 243, 195,
1867 -1, 253, 162, 17, 195, 243, 195, -1, -1, -1,
1868 254, 162, 244, -1, 162, 4, -1, 255, 162, 4,
1869 -1, 58, 57, -1, 57, -1, 174, 208, 243, 162,
1870 243, -1, 175, 208, 243, 162, 243, -1, 90, 177,
1871 208, 243, 162, 243, -1, 91, 178, 208, 243, 162,
1872 243, -1, 92, 177, 208, 243, 162, 243, -1, 93,
1873 178, 208, 243, 162, 243, -1, 176, 244, 38, 208,
1874 -1, 133, 244, 162, 244, 162, 244, -1, 134, 244,
1875 162, 208, -1, 135, 244, 162, 244, -1, 136, 244,
1876 162, 244, 162, 244, -1, 137, 244, 162, 244, 162,
1877 244, -1, 132, 252, -1, 256, 193, 197, 210, 243,
1878 159, 253, 160, 199, -1, 259, -1, 36, -1, -1,
1879 114, 208, 202, -1, 114, 208, 162, 11, 243, 202,
1880 -1, 115, 208, 202, -1, 115, 208, 162, 11, 243,
1881 202, -1, 116, 244, -1, 258, 117, 208, 243, 202,
1882 -1, 258, 118, 244, 162, 208, 243, 202, -1, 138,
1883 208, 243, 162, 4, -1, 119, 208, 243, 254, -1,
1884 139, 208, 243, 255, -1, 140, 208, 243, 162, 208,
1885 243, 255, -1
Dan Gohmanf4423b12008-04-19 00:24:39 +00001886};
1887
1888/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1889static const yytype_uint16 yyrline[] =
1890{
Nuno Lopes8a5f3472008-10-15 12:05:02 +00001891 0, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147,
1892 1147, 1148, 1148, 1148, 1148, 1148, 1148, 1149, 1149, 1149,
1893 1149, 1149, 1149, 1150, 1150, 1150, 1150, 1150, 1150, 1153,
1894 1153, 1154, 1154, 1155, 1155, 1156, 1156, 1157, 1157, 1161,
1895 1161, 1162, 1162, 1163, 1163, 1164, 1164, 1165, 1165, 1166,
1896 1166, 1167, 1167, 1168, 1169, 1172, 1172, 1172, 1173, 1173,
1897 1175, 1176, 1180, 1184, 1189, 1195, 1195, 1197, 1198, 1203,
1898 1209, 1210, 1211, 1212, 1213, 1214, 1218, 1219, 1220, 1224,
1899 1225, 1226, 1227, 1231, 1232, 1233, 1237, 1238, 1239, 1240,
1900 1241, 1245, 1246, 1247, 1250, 1251, 1252, 1253, 1254, 1255,
1901 1256, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271,
1902 1272, 1276, 1277, 1282, 1283, 1284, 1287, 1288, 1294, 1295,
1903 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1306, 1307,
1904 1313, 1314, 1321, 1322, 1328, 1329, 1338, 1346, 1347, 1352,
1905 1353, 1354, 1359, 1372, 1372, 1372, 1372, 1372, 1372, 1372,
1906 1375, 1379, 1383, 1390, 1395, 1403, 1438, 1469, 1474, 1484,
1907 1494, 1498, 1508, 1515, 1524, 1531, 1536, 1541, 1548, 1549,
1908 1556, 1563, 1571, 1577, 1589, 1617, 1633, 1660, 1688, 1714,
1909 1734, 1760, 1780, 1792, 1799, 1865, 1875, 1885, 1896, 1909,
1910 1920, 1934, 1941, 1948, 1966, 1978, 1999, 2007, 2013, 2024,
1911 2029, 2034, 2039, 2044, 2050, 2056, 2062, 2070, 2081, 2085,
1912 2093, 2093, 2096, 2096, 2099, 2111, 2132, 2137, 2145, 2146,
1913 2150, 2150, 2154, 2154, 2157, 2160, 2184, 2196, 2195, 2207,
1914 2206, 2216, 2215, 2226, 2266, 2269, 2275, 2285, 2289, 2294,
1915 2296, 2301, 2306, 2315, 2325, 2336, 2340, 2349, 2358, 2363,
1916 2512, 2512, 2514, 2523, 2523, 2525, 2530, 2542, 2546, 2551,
1917 2555, 2559, 2564, 2569, 2573, 2577, 2581, 2585, 2589, 2593,
1918 2615, 2637, 2643, 2656, 2668, 2673, 2685, 2691, 2695, 2705,
1919 2709, 2713, 2718, 2725, 2725, 2731, 2740, 2745, 2750, 2754,
1920 2763, 2772, 2785, 2794, 2798, 2806, 2826, 2830, 2835, 2846,
1921 2865, 2874, 2978, 2982, 2989, 3000, 3013, 3022, 3035, 3046,
1922 3056, 3067, 3075, 3085, 3092, 3095, 3096, 3104, 3110, 3119,
1923 3123, 3128, 3144, 3161, 3173, 3185, 3199, 3213, 3225, 3246,
1924 3253, 3259, 3265, 3271, 3286, 3396, 3401, 3405, 3412, 3419,
1925 3429, 3436, 3446, 3454, 3468, 3485, 3499, 3514, 3529
Dan Gohmanf4423b12008-04-19 00:24:39 +00001926};
1927#endif
1928
1929#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1930/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1931 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1932static const char *const yytname[] =
1933{
1934 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1935 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1936 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1937 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1938 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1939 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1940 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1941 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001942 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "COMMON", "OPAQUE",
Dan Gohmanf4423b12008-04-19 00:24:39 +00001943 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1944 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1945 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Dale Johannesendfe8c842008-09-26 19:32:34 +00001946 "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
1947 "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
1948 "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "VICMP",
1949 "VFCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1950 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1951 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1952 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1953 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1954 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1955 "GETRESULT", "EXTRACTVALUE", "INSERTVALUE", "SIGNEXT", "ZEROEXT",
1956 "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST",
Devang Patel652203f2008-09-29 20:49:50 +00001957 "READNONE", "READONLY", "GC", "OPTSIZE", "NOINLINE", "ALWAYSINLINE",
1958 "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'",
1959 "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'",
1960 "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates",
Chris Lattner740e7092008-10-15 06:16:57 +00001961 "FPredicates", "LocalName", "OptLocalName", "OptAddrSpace",
Chris Lattnerf9078f92008-10-15 06:03:48 +00001962 "OptLocalAssign", "LocalNumber", "GlobalName", "OptGlobalAssign",
1963 "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1964 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1965 "AliasLinkage", "OptCallingConv", "Attribute", "OptAttributes",
1966 "RetAttr", "OptRetAttrs", "FuncAttr", "OptFuncAttrs", "OptGC",
1967 "OptAlign", "OptCAlign", "SectionString", "OptSection",
Devang Patel652203f2008-09-29 20:49:50 +00001968 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1969 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1970 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "ThreadLocal",
1971 "AliaseeRef", "Module", "DefinitionList", "Definition", "@1", "@2", "@3",
1972 "@4", "@5", "AsmBlock", "TargetDefinition", "LibrariesDefinition",
1973 "LibList", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1974 "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect",
1975 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1976 "ReturnedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1977 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ParamList",
1978 "IndexList", "ConstantIndexList", "OptTailCall", "InstVal",
Chris Lattner15bd0952008-08-29 17:20:18 +00001979 "OptVolatile", "MemoryInst", 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00001980};
1981#endif
1982
1983# ifdef YYPRINT
1984/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1985 token YYLEX-NUM. */
1986static const yytype_uint16 yytoknum[] =
1987{
1988 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1989 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1990 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1991 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1992 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1993 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1994 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1995 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1996 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1997 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1998 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1999 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2000 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2001 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2002 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Devang Patel652203f2008-09-29 20:49:50 +00002003 405, 406, 407, 408, 409, 410, 411, 412, 413, 40,
2004 41, 61, 44, 42, 92, 91, 120, 93, 60, 62,
2005 123, 125, 99
Dan Gohmanf4423b12008-04-19 00:24:39 +00002006};
2007# endif
2008
2009/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002010static const yytype_uint16 yyr1[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002011{
Devang Patel652203f2008-09-29 20:49:50 +00002012 0, 173, 174, 174, 174, 174, 174, 174, 174, 174,
2013 174, 175, 175, 175, 175, 175, 175, 176, 176, 176,
2014 176, 176, 176, 176, 176, 176, 176, 176, 176, 177,
2015 177, 177, 177, 177, 177, 177, 177, 177, 177, 178,
2016 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
Chris Lattner740e7092008-10-15 06:16:57 +00002017 178, 178, 178, 178, 178, 179, 179, 179, 180, 180,
2018 181, 181, 182, 182, 183, 184, 184, 185, 185, 186,
2019 187, 187, 187, 187, 187, 187, 188, 188, 188, 189,
2020 189, 189, 189, 190, 190, 190, 191, 191, 191, 191,
2021 191, 192, 192, 192, 193, 193, 193, 193, 193, 193,
2022 193, 194, 194, 194, 194, 194, 194, 194, 194, 194,
2023 194, 195, 195, 196, 196, 196, 197, 197, 198, 198,
2024 198, 198, 198, 198, 198, 198, 198, 198, 199, 199,
2025 200, 200, 201, 201, 202, 202, 203, 204, 204, 205,
2026 205, 206, 206, 207, 207, 207, 207, 207, 207, 207,
2027 208, 208, 208, 208, 208, 208, 208, 208, 208, 208,
2028 208, 208, 208, 209, 210, 210, 211, 211, 212, 212,
2029 212, 212, 213, 213, 214, 214, 214, 214, 214, 214,
2030 214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
2031 214, 214, 214, 214, 215, 215, 215, 215, 215, 215,
2032 215, 215, 215, 215, 215, 215, 215, 215, 216, 216,
2033 217, 217, 218, 218, 219, 219, 220, 220, 221, 221,
2034 223, 222, 224, 222, 222, 222, 222, 225, 222, 226,
2035 222, 227, 222, 222, 222, 222, 228, 229, 229, 230,
2036 231, 231, 231, 232, 232, 233, 233, 233, 233, 234,
2037 235, 235, 236, 237, 237, 238, 239, 240, 240, 241,
2038 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2039 241, 241, 241, 241, 241, 241, 241, 241, 241, 242,
2040 242, 242, 242, 243, 243, 244, 245, 245, 246, 246,
2041 247, 247, 248, 248, 248, 249, 249, 249, 249, 249,
2042 249, 249, 249, 249, 250, 250, 251, 251, 252, 252,
2043 253, 253, 253, 253, 253, 254, 254, 255, 255, 256,
2044 256, 257, 257, 257, 257, 257, 257, 257, 257, 257,
2045 257, 257, 257, 257, 257, 257, 258, 258, 259, 259,
2046 259, 259, 259, 259, 259, 259, 259, 259, 259
Dan Gohmanf4423b12008-04-19 00:24:39 +00002047};
2048
2049/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2050static const yytype_uint8 yyr2[] =
2051{
2052 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2053 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2054 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2055 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2056 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Chris Lattner740e7092008-10-15 06:16:57 +00002057 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
2058 4, 0, 2, 0, 2, 1, 1, 1, 0, 2,
2059 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
2060 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
2061 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
2062 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2063 2, 0, 2, 1, 1, 1, 0, 2, 1, 1,
2064 1, 1, 1, 1, 1, 1, 1, 1, 0, 2,
2065 0, 2, 0, 2, 0, 3, 2, 0, 1, 0,
2066 3, 1, 2, 1, 1, 1, 1, 1, 1, 1,
2067 1, 1, 3, 1, 2, 5, 5, 5, 5, 3,
2068 2, 5, 4, 2, 1, 1, 1, 3, 1, 3,
2069 1, 0, 1, 3, 4, 3, 3, 4, 4, 3,
2070 6, 5, 2, 2, 2, 2, 2, 2, 2, 2,
2071 2, 2, 2, 2, 6, 5, 8, 6, 6, 7,
2072 7, 7, 7, 6, 8, 8, 5, 7, 3, 1,
2073 1, 1, 1, 0, 2, 6, 1, 0, 1, 2,
2074 0, 3, 0, 3, 3, 3, 3, 0, 8, 0,
2075 9, 0, 9, 5, 2, 3, 1, 3, 3, 3,
2076 3, 1, 0, 5, 3, 1, 3, 1, 0, 11,
2077 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
2078 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
2079 3, 2, 2, 3, 2, 5, 4, 1, 5, 1,
2080 1, 1, 1, 1, 1, 2, 1, 3, 2, 2,
2081 3, 3, 2, 0, 1, 2, 2, 3, 9, 9,
2082 8, 15, 1, 1, 6, 5, 2, 2, 6, 7,
2083 4, 4, 6, 6, 0, 0, 3, 2, 3, 2,
2084 1, 5, 5, 6, 6, 6, 6, 4, 6, 4,
2085 4, 6, 6, 2, 9, 1, 1, 0, 3, 6,
2086 3, 6, 2, 5, 7, 5, 4, 4, 7
Dan Gohmanf4423b12008-04-19 00:24:39 +00002087};
2088
2089/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2090 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2091 means the default is an error. */
2092static const yytype_uint16 yydefact[] =
2093{
Chris Lattner740e7092008-10-15 06:16:57 +00002094 68, 55, 65, 56, 66, 57, 222, 220, 0, 0,
2095 0, 0, 0, 0, 79, 67, 0, 68, 218, 83,
2096 86, 0, 0, 234, 0, 0, 62, 0, 69, 70,
2097 72, 71, 73, 76, 74, 77, 75, 78, 80, 81,
2098 82, 79, 79, 213, 1, 219, 84, 85, 79, 223,
2099 87, 88, 89, 90, 79, 293, 221, 293, 0, 0,
2100 242, 235, 236, 224, 279, 280, 226, 143, 144, 145,
2101 148, 147, 146, 149, 150, 0, 0, 0, 0, 281,
2102 282, 151, 225, 153, 213, 213, 91, 212, 0, 94,
2103 94, 294, 289, 63, 253, 254, 255, 288, 237, 238,
2104 241, 0, 171, 154, 0, 0, 0, 0, 160, 172,
2105 0, 0, 171, 0, 0, 0, 93, 92, 0, 210,
2106 211, 0, 0, 95, 96, 97, 98, 99, 116, 256,
2107 0, 0, 337, 337, 292, 0, 239, 170, 111, 166,
2108 168, 0, 0, 0, 0, 0, 0, 159, 0, 0,
2109 152, 0, 0, 165, 0, 164, 0, 233, 61, 61,
2110 100, 0, 250, 251, 252, 64, 336, 320, 0, 0,
2111 0, 0, 94, 302, 303, 2, 3, 4, 5, 6,
2112 7, 8, 9, 10, 14, 15, 16, 11, 12, 13,
2113 0, 0, 0, 0, 0, 0, 0, 0, 17, 18,
2114 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
Nate Begemanac80ade2008-05-12 19:01:56 +00002115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002116 0, 0, 290, 94, 306, 0, 335, 291, 307, 240,
2117 163, 0, 128, 61, 61, 162, 0, 173, 0, 128,
2118 61, 61, 0, 214, 187, 189, 188, 190, 193, 186,
2119 191, 192, 182, 183, 0, 0, 0, 0, 0, 0,
2120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2121 0, 0, 185, 184, 227, 115, 114, 113, 117, 0,
2122 319, 296, 61, 286, 295, 0, 0, 0, 116, 29,
2123 30, 31, 32, 33, 34, 35, 36, 37, 38, 0,
2124 53, 54, 49, 50, 51, 52, 39, 40, 41, 42,
2125 43, 44, 45, 46, 47, 48, 0, 0, 0, 134,
2126 134, 342, 61, 61, 333, 0, 0, 0, 0, 0,
2127 61, 61, 61, 61, 61, 0, 116, 0, 0, 0,
2128 102, 104, 103, 101, 105, 106, 107, 108, 109, 112,
2129 169, 167, 156, 157, 158, 161, 60, 155, 229, 231,
2130 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2131 0, 0, 175, 209, 0, 0, 0, 179, 0, 176,
2132 0, 0, 0, 139, 0, 259, 260, 261, 262, 263,
2133 268, 264, 265, 266, 267, 257, 0, 0, 0, 0,
2134 277, 284, 283, 285, 0, 0, 297, 0, 0, 61,
2135 61, 61, 61, 0, 338, 0, 340, 315, 0, 0,
2136 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2137 0, 0, 61, 0, 110, 122, 121, 118, 120, 119,
2138 123, 124, 127, 125, 126, 129, 139, 139, 0, 0,
2139 0, 0, 0, 315, 0, 0, 0, 0, 0, 0,
2140 0, 174, 160, 172, 0, 177, 178, 0, 0, 0,
2141 0, 228, 248, 258, 0, 271, 0, 0, 0, 274,
2142 0, 272, 287, 0, 0, 0, 0, 0, 0, 0,
2143 0, 0, 0, 346, 0, 0, 0, 329, 330, 0,
2144 0, 0, 0, 347, 0, 0, 0, 327, 0, 134,
2145 0, 230, 232, 61, 0, 0, 0, 0, 0, 0,
2146 0, 0, 0, 0, 0, 208, 181, 0, 0, 0,
2147 0, 0, 0, 141, 139, 247, 111, 245, 0, 0,
2148 270, 160, 0, 269, 273, 0, 0, 0, 0, 0,
2149 0, 0, 134, 135, 134, 0, 0, 0, 0, 0,
2150 0, 345, 317, 0, 61, 321, 322, 0, 0, 343,
2151 61, 215, 0, 0, 0, 0, 195, 0, 0, 0,
2152 0, 206, 0, 180, 0, 0, 61, 136, 142, 140,
2153 59, 0, 128, 0, 276, 0, 0, 0, 314, 323,
2154 324, 325, 326, 339, 341, 316, 0, 0, 328, 331,
2155 332, 318, 0, 314, 134, 0, 0, 0, 0, 0,
2156 203, 0, 0, 0, 197, 198, 194, 58, 244, 246,
2157 111, 137, 278, 275, 0, 0, 111, 111, 0, 308,
2158 0, 348, 0, 344, 199, 200, 201, 202, 0, 0,
2159 0, 207, 59, 138, 132, 0, 0, 300, 0, 0,
2160 0, 128, 0, 309, 128, 196, 204, 205, 243, 0,
2161 130, 298, 0, 0, 299, 102, 104, 111, 111, 0,
2162 111, 111, 334, 133, 0, 249, 0, 0, 311, 310,
2163 0, 0, 0, 131, 0, 0, 0, 111, 111, 305,
2164 0, 0, 313, 312, 304, 0, 0, 301
Dan Gohmanf4423b12008-04-19 00:24:39 +00002165};
2166
2167/* YYDEFGOTO[NTERM-NUM]. */
2168static const yytype_int16 yydefgoto[] =
2169{
Chris Lattner740e7092008-10-15 06:16:57 +00002170 -1, 269, 270, 271, 299, 316, 79, 628, 113, 12,
2171 133, 80, 14, 15, 41, 42, 43, 48, 54, 118,
2172 128, 349, 230, 278, 161, 445, 352, 685, 670, 414,
2173 533, 654, 471, 534, 81, 158, 139, 156, 140, 141,
2174 110, 373, 400, 374, 121, 88, 157, 16, 17, 18,
2175 20, 19, 383, 446, 447, 63, 23, 61, 101, 537,
2176 538, 129, 164, 55, 96, 56, 49, 474, 401, 83,
2177 403, 283, 284, 57, 92, 93, 222, 658, 134, 324,
2178 638, 493, 503, 223, 224, 225, 226
Dan Gohmanf4423b12008-04-19 00:24:39 +00002179};
2180
2181/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2182 STATE-NUM. */
Chris Lattner740e7092008-10-15 06:16:57 +00002183#define YYPACT_NINF -624
Dan Gohmanf4423b12008-04-19 00:24:39 +00002184static const yytype_int16 yypact[] =
2185{
Chris Lattner740e7092008-10-15 06:16:57 +00002186 815, -624, -624, -624, -624, -624, -624, -624, 14, -114,
2187 16, -73, 78, -31, 299, -624, 163, 2187, -624, 164,
2188 80, 19, 22, -624, 2, 179, -624, 1912, -624, -624,
2189 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2190 -624, 68, 68, 201, -624, -624, -624, -624, 68, -624,
2191 -624, -624, -624, -624, 68, 200, -624, 5, 215, 222,
2192 225, -624, -624, -624, -624, -624, 117, -624, -624, -624,
2193 -624, -624, -624, -624, -624, 264, 277, 7, 49, -624,
2194 -624, -624, -12, -624, 252, 252, 198, -624, 79, 231,
2195 231, -624, -624, 83, -624, -624, -624, -624, -624, -624,
2196 -624, -21, 649, -624, 138, 149, 627, 117, -624, -12,
2197 -120, 159, 649, 158, 79, 79, -624, -624, 1557, -624,
2198 -624, 2012, 320, -624, -624, -624, -624, -624, -624, -624,
2199 -13, 173, 2237, 2237, -624, 313, -624, -624, -12, -624,
2200 174, 177, 2012, 2012, 169, -118, 2012, -624, 336, 191,
2201 -624, 2012, 2012, 117, 193, -12, 226, -624, 1296, 308,
2202 -624, 1516, -624, -624, -624, -624, -624, -624, 307, 2031,
2203 108, 357, 231, -624, -624, -624, -624, -624, -624, -624,
2204 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2205 454, 958, 454, 958, 2012, 2012, 2012, 2012, -624, -624,
2206 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2207 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2208 2012, 2012, -624, 231, -624, 55, -624, -624, -624, -624,
2209 161, 1748, -624, -23, -41, -624, 203, -12, 214, -624,
2210 308, -20, 1557, -624, -624, -624, -624, -624, -624, -624,
2211 -624, -624, -624, -624, 454, 958, 454, 958, 216, 217,
2212 218, 220, 221, 224, 227, 1789, 2076, 732, 351, 228,
2213 229, 230, -624, -624, -624, -624, -624, -624, -624, 109,
2214 -624, 117, 956, -624, 219, 1466, 1466, 1466, -624, -624,
2215 -624, -624, -624, -624, -624, -624, -624, -624, -624, 2012,
2216 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2217 -624, -624, -624, -624, -624, -624, 2012, 2012, 2012, -10,
2218 3, -624, 956, -17, 223, 237, 238, 239, 240, 241,
2219 956, 956, 956, 956, 956, 352, -624, 2012, 2012, 387,
2220 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2221 -624, -624, 539, -624, -624, -624, -624, 539, -624, 158,
2222 354, 234, 248, 249, 250, 2012, 2012, 2012, 2012, 2012,
2223 2012, 2012, -624, -624, 42, 1006, -121, -624, -116, -624,
2224 2012, 2012, 2012, 253, 251, -624, -624, -624, -624, -624,
2225 -624, -624, -624, -624, -624, 353, 1807, 2094, 1175, 390,
2226 -624, -624, -624, -624, 2012, 255, -624, 256, 1516, 956,
2227 956, 956, 956, 20, -624, 29, -624, -624, 1466, 254,
2228 2012, 2012, 2012, 2012, 2012, 258, 259, 261, 262, 263,
2229 2012, 1516, 956, 266, -624, -624, -624, -624, -624, -624,
2230 -624, -624, -624, -624, -624, -624, 253, 253, 2012, 2012,
2231 2012, 2012, 2012, -624, 269, 270, 272, 273, 259, 274,
2232 2012, -624, 268, 1126, -84, -624, -624, 280, 281, 406,
2233 -5, -624, 1830, -624, 423, -624, 61, 1345, -56, -624,
2234 -77, -624, -624, 430, 431, 1466, 288, 290, 291, 292,
2235 1466, 455, 1466, 296, 298, 1466, 300, -12, -624, 301,
2236 302, 457, 461, 306, 2012, 1466, 1466, -12, 1466, 311,
2237 2012, -624, -624, -1, 312, 314, 317, 319, 101, 2012,
2238 2012, 2012, 2012, 112, 2012, -624, -624, 318, 2012, 2012,
2239 2012, 453, 478, -624, 253, -624, -12, 321, 326, 327,
2240 -624, 323, -67, -624, -624, 1466, 1466, 329, 1466, 1466,
2241 1466, 1466, 311, -624, 311, 2012, 1466, 328, 2012, 2012,
2242 2012, -624, -624, 489, 956, -624, -624, 335, 441, -624,
2243 956, -624, 2012, 2012, 2012, 2012, -624, 334, 337, 339,
2244 340, -624, 259, -624, 343, 345, 15, -624, -624, -624,
2245 178, 1848, -624, 484, -624, 338, 350, 349, 2117, -624,
2246 -624, -624, -624, -624, -624, -624, 348, 1466, -624, -624,
2247 -624, -624, 259, 2117, 311, 356, 359, 360, 361, 2012,
2248 -624, 2012, 2012, 115, -624, -624, -624, -624, -624, -624,
2249 -12, 116, -624, -624, 505, -7, 59, -12, 118, -624,
2250 358, 306, 124, -624, -624, -624, -624, -624, 363, 364,
2251 366, -624, 178, -624, 473, 1466, 1614, -624, -6, 802,
2252 802, -624, 2135, -624, -624, -624, -624, -624, -624, 526,
2253 379, -624, 374, 1614, -624, 378, 380, -624, -624, 442,
2254 59, -12, 539, -624, 516, -624, 523, 396, 161, 161,
2255 524, 802, 802, -624, 1466, 525, 1466, -624, -624, -624,
2256 1466, 486, 161, 161, -624, 543, 1466, -624
Dan Gohmanf4423b12008-04-19 00:24:39 +00002257};
2258
2259/* YYPGOTO[NTERM-NUM]. */
2260static const yytype_int16 yypgoto[] =
2261{
Chris Lattner740e7092008-10-15 06:16:57 +00002262 -624, 132, 155, 181, -165, -154, 0, -86, -143, 474,
2263 -624, 6, -624, -624, -624, -624, 67, -624, -624, -624,
2264 -142, -624, -499, -624, -252, -624, -231, -624, -624, -313,
2265 -63, -624, -434, -624, -624, -26, 342, -152, -624, 458,
2266 463, -11, -156, -242, 202, 244, 332, -624, -624, 554,
2267 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2268 -624, 485, -624, -624, -624, -624, -624, -624, -623, -79,
2269 213, -193, -624, -624, 520, -624, 445, -624, -624, -624,
2270 -34, 129, -448, -624, 456, -624, -624
Dan Gohmanf4423b12008-04-19 00:24:39 +00002271};
2272
2273/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2274 positive, shift that token. If negative, reduce the rule which
2275 number is the opposite. If zero, do what YYDEFACT says.
2276 If YYTABLE_NINF, syntax error. */
Chris Lattner740e7092008-10-15 06:16:57 +00002277#define YYTABLE_NINF -218
Dan Gohmanf4423b12008-04-19 00:24:39 +00002278static const yytype_int16 yytable[] =
2279{
Chris Lattner740e7092008-10-15 06:16:57 +00002280 11, 82, 272, 321, 656, 673, 13, 416, 357, 279,
2281 523, 105, 511, 512, 111, 162, 274, 11, 325, 326,
2282 327, 328, 329, 13, 376, 378, 91, 317, 335, 531,
2283 288, 490, 111, 672, 94, 111, 408, 590, 111, 318,
2284 492, 460, 146, 111, 146, 111, 460, 24, 465, 532,
2285 687, 147, 109, 236, 111, 466, 64, 65, 111, 107,
2286 67, 68, 69, 70, 71, 72, 73, 21, 1, 2,
2287 111, 3, 4, 5, 491, 25, 138, 243, 460, 273,
2288 109, 336, 22, 491, 431, 460, 138, 527, 26, 361,
2289 131, 363, 155, 11, 544, 460, 27, 358, 359, 74,
2290 589, 362, 1, 364, 595, 3, 460, 5, 84, 85,
2291 159, 119, 120, 543, -149, 89, 233, 234, 112, 285,
2292 237, 90, 50, 51, 52, 286, 241, 53, 354, 2,
2293 28, 652, 4, 464, 623, 155, 112, 659, 660, 112,
2294 240, 135, 112, 282, 353, 433, 136, 112, 418, 112,
2295 531, -61, 413, -61, 476, 478, 480, 163, 112, 571,
2296 657, 674, 112, 44, 641, 415, -61, 60, 319, 320,
2297 282, 322, 337, 338, 112, 626, 95, 106, 688, 689,
2298 58, 691, 692, 59, 323, 282, 282, 282, 282, 282,
2299 330, 331, 332, 333, 334, 282, 569, 1, 702, 703,
2300 3, 62, 5, 402, 460, 138, 402, 402, 402, 461,
2301 46, 482, 47, 75, 76, 339, 155, 77, -149, 78,
2302 108, 91, -149, 460, 38, 39, 40, 496, 540, 498,
2303 499, 500, 339, 64, 65, 542, 86, 98, 87, 603,
2304 116, 604, 117, 402, 99, 1, 2, 100, 3, 4,
2305 5, 402, 402, 402, 402, 402, 485, 435, 436, 437,
2306 438, 576, 439, 555, 219, 219, 440, 441, 103, 442,
2307 443, 444, 581, 409, 563, 651, 102, 563, 661, 508,
2308 662, 104, 340, 341, 664, 384, 662, 220, 220, 87,
2309 410, 411, 412, 122, 123, 124, 125, 126, 127, 340,
2310 341, 643, 342, 343, 142, 344, 345, 272, 346, 347,
2311 348, 432, 282, 221, 221, 143, 151, 152, 148, 342,
2312 343, 150, 344, 345, 160, 346, 347, 348, 114, 115,
2313 402, 402, 402, 402, 165, 229, 231, 232, 235, 402,
2314 238, 29, 30, 31, 32, 33, 34, 35, 36, 463,
2315 37, 239, 242, 402, 453, 454, 455, 456, 457, 458,
2316 459, 631, 605, 111, 280, 608, 609, 610, 287, 467,
2317 468, 469, 355, 379, 356, 365, 366, 367, 282, 368,
2318 369, 404, 155, 370, 273, 419, 371, 380, 381, 382,
2319 430, 434, 448, 449, 282, 497, 282, 282, 282, 420,
2320 421, 422, 423, 424, 507, 155, 402, 450, 451, 452,
2321 472, 402, 481, 402, 473, 470, 402, 483, 484, 495,
2322 501, 502, 513, 504, 505, 506, 402, 402, 510, 402,
2323 679, 519, 520, 682, 521, 522, 524, 526, 514, 515,
2324 516, 517, 528, 529, 530, 539, 536, 545, 546, 525,
2325 548, 463, 549, 550, 551, 38, 39, 40, 555, 553,
2326 556, 561, 558, 559, 560, 562, 402, 402, 563, 402,
2327 402, 402, 402, 568, 572, 587, 573, 402, 564, 574,
2328 690, 575, 588, 591, 570, 402, 592, 583, 598, 593,
2329 607, 402, 594, 611, 613, 491, 619, 620, 405, 406,
2330 407, 621, 622, 624, 586, 625, 632, 633, 577, 578,
2331 579, 580, 634, 582, 635, 639, 644, 584, 585, 645,
2332 646, 647, 655, 665, 666, 663, 667, 669, 402, 282,
2333 683, 684, 282, 282, 282, 417, 686, -18, 693, -19,
2334 694, 696, 700, 425, 426, 427, 428, 429, 289, 290,
2335 291, 292, 293, 294, 295, 296, 297, 298, 695, 705,
2336 706, 615, 616, 617, 618, 630, 668, 132, 653, 145,
2337 149, 45, 637, 351, 360, 130, 402, 97, 227, 642,
2338 402, 402, 518, 435, 436, 437, 438, 637, 439, 228,
2339 627, 0, 440, 441, 0, 442, 443, 444, 0, 0,
2340 0, 0, 0, 0, 0, 0, 0, 0, 648, 0,
2341 649, 650, 402, 402, 0, 402, 0, 402, 0, 0,
2342 0, 402, 486, 487, 488, 489, 0, 402, 0, 0,
2343 0, 494, 0, 0, 64, 65, 681, 107, 67, 68,
2344 69, 70, 71, 72, 73, 509, 1, 2, 0, 3,
2345 4, 5, 627, 0, 0, 0, 64, 65, 0, 107,
2346 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2347 0, 3, 4, 5, 0, 0, 0, 74, 0, 0,
2348 435, 436, 437, 438, 0, 439, 0, 0, 137, 440,
2349 441, 0, 442, 443, 444, 0, 0, 0, 547, 74,
2350 0, 0, 0, 552, 0, 554, 0, 0, 557, 0,
2351 0, 0, 0, 0, 0, 0, 0, 0, 565, 566,
2352 0, 567, 0, 0, 0, 0, 0, 0, 0, 0,
2353 0, 0, 0, 0, 0, 0, 0, 0, 0, 64,
2354 65, 0, 107, 67, 68, 69, 70, 71, 72, 73,
2355 0, 1, 2, 0, 3, 4, 5, 0, 596, 597,
2356 0, 599, 600, 601, 602, 0, 0, 0, 0, 606,
2357 0, 0, 0, 0, 0, 0, 0, 612, 0, 0,
2358 0, 0, 74, 614, 0, 0, 0, 0, 0, 0,
2359 0, 75, 76, 0, 0, 77, 0, 78, 144, 0,
2360 0, 0, 0, 0, 0, 385, 386, 387, 388, 64,
2361 65, 389, 0, 75, 76, -217, 0, 77, 0, 78,
2362 640, 1, 2, 0, 3, 4, 5, 390, 391, 392,
2363 0, 0, 0, -63, 1, 2, 0, 3, 4, 5,
2364 0, 0, 393, 394, 0, 6, 7, 0, 0, 0,
2365 0, 0, 0, 0, 0, 0, 339, 0, 0, 0,
2366 0, 395, 0, 0, 0, 0, 0, 8, 671, 0,
2367 0, 9, 677, 678, 0, 10, 0, 175, 176, 177,
2368 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2369 188, 189, 254, 255, 256, 257, 75, 76, 0, 0,
2370 77, 0, 78, 377, 697, 698, 0, 699, 0, 701,
2371 0, 0, 0, 704, 0, 0, 0, 0, 0, 707,
2372 0, 258, 198, 675, 676, 201, 202, 203, 204, 205,
2373 206, 207, 208, 209, 0, 259, 0, 260, 261, 262,
2374 0, 263, 264, 342, 343, 0, 344, 345, 0, 346,
2375 347, 348, 0, 0, 0, 0, 0, 0, 0, 385,
2376 386, 387, 388, 64, 65, 389, 0, 396, 0, 0,
2377 397, 0, 398, 0, 399, 1, 2, 0, 3, 4,
2378 5, 390, 391, 392, 300, 301, 0, 0, 0, 0,
2379 0, 0, 0, 0, 0, 0, 393, 394, 0, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002380 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002381 0, 111, 0, 64, 65, 395, 107, 67, 68, 69,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002382 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
Chris Lattner740e7092008-10-15 06:16:57 +00002383 5, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2384 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2385 0, 0, 0, 0, 0, 0, 74, 0, 302, 303,
2386 304, 305, 306, 307, 308, 309, 310, 311, 312, 313,
2387 314, 315, 0, 0, 0, 258, 198, 199, 200, 201,
2388 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2389 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002390 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002391 0, 0, 0, 0, 0, 112, 0, 0, 0, 0,
2392 0, 396, 0, 0, 397, 0, 398, 0, 399, 244,
2393 245, 246, 247, 64, 65, 248, 0, 0, 0, 0,
2394 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2395 5, 249, 250, 251, 0, 0, 0, 0, 0, 0,
2396 0, 0, 0, 0, 0, 0, 252, 253, 0, 0,
2397 75, 76, 0, 0, 77, 0, 78, 462, 0, 0,
2398 0, 111, 64, 65, 0, 107, 67, 68, 69, 70,
2399 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2400 0, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2401 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2402 0, 0, 0, 0, 0, 74, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002403 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002404 0, 0, 0, 0, 0, 258, 198, 199, 200, 201,
2405 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2406 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002407 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002408 0, 0, 0, 0, 0, 112, 0, 0, 0, -61,
2409 0, 265, 0, 0, 266, 0, 267, 0, 268, 244,
2410 245, 246, 247, 64, 65, 248, 0, 0, 0, 0,
2411 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2412 5, 249, 250, 251, 0, 0, 0, 0, 0, 0,
2413 0, 0, 0, 0, 0, 0, 252, 253, 0, 75,
2414 76, 0, 0, 77, 0, 78, 479, 0, 0, 0,
2415 0, 111, 64, 65, 0, 107, 67, 68, 69, 70,
2416 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2417 0, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2418 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2419 0, 0, 0, 0, 0, 74, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002420 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002421 0, 0, 0, 0, 0, 258, 198, 199, 200, 201,
2422 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2423 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
2424 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2425 0, 0, 0, 0, 0, 112, 0, 0, 0, 0,
2426 0, 265, 0, 0, 266, 0, 267, 0, 268, 385,
2427 386, 387, 388, 64, 65, 389, 0, 0, 0, 0,
2428 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2429 5, 390, 391, 392, 0, 0, 0, 0, 0, 0,
2430 0, 0, 0, 0, 0, 0, 393, 394, 0, 75,
2431 76, 0, 0, 77, 0, 78, 541, 0, 0, 0,
2432 0, 0, 0, 64, 65, 395, 153, 67, 68, 69,
2433 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
2434 5, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2435 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2436 0, 0, 0, 0, 64, 65, 74, 153, 67, 68,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002437 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
Chris Lattner740e7092008-10-15 06:16:57 +00002438 4, 5, 0, 0, 0, 258, 198, 199, 200, 201,
2439 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2440 0, 260, 261, 262, 0, 263, 264, 74, 0, 0,
2441 0, 0, 0, 0, 0, 0, 0, 385, 386, 387,
2442 388, 0, 0, 389, 0, 0, 0, 0, 0, 0,
2443 0, 396, 0, 0, 397, 0, 398, 0, 399, 390,
2444 391, 392, 0, 0, 0, 0, 0, 0, 0, 0,
2445 0, 0, 0, 0, 393, 394, 0, 275, 276, 0,
2446 277, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2447 0, 0, 0, 395, 0, 0, 0, 0, 0, 0,
2448 75, 76, 154, 0, 77, 0, 78, 0, 0, 175,
2449 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2450 186, 187, 188, 189, 254, 255, 256, 257, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002451 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002452 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002453 0, 0, 0, 258, 198, 199, 200, 201, 202, 203,
2454 204, 205, 206, 207, 208, 209, 0, 259, 0, 260,
2455 261, 262, 0, 263, 264, 64, 65, 0, 107, 67,
2456 68, 69, 70, 71, 72, 73, 0, 1, 2, 0,
2457 3, 4, 5, 0, 0, 0, 0, 0, 0, 396,
2458 0, 0, 397, 0, 398, 0, 399, 350, 0, 0,
2459 0, 0, 0, 0, 0, 0, 64, 65, 74, 107,
2460 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2461 0, 3, 4, 5, 64, 65, 0, 107, 67, 68,
2462 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
2463 4, 5, 0, 0, 0, 0, 0, 64, 65, 74,
2464 107, 67, 68, 69, 70, 71, 72, 73, 0, 1,
2465 2, 0, 3, 4, 5, 64, 65, 74, 107, 67,
2466 68, 69, 70, 71, 72, 73, 0, 1, 2, 535,
2467 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2468 74, 0, 0, 0, 0, 0, 0, 629, 0, 0,
2469 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002470 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002471 0, 0, 75, 76, 0, 0, 77, 0, 78, 64,
2472 65, 0, 66, 67, 68, 69, 70, 71, 72, 73,
2473 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2474 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2475 0, 0, 0, 75, 76, 0, 372, 77, 0, 78,
2476 0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
2477 0, 75, 76, 0, 475, 77, 0, 78, 0, 0,
2478 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2479 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2480 78, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2481 0, 0, 75, 76, 0, 0, 77, 0, 78, 64,
2482 65, 0, 107, 67, 68, 69, 70, 71, 72, 73,
2483 0, 1, 2, 0, 3, 4, 5, 0, 64, 65,
2484 0, 281, 67, 68, 69, 70, 71, 72, 73, 0,
2485 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2486 0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
2487 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2488 77, 74, 78, 64, 65, 0, 107, 67, 68, 69,
2489 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
2490 5, 64, 65, 0, 107, 67, 68, 69, 70, 71,
2491 72, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2492 0, 0, 0, 0, 64, 65, 74, 107, 67, 68,
2493 69, 70, 71, 72, 636, 0, 1, 2, 0, 3,
2494 4, 5, 64, 65, 74, 107, 67, 68, 69, 70,
2495 71, 72, 680, 0, 1, 2, 0, 3, 4, 5,
2496 0, 0, 0, 0, 0, 0, 0, 74, 0, 0,
2497 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2498 77, 0, 78, 0, 0, 74, 0, -216, 0, 0,
2499 0, 0, 0, 0, 0, 75, 76, 0, 0, 77,
2500 0, 78, 0, 0, 0, -63, 1, 2, 0, 3,
2501 4, 5, 0, 0, 0, 0, 0, 6, 7, 0,
2502 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2503 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
2504 75, 76, 0, 9, 77, 0, 375, 10, 0, 0,
2505 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2506 0, 0, 77, 0, 477, 0, 0, 0, 0, 0,
2507 0, 0, 0, 166, 0, 0, 0, 0, 0, 0,
2508 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
2509 0, 0, 0, 0, 167, 168, 0, 0, 0, 75,
2510 76, 0, 0, 77, 0, 78, 169, 170, 171, 172,
2511 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002512 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
Chris Lattner740e7092008-10-15 06:16:57 +00002513 193, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2514 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2515 0, 194, 195, 196, 0, 0, 197, 198, 199, 200,
2516 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
2517 211, 212, 213, 214, 215, 216, 217, 218
Dan Gohmanf4423b12008-04-19 00:24:39 +00002518};
2519
2520static const yytype_int16 yycheck[] =
2521{
Chris Lattner740e7092008-10-15 06:16:57 +00002522 0, 27, 158, 196, 11, 11, 0, 320, 239, 161,
2523 458, 4, 446, 447, 55, 28, 159, 17, 211, 212,
2524 213, 214, 215, 17, 266, 267, 21, 192, 221, 34,
2525 172, 11, 55, 656, 29, 55, 288, 536, 55, 193,
2526 11, 162, 162, 55, 162, 55, 162, 161, 169, 54,
2527 673, 171, 78, 171, 55, 171, 7, 8, 55, 10,
2528 11, 12, 13, 14, 15, 16, 17, 53, 19, 20,
2529 55, 22, 23, 24, 54, 59, 102, 156, 162, 158,
2530 106, 223, 68, 54, 336, 162, 112, 171, 161, 254,
2531 7, 256, 118, 93, 171, 162, 18, 240, 241, 50,
2532 534, 255, 19, 257, 171, 22, 162, 24, 41, 42,
2533 121, 32, 33, 169, 55, 48, 142, 143, 159, 11,
2534 146, 54, 42, 43, 44, 17, 152, 47, 169, 20,
2535 161, 630, 23, 375, 582, 161, 159, 636, 637, 159,
2536 151, 162, 159, 169, 167, 338, 167, 159, 165, 159,
2537 34, 163, 162, 163, 396, 397, 398, 170, 159, 160,
2538 167, 167, 159, 0, 612, 162, 163, 165, 194, 195,
2539 196, 197, 117, 118, 159, 160, 171, 170, 677, 678,
2540 161, 680, 681, 161, 210, 211, 212, 213, 214, 215,
2541 216, 217, 218, 219, 220, 221, 509, 19, 697, 698,
2542 22, 22, 24, 282, 162, 231, 285, 286, 287, 167,
2543 46, 404, 48, 164, 165, 54, 242, 168, 159, 170,
2544 171, 21, 163, 162, 156, 157, 158, 420, 167, 422,
2545 423, 424, 54, 7, 8, 477, 35, 22, 37, 552,
2546 42, 554, 44, 322, 22, 19, 20, 22, 22, 23,
2547 24, 330, 331, 332, 333, 334, 408, 141, 142, 143,
2548 144, 160, 146, 162, 132, 133, 150, 151, 4, 153,
2549 154, 155, 160, 299, 162, 160, 159, 162, 160, 431,
2550 162, 4, 121, 122, 160, 279, 162, 132, 133, 37,
2551 316, 317, 318, 62, 63, 64, 65, 66, 67, 121,
2552 122, 614, 141, 142, 166, 144, 145, 463, 147, 148,
2553 149, 337, 338, 132, 133, 166, 114, 115, 159, 141,
2554 142, 163, 144, 145, 4, 147, 148, 149, 84, 85,
2555 409, 410, 411, 412, 161, 22, 162, 160, 169, 418,
2556 4, 42, 43, 44, 45, 46, 47, 48, 49, 375,
2557 51, 160, 159, 432, 365, 366, 367, 368, 369, 370,
2558 371, 592, 555, 55, 57, 558, 559, 560, 11, 380,
2559 381, 382, 169, 22, 160, 159, 159, 159, 404, 159,
2560 159, 162, 408, 159, 463, 162, 159, 159, 159, 159,
2561 38, 4, 38, 159, 420, 421, 422, 423, 424, 162,
2562 162, 162, 162, 162, 430, 431, 485, 159, 159, 159,
2563 159, 490, 22, 492, 61, 162, 495, 162, 162, 165,
2564 162, 162, 448, 162, 162, 162, 505, 506, 162, 508,
2565 661, 162, 162, 664, 162, 162, 162, 169, 449, 450,
2566 451, 452, 162, 162, 38, 22, 472, 17, 17, 460,
2567 162, 477, 162, 162, 162, 156, 157, 158, 162, 4,
2568 162, 4, 162, 162, 162, 4, 545, 546, 162, 548,
2569 549, 550, 551, 162, 162, 22, 162, 556, 504, 162,
2570 38, 162, 4, 162, 510, 564, 160, 169, 159, 162,
2571 162, 570, 169, 4, 159, 54, 162, 160, 285, 286,
2572 287, 162, 162, 160, 530, 160, 22, 169, 519, 520,
2573 521, 522, 162, 524, 165, 167, 160, 528, 529, 160,
2574 160, 160, 17, 160, 160, 167, 160, 54, 607, 555,
2575 4, 152, 558, 559, 560, 322, 162, 159, 22, 159,
2576 17, 17, 17, 330, 331, 332, 333, 334, 94, 95,
2577 96, 97, 98, 99, 100, 101, 102, 103, 162, 73,
2578 17, 572, 573, 574, 575, 591, 652, 93, 631, 106,
2579 112, 17, 598, 231, 242, 90, 655, 57, 133, 613,
2580 659, 660, 453, 141, 142, 143, 144, 613, 146, 133,
2581 590, -1, 150, 151, -1, 153, 154, 155, -1, -1,
2582 -1, -1, -1, -1, -1, -1, -1, -1, 619, -1,
2583 621, 622, 691, 692, -1, 694, -1, 696, -1, -1,
2584 -1, 700, 409, 410, 411, 412, -1, 706, -1, -1,
2585 -1, 418, -1, -1, 7, 8, 662, 10, 11, 12,
2586 13, 14, 15, 16, 17, 432, 19, 20, -1, 22,
2587 23, 24, 652, -1, -1, -1, 7, 8, -1, 10,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002588 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Chris Lattner740e7092008-10-15 06:16:57 +00002589 -1, 22, 23, 24, -1, -1, -1, 50, -1, -1,
2590 141, 142, 143, 144, -1, 146, -1, -1, 39, 150,
2591 151, -1, 153, 154, 155, -1, -1, -1, 485, 50,
2592 -1, -1, -1, 490, -1, 492, -1, -1, 495, -1,
2593 -1, -1, -1, -1, -1, -1, -1, -1, 505, 506,
2594 -1, 508, -1, -1, -1, -1, -1, -1, -1, -1,
2595 -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
Devang Patel652203f2008-09-29 20:49:50 +00002596 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
Chris Lattner740e7092008-10-15 06:16:57 +00002597 -1, 19, 20, -1, 22, 23, 24, -1, 545, 546,
2598 -1, 548, 549, 550, 551, -1, -1, -1, -1, 556,
2599 -1, -1, -1, -1, -1, -1, -1, 564, -1, -1,
2600 -1, -1, 50, 570, -1, -1, -1, -1, -1, -1,
2601 -1, 164, 165, -1, -1, 168, -1, 170, 171, -1,
2602 -1, -1, -1, -1, -1, 3, 4, 5, 6, 7,
2603 8, 9, -1, 164, 165, 0, -1, 168, -1, 170,
2604 607, 19, 20, -1, 22, 23, 24, 25, 26, 27,
2605 -1, -1, -1, 18, 19, 20, -1, 22, 23, 24,
2606 -1, -1, 40, 41, -1, 30, 31, -1, -1, -1,
2607 -1, -1, -1, -1, -1, -1, 54, -1, -1, -1,
2608 -1, 59, -1, -1, -1, -1, -1, 52, 655, -1,
2609 -1, 56, 659, 660, -1, 60, -1, 75, 76, 77,
2610 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
2611 88, 89, 90, 91, 92, 93, 164, 165, -1, -1,
2612 168, -1, 170, 171, 691, 692, -1, 694, -1, 696,
2613 -1, -1, -1, 700, -1, -1, -1, -1, -1, 706,
2614 -1, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2615 128, 129, 130, 131, -1, 133, -1, 135, 136, 137,
2616 -1, 139, 140, 141, 142, -1, 144, 145, -1, 147,
2617 148, 149, -1, -1, -1, -1, -1, -1, -1, 3,
2618 4, 5, 6, 7, 8, 9, -1, 165, -1, -1,
2619 168, -1, 170, -1, 172, 19, 20, -1, 22, 23,
2620 24, 25, 26, 27, 26, 27, -1, -1, -1, -1,
2621 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002622 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002623 -1, 55, -1, 7, 8, 59, 10, 11, 12, 13,
2624 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2625 24, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2626 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2627 -1, -1, -1, -1, -1, -1, 50, -1, 100, 101,
2628 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
2629 112, 113, -1, -1, -1, 119, 120, 121, 122, 123,
2630 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2631 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
2632 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2633 -1, -1, -1, -1, -1, 159, -1, -1, -1, -1,
2634 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2635 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2636 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2637 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2638 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
2639 164, 165, -1, -1, 168, -1, 170, 171, -1, -1,
2640 -1, 55, 7, 8, -1, 10, 11, 12, 13, 14,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002641 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
Chris Lattner740e7092008-10-15 06:16:57 +00002642 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2643 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2644 -1, -1, -1, -1, -1, 50, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002645 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002646 -1, -1, -1, -1, -1, 119, 120, 121, 122, 123,
2647 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2648 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002649 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002650 -1, -1, -1, -1, -1, 159, -1, -1, -1, 163,
2651 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2652 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2653 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2654 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2655 -1, -1, -1, -1, -1, -1, 40, 41, -1, 164,
2656 165, -1, -1, 168, -1, 170, 171, -1, -1, -1,
2657 -1, 55, 7, 8, -1, 10, 11, 12, 13, 14,
2658 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2659 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2660 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2661 -1, -1, -1, -1, -1, 50, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002662 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002663 -1, -1, -1, -1, -1, 119, 120, 121, 122, 123,
2664 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2665 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
2666 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2667 -1, -1, -1, -1, -1, 159, -1, -1, -1, -1,
2668 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2669 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2670 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2671 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2672 -1, -1, -1, -1, -1, -1, 40, 41, -1, 164,
2673 165, -1, -1, 168, -1, 170, 171, -1, -1, -1,
2674 -1, -1, -1, 7, 8, 59, 10, 11, 12, 13,
2675 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2676 24, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2677 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2678 -1, -1, -1, -1, 7, 8, 50, 10, 11, 12,
2679 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2680 23, 24, -1, -1, -1, 119, 120, 121, 122, 123,
2681 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2682 -1, 135, 136, 137, -1, 139, 140, 50, -1, -1,
2683 -1, -1, -1, -1, -1, -1, -1, 3, 4, 5,
2684 6, -1, -1, 9, -1, -1, -1, -1, -1, -1,
2685 -1, 165, -1, -1, 168, -1, 170, -1, 172, 25,
2686 26, 27, -1, -1, -1, -1, -1, -1, -1, -1,
2687 -1, -1, -1, -1, 40, 41, -1, 141, 142, -1,
2688 144, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2689 -1, -1, -1, 59, -1, -1, -1, -1, -1, -1,
2690 164, 165, 125, -1, 168, -1, 170, -1, -1, 75,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002691 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2692 86, 87, 88, 89, 90, 91, 92, 93, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002693 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2694 -1, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2695 -1, -1, -1, 119, 120, 121, 122, 123, 124, 125,
2696 126, 127, 128, 129, 130, 131, -1, 133, -1, 135,
2697 136, 137, -1, 139, 140, 7, 8, -1, 10, 11,
2698 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2699 22, 23, 24, -1, -1, -1, -1, -1, -1, 165,
2700 -1, -1, 168, -1, 170, -1, 172, 39, -1, -1,
2701 -1, -1, -1, -1, -1, -1, 7, 8, 50, 10,
2702 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2703 -1, 22, 23, 24, 7, 8, -1, 10, 11, 12,
2704 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2705 23, 24, -1, -1, -1, -1, -1, 7, 8, 50,
2706 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2707 20, -1, 22, 23, 24, 7, 8, 50, 10, 11,
2708 12, 13, 14, 15, 16, 17, -1, 19, 20, 39,
2709 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2710 50, -1, -1, -1, -1, -1, -1, 39, -1, -1,
2711 -1, -1, -1, -1, -1, -1, -1, -1, 50, -1,
2712 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2713 -1, -1, 164, 165, -1, -1, 168, -1, 170, 7,
2714 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2715 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2716 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2717 -1, -1, -1, 164, 165, -1, 167, 168, -1, 170,
2718 -1, -1, 50, -1, -1, -1, -1, -1, -1, -1,
2719 -1, 164, 165, -1, 167, 168, -1, 170, -1, -1,
2720 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2721 -1, -1, -1, -1, 164, 165, -1, -1, 168, -1,
2722 170, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2723 -1, -1, 164, 165, -1, -1, 168, -1, 170, 7,
2724 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2725 -1, 19, 20, -1, 22, 23, 24, -1, 7, 8,
2726 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2727 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2728 -1, -1, 50, -1, -1, -1, -1, -1, -1, -1,
2729 -1, -1, -1, -1, -1, -1, 164, 165, -1, -1,
2730 168, 50, 170, 7, 8, -1, 10, 11, 12, 13,
2731 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2732 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2733 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2734 -1, -1, -1, -1, 7, 8, 50, 10, 11, 12,
2735 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2736 23, 24, 7, 8, 50, 10, 11, 12, 13, 14,
2737 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2738 -1, -1, -1, -1, -1, -1, -1, 50, -1, -1,
2739 -1, -1, -1, -1, -1, -1, 164, 165, -1, -1,
2740 168, -1, 170, -1, -1, 50, -1, 0, -1, -1,
2741 -1, -1, -1, -1, -1, 164, 165, -1, -1, 168,
2742 -1, 170, -1, -1, -1, 18, 19, 20, -1, 22,
2743 23, 24, -1, -1, -1, -1, -1, 30, 31, -1,
2744 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2745 -1, -1, -1, -1, -1, -1, -1, -1, -1, 52,
2746 164, 165, -1, 56, 168, -1, 170, 60, -1, -1,
2747 -1, -1, -1, -1, -1, -1, -1, -1, 164, 165,
2748 -1, -1, 168, -1, 170, -1, -1, -1, -1, -1,
2749 -1, -1, -1, 36, -1, -1, -1, -1, -1, -1,
2750 -1, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2751 -1, -1, -1, -1, 57, 58, -1, -1, -1, 164,
2752 165, -1, -1, 168, -1, 170, 69, 70, 71, 72,
2753 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2754 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2755 93, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2756 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2757 -1, 114, 115, 116, -1, -1, 119, 120, 121, 122,
2758 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
2759 133, 134, 135, 136, 137, 138, 139, 140
Dan Gohmanf4423b12008-04-19 00:24:39 +00002760};
2761
2762/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2763 symbol of state STATE-NUM. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002764static const yytype_uint16 yystos[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002765{
Dale Johannesenc7071cc2008-05-14 20:13:36 +00002766 0, 19, 20, 22, 23, 24, 30, 31, 52, 56,
Chris Lattner740e7092008-10-15 06:16:57 +00002767 60, 179, 182, 184, 185, 186, 220, 221, 222, 224,
2768 223, 53, 68, 229, 161, 59, 161, 18, 161, 42,
Devang Patel652203f2008-09-29 20:49:50 +00002769 43, 44, 45, 46, 47, 48, 49, 51, 156, 157,
Chris Lattner740e7092008-10-15 06:16:57 +00002770 158, 187, 188, 189, 0, 222, 46, 48, 190, 239,
2771 42, 43, 44, 47, 191, 236, 238, 246, 161, 161,
2772 165, 230, 22, 228, 7, 8, 10, 11, 12, 13,
2773 14, 15, 16, 17, 50, 164, 165, 168, 170, 179,
2774 184, 207, 208, 242, 189, 189, 35, 37, 218, 189,
2775 189, 21, 247, 248, 29, 171, 237, 247, 22, 22,
2776 22, 231, 159, 4, 4, 4, 170, 10, 171, 208,
2777 213, 55, 159, 181, 218, 218, 42, 44, 192, 32,
2778 33, 217, 62, 63, 64, 65, 66, 67, 193, 234,
2779 234, 7, 182, 183, 251, 162, 167, 39, 208, 209,
2780 211, 212, 166, 166, 171, 213, 162, 171, 159, 212,
2781 163, 217, 217, 10, 125, 208, 210, 219, 208, 214,
2782 4, 197, 28, 170, 235, 161, 36, 57, 58, 69,
2783 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2784 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2785 90, 91, 92, 93, 114, 115, 116, 119, 120, 121,
2786 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
2787 132, 133, 134, 135, 136, 137, 138, 139, 140, 174,
2788 175, 176, 249, 256, 257, 258, 259, 249, 257, 22,
2789 195, 162, 160, 208, 208, 169, 171, 208, 4, 160,
2790 214, 208, 159, 242, 3, 4, 5, 6, 9, 25,
2791 26, 27, 40, 41, 90, 91, 92, 93, 119, 133,
2792 135, 136, 137, 139, 140, 165, 168, 170, 172, 174,
2793 175, 176, 215, 242, 181, 141, 142, 144, 196, 210,
2794 57, 10, 208, 244, 245, 11, 17, 11, 193, 94,
2795 95, 96, 97, 98, 99, 100, 101, 102, 103, 177,
2796 26, 27, 100, 101, 102, 103, 104, 105, 106, 107,
2797 108, 109, 110, 111, 112, 113, 178, 177, 178, 208,
2798 208, 244, 208, 208, 252, 244, 244, 244, 244, 244,
2799 208, 208, 208, 208, 208, 244, 193, 117, 118, 54,
2800 121, 122, 141, 142, 144, 145, 147, 148, 149, 194,
2801 39, 209, 199, 167, 169, 169, 160, 199, 181, 181,
2802 219, 177, 178, 177, 178, 159, 159, 159, 159, 159,
2803 159, 159, 167, 214, 216, 170, 216, 171, 216, 22,
2804 159, 159, 159, 225, 184, 3, 4, 5, 6, 9,
2805 25, 26, 27, 40, 41, 59, 165, 168, 170, 172,
2806 215, 241, 242, 243, 162, 243, 243, 243, 197, 208,
2807 208, 208, 208, 162, 202, 162, 202, 243, 165, 162,
2808 162, 162, 162, 162, 162, 243, 243, 243, 243, 243,
2809 38, 197, 208, 244, 4, 141, 142, 143, 144, 146,
2810 150, 151, 153, 154, 155, 198, 226, 227, 38, 159,
2811 159, 159, 159, 214, 214, 214, 214, 214, 214, 214,
2812 162, 167, 171, 208, 216, 169, 171, 214, 214, 214,
2813 162, 205, 159, 61, 240, 167, 216, 170, 216, 171,
2814 216, 22, 244, 162, 162, 210, 243, 243, 243, 243,
2815 11, 54, 11, 254, 243, 165, 244, 208, 244, 244,
2816 244, 162, 162, 255, 162, 162, 162, 208, 210, 243,
2817 162, 205, 205, 208, 214, 214, 214, 214, 254, 162,
2818 162, 162, 162, 255, 162, 214, 169, 171, 162, 162,
2819 38, 34, 54, 203, 206, 39, 208, 232, 233, 22,
2820 167, 171, 216, 169, 171, 17, 17, 243, 162, 162,
2821 162, 162, 243, 4, 243, 162, 162, 243, 162, 162,
2822 162, 4, 4, 162, 208, 243, 243, 243, 162, 202,
2823 208, 160, 162, 162, 162, 162, 160, 214, 214, 214,
2824 214, 160, 214, 169, 214, 214, 208, 22, 4, 205,
2825 195, 162, 160, 162, 169, 171, 243, 243, 159, 243,
2826 243, 243, 243, 202, 202, 244, 243, 162, 244, 244,
2827 244, 4, 243, 159, 243, 214, 214, 214, 214, 162,
2828 160, 162, 162, 255, 160, 160, 160, 179, 180, 39,
2829 208, 199, 22, 169, 162, 165, 17, 208, 253, 167,
2830 243, 255, 253, 202, 160, 160, 160, 160, 214, 214,
2831 214, 160, 195, 203, 204, 17, 11, 167, 250, 195,
2832 195, 160, 162, 167, 160, 160, 160, 160, 180, 54,
2833 201, 243, 241, 11, 167, 121, 122, 243, 243, 199,
2834 17, 208, 199, 4, 152, 200, 162, 241, 195, 195,
2835 38, 195, 195, 22, 17, 162, 17, 243, 243, 243,
2836 17, 243, 195, 195, 243, 73, 17, 243
Dan Gohmanf4423b12008-04-19 00:24:39 +00002837};
David Greene718fda32007-08-01 03:59:32 +00002838
Reid Spencer68a24bd2005-08-27 18:50:39 +00002839#define yyerrok (yyerrstatus = 0)
2840#define yyclearin (yychar = YYEMPTY)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002841#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002842#define YYEOF 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00002843
Reid Spencer68a24bd2005-08-27 18:50:39 +00002844#define YYACCEPT goto yyacceptlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002845#define YYABORT goto yyabortlab
2846#define YYERROR goto yyerrorlab
2847
2848
2849/* Like YYERROR except do call yyerror. This remains here temporarily
2850 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002851 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00002852
Reid Spencer68a24bd2005-08-27 18:50:39 +00002853#define YYFAIL goto yyerrlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002854
Reid Spencer68a24bd2005-08-27 18:50:39 +00002855#define YYRECOVERING() (!!yyerrstatus)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002856
2857#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002858do \
2859 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002860 { \
2861 yychar = (Token); \
2862 yylval = (Value); \
2863 yytoken = YYTRANSLATE (yychar); \
2864 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002865 goto yybackup; \
2866 } \
2867 else \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002868 { \
2869 yyerror (YY_("syntax error: cannot back up")); \
2870 YYERROR; \
2871 } \
2872while (YYID (0))
2873
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002874
Reid Spencer68a24bd2005-08-27 18:50:39 +00002875#define YYTERROR 1
2876#define YYERRCODE 256
2877
Dan Gohmanf4423b12008-04-19 00:24:39 +00002878
2879/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2880 If N is 0, then set CURRENT to the empty location which ends
2881 the previous symbol: RHS[0] (always defined). */
2882
2883#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2884#ifndef YYLLOC_DEFAULT
2885# define YYLLOC_DEFAULT(Current, Rhs, N) \
2886 do \
2887 if (YYID (N)) \
2888 { \
2889 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2890 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2891 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2892 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2893 } \
2894 else \
2895 { \
2896 (Current).first_line = (Current).last_line = \
2897 YYRHSLOC (Rhs, 0).last_line; \
2898 (Current).first_column = (Current).last_column = \
2899 YYRHSLOC (Rhs, 0).last_column; \
2900 } \
2901 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002902#endif
2903
Dan Gohmanf4423b12008-04-19 00:24:39 +00002904
2905/* YY_LOCATION_PRINT -- Print the location on the stream.
2906 This macro was not mandated originally: define only if we know
2907 we won't break user code: when these are the locations we know. */
2908
2909#ifndef YY_LOCATION_PRINT
Nuno Lopes6ec8a252008-10-15 11:11:12 +00002910# if YYLTYPE_IS_TRIVIAL
Dan Gohmanf4423b12008-04-19 00:24:39 +00002911# define YY_LOCATION_PRINT(File, Loc) \
2912 fprintf (File, "%d.%d-%d.%d", \
2913 (Loc).first_line, (Loc).first_column, \
2914 (Loc).last_line, (Loc).last_column)
2915# else
2916# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2917# endif
2918#endif
2919
2920
2921/* YYLEX -- calling `yylex' with the right arguments. */
2922
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002923#ifdef YYLEX_PARAM
Dan Gohmanf4423b12008-04-19 00:24:39 +00002924# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002925#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002926# define YYLEX yylex ()
Gabor Greife64d2482008-04-06 23:07:54 +00002927#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002928
2929/* Enable debugging if requested. */
2930#if YYDEBUG
2931
2932# ifndef YYFPRINTF
2933# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2934# define YYFPRINTF fprintf
2935# endif
2936
2937# define YYDPRINTF(Args) \
2938do { \
2939 if (yydebug) \
2940 YYFPRINTF Args; \
2941} while (YYID (0))
2942
2943# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2944do { \
2945 if (yydebug) \
2946 { \
2947 YYFPRINTF (stderr, "%s ", Title); \
2948 yy_symbol_print (stderr, \
2949 Type, Value); \
2950 YYFPRINTF (stderr, "\n"); \
2951 } \
2952} while (YYID (0))
2953
2954
2955/*--------------------------------.
2956| Print this symbol on YYOUTPUT. |
2957`--------------------------------*/
2958
2959/*ARGSUSED*/
2960#if (defined __STDC__ || defined __C99__FUNC__ \
2961 || defined __cplusplus || defined _MSC_VER)
2962static void
2963yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greife64d2482008-04-06 23:07:54 +00002964#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002965static void
2966yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2967 FILE *yyoutput;
2968 int yytype;
2969 YYSTYPE const * const yyvaluep;
Gabor Greife64d2482008-04-06 23:07:54 +00002970#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002971{
2972 if (!yyvaluep)
2973 return;
2974# ifdef YYPRINT
2975 if (yytype < YYNTOKENS)
2976 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2977# else
2978 YYUSE (yyoutput);
2979# endif
2980 switch (yytype)
2981 {
2982 default:
2983 break;
2984 }
2985}
2986
2987
2988/*--------------------------------.
2989| Print this symbol on YYOUTPUT. |
2990`--------------------------------*/
2991
2992#if (defined __STDC__ || defined __C99__FUNC__ \
2993 || defined __cplusplus || defined _MSC_VER)
2994static void
2995yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2996#else
2997static void
2998yy_symbol_print (yyoutput, yytype, yyvaluep)
2999 FILE *yyoutput;
3000 int yytype;
3001 YYSTYPE const * const yyvaluep;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003002#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003003{
3004 if (yytype < YYNTOKENS)
3005 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3006 else
3007 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner38905612008-02-19 04:36:25 +00003008
Dan Gohmanf4423b12008-04-19 00:24:39 +00003009 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3010 YYFPRINTF (yyoutput, ")");
3011}
Chris Lattner38905612008-02-19 04:36:25 +00003012
Dan Gohmanf4423b12008-04-19 00:24:39 +00003013/*------------------------------------------------------------------.
3014| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3015| TOP (included). |
3016`------------------------------------------------------------------*/
Chris Lattner38905612008-02-19 04:36:25 +00003017
Dan Gohmanf4423b12008-04-19 00:24:39 +00003018#if (defined __STDC__ || defined __C99__FUNC__ \
3019 || defined __cplusplus || defined _MSC_VER)
3020static void
3021yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3022#else
3023static void
3024yy_stack_print (bottom, top)
3025 yytype_int16 *bottom;
3026 yytype_int16 *top;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003027#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003028{
3029 YYFPRINTF (stderr, "Stack now");
3030 for (; bottom <= top; ++bottom)
3031 YYFPRINTF (stderr, " %d", *bottom);
3032 YYFPRINTF (stderr, "\n");
3033}
Chris Lattner38905612008-02-19 04:36:25 +00003034
Dan Gohmanf4423b12008-04-19 00:24:39 +00003035# define YY_STACK_PRINT(Bottom, Top) \
3036do { \
3037 if (yydebug) \
3038 yy_stack_print ((Bottom), (Top)); \
3039} while (YYID (0))
Chris Lattner38905612008-02-19 04:36:25 +00003040
Dan Gohmanf4423b12008-04-19 00:24:39 +00003041
3042/*------------------------------------------------.
3043| Report that the YYRULE is going to be reduced. |
3044`------------------------------------------------*/
3045
3046#if (defined __STDC__ || defined __C99__FUNC__ \
3047 || defined __cplusplus || defined _MSC_VER)
3048static void
3049yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3050#else
3051static void
3052yy_reduce_print (yyvsp, yyrule)
3053 YYSTYPE *yyvsp;
3054 int yyrule;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003055#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003056{
3057 int yynrhs = yyr2[yyrule];
3058 int yyi;
3059 unsigned long int yylno = yyrline[yyrule];
3060 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3061 yyrule - 1, yylno);
3062 /* The symbols being reduced. */
3063 for (yyi = 0; yyi < yynrhs; yyi++)
3064 {
3065 fprintf (stderr, " $%d = ", yyi + 1);
3066 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3067 &(yyvsp[(yyi + 1) - (yynrhs)])
3068 );
3069 fprintf (stderr, "\n");
3070 }
3071}
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003072
Dan Gohmanf4423b12008-04-19 00:24:39 +00003073# define YY_REDUCE_PRINT(Rule) \
3074do { \
3075 if (yydebug) \
3076 yy_reduce_print (yyvsp, Rule); \
3077} while (YYID (0))
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003078
Dan Gohmanf4423b12008-04-19 00:24:39 +00003079/* Nonzero means print parse trace. It is left uninitialized so that
3080 multiple parsers can coexist. */
3081int yydebug;
3082#else /* !YYDEBUG */
3083# define YYDPRINTF(Args)
3084# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3085# define YY_STACK_PRINT(Bottom, Top)
3086# define YY_REDUCE_PRINT(Rule)
3087#endif /* !YYDEBUG */
3088
3089
3090/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003091#ifndef YYINITDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003092# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00003093#endif
3094
Dan Gohmanf4423b12008-04-19 00:24:39 +00003095/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3096 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00003097
Dan Gohmanf4423b12008-04-19 00:24:39 +00003098 Do not make this value too large; the results are undefined if
3099 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3100 evaluated with infinite-precision integer arithmetic. */
David Greene718fda32007-08-01 03:59:32 +00003101
Reid Spencer68a24bd2005-08-27 18:50:39 +00003102#ifndef YYMAXDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003103# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00003104#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003105
Reid Spencer68a24bd2005-08-27 18:50:39 +00003106
3107
Dan Gohmanf4423b12008-04-19 00:24:39 +00003108#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00003109
Dan Gohmanf4423b12008-04-19 00:24:39 +00003110# ifndef yystrlen
3111# if defined __GLIBC__ && defined _STRING_H
3112# define yystrlen strlen
3113# else
3114/* Return the length of YYSTR. */
3115#if (defined __STDC__ || defined __C99__FUNC__ \
3116 || defined __cplusplus || defined _MSC_VER)
3117static YYSIZE_T
3118yystrlen (const char *yystr)
Chris Lattner38905612008-02-19 04:36:25 +00003119#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003120static YYSIZE_T
3121yystrlen (yystr)
3122 const char *yystr;
3123#endif
3124{
3125 YYSIZE_T yylen;
3126 for (yylen = 0; yystr[yylen]; yylen++)
3127 continue;
3128 return yylen;
3129}
3130# endif
3131# endif
3132
3133# ifndef yystpcpy
3134# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3135# define yystpcpy stpcpy
3136# else
3137/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3138 YYDEST. */
3139#if (defined __STDC__ || defined __C99__FUNC__ \
3140 || defined __cplusplus || defined _MSC_VER)
3141static char *
3142yystpcpy (char *yydest, const char *yysrc)
3143#else
3144static char *
3145yystpcpy (yydest, yysrc)
3146 char *yydest;
3147 const char *yysrc;
3148#endif
3149{
3150 char *yyd = yydest;
3151 const char *yys = yysrc;
3152
3153 while ((*yyd++ = *yys++) != '\0')
3154 continue;
3155
3156 return yyd - 1;
3157}
3158# endif
3159# endif
3160
3161# ifndef yytnamerr
3162/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3163 quotes and backslashes, so that it's suitable for yyerror. The
3164 heuristic is that double-quoting is unnecessary unless the string
3165 contains an apostrophe, a comma, or backslash (other than
3166 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3167 null, do not copy; instead, return the length of what the result
3168 would have been. */
3169static YYSIZE_T
3170yytnamerr (char *yyres, const char *yystr)
3171{
3172 if (*yystr == '"')
3173 {
3174 YYSIZE_T yyn = 0;
3175 char const *yyp = yystr;
3176
3177 for (;;)
3178 switch (*++yyp)
3179 {
3180 case '\'':
3181 case ',':
3182 goto do_not_strip_quotes;
3183
3184 case '\\':
3185 if (*++yyp != '\\')
3186 goto do_not_strip_quotes;
3187 /* Fall through. */
3188 default:
3189 if (yyres)
3190 yyres[yyn] = *yyp;
3191 yyn++;
3192 break;
3193
3194 case '"':
3195 if (yyres)
3196 yyres[yyn] = '\0';
3197 return yyn;
3198 }
3199 do_not_strip_quotes: ;
3200 }
3201
3202 if (! yyres)
3203 return yystrlen (yystr);
3204
3205 return yystpcpy (yyres, yystr) - yyres;
3206}
3207# endif
3208
3209/* Copy into YYRESULT an error message about the unexpected token
3210 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3211 including the terminating null byte. If YYRESULT is null, do not
3212 copy anything; just return the number of bytes that would be
3213 copied. As a special case, return 0 if an ordinary "syntax error"
3214 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3215 size calculation. */
3216static YYSIZE_T
3217yysyntax_error (char *yyresult, int yystate, int yychar)
3218{
3219 int yyn = yypact[yystate];
3220
3221 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3222 return 0;
3223 else
3224 {
3225 int yytype = YYTRANSLATE (yychar);
3226 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3227 YYSIZE_T yysize = yysize0;
3228 YYSIZE_T yysize1;
3229 int yysize_overflow = 0;
3230 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3231 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3232 int yyx;
3233
3234# if 0
3235 /* This is so xgettext sees the translatable formats that are
3236 constructed on the fly. */
3237 YY_("syntax error, unexpected %s");
3238 YY_("syntax error, unexpected %s, expecting %s");
3239 YY_("syntax error, unexpected %s, expecting %s or %s");
3240 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3241 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3242# endif
3243 char *yyfmt;
3244 char const *yyf;
3245 static char const yyunexpected[] = "syntax error, unexpected %s";
3246 static char const yyexpecting[] = ", expecting %s";
3247 static char const yyor[] = " or %s";
3248 char yyformat[sizeof yyunexpected
3249 + sizeof yyexpecting - 1
3250 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3251 * (sizeof yyor - 1))];
3252 char const *yyprefix = yyexpecting;
3253
3254 /* Start YYX at -YYN if negative to avoid negative indexes in
3255 YYCHECK. */
3256 int yyxbegin = yyn < 0 ? -yyn : 0;
3257
3258 /* Stay within bounds of both yycheck and yytname. */
3259 int yychecklim = YYLAST - yyn + 1;
3260 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3261 int yycount = 1;
3262
3263 yyarg[0] = yytname[yytype];
3264 yyfmt = yystpcpy (yyformat, yyunexpected);
3265
3266 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3267 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3268 {
3269 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3270 {
3271 yycount = 1;
3272 yysize = yysize0;
3273 yyformat[sizeof yyunexpected - 1] = '\0';
3274 break;
3275 }
3276 yyarg[yycount++] = yytname[yyx];
3277 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3278 yysize_overflow |= (yysize1 < yysize);
3279 yysize = yysize1;
3280 yyfmt = yystpcpy (yyfmt, yyprefix);
3281 yyprefix = yyor;
3282 }
3283
3284 yyf = YY_(yyformat);
3285 yysize1 = yysize + yystrlen (yyf);
3286 yysize_overflow |= (yysize1 < yysize);
3287 yysize = yysize1;
3288
3289 if (yysize_overflow)
3290 return YYSIZE_MAXIMUM;
3291
3292 if (yyresult)
3293 {
3294 /* Avoid sprintf, as that infringes on the user's name space.
3295 Don't have undefined behavior even if the translation
3296 produced a string with the wrong number of "%s"s. */
3297 char *yyp = yyresult;
3298 int yyi = 0;
3299 while ((*yyp = *yyf) != '\0')
3300 {
3301 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3302 {
3303 yyp += yytnamerr (yyp, yyarg[yyi++]);
3304 yyf += 2;
3305 }
3306 else
3307 {
3308 yyp++;
3309 yyf++;
3310 }
3311 }
3312 }
3313 return yysize;
3314 }
3315}
3316#endif /* YYERROR_VERBOSE */
3317
3318
3319/*-----------------------------------------------.
3320| Release the memory associated to this symbol. |
3321`-----------------------------------------------*/
3322
3323/*ARGSUSED*/
3324#if (defined __STDC__ || defined __C99__FUNC__ \
3325 || defined __cplusplus || defined _MSC_VER)
3326static void
3327yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3328#else
3329static void
3330yydestruct (yymsg, yytype, yyvaluep)
3331 const char *yymsg;
3332 int yytype;
3333 YYSTYPE *yyvaluep;
3334#endif
3335{
3336 YYUSE (yyvaluep);
3337
3338 if (!yymsg)
3339 yymsg = "Deleting";
3340 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3341
3342 switch (yytype)
3343 {
3344
3345 default:
3346 break;
3347 }
3348}
3349
3350
3351/* Prevent warnings from -Wmissing-prototypes. */
3352
3353#ifdef YYPARSE_PARAM
3354#if defined __STDC__ || defined __cplusplus
3355int yyparse (void *YYPARSE_PARAM);
3356#else
3357int yyparse ();
3358#endif
3359#else /* ! YYPARSE_PARAM */
3360#if defined __STDC__ || defined __cplusplus
David Greene5fd22a82007-09-04 18:46:50 +00003361int yyparse (void);
Gabor Greife64d2482008-04-06 23:07:54 +00003362#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003363int yyparse ();
Scott Michel15dcd8e2008-01-30 03:10:00 +00003364#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003365#endif /* ! YYPARSE_PARAM */
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003366
Chris Lattner38905612008-02-19 04:36:25 +00003367
Dan Gohmanf4423b12008-04-19 00:24:39 +00003368
3369/* The look-ahead symbol. */
3370int yychar;
3371
3372/* The semantic value of the look-ahead symbol. */
3373YYSTYPE yylval;
3374
3375/* Number of syntax errors so far. */
3376int yynerrs;
3377
3378
3379
3380/*----------.
3381| yyparse. |
3382`----------*/
3383
3384#ifdef YYPARSE_PARAM
3385#if (defined __STDC__ || defined __C99__FUNC__ \
3386 || defined __cplusplus || defined _MSC_VER)
3387int
3388yyparse (void *YYPARSE_PARAM)
3389#else
3390int
3391yyparse (YYPARSE_PARAM)
3392 void *YYPARSE_PARAM;
3393#endif
3394#else /* ! YYPARSE_PARAM */
3395#if (defined __STDC__ || defined __C99__FUNC__ \
3396 || defined __cplusplus || defined _MSC_VER)
3397int
3398yyparse (void)
3399#else
3400int
3401yyparse ()
3402
Gabor Greife64d2482008-04-06 23:07:54 +00003403#endif
3404#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003405{
3406
3407 int yystate;
3408 int yyn;
3409 int yyresult;
3410 /* Number of tokens to shift before error messages enabled. */
3411 int yyerrstatus;
3412 /* Look-ahead token as an internal (translated) token number. */
3413 int yytoken = 0;
3414#if YYERROR_VERBOSE
3415 /* Buffer for error messages, and its allocated size. */
3416 char yymsgbuf[128];
3417 char *yymsg = yymsgbuf;
3418 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greife64d2482008-04-06 23:07:54 +00003419#endif
Chris Lattner38905612008-02-19 04:36:25 +00003420
Dan Gohmanf4423b12008-04-19 00:24:39 +00003421 /* Three stacks and their tools:
3422 `yyss': related to states,
3423 `yyvs': related to semantic values,
3424 `yyls': related to locations.
3425
3426 Refer to the stacks thru separate pointers, to allow yyoverflow
3427 to reallocate them elsewhere. */
3428
3429 /* The state stack. */
3430 yytype_int16 yyssa[YYINITDEPTH];
3431 yytype_int16 *yyss = yyssa;
3432 yytype_int16 *yyssp;
3433
3434 /* The semantic value stack. */
3435 YYSTYPE yyvsa[YYINITDEPTH];
3436 YYSTYPE *yyvs = yyvsa;
3437 YYSTYPE *yyvsp;
3438
3439
3440
3441#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3442
3443 YYSIZE_T yystacksize = YYINITDEPTH;
3444
3445 /* The variables used to return semantic value and location from the
3446 action routines. */
3447 YYSTYPE yyval;
3448
3449
3450 /* The number of symbols on the RHS of the reduced rule.
3451 Keep to zero when no symbol should be popped. */
3452 int yylen = 0;
3453
3454 YYDPRINTF ((stderr, "Starting parse\n"));
3455
Reid Spencer68a24bd2005-08-27 18:50:39 +00003456 yystate = 0;
3457 yyerrstatus = 0;
3458 yynerrs = 0;
3459 yychar = YYEMPTY; /* Cause a token to be read. */
3460
3461 /* Initialize stack pointers.
3462 Waste one element of value and location stack
3463 so that they stay on the same level as the state stack.
3464 The wasted elements are never initialized. */
3465
Dan Gohmanf4423b12008-04-19 00:24:39 +00003466 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003467 yyvsp = yyvs;
3468
Dan Gohmanf4423b12008-04-19 00:24:39 +00003469 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003470
Dan Gohmanf4423b12008-04-19 00:24:39 +00003471/*------------------------------------------------------------.
3472| yynewstate -- Push a new state, which is found in yystate. |
3473`------------------------------------------------------------*/
3474 yynewstate:
3475 /* In all cases, when you get here, the value and location stacks
3476 have just been pushed. So pushing a state here evens the stacks. */
3477 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003478
Dan Gohmanf4423b12008-04-19 00:24:39 +00003479 yysetstate:
3480 *yyssp = yystate;
3481
3482 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003483 {
3484 /* Get the current used size of the three stacks, in elements. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003485 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003486
3487#ifdef yyoverflow
Dan Gohmanf4423b12008-04-19 00:24:39 +00003488 {
3489 /* Give user a chance to reallocate the stack. Use copies of
3490 these so that the &'s don't force the real ones into
3491 memory. */
3492 YYSTYPE *yyvs1 = yyvs;
3493 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003494
Dan Gohmanf4423b12008-04-19 00:24:39 +00003495
3496 /* Each stack pointer address is followed by the size of the
3497 data in use in that stack, in bytes. This used to be a
3498 conditional around just the two extra args, but that might
3499 be undefined if yyoverflow is a macro. */
3500 yyoverflow (YY_("memory exhausted"),
3501 &yyss1, yysize * sizeof (*yyssp),
3502 &yyvs1, yysize * sizeof (*yyvsp),
3503
3504 &yystacksize);
3505
3506 yyss = yyss1;
3507 yyvs = yyvs1;
3508 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003509#else /* no yyoverflow */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003510# ifndef YYSTACK_RELOCATE
3511 goto yyexhaustedlab;
3512# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003513 /* Extend the stack our own way. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003514 if (YYMAXDEPTH <= yystacksize)
3515 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003516 yystacksize *= 2;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003517 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003518 yystacksize = YYMAXDEPTH;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003519
3520 {
3521 yytype_int16 *yyss1 = yyss;
3522 union yyalloc *yyptr =
3523 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3524 if (! yyptr)
3525 goto yyexhaustedlab;
3526 YYSTACK_RELOCATE (yyss);
3527 YYSTACK_RELOCATE (yyvs);
3528
3529# undef YYSTACK_RELOCATE
3530 if (yyss1 != yyssa)
3531 YYSTACK_FREE (yyss1);
3532 }
3533# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003534#endif /* no yyoverflow */
3535
Dan Gohmanf4423b12008-04-19 00:24:39 +00003536 yyssp = yyss + yysize - 1;
3537 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003538
3539
Dan Gohmanf4423b12008-04-19 00:24:39 +00003540 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3541 (unsigned long int) yystacksize));
3542
3543 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003544 YYABORT;
3545 }
3546
Dan Gohmanf4423b12008-04-19 00:24:39 +00003547 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003548
3549 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003550
Dan Gohmanf4423b12008-04-19 00:24:39 +00003551/*-----------.
3552| yybackup. |
3553`-----------*/
3554yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003555
Dan Gohmanf4423b12008-04-19 00:24:39 +00003556 /* Do appropriate processing given the current state. Read a
3557 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003558
Dan Gohmanf4423b12008-04-19 00:24:39 +00003559 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003560 yyn = yypact[yystate];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003561 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003562 goto yydefault;
3563
Dan Gohmanf4423b12008-04-19 00:24:39 +00003564 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003565
Dan Gohmanf4423b12008-04-19 00:24:39 +00003566 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003567 if (yychar == YYEMPTY)
3568 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003569 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003570 yychar = YYLEX;
3571 }
3572
Dan Gohmanf4423b12008-04-19 00:24:39 +00003573 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003574 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003575 yychar = yytoken = YYEOF;
3576 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003577 }
3578 else
3579 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003580 yytoken = YYTRANSLATE (yychar);
3581 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003582 }
3583
Dan Gohmanf4423b12008-04-19 00:24:39 +00003584 /* If the proper action on seeing token YYTOKEN is to reduce or to
3585 detect an error, take that action. */
3586 yyn += yytoken;
3587 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003588 goto yydefault;
3589 yyn = yytable[yyn];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003590 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003591 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003592 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003593 goto yyerrlab;
3594 yyn = -yyn;
3595 goto yyreduce;
3596 }
3597
3598 if (yyn == YYFINAL)
3599 YYACCEPT;
3600
Dan Gohmanf4423b12008-04-19 00:24:39 +00003601 /* Count tokens shifted since error; after three, turn off error
3602 status. */
3603 if (yyerrstatus)
3604 yyerrstatus--;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003605
Dan Gohmanf4423b12008-04-19 00:24:39 +00003606 /* Shift the look-ahead token. */
3607 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003608
Dan Gohmanf4423b12008-04-19 00:24:39 +00003609 /* Discard the shifted token unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003610 if (yychar != YYEOF)
3611 yychar = YYEMPTY;
3612
Gabor Greife64d2482008-04-06 23:07:54 +00003613 yystate = yyn;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003614 *++yyvsp = yylval;
3615
Reid Spencer68a24bd2005-08-27 18:50:39 +00003616 goto yynewstate;
3617
Gabor Greife64d2482008-04-06 23:07:54 +00003618
Dan Gohmanf4423b12008-04-19 00:24:39 +00003619/*-----------------------------------------------------------.
3620| yydefault -- do the default action for the current state. |
3621`-----------------------------------------------------------*/
3622yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003623 yyn = yydefact[yystate];
3624 if (yyn == 0)
3625 goto yyerrlab;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003626 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003627
Dan Gohmanf4423b12008-04-19 00:24:39 +00003628
3629/*-----------------------------.
3630| yyreduce -- Do a reduction. |
3631`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003632yyreduce:
Dan Gohmanf4423b12008-04-19 00:24:39 +00003633 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003634 yylen = yyr2[yyn];
3635
Dan Gohmanf4423b12008-04-19 00:24:39 +00003636 /* If YYLEN is nonzero, implement the default value of the action:
3637 `$$ = $1'.
3638
3639 Otherwise, the following line sets YYVAL to garbage.
3640 This behavior is undocumented and Bison
3641 users should not rely upon it. Assigning to YYVAL
3642 unconditionally makes the parser a bit smaller, and it avoids a
3643 GCC warning that YYVAL may be used uninitialized. */
3644 yyval = yyvsp[1-yylen];
3645
3646
3647 YY_REDUCE_PRINT (yyn);
3648 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003649 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003650 case 29:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003651#line 1153 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003652 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3653 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003654
Dan Gohmanf4423b12008-04-19 00:24:39 +00003655 case 30:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003656#line 1153 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003657 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3658 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003659
Dan Gohmanf4423b12008-04-19 00:24:39 +00003660 case 31:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003661#line 1154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003662 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3663 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003664
Dan Gohmanf4423b12008-04-19 00:24:39 +00003665 case 32:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003666#line 1154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003667 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3668 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003669
Dan Gohmanf4423b12008-04-19 00:24:39 +00003670 case 33:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003671#line 1155 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003672 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3673 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003674
Dan Gohmanf4423b12008-04-19 00:24:39 +00003675 case 34:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003676#line 1155 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003677 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3678 break;
3679
3680 case 35:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003681#line 1156 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003682 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3683 break;
3684
3685 case 36:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003686#line 1156 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003687 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3688 break;
3689
3690 case 37:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003691#line 1157 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003692 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3693 break;
3694
3695 case 38:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003696#line 1157 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003697 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3698 break;
3699
3700 case 39:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003701#line 1161 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003702 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3703 break;
3704
3705 case 40:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003706#line 1161 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003707 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3708 break;
3709
3710 case 41:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003711#line 1162 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003712 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3713 break;
3714
3715 case 42:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003716#line 1162 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003717 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3718 break;
3719
3720 case 43:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003721#line 1163 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003722 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3723 break;
3724
3725 case 44:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003726#line 1163 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003727 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3728 break;
3729
3730 case 45:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003731#line 1164 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003732 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3733 break;
3734
3735 case 46:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003736#line 1164 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003737 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3738 break;
3739
3740 case 47:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003741#line 1165 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003742 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3743 break;
3744
3745 case 48:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003746#line 1165 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003747 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3748 break;
3749
3750 case 49:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003751#line 1166 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003752 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3753 break;
3754
3755 case 50:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003756#line 1166 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003757 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3758 break;
3759
3760 case 51:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003761#line 1167 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003762 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3763 break;
3764
3765 case 52:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003766#line 1167 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003767 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3768 break;
3769
3770 case 53:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003771#line 1168 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003772 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3773 break;
3774
3775 case 54:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003776#line 1169 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003777 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3778 break;
3779
Chris Lattner740e7092008-10-15 06:16:57 +00003780 case 59:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003781#line 1173 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003782 { (yyval.StrVal) = 0; ;}
3783 break;
3784
Chris Lattner740e7092008-10-15 06:16:57 +00003785 case 60:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003786#line 1175 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003787 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3788 break;
3789
Chris Lattner740e7092008-10-15 06:16:57 +00003790 case 61:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003791#line 1176 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003792 { (yyval.UIntVal)=0; ;}
3793 break;
3794
Chris Lattner740e7092008-10-15 06:16:57 +00003795 case 62:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003796#line 1180 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003797 {
3798 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003799 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003800 ;}
3801 break;
3802
Chris Lattner740e7092008-10-15 06:16:57 +00003803 case 63:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003804#line 1184 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003805 {
3806 (yyval.StrVal) = 0;
3807 CHECK_FOR_ERROR
3808 ;}
3809 break;
3810
3811 case 64:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003812#line 1189 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003813 {
3814 (yyval.UIntVal) = (yyvsp[(1) - (2)].UIntVal);
3815 CHECK_FOR_ERROR
3816;}
3817 break;
3818
Chris Lattnerf9078f92008-10-15 06:03:48 +00003819 case 68:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003820#line 1198 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003821 {
3822 (yyval.StrVal) = 0;
Christopher Lambbf3348d2007-12-12 08:45:45 +00003823 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003824 ;}
3825 break;
3826
Chris Lattnerf9078f92008-10-15 06:03:48 +00003827 case 69:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003828#line 1203 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003829 {
3830 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00003831 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003832 ;}
3833 break;
3834
Chris Lattner740e7092008-10-15 06:16:57 +00003835 case 70:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003836#line 1209 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003837 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3838 break;
3839
Chris Lattner740e7092008-10-15 06:16:57 +00003840 case 71:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003841#line 1210 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003842 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3843 break;
3844
Chris Lattner740e7092008-10-15 06:16:57 +00003845 case 72:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003846#line 1211 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003847 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3848 break;
3849
Chris Lattner740e7092008-10-15 06:16:57 +00003850 case 73:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003851#line 1212 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003852 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3853 break;
3854
Chris Lattner740e7092008-10-15 06:16:57 +00003855 case 74:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003856#line 1213 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003857 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3858 break;
3859
Chris Lattner740e7092008-10-15 06:16:57 +00003860 case 75:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003861#line 1214 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003862 { (yyval.Linkage) = GlobalValue::CommonLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003863 break;
3864
Chris Lattner740e7092008-10-15 06:16:57 +00003865 case 76:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003866#line 1218 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003867 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003868 break;
3869
Chris Lattner740e7092008-10-15 06:16:57 +00003870 case 77:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003871#line 1219 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003872 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003873 break;
3874
Chris Lattner740e7092008-10-15 06:16:57 +00003875 case 78:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003876#line 1220 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003877 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3878 break;
3879
3880 case 79:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003881#line 1224 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003882 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3883 break;
3884
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003885 case 80:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003886#line 1225 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003887 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3888 break;
3889
3890 case 81:
3891#line 1226 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003892 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3893 break;
3894
3895 case 82:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003896#line 1227 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003897 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3898 break;
3899
3900 case 83:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003901#line 1231 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003902 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003903 break;
3904
Chris Lattnerf9078f92008-10-15 06:03:48 +00003905 case 84:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003906#line 1232 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003907 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003908 break;
3909
Chris Lattner740e7092008-10-15 06:16:57 +00003910 case 85:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003911#line 1233 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003912 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003913 break;
3914
Chris Lattner740e7092008-10-15 06:16:57 +00003915 case 86:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003916#line 1237 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003917 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3918 break;
3919
3920 case 87:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003921#line 1238 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003922 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3923 break;
3924
3925 case 88:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003926#line 1239 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003927 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3928 break;
3929
3930 case 89:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003931#line 1240 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003932 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3933 break;
3934
3935 case 90:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003936#line 1241 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003937 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3938 break;
3939
3940 case 91:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003941#line 1245 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003942 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3943 break;
3944
Chris Lattnerf9078f92008-10-15 06:03:48 +00003945 case 92:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003946#line 1246 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003947 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Chris Lattnerf9078f92008-10-15 06:03:48 +00003948 break;
3949
Chris Lattner15bd0952008-08-29 17:20:18 +00003950 case 93:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003951#line 1247 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003952 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003953 break;
3954
Chris Lattner740e7092008-10-15 06:16:57 +00003955 case 94:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003956#line 1250 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003957 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003958 break;
3959
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003960 case 95:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003961#line 1251 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003962 { (yyval.UIntVal) = CallingConv::C; ;}
3963 break;
3964
3965 case 96:
3966#line 1252 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003967 { (yyval.UIntVal) = CallingConv::Fast; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003968 break;
3969
Chris Lattner740e7092008-10-15 06:16:57 +00003970 case 97:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003971#line 1253 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003972 { (yyval.UIntVal) = CallingConv::Cold; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003973 break;
3974
Chris Lattner740e7092008-10-15 06:16:57 +00003975 case 98:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003976#line 1254 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003977 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003978 break;
3979
Chris Lattner740e7092008-10-15 06:16:57 +00003980 case 99:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003981#line 1255 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003982 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00003983 break;
3984
Chris Lattner740e7092008-10-15 06:16:57 +00003985 case 100:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00003986#line 1256 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003987 {
3988 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003989 GEN_ERROR("Calling conv too large");
Dan Gohmanf4423b12008-04-19 00:24:39 +00003990 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003991 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003992 ;}
3993 break;
3994
Chris Lattner740e7092008-10-15 06:16:57 +00003995 case 101:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003996#line 1263 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003997 { (yyval.Attributes) = Attribute::ZExt; ;}
3998 break;
3999
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004000 case 102:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004001#line 1264 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004002 { (yyval.Attributes) = Attribute::ZExt; ;}
Chris Lattner740e7092008-10-15 06:16:57 +00004003 break;
4004
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004005 case 103:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004006#line 1265 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004007 { (yyval.Attributes) = Attribute::SExt; ;}
4008 break;
4009
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004010 case 104:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004011#line 1266 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004012 { (yyval.Attributes) = Attribute::SExt; ;}
4013 break;
4014
4015 case 105:
4016#line 1267 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004017 { (yyval.Attributes) = Attribute::InReg; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004018 break;
4019
Chris Lattner740e7092008-10-15 06:16:57 +00004020 case 106:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004021#line 1268 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004022 { (yyval.Attributes) = Attribute::StructRet; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004023 break;
4024
Chris Lattner740e7092008-10-15 06:16:57 +00004025 case 107:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004026#line 1269 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004027 { (yyval.Attributes) = Attribute::NoAlias; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004028 break;
4029
Chris Lattner740e7092008-10-15 06:16:57 +00004030 case 108:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004031#line 1270 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004032 { (yyval.Attributes) = Attribute::ByVal; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004033 break;
4034
Chris Lattner740e7092008-10-15 06:16:57 +00004035 case 109:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004036#line 1271 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004037 { (yyval.Attributes) = Attribute::Nest; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004038 break;
4039
Chris Lattner740e7092008-10-15 06:16:57 +00004040 case 110:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004041#line 1272 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004042 { (yyval.Attributes) =
4043 Attribute::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004044 break;
4045
Chris Lattner740e7092008-10-15 06:16:57 +00004046 case 111:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004047#line 1276 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004048 { (yyval.Attributes) = Attribute::None; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004049 break;
4050
Chris Lattner740e7092008-10-15 06:16:57 +00004051 case 112:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004052#line 1277 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesendfe8c842008-09-26 19:32:34 +00004053 {
4054 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4055 ;}
4056 break;
4057
Chris Lattner740e7092008-10-15 06:16:57 +00004058 case 113:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004059#line 1282 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004060 { (yyval.Attributes) = Attribute::InReg; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004061 break;
4062
Chris Lattner740e7092008-10-15 06:16:57 +00004063 case 114:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004064#line 1283 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004065 { (yyval.Attributes) = Attribute::ZExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004066 break;
4067
Chris Lattner740e7092008-10-15 06:16:57 +00004068 case 115:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004069#line 1284 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004070 { (yyval.Attributes) = Attribute::SExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004071 break;
4072
Chris Lattner740e7092008-10-15 06:16:57 +00004073 case 116:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004074#line 1287 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004075 { (yyval.Attributes) = Attribute::None; ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00004076 break;
4077
Chris Lattner740e7092008-10-15 06:16:57 +00004078 case 117:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004079#line 1288 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004080 {
4081 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4082 ;}
4083 break;
4084
Chris Lattner740e7092008-10-15 06:16:57 +00004085 case 118:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004086#line 1294 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004087 { (yyval.Attributes) = Attribute::NoReturn; ;}
4088 break;
4089
Chris Lattner740e7092008-10-15 06:16:57 +00004090 case 119:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004091#line 1295 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004092 { (yyval.Attributes) = Attribute::NoUnwind; ;}
4093 break;
4094
Chris Lattner740e7092008-10-15 06:16:57 +00004095 case 120:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004096#line 1296 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004097 { (yyval.Attributes) = Attribute::InReg; ;}
4098 break;
4099
Chris Lattner740e7092008-10-15 06:16:57 +00004100 case 121:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004101#line 1297 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004102 { (yyval.Attributes) = Attribute::ZExt; ;}
4103 break;
4104
Chris Lattner740e7092008-10-15 06:16:57 +00004105 case 122:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004106#line 1298 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004107 { (yyval.Attributes) = Attribute::SExt; ;}
4108 break;
4109
Chris Lattner740e7092008-10-15 06:16:57 +00004110 case 123:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004111#line 1299 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004112 { (yyval.Attributes) = Attribute::ReadNone; ;}
4113 break;
4114
Chris Lattner740e7092008-10-15 06:16:57 +00004115 case 124:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004116#line 1300 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004117 { (yyval.Attributes) = Attribute::ReadOnly; ;}
4118 break;
4119
Chris Lattner740e7092008-10-15 06:16:57 +00004120 case 125:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004121#line 1301 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner9fc4da42008-10-08 06:44:45 +00004122 { (yyval.Attributes) = Attribute::NoInline; ;}
Devang Patel652203f2008-09-29 20:49:50 +00004123 break;
4124
Chris Lattner740e7092008-10-15 06:16:57 +00004125 case 126:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004126#line 1302 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner9fc4da42008-10-08 06:44:45 +00004127 { (yyval.Attributes) = Attribute::AlwaysInline; ;}
Devang Patel652203f2008-09-29 20:49:50 +00004128 break;
4129
Chris Lattner740e7092008-10-15 06:16:57 +00004130 case 127:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004131#line 1303 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner9fc4da42008-10-08 06:44:45 +00004132 { (yyval.Attributes) = Attribute::OptimizeForSize; ;}
Devang Patel652203f2008-09-29 20:49:50 +00004133 break;
4134
Chris Lattner740e7092008-10-15 06:16:57 +00004135 case 128:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004136#line 1306 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004137 { (yyval.Attributes) = Attribute::None; ;}
4138 break;
4139
Chris Lattner740e7092008-10-15 06:16:57 +00004140 case 129:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004141#line 1307 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004142 {
Devang Patel05988662008-09-25 21:00:45 +00004143 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
Chris Lattner15bd0952008-08-29 17:20:18 +00004144 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004145 break;
4146
Chris Lattner740e7092008-10-15 06:16:57 +00004147 case 130:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004148#line 1313 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld4980812008-09-02 20:52:40 +00004149 { (yyval.StrVal) = 0; ;}
4150 break;
4151
Chris Lattner740e7092008-10-15 06:16:57 +00004152 case 131:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004153#line 1314 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004154 {
4155 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4156 ;}
4157 break;
4158
Chris Lattner740e7092008-10-15 06:16:57 +00004159 case 132:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004160#line 1321 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004161 { (yyval.UIntVal) = 0; ;}
4162 break;
4163
Chris Lattner740e7092008-10-15 06:16:57 +00004164 case 133:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004165#line 1322 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004166 {
4167 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4168 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004169 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004170 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004171;}
4172 break;
4173
Chris Lattner740e7092008-10-15 06:16:57 +00004174 case 134:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004175#line 1328 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004176 { (yyval.UIntVal) = 0; ;}
4177 break;
4178
Chris Lattner740e7092008-10-15 06:16:57 +00004179 case 135:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004180#line 1329 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004181 {
4182 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4183 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lambbf3348d2007-12-12 08:45:45 +00004184 GEN_ERROR("Alignment must be a power of two");
4185 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004186;}
4187 break;
4188
Chris Lattner740e7092008-10-15 06:16:57 +00004189 case 136:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004190#line 1338 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004191 {
4192 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
4193 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004194 GEN_ERROR("Invalid character in section name");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004195 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004196 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004197;}
4198 break;
4199
Chris Lattner740e7092008-10-15 06:16:57 +00004200 case 137:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004201#line 1346 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004202 { (yyval.StrVal) = 0; ;}
4203 break;
4204
Chris Lattner740e7092008-10-15 06:16:57 +00004205 case 138:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004206#line 1347 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004207 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4208 break;
4209
Chris Lattner740e7092008-10-15 06:16:57 +00004210 case 139:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004211#line 1352 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004212 {;}
4213 break;
4214
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004215 case 140:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004216#line 1353 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004217 {;}
4218 break;
4219
4220 case 141:
4221#line 1354 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004222 {
4223 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4224 delete (yyvsp[(1) - (1)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004225 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004226 ;}
4227 break;
4228
Chris Lattner740e7092008-10-15 06:16:57 +00004229 case 142:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004230#line 1359 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004231 {
4232 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004233 GEN_ERROR("Alignment must be a power of two");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004234 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004235 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004236 ;}
4237 break;
4238
Chris Lattner740e7092008-10-15 06:16:57 +00004239 case 150:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004240#line 1375 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004241 {
4242 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004243 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004244 ;}
4245 break;
4246
Chris Lattner740e7092008-10-15 06:16:57 +00004247 case 151:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004248#line 1379 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004249 {
4250 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004251 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004252 ;}
4253 break;
4254
Chris Lattner740e7092008-10-15 06:16:57 +00004255 case 152:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004256#line 1383 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004257 { // Pointer type?
4258 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lambbf3348d2007-12-12 08:45:45 +00004259 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004260 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4261 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00004262 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004263 ;}
4264 break;
4265
Chris Lattner740e7092008-10-15 06:16:57 +00004266 case 153:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004267#line 1390 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004268 { // Named types are also simple types...
4269 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004270 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004271 (yyval.TypeVal) = new PATypeHolder(tmp);
4272 ;}
4273 break;
4274
Chris Lattner740e7092008-10-15 06:16:57 +00004275 case 154:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004276#line 1395 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004277 { // Type UpReference
4278 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004279 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohmanf4423b12008-04-19 00:24:39 +00004280 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4281 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004282 UR_OUT("New Upreference!\n");
4283 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004284 ;}
4285 break;
4286
Chris Lattner740e7092008-10-15 06:16:57 +00004287 case 155:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004288#line 1403 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004289 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004290 // Allow but ignore attributes on function types; this permits auto-upgrade.
4291 // FIXME: remove in LLVM 3.0.
Chris Lattnera925a142008-04-23 05:37:08 +00004292 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4293 if (!FunctionType::isValidReturnType(RetTy))
4294 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004295
Reid Spencer41dff5e2007-01-26 08:05:27 +00004296 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004297 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004298 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004299 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004300 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004301 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004302
Reid Spencer41dff5e2007-01-26 08:05:27 +00004303 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4304 if (isVarArg) Params.pop_back();
4305
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004306 for (unsigned i = 0; i != Params.size(); ++i)
4307 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4308 GEN_ERROR("Function arguments must be value types!");
4309
4310 CHECK_FOR_ERROR
4311
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004312 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004313 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
Eric Christopher2a5196f2008-09-24 04:55:49 +00004314 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Nuno Lopes8a88a372008-10-05 16:49:34 +00004315
4316 // Delete the argument list
4317 for (I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin() ; I != E; ++I ) {
4318 delete I->Ty;
4319 }
4320 delete (yyvsp[(3) - (5)].TypeWithAttrsList);
4321
Reid Spencere4d87aa2006-12-23 06:05:41 +00004322 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004323 ;}
4324 break;
4325
Chris Lattner740e7092008-10-15 06:16:57 +00004326 case 156:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004327#line 1438 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004328 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004329 // Allow but ignore attributes on function types; this permits auto-upgrade.
4330 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004331 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004332 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004333 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004334 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004335 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004336 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004337
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004338 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4339 if (isVarArg) Params.pop_back();
4340
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004341 for (unsigned i = 0; i != Params.size(); ++i)
4342 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4343 GEN_ERROR("Function arguments must be value types!");
4344
4345 CHECK_FOR_ERROR
4346
Dan Gohmanf4423b12008-04-19 00:24:39 +00004347 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
Eric Christopher2a5196f2008-09-24 04:55:49 +00004348 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Nuno Lopes8a88a372008-10-05 16:49:34 +00004349
4350 // Delete the argument list
4351 for (I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin() ; I != E; ++I ) {
4352 delete I->Ty;
4353 }
4354 delete (yyvsp[(3) - (5)].TypeWithAttrsList);
4355
Reid Spencer41dff5e2007-01-26 08:05:27 +00004356 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004357 ;}
4358 break;
4359
Chris Lattner740e7092008-10-15 06:16:57 +00004360 case 157:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004361#line 1469 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004362 { // Sized array type?
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004363 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (yyvsp[(2) - (5)].UInt64Val))));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004364 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004365 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004366 ;}
4367 break;
4368
Chris Lattner740e7092008-10-15 06:16:57 +00004369 case 158:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004370#line 1474 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004371 { // Vector type?
4372 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4373 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004374 GEN_ERROR("Unsigned result not equal to signed result");
4375 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4376 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004377 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4378 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004379 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004380 ;}
4381 break;
4382
Chris Lattner740e7092008-10-15 06:16:57 +00004383 case 159:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004384#line 1484 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004385 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004386 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004387 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4388 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004389 Elements.push_back(*I);
4390
Dan Gohmanf4423b12008-04-19 00:24:39 +00004391 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4392 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004393 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004394 ;}
4395 break;
4396
Chris Lattner740e7092008-10-15 06:16:57 +00004397 case 160:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004398#line 1494 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004399 { // Empty structure type?
4400 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004401 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004402 ;}
4403 break;
4404
Chris Lattner740e7092008-10-15 06:16:57 +00004405 case 161:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004406#line 1498 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004407 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004408 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004409 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4410 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004411 Elements.push_back(*I);
4412
Dan Gohmanf4423b12008-04-19 00:24:39 +00004413 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4414 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004415 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004416 ;}
4417 break;
4418
Chris Lattner740e7092008-10-15 06:16:57 +00004419 case 162:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004420#line 1508 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004421 { // Empty structure type?
4422 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004423 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004424 ;}
4425 break;
4426
Chris Lattner740e7092008-10-15 06:16:57 +00004427 case 163:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004428#line 1515 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004429 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004430 // Allow but ignore attributes on function types; this permits auto-upgrade.
4431 // FIXME: remove in LLVM 3.0.
Eric Christopher2a5196f2008-09-24 04:55:49 +00004432 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
Devang Patel05988662008-09-25 21:00:45 +00004433 (yyval.TypeWithAttrs).Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004434 ;}
4435 break;
4436
Chris Lattner740e7092008-10-15 06:16:57 +00004437 case 164:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004438#line 1524 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004439 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004440 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004441 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4442 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004443 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004444 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4445 ;}
4446 break;
4447
Chris Lattner740e7092008-10-15 06:16:57 +00004448 case 165:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004449#line 1531 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004450 {
4451 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4452 ;}
4453 break;
4454
Chris Lattner740e7092008-10-15 06:16:57 +00004455 case 166:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004456#line 1536 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004457 {
4458 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4459 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004460 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004461 ;}
4462 break;
4463
Chris Lattner740e7092008-10-15 06:16:57 +00004464 case 167:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004465#line 1541 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004466 {
4467 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004468 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004469 ;}
4470 break;
4471
Chris Lattner740e7092008-10-15 06:16:57 +00004472 case 169:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004473#line 1549 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004474 {
4475 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Devang Patel05988662008-09-25 21:00:45 +00004476 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004477 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004478 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004479 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004480 ;}
4481 break;
4482
Chris Lattner740e7092008-10-15 06:16:57 +00004483 case 170:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004484#line 1556 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004485 {
4486 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Devang Patel05988662008-09-25 21:00:45 +00004487 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004488 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004489 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004490 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004491 ;}
4492 break;
4493
Chris Lattner740e7092008-10-15 06:16:57 +00004494 case 171:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004495#line 1563 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004496 {
4497 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004498 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004499 ;}
4500 break;
4501
Chris Lattner740e7092008-10-15 06:16:57 +00004502 case 172:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004503#line 1571 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004504 {
4505 (yyval.TypeList) = new std::list<PATypeHolder>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004506 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004507 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004508 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004509 ;}
4510 break;
4511
Chris Lattner740e7092008-10-15 06:16:57 +00004512 case 173:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004513#line 1577 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004514 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00004515 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004516 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004517 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004518 ;}
4519 break;
4520
Chris Lattner740e7092008-10-15 06:16:57 +00004521 case 174:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004522#line 1589 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004523 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004524 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004525 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4526 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004527 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004528 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004529 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004530 const Type *ETy = ATy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004531 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004532
4533 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004534 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004535 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004536 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004537 utostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004538
4539 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004540 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4541 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004542 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004543 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004544 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004545 }
4546
Dan Gohmanf4423b12008-04-19 00:24:39 +00004547 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4548 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004549 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004550 ;}
4551 break;
4552
Chris Lattner740e7092008-10-15 06:16:57 +00004553 case 175:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004554#line 1617 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004555 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004556 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004557 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4558 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004559 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004560 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004561 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004562
Dan Gohman180c1692008-06-23 18:43:26 +00004563 uint64_t NumElements = ATy->getNumElements();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004564 if (NumElements != uint64_t(-1) && NumElements != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004565 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Mon P Wang28873102008-06-25 08:15:39 +00004566 " arguments, but has size of " + utostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004567 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4568 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004569 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004570 ;}
4571 break;
4572
Chris Lattner740e7092008-10-15 06:16:57 +00004573 case 176:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004574#line 1633 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004575 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004576 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004577 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4578 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004579 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004580 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004581 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004582
Dan Gohman180c1692008-06-23 18:43:26 +00004583 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004584 const Type *ETy = ATy->getElementType();
Mon P Wang28873102008-06-25 08:15:39 +00004585 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (3)].StrVal)->length())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004586 GEN_ERROR("Can't build string constant of size " +
Mon P Wang28873102008-06-25 08:15:39 +00004587 utostr((yyvsp[(3) - (3)].StrVal)->length()) +
4588 " when array has size " + utostr(NumElements) + "");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004589 std::vector<Constant*> Vals;
4590 if (ETy == Type::Int8Ty) {
Mon P Wang28873102008-06-25 08:15:39 +00004591 for (uint64_t i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004592 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004593 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004594 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004595 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4596 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004597 delete (yyvsp[(3) - (3)].StrVal);
4598 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4599 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004600 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004601 ;}
4602 break;
4603
Chris Lattner740e7092008-10-15 06:16:57 +00004604 case 177:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004605#line 1660 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004606 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004607 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004608 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4609 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004610 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004611 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004612 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004613 const Type *ETy = PTy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004614 unsigned NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004615
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004616 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004617 if (NumElements != unsigned(-1) && NumElements != (unsigned)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004618 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004619 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004620 utostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004621
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004622 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004623 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4624 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004625 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004626 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004627 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004628 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004629
Dan Gohmanf4423b12008-04-19 00:24:39 +00004630 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4631 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004632 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004633 ;}
4634 break;
4635
Chris Lattner740e7092008-10-15 06:16:57 +00004636 case 178:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004637#line 1688 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004638 {
4639 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004640 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004641 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004642 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004643
Dan Gohmanf4423b12008-04-19 00:24:39 +00004644 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004645 GEN_ERROR("Illegal number of initializers for structure type");
4646
4647 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004648 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4649 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004650 GEN_ERROR("Expected type '" +
4651 STy->getElementType(i)->getDescription() +
4652 "' for element #" + utostr(i) +
4653 " of structure initializer");
4654
4655 // Check to ensure that Type is not packed
4656 if (STy->isPacked())
4657 GEN_ERROR("Unpacked Initializer to vector type '" +
4658 STy->getDescription() + "'");
4659
Dan Gohmanf4423b12008-04-19 00:24:39 +00004660 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4661 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004662 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004663 ;}
4664 break;
4665
Chris Lattner740e7092008-10-15 06:16:57 +00004666 case 179:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004667#line 1714 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004668 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004669 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004670 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4671 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004672 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004673 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004674 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004675
4676 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004677 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004678
4679 // Check to ensure that Type is not packed
4680 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004681 GEN_ERROR("Unpacked Initializer to vector type '" +
4682 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004683
Dan Gohmanf4423b12008-04-19 00:24:39 +00004684 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4685 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004686 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004687 ;}
4688 break;
4689
Chris Lattner740e7092008-10-15 06:16:57 +00004690 case 180:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004691#line 1734 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004692 {
4693 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004694 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004695 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004696 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004697
Dan Gohmanf4423b12008-04-19 00:24:39 +00004698 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004699 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004700
4701 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004702 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4703 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004704 GEN_ERROR("Expected type '" +
4705 STy->getElementType(i)->getDescription() +
4706 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004707 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004708
4709 // Check to ensure that Type is packed
4710 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004711 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004712 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004713
Dan Gohmanf4423b12008-04-19 00:24:39 +00004714 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4715 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004716 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004717 ;}
4718 break;
4719
Chris Lattner740e7092008-10-15 06:16:57 +00004720 case 181:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004721#line 1760 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004722 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004723 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004724 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4725 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004726 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004727 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004728 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004729
4730 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004731 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004732
4733 // Check to ensure that Type is packed
4734 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004735 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004736 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004737
Dan Gohmanf4423b12008-04-19 00:24:39 +00004738 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4739 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004740 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004741 ;}
4742 break;
4743
Chris Lattner740e7092008-10-15 06:16:57 +00004744 case 182:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004745#line 1780 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004746 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004747 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004748 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4749 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004750 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004751 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004752 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004753
Dan Gohmanf4423b12008-04-19 00:24:39 +00004754 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4755 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004756 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004757 ;}
4758 break;
4759
Chris Lattner740e7092008-10-15 06:16:57 +00004760 case 183:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004761#line 1792 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004762 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004763 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004764 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4765 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4766 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004767 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004768 ;}
4769 break;
4770
Chris Lattner740e7092008-10-15 06:16:57 +00004771 case 184:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004772#line 1799 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004773 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004774 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004775 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4776 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004777 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004778 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004779
4780 // ConstExprs can exist in the body of a function, thus creating
4781 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004782 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004783 // symbol table instead of the module symbol table for the global symbol,
4784 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004785 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004786 //
4787 Function *SavedCurFn = CurFun.CurrentFunction;
4788 CurFun.CurrentFunction = 0;
4789
Dan Gohmanf4423b12008-04-19 00:24:39 +00004790 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004791 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004792
4793 CurFun.CurrentFunction = SavedCurFn;
4794
4795 // If this is an initializer for a constant pointer, which is referencing a
4796 // (currently) undefined variable, create a stub now that shall be replaced
4797 // in the future with the right type of variable.
4798 //
4799 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004800 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004801 const PointerType *PT = cast<PointerType>(Ty);
4802
4803 // First check to see if the forward references value is already created!
4804 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004805 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Eric Christopher2a5196f2008-09-24 04:55:49 +00004806
Reid Spencer68a24bd2005-08-27 18:50:39 +00004807 if (I != CurModule.GlobalRefs.end()) {
4808 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004809 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004810 } else {
4811 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004812 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4813 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4814 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004815 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004816
4817 // Create the forward referenced global.
4818 GlobalValue *GV;
Eric Christopher2a5196f2008-09-24 04:55:49 +00004819 if (const FunctionType *FTy =
Reid Spencer68a24bd2005-08-27 18:50:39 +00004820 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004821 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4822 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004823 } else {
4824 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004825 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004826 Name, CurModule.CurrentModule);
4827 }
4828
4829 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004830 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004831 V = GV;
4832 }
4833 }
4834
Dan Gohmanf4423b12008-04-19 00:24:39 +00004835 (yyval.ConstVal) = cast<GlobalValue>(V);
4836 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004837 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004838 ;}
4839 break;
4840
Chris Lattner740e7092008-10-15 06:16:57 +00004841 case 185:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004842#line 1865 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004843 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004844 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004845 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4846 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004847 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004848 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4849 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4850 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004851 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004852 ;}
4853 break;
4854
Chris Lattner740e7092008-10-15 06:16:57 +00004855 case 186:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004856#line 1875 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004857 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004858 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004859 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4860 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004861 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4862 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004863 (yyval.ConstVal) = Constant::getNullValue(Ty);
4864 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004865 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004866 ;}
4867 break;
4868
Chris Lattner740e7092008-10-15 06:16:57 +00004869 case 187:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004870#line 1885 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004871 { // integral constants
Chris Lattner740e7092008-10-15 06:16:57 +00004872 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4873 if (!ConstantInt::isValueValidForType(IT, (yyvsp[(2) - (2)].SInt64Val)))
4874 GEN_ERROR("Constant value doesn't fit in type");
4875 (yyval.ConstVal) = ConstantInt::get(IT, (yyvsp[(2) - (2)].SInt64Val), true);
4876 } else {
4877 GEN_ERROR("integer constant must have integer type");
4878 }
4879 delete (yyvsp[(1) - (2)].TypeVal);
4880 CHECK_FOR_ERROR
4881 ;}
4882 break;
4883
4884 case 188:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004885#line 1896 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004886 { // arbitrary precision integer constants
4887 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4888 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > IT->getBitWidth())
4889 GEN_ERROR("Constant value does not fit in type");
4890 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(IT->getBitWidth());
4891 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4892 } else {
4893 GEN_ERROR("integer constant must have integer type");
4894 }
4895 delete (yyvsp[(1) - (2)].TypeVal);
4896 delete (yyvsp[(2) - (2)].APIntVal);
4897 CHECK_FOR_ERROR
4898 ;}
4899 break;
4900
4901 case 189:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004902#line 1909 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004903 { // integral constants
4904 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4905 if (!ConstantInt::isValueValidForType(IT, (yyvsp[(2) - (2)].UInt64Val)))
4906 GEN_ERROR("Constant value doesn't fit in type");
4907 (yyval.ConstVal) = ConstantInt::get(IT, (yyvsp[(2) - (2)].UInt64Val), false);
4908 } else {
4909 GEN_ERROR("integer constant must have integer type");
4910 }
4911 delete (yyvsp[(1) - (2)].TypeVal);
4912 CHECK_FOR_ERROR
4913 ;}
4914 break;
4915
4916 case 190:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004917#line 1920 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004918 { // arbitrary precision integer constants
4919 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4920 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > IT->getBitWidth())
4921 GEN_ERROR("Constant value does not fit in type");
4922 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(IT->getBitWidth());
4923 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4924 } else {
4925 GEN_ERROR("integer constant must have integer type");
4926 }
4927
4928 delete (yyvsp[(2) - (2)].APIntVal);
4929 delete (yyvsp[(1) - (2)].TypeVal);
4930 CHECK_FOR_ERROR
4931 ;}
4932 break;
4933
4934 case 191:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004935#line 1934 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004936 { // Boolean constants
4937 if ((yyvsp[(1) - (2)].TypeVal)->get() != Type::Int1Ty)
4938 GEN_ERROR("Constant true must have type i1");
4939 (yyval.ConstVal) = ConstantInt::getTrue();
4940 delete (yyvsp[(1) - (2)].TypeVal);
4941 CHECK_FOR_ERROR
4942 ;}
4943 break;
4944
4945 case 192:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004946#line 1941 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004947 { // Boolean constants
4948 if ((yyvsp[(1) - (2)].TypeVal)->get() != Type::Int1Ty)
4949 GEN_ERROR("Constant false must have type i1");
4950 (yyval.ConstVal) = ConstantInt::getFalse();
4951 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00004952 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004953 ;}
4954 break;
4955
Chris Lattnerf9078f92008-10-15 06:03:48 +00004956 case 193:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004957#line 1948 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004958 { // Floating point constants
Chris Lattner740e7092008-10-15 06:16:57 +00004959 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].TypeVal)->get(), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004960 GEN_ERROR("Floating point constant invalid for type");
Chris Lattner740e7092008-10-15 06:16:57 +00004961
Eric Christopher2a5196f2008-09-24 04:55:49 +00004962 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004963 // as double. Fix this here. Long double is done right.
Chris Lattner740e7092008-10-15 06:16:57 +00004964 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].TypeVal)->get()==Type::FloatTy) {
Dale Johannesen236bbd42008-10-09 23:01:34 +00004965 bool ignored;
4966 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
4967 &ignored);
4968 }
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004969 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Chris Lattner740e7092008-10-15 06:16:57 +00004970 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004971 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004972 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004973 ;}
4974 break;
4975
Chris Lattner740e7092008-10-15 06:16:57 +00004976 case 194:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004977#line 1966 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004978 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004979 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004980 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4981 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4982 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4983 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004984 GEN_ERROR("invalid cast opcode for cast from '" +
4985 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004986 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004987 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4988 delete (yyvsp[(5) - (6)].TypeVal);
4989 ;}
4990 break;
4991
Chris Lattner740e7092008-10-15 06:16:57 +00004992 case 195:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00004993#line 1978 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004994 {
4995 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004996 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004997
4998 const Type *IdxTy =
Dan Gohman041e2eb2008-05-15 19:50:34 +00004999 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005000 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00005001 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005002
Chris Lattnerf7469af2007-01-31 04:44:08 +00005003 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005004 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
5005 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005006 IdxVec.push_back(C);
5007 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005008 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005009
Dan Gohmanf4423b12008-04-19 00:24:39 +00005010 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005011
Dan Gohmanf4423b12008-04-19 00:24:39 +00005012 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00005013 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005014 ;}
5015 break;
5016
Chris Lattner740e7092008-10-15 06:16:57 +00005017 case 196:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005018#line 1999 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005019 {
5020 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005021 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005022 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005023 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005024 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005025 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005026 ;}
5027 break;
5028
Chris Lattner740e7092008-10-15 06:16:57 +00005029 case 197:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005030#line 2007 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005031 {
5032 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005033 GEN_ERROR("Binary operator types must match");
5034 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005035 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
5036 ;}
5037 break;
5038
Chris Lattner740e7092008-10-15 06:16:57 +00005039 case 198:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005040#line 2013 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005041 {
5042 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005043 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005044 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005045 if (!isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00005046 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005047 GEN_ERROR("Logical operator requires integral operands");
5048 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005049 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005050 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005051 ;}
5052 break;
5053
Chris Lattner740e7092008-10-15 06:16:57 +00005054 case 199:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005055#line 2024 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005056 {
5057 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005058 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005059 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5060 ;}
5061 break;
5062
Chris Lattner740e7092008-10-15 06:16:57 +00005063 case 200:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005064#line 2029 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005065 {
5066 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005067 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005068 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5069 ;}
5070 break;
5071
Chris Lattner740e7092008-10-15 06:16:57 +00005072 case 201:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005073#line 2034 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005074 {
5075 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5076 GEN_ERROR("vicmp operand types must match");
5077 (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5078 ;}
5079 break;
5080
Chris Lattner740e7092008-10-15 06:16:57 +00005081 case 202:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005082#line 2039 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005083 {
5084 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5085 GEN_ERROR("vfcmp operand types must match");
5086 (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5087 ;}
5088 break;
5089
Chris Lattner740e7092008-10-15 06:16:57 +00005090 case 203:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005091#line 2044 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005092 {
5093 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005094 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005095 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005096 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005097 ;}
5098 break;
5099
Chris Lattner740e7092008-10-15 06:16:57 +00005100 case 204:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005101#line 2050 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005102 {
5103 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005104 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005105 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005106 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005107 ;}
5108 break;
5109
Chris Lattner740e7092008-10-15 06:16:57 +00005110 case 205:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005111#line 2056 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005112 {
5113 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005114 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005115 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005116 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005117 ;}
5118 break;
5119
Chris Lattner740e7092008-10-15 06:16:57 +00005120 case 206:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005121#line 2062 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005122 {
5123 if (!isa<StructType>((yyvsp[(3) - (5)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (5)].ConstVal)->getType()))
5124 GEN_ERROR("ExtractValue requires an aggregate operand");
5125
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005126 (yyval.ConstVal) = ConstantExpr::getExtractValue((yyvsp[(3) - (5)].ConstVal), &(*(yyvsp[(4) - (5)].ConstantList))[0], (yyvsp[(4) - (5)].ConstantList)->size());
5127 delete (yyvsp[(4) - (5)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005128 CHECK_FOR_ERROR
5129 ;}
5130 break;
5131
Chris Lattner740e7092008-10-15 06:16:57 +00005132 case 207:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005133#line 2070 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005134 {
5135 if (!isa<StructType>((yyvsp[(3) - (7)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (7)].ConstVal)->getType()))
5136 GEN_ERROR("InsertValue requires an aggregate operand");
5137
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005138 (yyval.ConstVal) = ConstantExpr::getInsertValue((yyvsp[(3) - (7)].ConstVal), (yyvsp[(5) - (7)].ConstVal), &(*(yyvsp[(6) - (7)].ConstantList))[0], (yyvsp[(6) - (7)].ConstantList)->size());
5139 delete (yyvsp[(6) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005140 CHECK_FOR_ERROR
5141 ;}
5142 break;
5143
Chris Lattner740e7092008-10-15 06:16:57 +00005144 case 208:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005145#line 2081 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005146 {
5147 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005148 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005149 ;}
5150 break;
5151
Chris Lattner740e7092008-10-15 06:16:57 +00005152 case 209:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005153#line 2085 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005154 {
5155 (yyval.ConstVector) = new std::vector<Constant*>();
5156 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005157 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005158 ;}
5159 break;
5160
Chris Lattner740e7092008-10-15 06:16:57 +00005161 case 210:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005162#line 2093 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005163 { (yyval.BoolVal) = false; ;}
Nate Begemanac80ade2008-05-12 19:01:56 +00005164 break;
5165
Chris Lattner740e7092008-10-15 06:16:57 +00005166 case 211:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005167#line 2093 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005168 { (yyval.BoolVal) = true; ;}
5169 break;
5170
Chris Lattner740e7092008-10-15 06:16:57 +00005171 case 212:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005172#line 2096 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005173 { (yyval.BoolVal) = true; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005174 break;
5175
Chris Lattner740e7092008-10-15 06:16:57 +00005176 case 213:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005177#line 2096 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005178 { (yyval.BoolVal) = false; ;}
5179 break;
5180
Chris Lattner740e7092008-10-15 06:16:57 +00005181 case 214:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005182#line 2099 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005183 {
5184 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
5185 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00005186 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005187 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
5188 if (!Aliasee)
5189 GEN_ERROR("Aliases can be created only to global values");
5190
Dan Gohmanf4423b12008-04-19 00:24:39 +00005191 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005192 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005193 delete (yyvsp[(1) - (2)].TypeVal);
5194 ;}
5195 break;
5196
Chris Lattner740e7092008-10-15 06:16:57 +00005197 case 215:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005198#line 2111 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005199 {
5200 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
5201 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
5202 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005203 GEN_ERROR("invalid cast opcode for cast from '" +
5204 Val->getType()->getDescription() + "' to '" +
5205 DestTy->getDescription() + "'");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005206
Dan Gohmanf4423b12008-04-19 00:24:39 +00005207 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005208 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005209 delete (yyvsp[(5) - (6)].TypeVal);
5210 ;}
5211 break;
5212
Chris Lattner740e7092008-10-15 06:16:57 +00005213 case 216:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005214#line 2132 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005215 {
5216 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5217 CurModule.ModuleDone();
5218 CHECK_FOR_ERROR;
5219 ;}
5220 break;
5221
Chris Lattner740e7092008-10-15 06:16:57 +00005222 case 217:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005223#line 2137 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005224 {
5225 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5226 CurModule.ModuleDone();
5227 CHECK_FOR_ERROR;
5228 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005229 break;
5230
Chris Lattner740e7092008-10-15 06:16:57 +00005231 case 220:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005232#line 2150 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005233 { CurFun.isDeclare = false; ;}
5234 break;
5235
Chris Lattner740e7092008-10-15 06:16:57 +00005236 case 221:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005237#line 2150 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005238 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005239 CurFun.FunctionDone();
5240 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005241 ;}
5242 break;
5243
Chris Lattner740e7092008-10-15 06:16:57 +00005244 case 222:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005245#line 2154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005246 { CurFun.isDeclare = true; ;}
5247 break;
5248
Chris Lattner740e7092008-10-15 06:16:57 +00005249 case 223:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005250#line 2154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005251 {
5252 CHECK_FOR_ERROR
5253 ;}
5254 break;
5255
Chris Lattner740e7092008-10-15 06:16:57 +00005256 case 224:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005257#line 2157 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005258 {
5259 CHECK_FOR_ERROR
5260 ;}
5261 break;
5262
Chris Lattner740e7092008-10-15 06:16:57 +00005263 case 225:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005264#line 2160 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005265 {
Reid Spencer14310612006-12-31 05:40:51 +00005266 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005267 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005268 // Eagerly resolve types. This is not an optimization, this is a
5269 // requirement that is due to the fact that we could have this:
5270 //
5271 // %list = type { %list * }
5272 // %list = type { %list * } ; repeated type decl
5273 //
5274 // If types are not resolved eagerly, then the two types will not be
5275 // determined to be the same type!
5276 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00005277 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005278
Dan Gohmanf4423b12008-04-19 00:24:39 +00005279 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00005280 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005281 // If this is a named type that is not a redefinition, add it to the slot
5282 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005283 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005284 }
Reid Spencera132e042006-12-03 05:46:11 +00005285
Dan Gohmanf4423b12008-04-19 00:24:39 +00005286 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005287 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005288 ;}
5289 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00005290
Chris Lattner740e7092008-10-15 06:16:57 +00005291 case 226:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005292#line 2184 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005293 {
5294 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
5295
5296 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005297 CHECK_FOR_ERROR
5298 // If this is a named type that is not a redefinition, add it to the slot
5299 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005300 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005301 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005302 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005303 ;}
5304 break;
5305
Chris Lattner740e7092008-10-15 06:16:57 +00005306 case 227:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005307#line 2196 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005308 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005309 /* "Externally Visible" Linkage */
Eric Christopher2a5196f2008-09-24 04:55:49 +00005310 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005311 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005312 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5313 (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 +00005314 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005315 ;}
5316 break;
5317
Chris Lattner740e7092008-10-15 06:16:57 +00005318 case 228:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005319#line 2203 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005320 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005321 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005322 ;}
5323 break;
5324
Chris Lattner740e7092008-10-15 06:16:57 +00005325 case 229:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005326#line 2207 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005327 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005328 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005329 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005330 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 +00005331 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005332 ;}
5333 break;
5334
Chris Lattner740e7092008-10-15 06:16:57 +00005335 case 230:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005336#line 2212 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005337 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005338 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005339 ;}
5340 break;
5341
Chris Lattner740e7092008-10-15 06:16:57 +00005342 case 231:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005343#line 2216 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005344 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005345 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005346 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5347 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 +00005348 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005349 delete (yyvsp[(6) - (7)].TypeVal);
5350 ;}
5351 break;
5352
Chris Lattner740e7092008-10-15 06:16:57 +00005353 case 232:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005354#line 2222 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005355 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005356 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005357 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005358 ;}
5359 break;
5360
Chris Lattner740e7092008-10-15 06:16:57 +00005361 case 233:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005362#line 2226 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005363 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005364 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005365 if ((yyvsp[(1) - (5)].StrVal)) {
5366 Name = *(yyvsp[(1) - (5)].StrVal);
5367 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005368 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005369 if (Name.empty())
5370 GEN_ERROR("Alias name cannot be empty");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005371
Dan Gohmanf4423b12008-04-19 00:24:39 +00005372 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005373 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005374 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005375
Dan Gohmanf4423b12008-04-19 00:24:39 +00005376 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005377 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005378 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005379 InsertValue(GA, CurModule.Values);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005380
5381
Chris Lattner569f7372007-09-10 23:24:14 +00005382 // If there was a forward reference of this alias, resolve it now.
Eric Christopher2a5196f2008-09-24 04:55:49 +00005383
Chris Lattner569f7372007-09-10 23:24:14 +00005384 ValID ID;
5385 if (!Name.empty())
5386 ID = ValID::createGlobalName(Name);
5387 else
5388 ID = ValID::createGlobalID(CurModule.Values.size()-1);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005389
Chris Lattner569f7372007-09-10 23:24:14 +00005390 if (GlobalValue *FWGV =
5391 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5392 // Replace uses of the fwdref with the actual alias.
5393 FWGV->replaceAllUsesWith(GA);
5394 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5395 GV->eraseFromParent();
5396 else
5397 cast<Function>(FWGV)->eraseFromParent();
5398 }
5399 ID.destroy();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005400
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005401 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005402 ;}
5403 break;
5404
Chris Lattner740e7092008-10-15 06:16:57 +00005405 case 234:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005406#line 2266 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005407 {
5408 CHECK_FOR_ERROR
5409 ;}
5410 break;
5411
Chris Lattner740e7092008-10-15 06:16:57 +00005412 case 235:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005413#line 2269 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005414 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005415 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005416 ;}
5417 break;
5418
Chris Lattner740e7092008-10-15 06:16:57 +00005419 case 236:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005420#line 2275 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005421 {
Chris Lattner66316012006-01-24 04:14:29 +00005422 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005423 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005424 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005425 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005426 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5427 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005428 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005429;}
5430 break;
5431
Chris Lattner740e7092008-10-15 06:16:57 +00005432 case 237:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005433#line 2285 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005434 {
5435 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5436 delete (yyvsp[(3) - (3)].StrVal);
5437 ;}
5438 break;
5439
Chris Lattner740e7092008-10-15 06:16:57 +00005440 case 238:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005441#line 2289 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005442 {
5443 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5444 delete (yyvsp[(3) - (3)].StrVal);
5445 ;}
5446 break;
5447
Chris Lattner740e7092008-10-15 06:16:57 +00005448 case 240:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005449#line 2296 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005450 {
5451 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5452 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005453 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005454 ;}
5455 break;
5456
Chris Lattner740e7092008-10-15 06:16:57 +00005457 case 241:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005458#line 2301 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005459 {
5460 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5461 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005462 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005463 ;}
5464 break;
5465
Chris Lattner740e7092008-10-15 06:16:57 +00005466 case 242:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005467#line 2306 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005468 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005469 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005470 ;}
5471 break;
5472
Chris Lattner740e7092008-10-15 06:16:57 +00005473 case 243:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005474#line 2315 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005475 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005476 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005477 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005478 if (!(*(yyvsp[(3) - (5)].TypeVal))->isFirstClassType())
5479 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005480 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 +00005481 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5482 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005483 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005484 ;}
5485 break;
5486
Chris Lattner740e7092008-10-15 06:16:57 +00005487 case 244:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005488#line 2325 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005489 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005490 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005491 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005492 if (!(*(yyvsp[(1) - (3)].TypeVal))->isFirstClassType())
5493 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005494 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 +00005495 (yyval.ArgList) = new ArgListType;
5496 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005497 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005498 ;}
5499 break;
5500
Chris Lattner740e7092008-10-15 06:16:57 +00005501 case 245:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005502#line 2336 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005503 {
5504 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005505 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005506 ;}
5507 break;
5508
Chris Lattner740e7092008-10-15 06:16:57 +00005509 case 246:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005510#line 2340 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005511 {
5512 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005513 struct ArgListEntry E;
5514 E.Ty = new PATypeHolder(Type::VoidTy);
5515 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005516 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005517 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005518 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005519 ;}
5520 break;
5521
Chris Lattner740e7092008-10-15 06:16:57 +00005522 case 247:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005523#line 2349 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005524 {
5525 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005526 struct ArgListEntry E;
5527 E.Ty = new PATypeHolder(Type::VoidTy);
5528 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005529 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005530 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005531 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005532 ;}
5533 break;
5534
Chris Lattner740e7092008-10-15 06:16:57 +00005535 case 248:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005536#line 2358 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005537 {
5538 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005539 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005540 ;}
5541 break;
5542
Chris Lattner740e7092008-10-15 06:16:57 +00005543 case 249:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005544#line 2364 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005545 {
Devang Patel652203f2008-09-29 20:49:50 +00005546 std::string FunctionName(*(yyvsp[(4) - (11)].StrVal));
5547 delete (yyvsp[(4) - (11)].StrVal); // Free strdup'd memory!
Eric Christopher2a5196f2008-09-24 04:55:49 +00005548
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005549 // Check the function result for abstractness if this is a define. We should
5550 // have no abstract types at this point
Devang Patel652203f2008-09-29 20:49:50 +00005551 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(3) - (11)].TypeVal)))
5552 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(3) - (11)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005553
Devang Patel652203f2008-09-29 20:49:50 +00005554 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (11)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00005555 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005556
Reid Spencer68a24bd2005-08-27 18:50:39 +00005557 std::vector<const Type*> ParamTypeList;
Devang Patel05988662008-09-25 21:00:45 +00005558 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00005559 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
5560 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00005561 Attributes RetAttrs = (yyvsp[(2) - (11)].Attributes);
5562 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None) {
5563 if ((yyvsp[(8) - (11)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005564 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00005565 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005566 }
Devang Patel652203f2008-09-29 20:49:50 +00005567 if ((yyvsp[(8) - (11)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005568 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00005569 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005570 }
Devang Patel652203f2008-09-29 20:49:50 +00005571 if ((yyvsp[(8) - (11)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00005572 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00005573 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00005574 }
Dale Johannesene7261862008-09-26 23:46:20 +00005575 }
Devang Patel652203f2008-09-29 20:49:50 +00005576 if (RetAttrs != Attribute::None)
5577 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
5578 if ((yyvsp[(6) - (11)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005579 unsigned index = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005580 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin(); I != (yyvsp[(6) - (11)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005581 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005582 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5583 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005584 ParamTypeList.push_back(Ty);
Devang Patel05988662008-09-25 21:00:45 +00005585 if (Ty != Type::VoidTy && I->Attrs != Attribute::None)
5586 Attrs.push_back(AttributeWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005587 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005588 }
Devang Patel652203f2008-09-29 20:49:50 +00005589 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None)
5590 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(8) - (11)].Attributes)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005591
5592 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5593 if (isVarArg) ParamTypeList.pop_back();
5594
Devang Patel05988662008-09-25 21:00:45 +00005595 AttrListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005596 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00005597 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005598
Devang Patel652203f2008-09-29 20:49:50 +00005599 FunctionType *FT = FunctionType::get(*(yyvsp[(3) - (11)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005600 const PointerType *PFT = PointerType::getUnqual(FT);
Devang Patel652203f2008-09-29 20:49:50 +00005601 delete (yyvsp[(3) - (11)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005602
5603 ValID ID;
5604 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005605 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005606 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005607 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005608 }
5609
5610 Function *Fn = 0;
5611 // See if this function was forward referenced. If so, recycle the object.
5612 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005613 // Move the function to the end of the list, from whereever it was
Reid Spencer68a24bd2005-08-27 18:50:39 +00005614 // previously inserted.
5615 Fn = cast<Function>(FWRef);
Devang Patel05988662008-09-25 21:00:45 +00005616 assert(Fn->getAttributes().isEmpty() &&
Chris Lattner58d74912008-03-12 17:45:29 +00005617 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005618 CurModule.CurrentModule->getFunctionList().remove(Fn);
5619 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5620 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005621 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005622 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005623 // The existing function doesn't have the same type. This is an overload
5624 // error.
5625 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Devang Patel05988662008-09-25 21:00:45 +00005626 } else if (Fn->getAttributes() != PAL) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005627 // The existing function doesn't have the same parameter attributes.
5628 // This is an overload error.
5629 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005630 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005631 // Neither the existing or the current function is a declaration and they
5632 // have the same name and same type. Clearly this is a redefinition.
5633 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005634 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005635 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005636 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5637 AI != AE; ++AI)
5638 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005639 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005640 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005641 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5642 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005643 InsertValue(Fn, CurModule.Values);
5644 }
5645
Nuno Lopes9e9631d2008-10-03 15:45:58 +00005646 ID.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005647 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005648
5649 if (CurFun.isDeclare) {
5650 // If we have declaration, always overwrite linkage. This will allow us to
5651 // correctly handle cases, when pointer to function is passed as argument to
5652 // another function.
5653 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005654 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005655 }
Devang Pateld4980812008-09-02 20:52:40 +00005656 Fn->setCallingConv((yyvsp[(1) - (11)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00005657 Fn->setAttributes(PAL);
Devang Patel652203f2008-09-29 20:49:50 +00005658 Fn->setAlignment((yyvsp[(10) - (11)].UIntVal));
5659 if ((yyvsp[(9) - (11)].StrVal)) {
5660 Fn->setSection(*(yyvsp[(9) - (11)].StrVal));
5661 delete (yyvsp[(9) - (11)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005662 }
Devang Patel652203f2008-09-29 20:49:50 +00005663 if ((yyvsp[(11) - (11)].StrVal)) {
5664 Fn->setGC((yyvsp[(11) - (11)].StrVal)->c_str());
5665 delete (yyvsp[(11) - (11)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005666 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005667
5668 // Add all of the arguments we parsed to the function...
Devang Patel652203f2008-09-29 20:49:50 +00005669 if ((yyvsp[(6) - (11)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005670 if (isVarArg) { // Nuke the last entry
Devang Patel652203f2008-09-29 20:49:50 +00005671 assert((yyvsp[(6) - (11)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(6) - (11)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005672 "Not a varargs marker!");
Devang Patel652203f2008-09-29 20:49:50 +00005673 delete (yyvsp[(6) - (11)].ArgList)->back().Ty;
5674 (yyvsp[(6) - (11)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005675 }
5676 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005677 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005678 unsigned Idx = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005679 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin();
5680 I != (yyvsp[(6) - (11)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005681 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005682 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005683 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005684 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005685 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005686 }
Reid Spencera132e042006-12-03 05:46:11 +00005687
Devang Patel652203f2008-09-29 20:49:50 +00005688 delete (yyvsp[(6) - (11)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005689 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005690 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005691;}
5692 break;
5693
Chris Lattner740e7092008-10-15 06:16:57 +00005694 case 252:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005695#line 2514 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005696 {
5697 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005698
5699 // Make sure that we keep track of the linkage type even if there was a
5700 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005701 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5702 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5703;}
5704 break;
5705
Chris Lattner740e7092008-10-15 06:16:57 +00005706 case 255:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005707#line 2525 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005708 {
5709 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005710 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005711;}
5712 break;
5713
Chris Lattner740e7092008-10-15 06:16:57 +00005714 case 256:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005715#line 2530 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005716 {
5717 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5718 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5719 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005720 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005721 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005722 ;}
5723 break;
5724
Chris Lattner740e7092008-10-15 06:16:57 +00005725 case 257:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005726#line 2542 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005727 {
5728 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005729 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005730 ;}
5731 break;
5732
Chris Lattner740e7092008-10-15 06:16:57 +00005733 case 258:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005734#line 2546 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005735 {
5736 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005737 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005738 ;}
5739 break;
5740
Chris Lattner740e7092008-10-15 06:16:57 +00005741 case 259:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005742#line 2551 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005743 { // A reference to a direct constant
5744 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005745 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005746 ;}
5747 break;
5748
Chris Lattner740e7092008-10-15 06:16:57 +00005749 case 260:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005750#line 2555 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005751 {
5752 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005753 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005754 ;}
5755 break;
5756
Chris Lattner740e7092008-10-15 06:16:57 +00005757 case 261:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005758#line 2559 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005759 { // arbitrary precision integer constants
5760 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), true);
5761 delete (yyvsp[(1) - (1)].APIntVal);
5762 CHECK_FOR_ERROR
5763 ;}
5764 break;
5765
Chris Lattner740e7092008-10-15 06:16:57 +00005766 case 262:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005767#line 2564 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005768 { // arbitrary precision integer constants
5769 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), false);
5770 delete (yyvsp[(1) - (1)].APIntVal);
5771 CHECK_FOR_ERROR
5772 ;}
5773 break;
5774
Chris Lattner740e7092008-10-15 06:16:57 +00005775 case 263:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005776#line 2569 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005777 { // Perhaps it's an FP constant?
5778 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005779 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005780 ;}
5781 break;
5782
Chris Lattner740e7092008-10-15 06:16:57 +00005783 case 264:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005784#line 2573 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005785 {
5786 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005787 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005788 ;}
5789 break;
5790
Chris Lattner740e7092008-10-15 06:16:57 +00005791 case 265:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005792#line 2577 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005793 {
5794 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005795 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005796 ;}
5797 break;
5798
Chris Lattner740e7092008-10-15 06:16:57 +00005799 case 266:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005800#line 2581 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005801 {
5802 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005803 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005804 ;}
5805 break;
5806
Chris Lattner740e7092008-10-15 06:16:57 +00005807 case 267:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005808#line 2585 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005809 {
5810 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005811 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005812 ;}
5813 break;
5814
Chris Lattner740e7092008-10-15 06:16:57 +00005815 case 268:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005816#line 2589 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005817 { // A vector zero constant.
5818 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005819 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005820 ;}
5821 break;
5822
Chris Lattner740e7092008-10-15 06:16:57 +00005823 case 269:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005824#line 2593 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005825 { // Nonempty unsized packed vector
5826 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005827 unsigned NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005828
5829 if (!ETy->isInteger() && !ETy->isFloatingPoint())
5830 GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005831
Reid Spencer9d6565a2007-02-15 02:26:10 +00005832 VectorType* pt = VectorType::get(ETy, NumElements);
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005833 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
Eric Christopher2a5196f2008-09-24 04:55:49 +00005834
Reid Spencer68a24bd2005-08-27 18:50:39 +00005835 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005836 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5837 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005838 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005839 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005840 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005841 }
5842
Dan Gohmanf4423b12008-04-19 00:24:39 +00005843 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5844 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005845 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005846 ;}
5847 break;
5848
Chris Lattner740e7092008-10-15 06:16:57 +00005849 case 270:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005850#line 2615 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005851 { // Nonempty unsized arr
5852 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005853 uint64_t NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005854
5855 if (!ETy->isFirstClassType())
5856 GEN_ERROR("Invalid array element type: " + ETy->getDescription());
5857
5858 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5859 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
5860
5861 // Verify all elements are correct type!
5862 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5863 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005864 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005865 ETy->getDescription() +"' as required!\nIt is of type '"+
5866 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
5867 }
5868
5869 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, *(yyvsp[(2) - (3)].ConstVector)));
5870 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5871 CHECK_FOR_ERROR
5872 ;}
5873 break;
5874
Chris Lattner740e7092008-10-15 06:16:57 +00005875 case 271:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005876#line 2637 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005877 {
Dan Gohman180c1692008-06-23 18:43:26 +00005878 // Use undef instead of an array because it's inconvenient to determine
5879 // the element type at this point, there being no elements to examine.
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005880 (yyval.ValIDVal) = ValID::createUndef();
5881 CHECK_FOR_ERROR
5882 ;}
5883 break;
5884
Chris Lattner740e7092008-10-15 06:16:57 +00005885 case 272:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005886#line 2643 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005887 {
Dan Gohman180c1692008-06-23 18:43:26 +00005888 uint64_t NumElements = (yyvsp[(2) - (2)].StrVal)->length();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005889 const Type *ETy = Type::Int8Ty;
5890
5891 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5892
5893 std::vector<Constant*> Vals;
5894 for (unsigned i = 0; i < (yyvsp[(2) - (2)].StrVal)->length(); ++i)
5895 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(2) - (2)].StrVal))[i]));
5896 delete (yyvsp[(2) - (2)].StrVal);
5897 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, Vals));
5898 CHECK_FOR_ERROR
5899 ;}
5900 break;
5901
Chris Lattner740e7092008-10-15 06:16:57 +00005902 case 273:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005903#line 2656 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005904 {
5905 std::vector<const Type*> Elements((yyvsp[(2) - (3)].ConstVector)->size());
5906 for (unsigned i = 0, e = (yyvsp[(2) - (3)].ConstVector)->size(); i != e; ++i)
5907 Elements[i] = (*(yyvsp[(2) - (3)].ConstVector))[i]->getType();
5908
5909 const StructType *STy = StructType::get(Elements);
5910 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5911
5912 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(2) - (3)].ConstVector)));
5913 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5914 CHECK_FOR_ERROR
5915 ;}
5916 break;
5917
Chris Lattner740e7092008-10-15 06:16:57 +00005918 case 274:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005919#line 2668 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005920 {
5921 const StructType *STy = StructType::get(std::vector<const Type*>());
5922 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5923 CHECK_FOR_ERROR
5924 ;}
5925 break;
5926
Chris Lattner740e7092008-10-15 06:16:57 +00005927 case 275:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005928#line 2673 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005929 {
5930 std::vector<const Type*> Elements((yyvsp[(3) - (5)].ConstVector)->size());
5931 for (unsigned i = 0, e = (yyvsp[(3) - (5)].ConstVector)->size(); i != e; ++i)
5932 Elements[i] = (*(yyvsp[(3) - (5)].ConstVector))[i]->getType();
5933
5934 const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
5935 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5936
5937 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(3) - (5)].ConstVector)));
5938 delete PTy; delete (yyvsp[(3) - (5)].ConstVector);
5939 CHECK_FOR_ERROR
5940 ;}
5941 break;
5942
Chris Lattner740e7092008-10-15 06:16:57 +00005943 case 276:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005944#line 2685 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005945 {
5946 const StructType *STy = StructType::get(std::vector<const Type*>(),
5947 /*isPacked=*/true);
5948 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5949 CHECK_FOR_ERROR
5950 ;}
5951 break;
5952
Chris Lattner740e7092008-10-15 06:16:57 +00005953 case 277:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005954#line 2691 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005955 {
5956 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005957 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005958 ;}
5959 break;
5960
Chris Lattner740e7092008-10-15 06:16:57 +00005961 case 278:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005962#line 2695 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005963 {
5964 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5965 delete (yyvsp[(3) - (5)].StrVal);
5966 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005967 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005968 ;}
5969 break;
5970
Chris Lattner740e7092008-10-15 06:16:57 +00005971 case 279:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005972#line 2705 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005973 { // Is it an integer reference...?
5974 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005975 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005976 ;}
5977 break;
5978
Chris Lattner740e7092008-10-15 06:16:57 +00005979 case 280:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005980#line 2709 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005981 {
5982 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005983 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005984 ;}
5985 break;
5986
Chris Lattner740e7092008-10-15 06:16:57 +00005987 case 281:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005988#line 2713 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005989 { // Is it a named reference...?
5990 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5991 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005992 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005993 ;}
5994 break;
5995
Chris Lattner740e7092008-10-15 06:16:57 +00005996 case 282:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00005997#line 2718 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005998 { // Is it a named reference...?
5999 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
6000 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00006001 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006002 ;}
6003 break;
6004
Chris Lattner740e7092008-10-15 06:16:57 +00006005 case 285:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006006#line 2731 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006007 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006008 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006009 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006010 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006011 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00006012 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006013 ;}
6014 break;
6015
Chris Lattner740e7092008-10-15 06:16:57 +00006016 case 286:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006017#line 2740 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006018 {
6019 (yyval.ValueList) = new std::vector<Value *>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00006020 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00006021 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006022 ;}
6023 break;
6024
Chris Lattner740e7092008-10-15 06:16:57 +00006025 case 287:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006026#line 2745 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006027 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006028 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00006029 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006030 ;}
6031 break;
6032
Chris Lattner740e7092008-10-15 06:16:57 +00006033 case 288:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006034#line 2750 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006035 {
6036 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006037 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006038 ;}
6039 break;
6040
Chris Lattner740e7092008-10-15 06:16:57 +00006041 case 289:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006042#line 2754 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006043 { // Do not allow functions with 0 basic blocks
Dan Gohmanf4423b12008-04-19 00:24:39 +00006044 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006045 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006046 ;}
6047 break;
6048
Chris Lattner740e7092008-10-15 06:16:57 +00006049 case 290:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006050#line 2763 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006051 {
6052 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006053 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006054 InsertValue((yyvsp[(3) - (3)].TermInstVal));
6055 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6056 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006057 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006058 ;}
6059 break;
6060
Chris Lattner740e7092008-10-15 06:16:57 +00006061 case 291:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006062#line 2772 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006063 {
6064 CHECK_FOR_ERROR
6065 int ValNum = InsertValue((yyvsp[(3) - (3)].TermInstVal));
6066 if (ValNum != (int)(yyvsp[(2) - (3)].UIntVal))
6067 GEN_ERROR("Result value number %" + utostr((yyvsp[(2) - (3)].UIntVal)) +
6068 " is incorrect, expected %" + utostr((unsigned)ValNum));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006069
Chris Lattner15bd0952008-08-29 17:20:18 +00006070 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6071 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
6072 CHECK_FOR_ERROR
6073;}
6074 break;
6075
Chris Lattner740e7092008-10-15 06:16:57 +00006076 case 292:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006077#line 2785 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006078 {
6079 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006080 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
6081 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00006082 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
6083 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
6084 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006085 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006086 ;}
6087 break;
Chris Lattner38905612008-02-19 04:36:25 +00006088
Chris Lattner740e7092008-10-15 06:16:57 +00006089 case 293:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006090#line 2794 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006091 { // Empty space between instruction lists
Chris Lattnercc81d152008-05-04 17:18:47 +00006092 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006093 CHECK_FOR_ERROR
6094 ;}
6095 break;
6096
Chris Lattner740e7092008-10-15 06:16:57 +00006097 case 294:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006098#line 2798 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnercc81d152008-05-04 17:18:47 +00006099 { // Labelled (named) basic block
6100 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
6101 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006102 CHECK_FOR_ERROR
Chris Lattnercc81d152008-05-04 17:18:47 +00006103
Dan Gohmanf4423b12008-04-19 00:24:39 +00006104 ;}
6105 break;
6106
Chris Lattner740e7092008-10-15 06:16:57 +00006107 case 295:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006108#line 2806 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006109 { // Return with a result...
6110 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
6111 assert(!VL.empty() && "Invalid ret operands!");
Dan Gohman1a570242008-07-23 00:54:54 +00006112 const Type *ReturnType = CurFun.CurrentFunction->getReturnType();
6113 if (VL.size() > 1 ||
6114 (isa<StructType>(ReturnType) &&
6115 (VL.empty() || VL[0]->getType() != ReturnType))) {
6116 Value *RV = UndefValue::get(ReturnType);
6117 for (unsigned i = 0, e = VL.size(); i != e; ++i) {
6118 Instruction *I = InsertValueInst::Create(RV, VL[i], i, "mrv");
6119 ((yyvsp[(-1) - (2)].BasicBlockVal))->getInstList().push_back(I);
6120 RV = I;
6121 }
6122 (yyval.TermInstVal) = ReturnInst::Create(RV);
6123 } else {
6124 (yyval.TermInstVal) = ReturnInst::Create(VL[0]);
6125 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006126 delete (yyvsp[(2) - (2)].ValueList);
6127 CHECK_FOR_ERROR
6128 ;}
6129 break;
6130
Chris Lattner740e7092008-10-15 06:16:57 +00006131 case 296:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006132#line 2826 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006133 { // Return with no result...
6134 (yyval.TermInstVal) = ReturnInst::Create();
6135 CHECK_FOR_ERROR
6136 ;}
6137 break;
6138
Chris Lattner740e7092008-10-15 06:16:57 +00006139 case 297:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006140#line 2830 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006141 { // Unconditional Branch...
6142 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6143 CHECK_FOR_ERROR
6144 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
6145 ;}
6146 break;
6147
Chris Lattner740e7092008-10-15 06:16:57 +00006148 case 298:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006149#line 2835 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006150 {
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006151 if (cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() != 1)
6152 GEN_ERROR("Branch condition must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006153 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6154 CHECK_FOR_ERROR
6155 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6156 CHECK_FOR_ERROR
6157 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6158 CHECK_FOR_ERROR
6159 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
6160 ;}
6161 break;
6162
Chris Lattner740e7092008-10-15 06:16:57 +00006163 case 299:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006164#line 2846 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006165 {
6166 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
6167 CHECK_FOR_ERROR
6168 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6169 CHECK_FOR_ERROR
6170 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6171 (yyval.TermInstVal) = S;
6172
6173 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6174 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00006175 for (; I != E; ++I) {
6176 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6177 S->addCase(CI, I->second);
6178 else
Reid Spencerb5334b02007-02-05 10:18:06 +00006179 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006180 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006181 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00006182 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006183 ;}
6184 break;
6185
Chris Lattner740e7092008-10-15 06:16:57 +00006186 case 300:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006187#line 2865 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006188 {
6189 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006190 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006191 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006192 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00006193 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006194 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006195 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006196 ;}
6197 break;
6198
Chris Lattner740e7092008-10-15 06:16:57 +00006199 case 301:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006200#line 2875 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006201 {
Reid Spencer3822ff52006-11-08 06:47:33 +00006202
Reid Spencer14310612006-12-31 05:40:51 +00006203 // Handle the short syntax
6204 const PointerType *PFTy = 0;
6205 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006206 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (15)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00006207 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6208 // Pull out the types of all of the arguments...
6209 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006210 ParamList::iterator I = (yyvsp[(7) - (15)].ParamList)->begin(), E = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006211 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006212 const Type *Ty = I->Val->getType();
6213 if (Ty == Type::VoidTy)
6214 GEN_ERROR("Short call syntax cannot be used with varargs");
6215 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006216 }
Eric Christopher2a5196f2008-09-24 04:55:49 +00006217
Devang Patel652203f2008-09-29 20:49:50 +00006218 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (15)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006219 GEN_ERROR("Invalid result type for LLVM function");
6220
Devang Patel652203f2008-09-29 20:49:50 +00006221 Ty = FunctionType::get((yyvsp[(4) - (15)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006222 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006223 }
6224
Devang Patel652203f2008-09-29 20:49:50 +00006225 delete (yyvsp[(4) - (15)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00006226
Devang Patel652203f2008-09-29 20:49:50 +00006227 Value *V = getVal(PFTy, (yyvsp[(5) - (15)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006228 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006229 BasicBlock *Normal = getBBVal((yyvsp[(12) - (15)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006230 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006231 BasicBlock *Except = getBBVal((yyvsp[(15) - (15)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00006232 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00006233
Devang Patel05988662008-09-25 21:00:45 +00006234 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006235 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6236 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006237 Attributes RetAttrs = (yyvsp[(3) - (15)].Attributes);
6238 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None) {
6239 if ((yyvsp[(9) - (15)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006240 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006241 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006242 }
Devang Patel652203f2008-09-29 20:49:50 +00006243 if ((yyvsp[(9) - (15)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006244 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006245 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006246 }
Devang Patel652203f2008-09-29 20:49:50 +00006247 if ((yyvsp[(9) - (15)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006248 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006249 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006250 }
Dale Johannesene7261862008-09-26 23:46:20 +00006251 }
Devang Patel652203f2008-09-29 20:49:50 +00006252 if (RetAttrs != Attribute::None)
6253 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006254
Reid Spencer14310612006-12-31 05:40:51 +00006255 // Check the arguments
6256 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006257 if ((yyvsp[(7) - (15)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00006258 // Make sure no arguments is a good thing!
6259 if (Ty->getNumParams() != 0)
6260 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006261 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006262 } else { // Has arguments?
6263 // Loop through FunctionType's arguments and ensure they are specified
6264 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00006265 FunctionType::param_iterator I = Ty->param_begin();
6266 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006267 ParamList::iterator ArgI = (yyvsp[(7) - (15)].ParamList)->begin(), ArgE = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006268 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006269
Duncan Sandsdc024672007-11-27 13:23:08 +00006270 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006271 if (ArgI->Val->getType() != *I)
6272 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006273 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006274 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006275 if (ArgI->Attrs != Attribute::None)
6276 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006277 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00006278
Reid Spencer14310612006-12-31 05:40:51 +00006279 if (Ty->isVarArg()) {
6280 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006281 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006282 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006283 if (ArgI->Attrs != Attribute::None)
6284 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006285 }
Reid Spencer14310612006-12-31 05:40:51 +00006286 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006287 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006288 }
Devang Patel652203f2008-09-29 20:49:50 +00006289 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None)
6290 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (15)].Attributes)));
Devang Patel05988662008-09-25 21:00:45 +00006291 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006292 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006293 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006294
Reid Spencer14310612006-12-31 05:40:51 +00006295 // Create the InvokeInst
Dan Gohman041e2eb2008-05-15 19:50:34 +00006296 InvokeInst *II = InvokeInst::Create(V, Normal, Except,
6297 Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006298 II->setCallingConv((yyvsp[(2) - (15)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006299 II->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006300 (yyval.TermInstVal) = II;
Devang Patel652203f2008-09-29 20:49:50 +00006301 delete (yyvsp[(7) - (15)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006302 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006303 ;}
6304 break;
6305
Chris Lattner740e7092008-10-15 06:16:57 +00006306 case 302:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006307#line 2978 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006308 {
6309 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006310 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006311 ;}
6312 break;
6313
Chris Lattner740e7092008-10-15 06:16:57 +00006314 case 303:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006315#line 2982 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006316 {
6317 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006318 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006319 ;}
6320 break;
6321
Chris Lattner740e7092008-10-15 06:16:57 +00006322 case 304:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006323#line 2989 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006324 {
6325 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6326 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006327 CHECK_FOR_ERROR
6328 if (V == 0)
6329 GEN_ERROR("May only switch on a constant pool value");
6330
Dan Gohmanf4423b12008-04-19 00:24:39 +00006331 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006332 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006333 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6334 ;}
6335 break;
6336
Chris Lattner740e7092008-10-15 06:16:57 +00006337 case 305:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006338#line 3000 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006339 {
6340 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6341 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006342 CHECK_FOR_ERROR
6343
6344 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00006345 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006346
Dan Gohmanf4423b12008-04-19 00:24:39 +00006347 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006348 CHECK_FOR_ERROR
Eric Christopher2a5196f2008-09-24 04:55:49 +00006349 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006350 ;}
6351 break;
6352
Chris Lattner740e7092008-10-15 06:16:57 +00006353 case 306:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006354#line 3013 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006355 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006356 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00006357 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006358 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006359 InsertValue((yyvsp[(2) - (2)].InstVal));
6360 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006361 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006362 ;}
6363 break;
6364
Chris Lattner740e7092008-10-15 06:16:57 +00006365 case 307:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006366#line 3022 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006367 {
6368 CHECK_FOR_ERROR
6369 int ValNum = InsertValue((yyvsp[(2) - (2)].InstVal));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006370
Chris Lattner15bd0952008-08-29 17:20:18 +00006371 if (ValNum != (int)(yyvsp[(1) - (2)].UIntVal))
6372 GEN_ERROR("Result value number %" + utostr((yyvsp[(1) - (2)].UIntVal)) +
6373 " is incorrect, expected %" + utostr((unsigned)ValNum));
6374
6375 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6376 CHECK_FOR_ERROR
6377 ;}
6378 break;
6379
Chris Lattner740e7092008-10-15 06:16:57 +00006380 case 308:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006381#line 3035 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006382 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006383 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006384 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
6385 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
6386 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00006387 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006388 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006389 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006390 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6391 delete (yyvsp[(1) - (6)].TypeVal);
6392 ;}
6393 break;
6394
Chris Lattner740e7092008-10-15 06:16:57 +00006395 case 309:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006396#line 3046 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006397 {
6398 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6399 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006400 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006401 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006402 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006403 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6404 ;}
6405 break;
6406
Chris Lattner740e7092008-10-15 06:16:57 +00006407 case 310:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006408#line 3056 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006409 {
Devang Patel05988662008-09-25 21:00:45 +00006410 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006411 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006412 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006413 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00006414 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006415 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 +00006416 (yyval.ParamList)->push_back(E);
6417 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00006418 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006419 ;}
6420 break;
6421
Chris Lattner740e7092008-10-15 06:16:57 +00006422 case 311:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006423#line 3067 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006424 {
Devang Patel05988662008-09-25 21:00:45 +00006425 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006426 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00006427 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006428 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 +00006429 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00006430 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006431 ;}
6432 break;
6433
Chris Lattner740e7092008-10-15 06:16:57 +00006434 case 312:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006435#line 3075 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006436 {
Devang Patel05988662008-09-25 21:00:45 +00006437 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006438 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006439 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6440 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006441 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 +00006442 (yyval.ParamList)->push_back(E);
6443 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006444 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006445 ;}
6446 break;
6447
Chris Lattner740e7092008-10-15 06:16:57 +00006448 case 313:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006449#line 3085 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006450 {
Devang Patel05988662008-09-25 21:00:45 +00006451 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00006452 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006453 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 +00006454 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006455 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006456 ;}
6457 break;
6458
Chris Lattner740e7092008-10-15 06:16:57 +00006459 case 314:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006460#line 3092 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006461 { (yyval.ParamList) = new ParamList(); ;}
6462 break;
6463
Chris Lattner740e7092008-10-15 06:16:57 +00006464 case 315:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006465#line 3095 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006466 { (yyval.ValueList) = new std::vector<Value*>(); ;}
6467 break;
6468
Chris Lattner740e7092008-10-15 06:16:57 +00006469 case 316:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006470#line 3096 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006471 {
6472 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6473 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00006474 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006475 ;}
6476 break;
6477
Chris Lattner740e7092008-10-15 06:16:57 +00006478 case 317:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006479#line 3104 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006480 {
6481 (yyval.ConstantList) = new std::vector<unsigned>();
6482 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
6483 GEN_ERROR("Index " + utostr((yyvsp[(2) - (2)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6484 (yyval.ConstantList)->push_back((yyvsp[(2) - (2)].UInt64Val));
6485 ;}
6486 break;
6487
Chris Lattner740e7092008-10-15 06:16:57 +00006488 case 318:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006489#line 3110 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006490 {
6491 (yyval.ConstantList) = (yyvsp[(1) - (3)].ConstantList);
6492 if ((unsigned)(yyvsp[(3) - (3)].UInt64Val) != (yyvsp[(3) - (3)].UInt64Val))
6493 GEN_ERROR("Index " + utostr((yyvsp[(3) - (3)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6494 (yyval.ConstantList)->push_back((yyvsp[(3) - (3)].UInt64Val));
6495 CHECK_FOR_ERROR
6496 ;}
6497 break;
6498
Chris Lattner740e7092008-10-15 06:16:57 +00006499 case 319:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006500#line 3119 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006501 {
6502 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006503 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006504 ;}
6505 break;
6506
Chris Lattner740e7092008-10-15 06:16:57 +00006507 case 320:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006508#line 3123 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006509 {
6510 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006511 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006512 ;}
6513 break;
6514
Chris Lattner740e7092008-10-15 06:16:57 +00006515 case 321:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006516#line 3128 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006517 {
Reid Spencer14310612006-12-31 05:40:51 +00006518 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006519 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006520 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
Dan Gohmanf4423b12008-04-19 00:24:39 +00006521 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006522 GEN_ERROR(
6523 "Arithmetic operator requires integer, FP, or packed operands");
Eric Christopher2a5196f2008-09-24 04:55:49 +00006524 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006525 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006526 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006527 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006528 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006529 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006530 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006531 delete (yyvsp[(2) - (5)].TypeVal);
6532 ;}
6533 break;
6534
Chris Lattner740e7092008-10-15 06:16:57 +00006535 case 322:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006536#line 3144 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006537 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006538 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006539 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6540 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
Nate Begeman5bc1ea02008-07-29 15:49:41 +00006541 if (!isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00006542 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006543 GEN_ERROR("Logical operator requires integral operands");
6544 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006545 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006546 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006547 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006548 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006549 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006550 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006551 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006552 delete (yyvsp[(2) - (5)].TypeVal);
6553 ;}
6554 break;
6555
Chris Lattner740e7092008-10-15 06:16:57 +00006556 case 323:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006557#line 3161 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006558 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006559 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006560 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006561 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006562 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006563 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006564 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006565 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006566 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006567 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006568 delete (yyvsp[(3) - (6)].TypeVal);
6569 ;}
6570 break;
6571
Chris Lattner740e7092008-10-15 06:16:57 +00006572 case 324:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006573#line 3173 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006574 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006575 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006576 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006577 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006578 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006579 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006580 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006581 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006582 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006583 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006584 delete (yyvsp[(3) - (6)].TypeVal);
6585 ;}
6586 break;
6587
Chris Lattner740e7092008-10-15 06:16:57 +00006588 case 325:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006589#line 3185 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006590 {
6591 if (!UpRefs.empty())
6592 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6593 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6594 GEN_ERROR("Scalar types not supported by vicmp instruction");
6595 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6596 CHECK_FOR_ERROR
6597 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6598 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006599 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006600 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006601 GEN_ERROR("vicmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006602 delete (yyvsp[(3) - (6)].TypeVal);
6603 ;}
6604 break;
6605
Chris Lattner740e7092008-10-15 06:16:57 +00006606 case 326:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006607#line 3199 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006608 {
6609 if (!UpRefs.empty())
6610 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6611 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6612 GEN_ERROR("Scalar types not supported by vfcmp instruction");
6613 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6614 CHECK_FOR_ERROR
6615 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6616 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006617 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006618 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006619 GEN_ERROR("vfcmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006620 delete (yyvsp[(3) - (6)].TypeVal);
6621 ;}
6622 break;
6623
Chris Lattner740e7092008-10-15 06:16:57 +00006624 case 327:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006625#line 3213 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006626 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006627 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006628 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6629 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6630 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6631 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006632 GEN_ERROR("invalid cast opcode for cast from '" +
6633 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00006634 DestTy->getDescription() + "'");
Dan Gohmane4977cf2008-05-23 01:55:30 +00006635 (yyval.InstVal) = CastInst::Create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006636 delete (yyvsp[(4) - (4)].TypeVal);
6637 ;}
6638 break;
6639
Chris Lattner740e7092008-10-15 06:16:57 +00006640 case 328:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006641#line 3225 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006642 {
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006643 if (isa<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType())) {
6644 // vector select
6645 if (!isa<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType())
6646 || !isa<VectorType>((yyvsp[(6) - (6)].ValueVal)->getType()) )
6647 GEN_ERROR("vector select value types must be vector types");
6648 const VectorType* cond_type = cast<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType());
6649 const VectorType* select_type = cast<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType());
6650 if (cond_type->getElementType() != Type::Int1Ty)
6651 GEN_ERROR("vector select condition element type must be boolean");
6652 if (cond_type->getNumElements() != select_type->getNumElements())
6653 GEN_ERROR("vector select number of elements must be the same");
6654 } else {
6655 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
6656 GEN_ERROR("select condition must be boolean");
6657 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006658 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006659 GEN_ERROR("select value types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006660 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006661 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006662 ;}
6663 break;
6664
Chris Lattner740e7092008-10-15 06:16:57 +00006665 case 329:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006666#line 3246 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006667 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006668 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006669 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6670 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6671 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006672 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006673 ;}
6674 break;
6675
Chris Lattner740e7092008-10-15 06:16:57 +00006676 case 330:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006677#line 3253 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006678 {
6679 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006680 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006681 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006682 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006683 ;}
6684 break;
6685
Chris Lattner740e7092008-10-15 06:16:57 +00006686 case 331:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006687#line 3259 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006688 {
6689 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006690 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006691 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006692 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006693 ;}
6694 break;
6695
Chris Lattner740e7092008-10-15 06:16:57 +00006696 case 332:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006697#line 3265 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006698 {
6699 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006700 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006701 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006702 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006703 ;}
6704 break;
6705
Chris Lattner740e7092008-10-15 06:16:57 +00006706 case 333:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006707#line 3271 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006708 {
6709 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006710 if (!Ty->isFirstClassType())
6711 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006712 (yyval.InstVal) = PHINode::Create(Ty);
6713 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6714 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006715 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006716 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006717 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6718 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006719 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006720 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006721 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006722 ;}
6723 break;
6724
Chris Lattner740e7092008-10-15 06:16:57 +00006725 case 334:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006726#line 3287 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006727 {
Reid Spencer14310612006-12-31 05:40:51 +00006728
6729 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006730 const PointerType *PFTy = 0;
6731 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006732 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (9)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006733 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6734 // Pull out the types of all of the arguments...
6735 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006736 ParamList::iterator I = (yyvsp[(7) - (9)].ParamList)->begin(), E = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006737 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006738 const Type *Ty = I->Val->getType();
6739 if (Ty == Type::VoidTy)
6740 GEN_ERROR("Short call syntax cannot be used with varargs");
6741 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006742 }
Chris Lattnera925a142008-04-23 05:37:08 +00006743
Devang Patel652203f2008-09-29 20:49:50 +00006744 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (9)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006745 GEN_ERROR("Invalid result type for LLVM function");
6746
Devang Patel652203f2008-09-29 20:49:50 +00006747 Ty = FunctionType::get((yyvsp[(4) - (9)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006748 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006749 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006750
Devang Patel652203f2008-09-29 20:49:50 +00006751 Value *V = getVal(PFTy, (yyvsp[(5) - (9)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006752 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006753
Reid Spencer7780acb2007-04-16 06:56:07 +00006754 // Check for call to invalid intrinsic to avoid crashing later.
6755 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006756 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006757 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6758 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006759 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6760 theF->getName() + "'");
6761 }
6762
Devang Patel05988662008-09-25 21:00:45 +00006763 // Set up the Attributes for the function
6764 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006765 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6766 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006767 Attributes RetAttrs = (yyvsp[(3) - (9)].Attributes);
6768 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None) {
6769 if ((yyvsp[(9) - (9)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006770 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006771 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006772 }
Devang Patel652203f2008-09-29 20:49:50 +00006773 if ((yyvsp[(9) - (9)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006774 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006775 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006776 }
Devang Patel652203f2008-09-29 20:49:50 +00006777 if ((yyvsp[(9) - (9)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006778 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006779 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006780 }
Dale Johannesene7261862008-09-26 23:46:20 +00006781 }
Devang Patel652203f2008-09-29 20:49:50 +00006782 if (RetAttrs != Attribute::None)
6783 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006784
Eric Christopher2a5196f2008-09-24 04:55:49 +00006785 // Check the arguments
Reid Spencer14310612006-12-31 05:40:51 +00006786 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006787 if ((yyvsp[(7) - (9)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006788 // Make sure no arguments is a good thing!
6789 if (Ty->getNumParams() != 0)
6790 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006791 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006792 } else { // Has arguments?
6793 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006794 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006795 FunctionType::param_iterator I = Ty->param_begin();
6796 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006797 ParamList::iterator ArgI = (yyvsp[(7) - (9)].ParamList)->begin(), ArgE = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006798 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006799
Duncan Sandsdc024672007-11-27 13:23:08 +00006800 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006801 if (ArgI->Val->getType() != *I)
6802 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006803 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006804 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006805 if (ArgI->Attrs != Attribute::None)
6806 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006807 }
6808 if (Ty->isVarArg()) {
6809 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006810 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006811 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006812 if (ArgI->Attrs != Attribute::None)
6813 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006814 }
Reid Spencer14310612006-12-31 05:40:51 +00006815 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006816 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006817 }
Devang Patel652203f2008-09-29 20:49:50 +00006818 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None)
6819 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (9)].Attributes)));
Duncan Sandsdc024672007-11-27 13:23:08 +00006820
Devang Patel05988662008-09-25 21:00:45 +00006821 // Finish off the Attributes and check them
6822 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006823 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006824 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006825
Reid Spencer14310612006-12-31 05:40:51 +00006826 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006827 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006828 CI->setTailCall((yyvsp[(1) - (9)].BoolVal));
6829 CI->setCallingConv((yyvsp[(2) - (9)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006830 CI->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006831 (yyval.InstVal) = CI;
Devang Patel652203f2008-09-29 20:49:50 +00006832 delete (yyvsp[(7) - (9)].ParamList);
6833 delete (yyvsp[(4) - (9)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006834 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006835 ;}
6836 break;
6837
Chris Lattner740e7092008-10-15 06:16:57 +00006838 case 335:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006839#line 3396 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006840 {
6841 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006842 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006843 ;}
6844 break;
6845
Chris Lattner740e7092008-10-15 06:16:57 +00006846 case 336:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006847#line 3401 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006848 {
6849 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006850 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006851 ;}
6852 break;
6853
Chris Lattner740e7092008-10-15 06:16:57 +00006854 case 337:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006855#line 3405 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006856 {
6857 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006858 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006859 ;}
6860 break;
6861
Chris Lattner740e7092008-10-15 06:16:57 +00006862 case 338:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006863#line 3412 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006864 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006865 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006866 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6867 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6868 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006869 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006870 ;}
6871 break;
6872
Chris Lattner740e7092008-10-15 06:16:57 +00006873 case 339:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006874#line 3419 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006875 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006876 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006877 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006878 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6879 GEN_ERROR("Malloc array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006880 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006881 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006882 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6883 delete (yyvsp[(2) - (6)].TypeVal);
6884 ;}
6885 break;
6886
Chris Lattner740e7092008-10-15 06:16:57 +00006887 case 340:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006888#line 3429 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006889 {
Reid Spencer14310612006-12-31 05:40:51 +00006890 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006891 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6892 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6893 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006894 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006895 ;}
6896 break;
6897
Chris Lattner740e7092008-10-15 06:16:57 +00006898 case 341:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006899#line 3436 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006900 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006901 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006902 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006903 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6904 GEN_ERROR("Alloca array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006905 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006906 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006907 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6908 delete (yyvsp[(2) - (6)].TypeVal);
6909 ;}
6910 break;
6911
Chris Lattner740e7092008-10-15 06:16:57 +00006912 case 342:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006913#line 3446 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006914 {
6915 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Eric Christopher2a5196f2008-09-24 04:55:49 +00006916 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006917 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6918 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006919 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006920 ;}
6921 break;
6922
Chris Lattner740e7092008-10-15 06:16:57 +00006923 case 343:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006924#line 3454 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006925 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006926 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006927 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6928 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006929 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006930 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6931 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006932 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006933 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6934 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006935 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006936 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6937 delete (yyvsp[(3) - (5)].TypeVal);
6938 ;}
6939 break;
6940
Chris Lattner740e7092008-10-15 06:16:57 +00006941 case 344:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006942#line 3468 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006943 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006944 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006945 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6946 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006947 if (!PT)
6948 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006949 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006950 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006951 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6952 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006953 "' into space of type '" + ElTy->getDescription() + "'");
6954
Dan Gohmanf4423b12008-04-19 00:24:39 +00006955 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006956 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006957 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6958 delete (yyvsp[(5) - (7)].TypeVal);
6959 ;}
6960 break;
6961
Chris Lattner740e7092008-10-15 06:16:57 +00006962 case 345:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006963#line 3485 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006964 {
Dan Gohman1a570242008-07-23 00:54:54 +00006965 if (!UpRefs.empty())
6966 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6967 if (!isa<StructType>((yyvsp[(2) - (5)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (5)].TypeVal)->get()))
6968 GEN_ERROR("getresult insn requires an aggregate operand");
6969 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].UInt64Val)))
6970 GEN_ERROR("Invalid getresult index for type '" +
6971 (*(yyvsp[(2) - (5)].TypeVal))->getDescription()+ "'");
6972
6973 Value *tmpVal = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Devang Patel5a970972008-02-19 22:27:01 +00006974 CHECK_FOR_ERROR
Dan Gohman1a570242008-07-23 00:54:54 +00006975 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(5) - (5)].UInt64Val));
6976 delete (yyvsp[(2) - (5)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006977 ;}
6978 break;
6979
Chris Lattner740e7092008-10-15 06:16:57 +00006980 case 346:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00006981#line 3499 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006982 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006983 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006984 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6985 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006986 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006987
Dan Gohman041e2eb2008-05-15 19:50:34 +00006988 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()))
Reid Spencer61c83e02006-08-18 08:43:06 +00006989 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006990 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6991 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006992 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006993 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006994 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006995 delete (yyvsp[(4) - (4)].ValueList);
6996 ;}
6997 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006998
Chris Lattner740e7092008-10-15 06:16:57 +00006999 case 347:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00007000#line 3514 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00007001 {
7002 if (!UpRefs.empty())
7003 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
7004 if (!isa<StructType>((yyvsp[(2) - (4)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (4)].TypeVal)->get()))
7005 GEN_ERROR("extractvalue insn requires an aggregate operand");
7006
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007007 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end()))
Dan Gohmane4977cf2008-05-23 01:55:30 +00007008 GEN_ERROR("Invalid extractvalue indices for type '" +
7009 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
7010 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
7011 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007012 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00007013 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007014 delete (yyvsp[(4) - (4)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007015 ;}
7016 break;
7017
Chris Lattner740e7092008-10-15 06:16:57 +00007018 case 348:
Nuno Lopes8a5f3472008-10-15 12:05:02 +00007019#line 3529 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00007020 {
7021 if (!UpRefs.empty())
7022 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (7)].TypeVal))->getDescription());
7023 if (!isa<StructType>((yyvsp[(2) - (7)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (7)].TypeVal)->get()))
7024 GEN_ERROR("extractvalue insn requires an aggregate operand");
7025
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007026 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 +00007027 GEN_ERROR("Invalid insertvalue indices for type '" +
7028 (*(yyvsp[(2) - (7)].TypeVal))->getDescription()+ "'");
7029 Value* aggVal = getVal(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(3) - (7)].ValIDVal));
7030 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
7031 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007032 (yyval.InstVal) = InsertValueInst::Create(aggVal, tmpVal, (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00007033 delete (yyvsp[(2) - (7)].TypeVal);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007034 delete (yyvsp[(5) - (7)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007035 delete (yyvsp[(7) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007036 ;}
7037 break;
7038
Dan Gohmanf4423b12008-04-19 00:24:39 +00007039
7040/* Line 1267 of yacc.c. */
Nuno Lopes8a5f3472008-10-15 12:05:02 +00007041#line 7042 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00007042 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00007043 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007044 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
7045
7046 YYPOPSTACK (yylen);
7047 yylen = 0;
7048 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007049
7050 *++yyvsp = yyval;
7051
7052
Dan Gohmanf4423b12008-04-19 00:24:39 +00007053 /* Now `shift' the result of the reduction. Determine what state
7054 that goes to, based on the state we popped back to and the rule
7055 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00007056
7057 yyn = yyr1[yyn];
7058
Dan Gohmanf4423b12008-04-19 00:24:39 +00007059 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
7060 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007061 yystate = yytable[yystate];
7062 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00007063 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00007064
7065 goto yynewstate;
7066
7067
Dan Gohmanf4423b12008-04-19 00:24:39 +00007068/*------------------------------------.
7069| yyerrlab -- here on detecting error |
7070`------------------------------------*/
7071yyerrlab:
7072 /* If not already recovering from an error, report this error. */
7073 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007074 {
7075 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007076#if ! YYERROR_VERBOSE
7077 yyerror (YY_("syntax error"));
7078#else
7079 {
7080 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
7081 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
7082 {
7083 YYSIZE_T yyalloc = 2 * yysize;
7084 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
7085 yyalloc = YYSTACK_ALLOC_MAXIMUM;
7086 if (yymsg != yymsgbuf)
7087 YYSTACK_FREE (yymsg);
7088 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
7089 if (yymsg)
7090 yymsg_alloc = yyalloc;
7091 else
7092 {
7093 yymsg = yymsgbuf;
7094 yymsg_alloc = sizeof yymsgbuf;
7095 }
7096 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00007097
Dan Gohmanf4423b12008-04-19 00:24:39 +00007098 if (0 < yysize && yysize <= yymsg_alloc)
7099 {
7100 (void) yysyntax_error (yymsg, yystate, yychar);
7101 yyerror (yymsg);
7102 }
7103 else
7104 {
7105 yyerror (YY_("syntax error"));
7106 if (yysize != 0)
7107 goto yyexhaustedlab;
7108 }
7109 }
7110#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007111 }
7112
Dan Gohmanf4423b12008-04-19 00:24:39 +00007113
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007114
7115 if (yyerrstatus == 3)
7116 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00007117 /* If just tried and failed to reuse look-ahead token after an
7118 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007119
Dan Gohmanf4423b12008-04-19 00:24:39 +00007120 if (yychar <= YYEOF)
7121 {
7122 /* Return failure if at end of input. */
7123 if (yychar == YYEOF)
7124 YYABORT;
7125 }
7126 else
7127 {
7128 yydestruct ("Error: discarding",
7129 yytoken, &yylval);
7130 yychar = YYEMPTY;
7131 }
7132 }
7133
7134 /* Else will try to reuse look-ahead token after shifting the error
7135 token. */
7136 goto yyerrlab1;
7137
7138
7139/*---------------------------------------------------.
7140| yyerrorlab -- error raised explicitly by YYERROR. |
7141`---------------------------------------------------*/
7142yyerrorlab:
7143
7144 /* Pacify compilers like GCC when the user code never invokes
7145 YYERROR and the label yyerrorlab therefore never appears in user
7146 code. */
7147 if (/*CONSTCOND*/ 0)
7148 goto yyerrorlab;
7149
7150 /* Do not reclaim the symbols of the rule which action triggered
7151 this YYERROR. */
7152 YYPOPSTACK (yylen);
7153 yylen = 0;
7154 YY_STACK_PRINT (yyss, yyssp);
7155 yystate = *yyssp;
7156 goto yyerrlab1;
7157
7158
7159/*-------------------------------------------------------------.
7160| yyerrlab1 -- common code for both syntax error and YYERROR. |
7161`-------------------------------------------------------------*/
7162yyerrlab1:
7163 yyerrstatus = 3; /* Each real token shifted decrements this. */
7164
7165 for (;;)
7166 {
7167 yyn = yypact[yystate];
7168 if (yyn != YYPACT_NINF)
7169 {
7170 yyn += YYTERROR;
7171 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7172 {
7173 yyn = yytable[yyn];
7174 if (0 < yyn)
7175 break;
7176 }
7177 }
7178
7179 /* Pop the current state because it cannot handle the error token. */
7180 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007181 YYABORT;
7182
Dale Johannesencdd509a2007-09-07 21:07:57 +00007183
Dan Gohmanf4423b12008-04-19 00:24:39 +00007184 yydestruct ("Error: popping",
7185 yystos[yystate], yyvsp);
7186 YYPOPSTACK (1);
7187 yystate = *yyssp;
7188 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007189 }
7190
7191 if (yyn == YYFINAL)
7192 YYACCEPT;
7193
Reid Spencer68a24bd2005-08-27 18:50:39 +00007194 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007195
7196
7197 /* Shift the error token. */
7198 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00007199
Reid Spencer68a24bd2005-08-27 18:50:39 +00007200 yystate = yyn;
7201 goto yynewstate;
7202
Gabor Greife64d2482008-04-06 23:07:54 +00007203
Dan Gohmanf4423b12008-04-19 00:24:39 +00007204/*-------------------------------------.
7205| yyacceptlab -- YYACCEPT comes here. |
7206`-------------------------------------*/
7207yyacceptlab:
7208 yyresult = 0;
7209 goto yyreturn;
7210
7211/*-----------------------------------.
7212| yyabortlab -- YYABORT comes here. |
7213`-----------------------------------*/
7214yyabortlab:
7215 yyresult = 1;
7216 goto yyreturn;
7217
7218#ifndef yyoverflow
7219/*-------------------------------------------------.
7220| yyexhaustedlab -- memory exhaustion comes here. |
7221`-------------------------------------------------*/
7222yyexhaustedlab:
7223 yyerror (YY_("memory exhausted"));
7224 yyresult = 2;
7225 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00007226#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00007227
7228yyreturn:
7229 if (yychar != YYEOF && yychar != YYEMPTY)
7230 yydestruct ("Cleanup: discarding lookahead",
7231 yytoken, &yylval);
7232 /* Do not reclaim the symbols of the rule which action triggered
7233 this YYABORT or YYACCEPT. */
7234 YYPOPSTACK (yylen);
7235 YY_STACK_PRINT (yyss, yyssp);
7236 while (yyssp != yyss)
7237 {
7238 yydestruct ("Cleanup: popping",
7239 yystos[*yyssp], yyvsp);
7240 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00007241 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007242#ifndef yyoverflow
7243 if (yyss != yyssa)
7244 YYSTACK_FREE (yyss);
7245#endif
7246#if YYERROR_VERBOSE
7247 if (yymsg != yymsgbuf)
7248 YYSTACK_FREE (yymsg);
7249#endif
7250 /* Make sure YYID is used. */
7251 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007252}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007253
7254
Nuno Lopes8a5f3472008-10-15 12:05:02 +00007255#line 3548 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00007256
7257
Reid Spencer14310612006-12-31 05:40:51 +00007258// common code from the two 'RunVMAsmParser' functions
7259static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00007260 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00007261 // Check to make sure the parser succeeded
7262 if (yyparse()) {
7263 if (ParserResult)
7264 delete ParserResult;
7265 return 0;
7266 }
7267
Reid Spencer0d60b5a2007-03-30 01:37:39 +00007268 // Emit an error if there are any unresolved types left.
7269 if (!CurModule.LateResolveTypes.empty()) {
7270 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
7271 if (DID.Type == ValID::LocalName) {
7272 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
7273 } else {
7274 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
7275 }
7276 if (ParserResult)
7277 delete ParserResult;
7278 return 0;
7279 }
7280
7281 // Emit an error if there are any unresolved values left.
7282 if (!CurModule.LateResolveValues.empty()) {
7283 Value *V = CurModule.LateResolveValues.back();
7284 std::map<Value*, std::pair<ValID, int> >::iterator I =
7285 CurModule.PlaceHolderInfo.find(V);
7286
7287 if (I != CurModule.PlaceHolderInfo.end()) {
7288 ValID &DID = I->second.first;
7289 if (DID.Type == ValID::LocalName) {
7290 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
7291 } else {
7292 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
7293 }
7294 if (ParserResult)
7295 delete ParserResult;
7296 return 0;
7297 }
7298 }
7299
Reid Spencer14310612006-12-31 05:40:51 +00007300 // Check to make sure that parsing produced a result
7301 if (!ParserResult)
7302 return 0;
7303
7304 // Reset ParserResult variable while saving its value for the result.
7305 Module *Result = ParserResult;
7306 ParserResult = 0;
7307
7308 return Result;
7309}
7310
Reid Spencer61c83e02006-08-18 08:43:06 +00007311void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007312 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00007313 // TODO: column number in exception
7314 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00007315 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00007316 TriggerError = 1;
7317}
Reid Spencer68a24bd2005-08-27 18:50:39 +00007318
7319int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007320 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00007321 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00007322 if (yychar != YYEMPTY && yychar != 0) {
7323 errMsg += " while reading token: '";
Eric Christopher2a5196f2008-09-24 04:55:49 +00007324 errMsg += std::string(LLLgetTokenStart(),
Duncan Sandsdc024672007-11-27 13:23:08 +00007325 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
7326 }
Reid Spencer61c83e02006-08-18 08:43:06 +00007327 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007328 return 0;
7329}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007330