blob: eb6f6d7885a55b63a2cf83c7233cd0d7e98939d3 [file] [log] [blame]
Dan Gohmanf4423b12008-04-19 00:24:39 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Dan Gohmanf4423b12008-04-19 00:24:39 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004
Dan Gohmanf4423b12008-04-19 00:24:39 +00005 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Anton Korobeynikov178a3522007-01-12 19:22:51 +00007
Dan Gohmanf4423b12008-04-19 00:24:39 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
49/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
61/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000062#define yyparse llvmAsmparse
Dan Gohmanf4423b12008-04-19 00:24:39 +000063#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000064#define yyerror llvmAsmerror
Dan Gohmanf4423b12008-04-19 00:24:39 +000065#define yylval llvmAsmlval
66#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000067#define yydebug llvmAsmdebug
68#define yynerrs llvmAsmnerrs
69
Dan Gohmanf4423b12008-04-19 00:24:39 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 ESAPINTVAL = 260,
80 EUAPINTVAL = 261,
81 LOCALVAL_ID = 262,
82 GLOBALVAL_ID = 263,
83 FPVAL = 264,
84 VOID = 265,
85 INTTYPE = 266,
86 FLOAT = 267,
87 DOUBLE = 268,
88 X86_FP80 = 269,
89 FP128 = 270,
90 PPC_FP128 = 271,
91 LABEL = 272,
92 TYPE = 273,
93 LOCALVAR = 274,
94 GLOBALVAR = 275,
95 LABELSTR = 276,
96 STRINGCONSTANT = 277,
97 ATSTRINGCONSTANT = 278,
98 PCTSTRINGCONSTANT = 279,
99 ZEROINITIALIZER = 280,
100 TRUETOK = 281,
101 FALSETOK = 282,
102 BEGINTOK = 283,
103 ENDTOK = 284,
104 DECLARE = 285,
105 DEFINE = 286,
106 GLOBAL = 287,
107 CONSTANT = 288,
108 SECTION = 289,
109 ALIAS = 290,
110 VOLATILE = 291,
111 THREAD_LOCAL = 292,
112 TO = 293,
113 DOTDOTDOT = 294,
114 NULL_TOK = 295,
115 UNDEF = 296,
116 INTERNAL = 297,
117 LINKONCE = 298,
118 WEAK = 299,
119 APPENDING = 300,
120 DLLIMPORT = 301,
121 DLLEXPORT = 302,
122 EXTERN_WEAK = 303,
Dale Johannesenc7071cc2008-05-14 20:13:36 +0000123 COMMON = 304,
124 OPAQUE = 305,
125 EXTERNAL = 306,
126 TARGET = 307,
127 TRIPLE = 308,
128 ALIGN = 309,
129 ADDRSPACE = 310,
130 DEPLIBS = 311,
131 CALL = 312,
132 TAIL = 313,
133 ASM_TOK = 314,
134 MODULE = 315,
135 SIDEEFFECT = 316,
136 CC_TOK = 317,
137 CCC_TOK = 318,
138 FASTCC_TOK = 319,
139 COLDCC_TOK = 320,
140 X86_STDCALLCC_TOK = 321,
141 X86_FASTCALLCC_TOK = 322,
Dale Johannesendfe8c842008-09-26 19:32:34 +0000142 DATALAYOUT = 323,
143 RET = 324,
144 BR = 325,
145 SWITCH = 326,
146 INVOKE = 327,
147 UNWIND = 328,
148 UNREACHABLE = 329,
149 ADD = 330,
150 SUB = 331,
151 MUL = 332,
152 UDIV = 333,
153 SDIV = 334,
154 FDIV = 335,
155 UREM = 336,
156 SREM = 337,
157 FREM = 338,
158 AND = 339,
159 OR = 340,
160 XOR = 341,
161 SHL = 342,
162 LSHR = 343,
163 ASHR = 344,
164 ICMP = 345,
165 FCMP = 346,
166 VICMP = 347,
167 VFCMP = 348,
168 EQ = 349,
169 NE = 350,
170 SLT = 351,
171 SGT = 352,
172 SLE = 353,
173 SGE = 354,
174 ULT = 355,
175 UGT = 356,
176 ULE = 357,
177 UGE = 358,
178 OEQ = 359,
179 ONE = 360,
180 OLT = 361,
181 OGT = 362,
182 OLE = 363,
183 OGE = 364,
184 ORD = 365,
185 UNO = 366,
186 UEQ = 367,
187 UNE = 368,
188 MALLOC = 369,
189 ALLOCA = 370,
190 FREE = 371,
191 LOAD = 372,
192 STORE = 373,
193 GETELEMENTPTR = 374,
194 TRUNC = 375,
195 ZEXT = 376,
196 SEXT = 377,
197 FPTRUNC = 378,
198 FPEXT = 379,
199 BITCAST = 380,
200 UITOFP = 381,
201 SITOFP = 382,
202 FPTOUI = 383,
203 FPTOSI = 384,
204 INTTOPTR = 385,
205 PTRTOINT = 386,
206 PHI_TOK = 387,
207 SELECT = 388,
208 VAARG = 389,
209 EXTRACTELEMENT = 390,
210 INSERTELEMENT = 391,
211 SHUFFLEVECTOR = 392,
212 GETRESULT = 393,
213 EXTRACTVALUE = 394,
214 INSERTVALUE = 395,
215 SIGNEXT = 396,
216 ZEROEXT = 397,
217 NORETURN = 398,
218 INREG = 399,
219 SRET = 400,
220 NOUNWIND = 401,
221 NOALIAS = 402,
222 BYVAL = 403,
223 NEST = 404,
224 READNONE = 405,
225 READONLY = 406,
226 GC = 407,
Devang Patel652203f2008-09-29 20:49:50 +0000227 OPTSIZE = 408,
228 NOINLINE = 409,
229 ALWAYSINLINE = 410,
230 DEFAULT = 411,
231 HIDDEN = 412,
232 PROTECTED = 413
Dan Gohmanf4423b12008-04-19 00:24:39 +0000233 };
234#endif
235/* Tokens. */
236#define ESINT64VAL 258
237#define EUINT64VAL 259
238#define ESAPINTVAL 260
239#define EUAPINTVAL 261
240#define LOCALVAL_ID 262
241#define GLOBALVAL_ID 263
242#define FPVAL 264
243#define VOID 265
244#define INTTYPE 266
245#define FLOAT 267
246#define DOUBLE 268
247#define X86_FP80 269
248#define FP128 270
249#define PPC_FP128 271
250#define LABEL 272
251#define TYPE 273
252#define LOCALVAR 274
253#define GLOBALVAR 275
254#define LABELSTR 276
255#define STRINGCONSTANT 277
256#define ATSTRINGCONSTANT 278
257#define PCTSTRINGCONSTANT 279
258#define ZEROINITIALIZER 280
259#define TRUETOK 281
260#define FALSETOK 282
261#define BEGINTOK 283
262#define ENDTOK 284
263#define DECLARE 285
264#define DEFINE 286
265#define GLOBAL 287
266#define CONSTANT 288
267#define SECTION 289
268#define ALIAS 290
269#define VOLATILE 291
270#define THREAD_LOCAL 292
271#define TO 293
272#define DOTDOTDOT 294
273#define NULL_TOK 295
274#define UNDEF 296
275#define INTERNAL 297
276#define LINKONCE 298
277#define WEAK 299
278#define APPENDING 300
279#define DLLIMPORT 301
280#define DLLEXPORT 302
281#define EXTERN_WEAK 303
Dale Johannesenc7071cc2008-05-14 20:13:36 +0000282#define COMMON 304
283#define OPAQUE 305
284#define EXTERNAL 306
285#define TARGET 307
286#define TRIPLE 308
287#define ALIGN 309
288#define ADDRSPACE 310
289#define DEPLIBS 311
290#define CALL 312
291#define TAIL 313
292#define ASM_TOK 314
293#define MODULE 315
294#define SIDEEFFECT 316
295#define CC_TOK 317
296#define CCC_TOK 318
297#define FASTCC_TOK 319
298#define COLDCC_TOK 320
299#define X86_STDCALLCC_TOK 321
300#define X86_FASTCALLCC_TOK 322
Dale Johannesendfe8c842008-09-26 19:32:34 +0000301#define DATALAYOUT 323
302#define RET 324
303#define BR 325
304#define SWITCH 326
305#define INVOKE 327
306#define UNWIND 328
307#define UNREACHABLE 329
308#define ADD 330
309#define SUB 331
310#define MUL 332
311#define UDIV 333
312#define SDIV 334
313#define FDIV 335
314#define UREM 336
315#define SREM 337
316#define FREM 338
317#define AND 339
318#define OR 340
319#define XOR 341
320#define SHL 342
321#define LSHR 343
322#define ASHR 344
323#define ICMP 345
324#define FCMP 346
325#define VICMP 347
326#define VFCMP 348
327#define EQ 349
328#define NE 350
329#define SLT 351
330#define SGT 352
331#define SLE 353
332#define SGE 354
333#define ULT 355
334#define UGT 356
335#define ULE 357
336#define UGE 358
337#define OEQ 359
338#define ONE 360
339#define OLT 361
340#define OGT 362
341#define OLE 363
342#define OGE 364
343#define ORD 365
344#define UNO 366
345#define UEQ 367
346#define UNE 368
347#define MALLOC 369
348#define ALLOCA 370
349#define FREE 371
350#define LOAD 372
351#define STORE 373
352#define GETELEMENTPTR 374
353#define TRUNC 375
354#define ZEXT 376
355#define SEXT 377
356#define FPTRUNC 378
357#define FPEXT 379
358#define BITCAST 380
359#define UITOFP 381
360#define SITOFP 382
361#define FPTOUI 383
362#define FPTOSI 384
363#define INTTOPTR 385
364#define PTRTOINT 386
365#define PHI_TOK 387
366#define SELECT 388
367#define VAARG 389
368#define EXTRACTELEMENT 390
369#define INSERTELEMENT 391
370#define SHUFFLEVECTOR 392
371#define GETRESULT 393
372#define EXTRACTVALUE 394
373#define INSERTVALUE 395
374#define SIGNEXT 396
375#define ZEROEXT 397
376#define NORETURN 398
377#define INREG 399
378#define SRET 400
379#define NOUNWIND 401
380#define NOALIAS 402
381#define BYVAL 403
382#define NEST 404
383#define READNONE 405
384#define READONLY 406
385#define GC 407
Devang Patel652203f2008-09-29 20:49:50 +0000386#define OPTSIZE 408
387#define NOINLINE 409
388#define ALWAYSINLINE 410
389#define DEFAULT 411
390#define HIDDEN 412
391#define PROTECTED 413
Dan Gohmanf4423b12008-04-19 00:24:39 +0000392
393
394
395
396/* Copy the first part of user declarations. */
Nuno Lopes6ec8a252008-10-15 11:11:12 +0000397#line 14 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000398
399#include "ParserInternals.h"
400#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000401#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000402#include "llvm/Instructions.h"
403#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000404#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000405#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000406#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000407#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000408#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000409#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000410#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000411#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000412#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000413#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000414#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000415#include <utility>
416
Reid Spencere4f47592006-08-18 17:32:55 +0000417// The following is a gross hack. In order to rid the libAsmParser library of
418// exceptions, we have to have a way of getting the yyparse function to go into
419// an error situation. So, whenever we want an error to occur, the GenerateError
Eric Christopher2a5196f2008-09-24 04:55:49 +0000420// function (see bottom of file) sets TriggerError. Then, at the end of each
421// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
422// (a goto) to put YACC in error state. Furthermore, several calls to
Reid Spencere4f47592006-08-18 17:32:55 +0000423// GenerateError are made from inside productions and they must simulate the
424// previous exception behavior by exiting the production immediately. We have
425// replaced these with the GEN_ERROR macro which calls GeneratError and then
Eric Christopher2a5196f2008-09-24 04:55:49 +0000426// immediately invokes YYERROR. This would be so much cleaner if it was a
Reid Spencere4f47592006-08-18 17:32:55 +0000427// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000428static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000429#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000430#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
431
Reid Spencer68a24bd2005-08-27 18:50:39 +0000432int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
433int yylex(); // declaration" of xxx warnings.
434int yyparse();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000435using namespace llvm;
436
437static Module *ParserResult;
438
439// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
440// relating to upreferences in the input stream.
441//
442//#define DEBUG_UPREFS 1
443#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000444#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000445#else
446#define UR_OUT(X)
447#endif
448
449#define YYERROR_VERBOSE 1
450
Chris Lattnerb475c422005-11-12 18:22:38 +0000451static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000452
453
454// This contains info used when building the body of a function. It is
455// destroyed when the function is completed.
456//
457typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000458
Eric Christopher2a5196f2008-09-24 04:55:49 +0000459static void
Reid Spencer93c40032007-03-19 18:40:50 +0000460ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000461
462static struct PerModuleInfo {
463 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000464 ValueList Values; // Module level numbered definitions
465 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000466 std::vector<PATypeHolder> Types;
467 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000468
469 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000470 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000471 /// that we can resolve them later and print error messages as appropriate.
472 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
473
474 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
475 // references to global values. Global values may be referenced before they
476 // are defined, and if so, the temporary object that they represent is held
477 // here. This is used for forward references of GlobalValues.
478 //
479 typedef std::map<std::pair<const PointerType *,
480 ValID>, GlobalValue*> GlobalRefsType;
481 GlobalRefsType GlobalRefs;
482
483 void ModuleDone() {
484 // If we could not resolve some functions at function compilation time
485 // (calls to functions before they are defined), resolve them now... Types
486 // are resolved when the constant pool has been completely parsed.
487 //
488 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000489 if (TriggerError)
490 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000491
492 // Check to make sure that all global value forward references have been
493 // resolved!
494 //
495 if (!GlobalRefs.empty()) {
496 std::string UndefinedReferences = "Unresolved global references exist:\n";
497
498 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
499 I != E; ++I) {
500 UndefinedReferences += " " + I->first.first->getDescription() + " " +
501 I->first.second.getName() + "\n";
502 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000503 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000504 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000505 }
506
Chandler Carruth02202192007-08-04 01:56:21 +0000507 // Look for intrinsic functions and CallInst that need to be upgraded
508 for (Module::iterator FI = CurrentModule->begin(),
509 FE = CurrentModule->end(); FI != FE; )
510 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
511
Reid Spencer68a24bd2005-08-27 18:50:39 +0000512 Values.clear(); // Clear out function local definitions
513 Types.clear();
514 CurrentModule = 0;
515 }
516
Reid Spencer68a24bd2005-08-27 18:50:39 +0000517 // GetForwardRefForGlobal - Check to see if there is a forward reference
518 // for this global. If so, remove it from the GlobalRefs map and return it.
519 // If not, just return null.
520 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
521 // Check to see if there is a forward reference to this global variable...
522 // if there is, eliminate it and patch the reference to use the new def'n.
523 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
524 GlobalValue *Ret = 0;
525 if (I != GlobalRefs.end()) {
526 Ret = I->second;
527 GlobalRefs.erase(I);
528 }
529 return Ret;
530 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000531
532 bool TypeIsUnresolved(PATypeHolder* PATy) {
533 // If it isn't abstract, its resolved
534 const Type* Ty = PATy->get();
535 if (!Ty->isAbstract())
536 return false;
537 // Traverse the type looking for abstract types. If it isn't abstract then
Eric Christopher2a5196f2008-09-24 04:55:49 +0000538 // we don't need to traverse that leg of the type.
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000539 std::vector<const Type*> WorkList, SeenList;
540 WorkList.push_back(Ty);
541 while (!WorkList.empty()) {
542 const Type* Ty = WorkList.back();
543 SeenList.push_back(Ty);
544 WorkList.pop_back();
545 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
546 // Check to see if this is an unresolved type
547 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
548 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
549 for ( ; I != E; ++I) {
550 if (I->second.get() == OpTy)
551 return true;
552 }
553 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
554 const Type* TheTy = SeqTy->getElementType();
555 if (TheTy->isAbstract() && TheTy != Ty) {
Eric Christopher2a5196f2008-09-24 04:55:49 +0000556 std::vector<const Type*>::iterator I = SeenList.begin(),
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000557 E = SeenList.end();
558 for ( ; I != E; ++I)
559 if (*I == TheTy)
560 break;
561 if (I == E)
562 WorkList.push_back(TheTy);
563 }
564 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
565 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
566 const Type* TheTy = StrTy->getElementType(i);
567 if (TheTy->isAbstract() && TheTy != Ty) {
Eric Christopher2a5196f2008-09-24 04:55:49 +0000568 std::vector<const Type*>::iterator I = SeenList.begin(),
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000569 E = SeenList.end();
570 for ( ; I != E; ++I)
571 if (*I == TheTy)
572 break;
573 if (I == E)
574 WorkList.push_back(TheTy);
575 }
576 }
577 }
578 }
579 return false;
580 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000581} CurModule;
582
583static struct PerFunctionInfo {
584 Function *CurrentFunction; // Pointer to current function being created
585
Reid Spencer93c40032007-03-19 18:40:50 +0000586 ValueList Values; // Keep track of #'d definitions
587 unsigned NextValNum;
588 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000589 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000590 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000591 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000592
593 /// BBForwardRefs - When we see forward references to basic blocks, keep
594 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000595 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000596
597 inline PerFunctionInfo() {
598 CurrentFunction = 0;
599 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000600 Linkage = GlobalValue::ExternalLinkage;
601 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000602 }
603
604 inline void FunctionStart(Function *M) {
605 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000606 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000607 }
608
609 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000610 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000611 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000612 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000613 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000614 return;
615 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000616
617 // Resolve all forward references now.
618 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
619
620 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000621 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000622 CurrentFunction = 0;
623 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000624 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000625 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626 }
627} CurFun; // Info for the current function...
628
629static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
630
631
632//===----------------------------------------------------------------------===//
633// Code to handle definitions of all the types
634//===----------------------------------------------------------------------===//
635
Chris Lattner15bd0952008-08-29 17:20:18 +0000636/// InsertValue - Insert a value into the value table. If it is named, this
637/// returns -1, otherwise it returns the slot number for the value.
638static int InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
Reid Spencer93c40032007-03-19 18:40:50 +0000639 // Things that have names or are void typed don't get slot numbers
640 if (V->hasName() || (V->getType() == Type::VoidTy))
Chris Lattner15bd0952008-08-29 17:20:18 +0000641 return -1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000642
Reid Spencer93c40032007-03-19 18:40:50 +0000643 // In the case of function values, we have to allow for the forward reference
644 // of basic blocks, which are included in the numbering. Consequently, we keep
Eric Christopher2a5196f2008-09-24 04:55:49 +0000645 // track of the next insertion location with NextValNum. When a BB gets
Reid Spencer93c40032007-03-19 18:40:50 +0000646 // inserted, it could change the size of the CurFun.Values vector.
647 if (&ValueTab == &CurFun.Values) {
648 if (ValueTab.size() <= CurFun.NextValNum)
649 ValueTab.resize(CurFun.NextValNum+1);
650 ValueTab[CurFun.NextValNum++] = V;
Chris Lattner15bd0952008-08-29 17:20:18 +0000651 return CurFun.NextValNum-1;
Eric Christopher2a5196f2008-09-24 04:55:49 +0000652 }
Reid Spencer93c40032007-03-19 18:40:50 +0000653 // For all other lists, its okay to just tack it on the back of the vector.
654 ValueTab.push_back(V);
Chris Lattner15bd0952008-08-29 17:20:18 +0000655 return ValueTab.size()-1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000656}
657
658static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
659 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000660 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000661 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000662 if (D.Num < CurModule.Types.size())
663 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000664 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000665 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000666 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000667 D.destroy(); // Free old strdup'd memory...
668 return N;
669 }
670 break;
671 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000672 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000673 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000674 }
675
676 // If we reached here, we referenced either a symbol that we don't know about
677 // or an id number that hasn't been read yet. We may be referencing something
678 // forward, so just create an entry to be resolved later and get to it...
679 //
680 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
681
682
683 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000684 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000685 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000686 return 0;
687 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000688 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000689 return 0;
690 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000691 }
692
Reid Spencer861d9d62006-11-28 07:29:44 +0000693 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Nuno Lopesf05ff662008-10-15 11:20:21 +0000694 if (I != CurModule.LateResolveTypes.end()) {
695 D.destroy();
Reid Spencer861d9d62006-11-28 07:29:44 +0000696 return I->second;
Nuno Lopesf05ff662008-10-15 11:20:21 +0000697 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000698
Reid Spencer861d9d62006-11-28 07:29:44 +0000699 Type *Typ = OpaqueType::get();
700 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
701 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000702 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000703
Reid Spencer93c40032007-03-19 18:40:50 +0000704// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000705// the provided ValID. If the value exists and has already been defined, return
706// it. Otherwise return null.
707//
Reid Spencer93c40032007-03-19 18:40:50 +0000708static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000709 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000710 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000711 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000712 return 0;
713 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000714
715 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000716 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000717 // Check that the number is within bounds.
Eric Christopher2a5196f2008-09-24 04:55:49 +0000718 if (D.Num >= CurFun.Values.size())
Reid Spencer93c40032007-03-19 18:40:50 +0000719 return 0;
720 Value *Result = CurFun.Values[D.Num];
721 if (Ty != Result->getType()) {
722 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +0000723 Result->getType()->getDescription() + "' does not match "
Reid Spencer93c40032007-03-19 18:40:50 +0000724 "expected type, '" + Ty->getDescription() + "'");
725 return 0;
726 }
727 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000728 }
729 case ValID::GlobalID: { // Is it a numbered definition?
Eric Christopher2a5196f2008-09-24 04:55:49 +0000730 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000731 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000732 Value *Result = CurModule.Values[D.Num];
733 if (Ty != Result->getType()) {
734 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +0000735 Result->getType()->getDescription() + "' does not match "
Reid Spencer93c40032007-03-19 18:40:50 +0000736 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000737 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000738 }
739 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000740 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000741
Reid Spencer41dff5e2007-01-26 08:05:27 +0000742 case ValID::LocalName: { // Is it a named definition?
Eric Christopher2a5196f2008-09-24 04:55:49 +0000743 if (!inFunctionScope())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000744 return 0;
745 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000746 Value *N = SymTab.lookup(D.getName());
Eric Christopher2a5196f2008-09-24 04:55:49 +0000747 if (N == 0)
Reid Spenceref9b9a72007-02-05 20:47:22 +0000748 return 0;
749 if (N->getType() != Ty)
750 return 0;
Eric Christopher2a5196f2008-09-24 04:55:49 +0000751
Reid Spencer41dff5e2007-01-26 08:05:27 +0000752 D.destroy(); // Free old strdup'd memory...
753 return N;
754 }
755 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000756 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000757 Value *N = SymTab.lookup(D.getName());
Eric Christopher2a5196f2008-09-24 04:55:49 +0000758 if (N == 0)
Reid Spenceref9b9a72007-02-05 20:47:22 +0000759 return 0;
760 if (N->getType() != Ty)
761 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000762
763 D.destroy(); // Free old strdup'd memory...
764 return N;
765 }
766
767 // Check to make sure that "Ty" is an integral type, and that our
768 // value will fit into the specified type...
769 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner38905612008-02-19 04:36:25 +0000770 if (!isa<IntegerType>(Ty) ||
771 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000772 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000773 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000774 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000775 return 0;
776 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000777 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000778
779 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000780 if (isa<IntegerType>(Ty) &&
781 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Reid Spencerb83eb642006-10-20 07:07:24 +0000782 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner38905612008-02-19 04:36:25 +0000783
784 if (!isa<IntegerType>(Ty) ||
785 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
786 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
787 "' is invalid or out of range for type '" +
788 Ty->getDescription() + "'");
789 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000790 }
Chris Lattner38905612008-02-19 04:36:25 +0000791 // This is really a signed reference. Transmogrify.
792 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000793
Chris Lattner1913b942008-07-11 00:30:39 +0000794 case ValID::ConstAPInt: // Is it an unsigned const pool reference?
795 if (!isa<IntegerType>(Ty)) {
796 GenerateError("Integral constant '" + D.getName() +
797 "' is invalid or out of range for type '" +
798 Ty->getDescription() + "'");
799 return 0;
800 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000801
Chris Lattner1913b942008-07-11 00:30:39 +0000802 {
803 APSInt Tmp = *D.ConstPoolInt;
804 Tmp.extOrTrunc(Ty->getPrimitiveSizeInBits());
805 return ConstantInt::get(Tmp);
806 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000807
Reid Spencer68a24bd2005-08-27 18:50:39 +0000808 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000809 if (!Ty->isFloatingPoint() ||
810 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000811 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000812 return 0;
813 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000814 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +0000815 // as double. Fix this here. Long double does not need this.
816 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
Dale Johannesen236bbd42008-10-09 23:01:34 +0000817 Ty==Type::FloatTy) {
818 bool ignored;
819 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
820 &ignored);
821 }
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000822 return ConstantFP::get(*D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000823
824 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000825 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000826 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000827 return 0;
828 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829 return ConstantPointerNull::get(cast<PointerType>(Ty));
830
831 case ValID::ConstUndefVal: // Is it an undef value?
832 return UndefValue::get(Ty);
833
Chris Lattner7aa61892005-12-21 17:53:23 +0000834 case ValID::ConstZeroVal: // Is it a zero value?
835 return Constant::getNullValue(Ty);
Eric Christopher2a5196f2008-09-24 04:55:49 +0000836
Reid Spencer68a24bd2005-08-27 18:50:39 +0000837 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000838 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000839 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000840 return 0;
841 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000842 return D.ConstantValue;
843
Chris Lattner0e9c3762006-01-25 22:27:16 +0000844 case ValID::InlineAsmVal: { // Inline asm expression
845 const PointerType *PTy = dyn_cast<PointerType>(Ty);
846 const FunctionType *FTy =
847 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000848 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000849 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000850 return 0;
851 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000852 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
853 D.IAD->HasSideEffects);
854 D.destroy(); // Free InlineAsmDescriptor.
855 return IA;
856 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000857 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000858 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000859 return 0;
860 } // End of switch
861
Reid Spencera9720f52007-02-05 17:04:00 +0000862 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000863 return 0;
864}
865
Reid Spencer93c40032007-03-19 18:40:50 +0000866// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000867// value is not already defined, it "improvises" by creating a placeholder var
868// that looks and acts just like the requested variable. When the value is
869// defined later, all uses of the placeholder variable are replaced with the
870// real thing.
871//
872static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000873 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000874 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000875 return 0;
876 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000877
878 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000879 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000880 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000881 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000882
Reid Spencer5b7e7532006-09-28 19:28:24 +0000883 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Dan Gohmane4977cf2008-05-23 01:55:30 +0000884 GenerateError("Invalid use of a non-first-class type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000885 return 0;
886 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000887
888 // If we reached here, we referenced either a symbol that we don't know about
889 // or an id number that hasn't been read yet. We may be referencing something
890 // forward, so just create an entry to be resolved later and get to it...
891 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000892 switch (ID.Type) {
893 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000894 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000895 const PointerType *PTy = dyn_cast<PointerType>(Ty);
896 if (!PTy) {
897 GenerateError("Invalid type for reference to global" );
898 return 0;
899 }
900 const Type* ElTy = PTy->getElementType();
901 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greife64d2482008-04-06 23:07:54 +0000902 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000903 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000904 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
905 (Module*)0, false, PTy->getAddressSpace());
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000906 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000907 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000908 default:
909 V = new Argument(Ty);
910 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000911
Reid Spencer68a24bd2005-08-27 18:50:39 +0000912 // Remember where this forward reference came from. FIXME, shouldn't we try
913 // to recycle these things??
914 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsdc024672007-11-27 13:23:08 +0000915 LLLgetLineNo())));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000916
917 if (inFunctionScope())
918 InsertValue(V, CurFun.LateResolveValues);
919 else
920 InsertValue(V, CurModule.LateResolveValues);
921 return V;
922}
923
Reid Spencer93c40032007-03-19 18:40:50 +0000924/// defineBBVal - This is a definition of a new basic block with the specified
925/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Chris Lattnercc81d152008-05-04 17:18:47 +0000926static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000927 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000928
Reid Spencer68a24bd2005-08-27 18:50:39 +0000929 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000930
Reid Spencer93c40032007-03-19 18:40:50 +0000931 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000932
Reid Spencer93c40032007-03-19 18:40:50 +0000933 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
934 if (BBI != CurFun.BBForwardRefs.end()) {
935 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000936 // The forward declaration could have been inserted anywhere in the
937 // function: insert it into the correct place now.
938 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
939 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000940
Reid Spencer66728ef2007-03-20 01:13:36 +0000941 // We're about to erase the entry, save the key so we can clean it up.
942 ValID Tmp = BBI->first;
943
Reid Spencer93c40032007-03-19 18:40:50 +0000944 // Erase the forward ref from the map as its no longer "forward"
945 CurFun.BBForwardRefs.erase(ID);
946
Eric Christopher2a5196f2008-09-24 04:55:49 +0000947 // The key has been removed from the map but so we don't want to leave
Reid Spencer66728ef2007-03-20 01:13:36 +0000948 // strdup'd memory around so destroy it too.
949 Tmp.destroy();
950
Reid Spencer93c40032007-03-19 18:40:50 +0000951 // If its a numbered definition, bump the number and set the BB value.
952 if (ID.Type == ValID::LocalID) {
953 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
954 InsertValue(BB);
955 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000956 } else {
957 // We haven't seen this BB before and its first mention is a definition.
Devang Patel67909432008-03-03 18:58:47 +0000958 // Just create it and return it.
959 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greife64d2482008-04-06 23:07:54 +0000960 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel67909432008-03-03 18:58:47 +0000961 if (ID.Type == ValID::LocalID) {
962 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
963 InsertValue(BB);
964 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000965 }
Reid Spencer93c40032007-03-19 18:40:50 +0000966
Devang Patel67909432008-03-03 18:58:47 +0000967 ID.destroy();
Reid Spencer93c40032007-03-19 18:40:50 +0000968 return BB;
969}
970
971/// getBBVal - get an existing BB value or create a forward reference for it.
Eric Christopher2a5196f2008-09-24 04:55:49 +0000972///
Reid Spencer93c40032007-03-19 18:40:50 +0000973static BasicBlock *getBBVal(const ValID &ID) {
974 assert(inFunctionScope() && "Can't get basic block at global scope!");
975
976 BasicBlock *BB = 0;
977
978 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
979 if (BBI != CurFun.BBForwardRefs.end()) {
980 BB = BBI->second;
981 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000982 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000983 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000984 if (N) {
Reid Spencer93c40032007-03-19 18:40:50 +0000985 if (N->getType()->getTypeID() == Type::LabelTyID)
986 BB = cast<BasicBlock>(N);
987 else
988 GenerateError("Reference to label '" + Name + "' is actually of type '"+
989 N->getType()->getDescription() + "'");
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000990 }
Reid Spencer93c40032007-03-19 18:40:50 +0000991 } else if (ID.Type == ValID::LocalID) {
992 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
993 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
994 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
995 else
Eric Christopher2a5196f2008-09-24 04:55:49 +0000996 GenerateError("Reference to label '%" + utostr(ID.Num) +
997 "' is actually of type '"+
Reid Spencer93c40032007-03-19 18:40:50 +0000998 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
999 }
1000 } else {
1001 GenerateError("Illegal label reference " + ID.getName());
1002 return 0;
1003 }
1004
1005 // If its already been defined, return it now.
1006 if (BB) {
1007 ID.destroy(); // Free strdup'd memory.
1008 return BB;
1009 }
1010
1011 // Otherwise, this block has not been seen before, create it.
1012 std::string Name;
1013 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001014 Name = ID.getName();
Gabor Greife64d2482008-04-06 23:07:54 +00001015 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Reid Spencer93c40032007-03-19 18:40:50 +00001016
1017 // Insert it in the forward refs map.
1018 CurFun.BBForwardRefs[ID] = BB;
1019
Reid Spencer68a24bd2005-08-27 18:50:39 +00001020 return BB;
1021}
1022
1023
1024//===----------------------------------------------------------------------===//
1025// Code to handle forward references in instructions
1026//===----------------------------------------------------------------------===//
1027//
1028// This code handles the late binding needed with statements that reference
1029// values not defined yet... for example, a forward branch, or the PHI node for
1030// a loop body.
1031//
1032// This keeps a table (CurFun.LateResolveValues) of all such forward references
1033// and back patchs after we are done.
1034//
1035
1036// ResolveDefinitions - If we could not resolve some defs at parsing
1037// time (forward branches, phi functions for loops, etc...) resolve the
1038// defs now...
1039//
Eric Christopher2a5196f2008-09-24 04:55:49 +00001040static void
Reid Spencer93c40032007-03-19 18:40:50 +00001041ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001042 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +00001043 while (!LateResolvers.empty()) {
1044 Value *V = LateResolvers.back();
1045 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001046
Reid Spencer93c40032007-03-19 18:40:50 +00001047 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1048 CurModule.PlaceHolderInfo.find(V);
1049 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001050
Reid Spencer93c40032007-03-19 18:40:50 +00001051 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001052
Reid Spencer93c40032007-03-19 18:40:50 +00001053 Value *TheRealValue = getExistingVal(V->getType(), DID);
1054 if (TriggerError)
1055 return;
1056 if (TheRealValue) {
1057 V->replaceAllUsesWith(TheRealValue);
1058 delete V;
1059 CurModule.PlaceHolderInfo.erase(PHI);
1060 } else if (FutureLateResolvers) {
1061 // Functions have their unresolved items forwarded to the module late
1062 // resolver table
1063 InsertValue(V, *FutureLateResolvers);
1064 } else {
1065 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1066 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1067 "' of type '" + V->getType()->getDescription() + "'",
1068 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001069 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001070 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001071 GenerateError("Reference to an invalid definition: #" +
1072 itostr(DID.Num) + " of type '" +
1073 V->getType()->getDescription() + "'",
1074 PHI->second.second);
1075 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001076 }
1077 }
1078 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001079 LateResolvers.clear();
1080}
1081
1082// ResolveTypeTo - A brand new type was just declared. This means that (if
1083// name is not null) things referencing Name can be resolved. Otherwise, things
1084// refering to the number can be resolved. Do this now.
1085//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001086static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001087 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001088 if (Name)
1089 D = ValID::createLocalName(*Name);
Eric Christopher2a5196f2008-09-24 04:55:49 +00001090 else
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001091 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001092
Reid Spencer861d9d62006-11-28 07:29:44 +00001093 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001094 CurModule.LateResolveTypes.find(D);
1095 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001096 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001097 I->first.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001098 CurModule.LateResolveTypes.erase(I);
1099 }
Nuno Lopes191dfb92008-10-03 15:52:39 +00001100 D.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001101}
1102
1103// setValueName - Set the specified value to the name given. The name may be
1104// null potentially, in which case this is a noop. The string passed in is
1105// assumed to be a malloc'd string buffer, and is free'd by this function.
1106//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001107static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001108 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001109 std::string Name(*NameStr); // Copy string
1110 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001111
Reid Spencer41dff5e2007-01-26 08:05:27 +00001112 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001113 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001114 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001115 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001116
Reid Spencera9720f52007-02-05 17:04:00 +00001117 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001118 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1119 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001120 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001121 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001122 return;
1123 }
1124
1125 // Set the name.
1126 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001127}
1128
1129/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1130/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001131static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001132ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001133 GlobalValue::LinkageTypes Linkage,
1134 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001135 bool isConstantGlobal, const Type *Ty,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001136 Constant *Initializer, bool IsThreadLocal,
1137 unsigned AddressSpace = 0) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001138 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001139 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001140 return 0;
1141 }
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001142 if (Ty == Type::LabelTy) {
1143 GenerateError("Cannot declare global vars of label type");
1144 return 0;
1145 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001146
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001147 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001148
1149 std::string Name;
1150 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001151 Name = *NameStr; // Copy string
1152 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001153 }
1154
1155 // See if this global value was forward referenced. If so, recycle the
1156 // object.
1157 ValID ID;
1158 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001159 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001160 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001161 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001162 }
1163
1164 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1165 // Move the global to the end of the list, from whereever it was
1166 // previously inserted.
1167 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1168 CurModule.CurrentModule->getGlobalList().remove(GV);
1169 CurModule.CurrentModule->getGlobalList().push_back(GV);
1170 GV->setInitializer(Initializer);
1171 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001172 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001173 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001174 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001175 InsertValue(GV, CurModule.Values);
Nuno Lopes191dfb92008-10-03 15:52:39 +00001176 ID.destroy();
Chris Lattnerb475c422005-11-12 18:22:38 +00001177 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001178 }
1179
Nuno Lopes191dfb92008-10-03 15:52:39 +00001180 ID.destroy();
1181
Reid Spenceref9b9a72007-02-05 20:47:22 +00001182 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001183 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001184 // if the global we're parsing has an initializer (is a definition) and
1185 // has external linkage.
1186 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1187 // If there is already a global with external linkage with this name
1188 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1189 // If we allow this GVar to get created, it will be renamed in the
1190 // symbol table because it conflicts with an existing GVar. We can't
1191 // allow redefinition of GVars whose linking indicates that their name
1192 // must stay the same. Issue the error.
1193 GenerateError("Redefinition of global variable named '" + Name +
1194 "' of type '" + Ty->getDescription() + "'");
1195 return 0;
1196 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001197 }
1198
1199 // Otherwise there is no existing GV to use, create one now.
1200 GlobalVariable *GV =
1201 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001202 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001203 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001204 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001205 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001206}
1207
1208// setTypeName - Set the specified type to the name given. The name may be
1209// null potentially, in which case this is a noop. The string passed in is
1210// assumed to be a malloc'd string buffer, and is freed by this function.
1211//
1212// This function returns true if the type has already been defined, but is
1213// allowed to be redefined in the specified context. If the name is a new name
1214// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001215static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001216 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001217 if (NameStr == 0) return false;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001218
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001219 std::string Name(*NameStr); // Copy string
1220 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001221
1222 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001223 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001224 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001225 return false;
1226 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001227
1228 // Set the type name, checking for conflicts as we do so.
1229 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1230
1231 if (AlreadyExists) { // Inserting a name that is already defined???
1232 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001233 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001234
1235 // There is only one case where this is allowed: when we are refining an
1236 // opaque type. In this case, Existing will be an opaque type.
1237 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1238 // We ARE replacing an opaque type!
1239 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1240 return true;
1241 }
1242
1243 // Otherwise, this is an attempt to redefine a type. That's okay if
1244 // the redefinition is identical to the original. This will be so if
1245 // Existing and T point to the same Type object. In this one case we
1246 // allow the equivalent redefinition.
1247 if (Existing == T) return true; // Yes, it's equal.
1248
1249 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001250 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001251 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001252 }
1253
1254 return false;
1255}
1256
1257//===----------------------------------------------------------------------===//
1258// Code for handling upreferences in type names...
1259//
1260
1261// TypeContains - Returns true if Ty directly contains E in it.
1262//
1263static bool TypeContains(const Type *Ty, const Type *E) {
1264 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1265 E) != Ty->subtype_end();
1266}
1267
1268namespace {
1269 struct UpRefRecord {
1270 // NestingLevel - The number of nesting levels that need to be popped before
1271 // this type is resolved.
1272 unsigned NestingLevel;
1273
1274 // LastContainedTy - This is the type at the current binding level for the
1275 // type. Every time we reduce the nesting level, this gets updated.
1276 const Type *LastContainedTy;
1277
1278 // UpRefTy - This is the actual opaque type that the upreference is
1279 // represented with.
1280 OpaqueType *UpRefTy;
1281
1282 UpRefRecord(unsigned NL, OpaqueType *URTy)
1283 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1284 };
1285}
1286
1287// UpRefs - A list of the outstanding upreferences that need to be resolved.
1288static std::vector<UpRefRecord> UpRefs;
1289
1290/// HandleUpRefs - Every time we finish a new layer of types, this function is
1291/// called. It loops through the UpRefs vector, which is a list of the
1292/// currently active types. For each type, if the up reference is contained in
1293/// the newly completed type, we decrement the level count. When the level
1294/// count reaches zero, the upreferenced type is the type that is passed in:
1295/// thus we can complete the cycle.
1296///
1297static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001298 // If Ty isn't abstract, or if there are no up-references in it, then there is
1299 // nothing to resolve here.
1300 if (!ty->isAbstract() || UpRefs.empty()) return ty;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001301
Reid Spencer68a24bd2005-08-27 18:50:39 +00001302 PATypeHolder Ty(ty);
1303 UR_OUT("Type '" << Ty->getDescription() <<
1304 "' newly formed. Resolving upreferences.\n" <<
1305 UpRefs.size() << " upreferences active!\n");
1306
1307 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1308 // to zero), we resolve them all together before we resolve them to Ty. At
1309 // the end of the loop, if there is anything to resolve to Ty, it will be in
1310 // this variable.
1311 OpaqueType *TypeToResolve = 0;
1312
1313 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1314 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1315 << UpRefs[i].second->getDescription() << ") = "
1316 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1317 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1318 // Decrement level of upreference
1319 unsigned Level = --UpRefs[i].NestingLevel;
1320 UpRefs[i].LastContainedTy = Ty;
1321 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1322 if (Level == 0) { // Upreference should be resolved!
1323 if (!TypeToResolve) {
1324 TypeToResolve = UpRefs[i].UpRefTy;
1325 } else {
1326 UR_OUT(" * Resolving upreference for "
1327 << UpRefs[i].second->getDescription() << "\n";
1328 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1329 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1330 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1331 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1332 }
1333 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1334 --i; // Do not skip the next element...
1335 }
1336 }
1337 }
1338
1339 if (TypeToResolve) {
1340 UR_OUT(" * Resolving upreference for "
1341 << UpRefs[i].second->getDescription() << "\n";
1342 std::string OldName = TypeToResolve->getDescription());
1343 TypeToResolve->refineAbstractTypeTo(Ty);
1344 }
1345
1346 return Ty;
1347}
1348
Reid Spencer68a24bd2005-08-27 18:50:39 +00001349//===----------------------------------------------------------------------===//
1350// RunVMAsmParser - Define an interface to this parser
1351//===----------------------------------------------------------------------===//
1352//
Reid Spencer14310612006-12-31 05:40:51 +00001353static Module* RunParser(Module * M);
1354
Duncan Sandsdc024672007-11-27 13:23:08 +00001355Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1356 InitLLLexer(MB);
1357 Module *M = RunParser(new Module(LLLgetFilename()));
1358 FreeLexer();
1359 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001360}
1361
1362
Dan Gohmanf4423b12008-04-19 00:24:39 +00001363
1364/* Enabling traces. */
1365#ifndef YYDEBUG
1366# define YYDEBUG 0
1367#endif
1368
1369/* Enabling verbose error messages. */
1370#ifdef YYERROR_VERBOSE
1371# undef YYERROR_VERBOSE
1372# define YYERROR_VERBOSE 1
1373#else
1374# define YYERROR_VERBOSE 0
1375#endif
1376
1377/* Enabling the token table. */
1378#ifndef YYTOKEN_TABLE
1379# define YYTOKEN_TABLE 0
1380#endif
1381
1382#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1383typedef union YYSTYPE
Nuno Lopesf05ff662008-10-15 11:20:21 +00001384#line 980 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001385{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001386 llvm::Module *ModuleVal;
1387 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001388 llvm::BasicBlock *BasicBlockVal;
1389 llvm::TerminatorInst *TermInstVal;
1390 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001391 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001392
Reid Spencera132e042006-12-03 05:46:11 +00001393 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001394 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001395 llvm::PATypeHolder *TypeVal;
1396 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001397 std::vector<llvm::Value*> *ValueList;
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001398 std::vector<unsigned> *ConstantList;
Reid Spencer14310612006-12-31 05:40:51 +00001399 llvm::ArgListType *ArgList;
1400 llvm::TypeWithAttrs TypeWithAttrs;
1401 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001402 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001403
Reid Spencer68a24bd2005-08-27 18:50:39 +00001404 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001405 std::list<std::pair<llvm::Value*,
1406 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001407 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001408 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001409
1410 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001411 llvm::GlobalValue::VisibilityTypes Visibility;
Devang Patel05988662008-09-25 21:00:45 +00001412 llvm::Attributes Attributes;
Reid Spencer38c91a92007-02-28 02:24:54 +00001413 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001414 int64_t SInt64Val;
1415 uint64_t UInt64Val;
1416 int SIntVal;
1417 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001418 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001419 bool BoolVal;
1420
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001421 std::string *StrVal; // This memory must be deleted
1422 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001423
Reid Spencera132e042006-12-03 05:46:11 +00001424 llvm::Instruction::BinaryOps BinaryOpVal;
1425 llvm::Instruction::TermOps TermOpVal;
1426 llvm::Instruction::MemoryOps MemOpVal;
1427 llvm::Instruction::CastOps CastOpVal;
1428 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001429 llvm::ICmpInst::Predicate IPredicate;
1430 llvm::FCmpInst::Predicate FPredicate;
Dan Gohmanf4423b12008-04-19 00:24:39 +00001431}
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001432/* Line 187 of yacc.c. */
Nuno Lopesf05ff662008-10-15 11:20:21 +00001433#line 1434 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001434 YYSTYPE;
1435# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1436# define YYSTYPE_IS_DECLARED 1
1437# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001438#endif
1439
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001440
Reid Spencer68a24bd2005-08-27 18:50:39 +00001441
Dan Gohmanf4423b12008-04-19 00:24:39 +00001442/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001443
1444
Dan Gohmanf4423b12008-04-19 00:24:39 +00001445/* Line 216 of yacc.c. */
Nuno Lopesf05ff662008-10-15 11:20:21 +00001446#line 1447 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001447
Dan Gohmanf4423b12008-04-19 00:24:39 +00001448#ifdef short
1449# undef short
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001450#endif
1451
Dan Gohmanf4423b12008-04-19 00:24:39 +00001452#ifdef YYTYPE_UINT8
1453typedef YYTYPE_UINT8 yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001454#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00001455typedef unsigned char yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001456#endif
1457
Dan Gohmanf4423b12008-04-19 00:24:39 +00001458#ifdef YYTYPE_INT8
1459typedef YYTYPE_INT8 yytype_int8;
1460#elif (defined __STDC__ || defined __C99__FUNC__ \
1461 || defined __cplusplus || defined _MSC_VER)
1462typedef signed char yytype_int8;
1463#else
1464typedef short int yytype_int8;
1465#endif
1466
1467#ifdef YYTYPE_UINT16
1468typedef YYTYPE_UINT16 yytype_uint16;
1469#else
1470typedef unsigned short int yytype_uint16;
1471#endif
1472
1473#ifdef YYTYPE_INT16
1474typedef YYTYPE_INT16 yytype_int16;
1475#else
1476typedef short int yytype_int16;
1477#endif
1478
1479#ifndef YYSIZE_T
1480# ifdef __SIZE_TYPE__
1481# define YYSIZE_T __SIZE_TYPE__
1482# elif defined size_t
1483# define YYSIZE_T size_t
1484# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1485 || defined __cplusplus || defined _MSC_VER)
1486# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1487# define YYSIZE_T size_t
1488# else
1489# define YYSIZE_T unsigned int
1490# endif
1491#endif
1492
1493#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1494
1495#ifndef YY_
Nuno Lopes6ec8a252008-10-15 11:11:12 +00001496# if YYENABLE_NLS
Dan Gohmanf4423b12008-04-19 00:24:39 +00001497# if ENABLE_NLS
1498# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1499# define YY_(msgid) dgettext ("bison-runtime", msgid)
1500# endif
1501# endif
1502# ifndef YY_
1503# define YY_(msgid) msgid
1504# endif
1505#endif
1506
1507/* Suppress unused-variable warnings by "using" E. */
1508#if ! defined lint || defined __GNUC__
1509# define YYUSE(e) ((void) (e))
1510#else
1511# define YYUSE(e) /* empty */
1512#endif
1513
1514/* Identity function, used to suppress warnings about constant conditions. */
1515#ifndef lint
1516# define YYID(n) (n)
1517#else
1518#if (defined __STDC__ || defined __C99__FUNC__ \
1519 || defined __cplusplus || defined _MSC_VER)
1520static int
1521YYID (int i)
1522#else
1523static int
1524YYID (i)
1525 int i;
1526#endif
1527{
1528 return i;
1529}
1530#endif
1531
1532#if ! defined yyoverflow || YYERROR_VERBOSE
1533
1534/* The parser invokes alloca or malloc; define the necessary symbols. */
1535
1536# ifdef YYSTACK_USE_ALLOCA
1537# if YYSTACK_USE_ALLOCA
1538# ifdef __GNUC__
1539# define YYSTACK_ALLOC __builtin_alloca
1540# elif defined __BUILTIN_VA_ARG_INCR
1541# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1542# elif defined _AIX
1543# define YYSTACK_ALLOC __alloca
1544# elif defined _MSC_VER
1545# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1546# define alloca _alloca
1547# else
1548# define YYSTACK_ALLOC alloca
1549# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1550 || defined __cplusplus || defined _MSC_VER)
1551# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1552# ifndef _STDLIB_H
1553# define _STDLIB_H 1
1554# endif
1555# endif
1556# endif
1557# endif
1558# endif
1559
1560# ifdef YYSTACK_ALLOC
1561 /* Pacify GCC's `empty if-body' warning. */
1562# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1563# ifndef YYSTACK_ALLOC_MAXIMUM
1564 /* The OS might guarantee only one guard page at the bottom of the stack,
1565 and a page size can be as small as 4096 bytes. So we cannot safely
1566 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1567 to allow for a few compiler-allocated temporary stack slots. */
1568# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1569# endif
1570# else
1571# define YYSTACK_ALLOC YYMALLOC
1572# define YYSTACK_FREE YYFREE
1573# ifndef YYSTACK_ALLOC_MAXIMUM
1574# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1575# endif
1576# if (defined __cplusplus && ! defined _STDLIB_H \
1577 && ! ((defined YYMALLOC || defined malloc) \
1578 && (defined YYFREE || defined free)))
1579# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1580# ifndef _STDLIB_H
1581# define _STDLIB_H 1
1582# endif
1583# endif
1584# ifndef YYMALLOC
1585# define YYMALLOC malloc
1586# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1587 || defined __cplusplus || defined _MSC_VER)
1588void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1589# endif
1590# endif
1591# ifndef YYFREE
1592# define YYFREE free
1593# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1594 || defined __cplusplus || defined _MSC_VER)
1595void free (void *); /* INFRINGES ON USER NAME SPACE */
1596# endif
1597# endif
1598# endif
1599#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1600
1601
1602#if (! defined yyoverflow \
1603 && (! defined __cplusplus \
1604 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1605
1606/* A type that is properly aligned for any stack member. */
1607union yyalloc
1608{
1609 yytype_int16 yyss;
1610 YYSTYPE yyvs;
1611 };
1612
1613/* The size of the maximum gap between one aligned stack and the next. */
1614# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1615
1616/* The size of an array large to enough to hold all stacks, each with
1617 N elements. */
1618# define YYSTACK_BYTES(N) \
1619 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1620 + YYSTACK_GAP_MAXIMUM)
1621
1622/* Copy COUNT objects from FROM to TO. The source and destination do
1623 not overlap. */
1624# ifndef YYCOPY
1625# if defined __GNUC__ && 1 < __GNUC__
1626# define YYCOPY(To, From, Count) \
1627 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1628# else
1629# define YYCOPY(To, From, Count) \
1630 do \
1631 { \
1632 YYSIZE_T yyi; \
1633 for (yyi = 0; yyi < (Count); yyi++) \
1634 (To)[yyi] = (From)[yyi]; \
1635 } \
1636 while (YYID (0))
1637# endif
1638# endif
1639
1640/* Relocate STACK from its old location to the new one. The
1641 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1642 elements in the stack, and YYPTR gives the new location of the
1643 stack. Advance YYPTR to a properly aligned location for the next
1644 stack. */
1645# define YYSTACK_RELOCATE(Stack) \
1646 do \
1647 { \
1648 YYSIZE_T yynewbytes; \
1649 YYCOPY (&yyptr->Stack, Stack, yysize); \
1650 Stack = &yyptr->Stack; \
1651 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1652 yyptr += yynewbytes / sizeof (*yyptr); \
1653 } \
1654 while (YYID (0))
1655
1656#endif
1657
1658/* YYFINAL -- State number of the termination state. */
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001659#define YYFINAL 44
Dan Gohmanf4423b12008-04-19 00:24:39 +00001660/* YYLAST -- Last index in YYTABLE. */
Chris Lattner740e7092008-10-15 06:16:57 +00001661#define YYLAST 2377
Dan Gohmanf4423b12008-04-19 00:24:39 +00001662
1663/* YYNTOKENS -- Number of terminals. */
Devang Patel652203f2008-09-29 20:49:50 +00001664#define YYNTOKENS 173
Dan Gohmanf4423b12008-04-19 00:24:39 +00001665/* YYNNTS -- Number of nonterminals. */
Chris Lattner740e7092008-10-15 06:16:57 +00001666#define YYNNTS 87
Dan Gohmanf4423b12008-04-19 00:24:39 +00001667/* YYNRULES -- Number of rules. */
Chris Lattner740e7092008-10-15 06:16:57 +00001668#define YYNRULES 348
Dan Gohmanf4423b12008-04-19 00:24:39 +00001669/* YYNRULES -- Number of states. */
Chris Lattner740e7092008-10-15 06:16:57 +00001670#define YYNSTATES 708
Dan Gohmanf4423b12008-04-19 00:24:39 +00001671
1672/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1673#define YYUNDEFTOK 2
Devang Patel652203f2008-09-29 20:49:50 +00001674#define YYMAXUTOK 413
Dan Gohmanf4423b12008-04-19 00:24:39 +00001675
1676#define YYTRANSLATE(YYX) \
1677 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1678
1679/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1680static const yytype_uint8 yytranslate[] =
1681{
1682 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1683 2, 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,
Devang Patel652203f2008-09-29 20:49:50 +00001686 159, 160, 163, 2, 162, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001688 168, 161, 169, 2, 2, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001689 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1690 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001691 2, 165, 164, 167, 2, 2, 2, 2, 2, 172,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001692 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1693 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel652203f2008-09-29 20:49:50 +00001694 166, 2, 2, 170, 2, 171, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001695 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1696 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1697 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1698 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1699 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1700 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1701 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1702 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1703 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1704 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1705 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1706 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1707 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1708 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1709 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1710 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1711 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1712 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1713 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1714 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1715 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1716 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1717 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1718 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1719 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1720 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1721 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Dan Gohmane4977cf2008-05-23 01:55:30 +00001722 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
Devang Patel652203f2008-09-29 20:49:50 +00001723 155, 156, 157, 158
Dan Gohmanf4423b12008-04-19 00:24:39 +00001724};
1725
1726#if YYDEBUG
1727/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1728 YYRHS. */
1729static const yytype_uint16 yyprhs[] =
1730{
1731 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1732 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1733 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1734 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1735 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1736 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
Chris Lattner740e7092008-10-15 06:16:57 +00001737 118, 123, 124, 127, 128, 131, 133, 135, 137, 138,
1738 141, 143, 145, 147, 149, 151, 153, 155, 157, 159,
1739 160, 162, 164, 166, 167, 169, 171, 172, 174, 176,
1740 178, 180, 181, 183, 185, 186, 188, 190, 192, 194,
1741 196, 199, 201, 203, 205, 207, 209, 211, 213, 215,
1742 217, 220, 221, 224, 226, 228, 230, 231, 234, 236,
1743 238, 240, 242, 244, 246, 248, 250, 252, 254, 255,
1744 258, 259, 262, 263, 266, 267, 271, 274, 275, 277,
1745 278, 282, 284, 287, 289, 291, 293, 295, 297, 299,
1746 301, 303, 305, 309, 311, 314, 320, 326, 332, 338,
1747 342, 345, 351, 356, 359, 361, 363, 365, 369, 371,
1748 375, 377, 378, 380, 384, 389, 393, 397, 402, 407,
1749 411, 418, 424, 427, 430, 433, 436, 439, 442, 445,
1750 448, 451, 454, 457, 460, 467, 473, 482, 489, 496,
1751 504, 512, 520, 528, 535, 544, 553, 559, 567, 571,
1752 573, 575, 577, 579, 580, 583, 590, 592, 593, 595,
1753 598, 599, 603, 604, 608, 612, 616, 620, 621, 630,
1754 631, 641, 642, 652, 658, 661, 665, 667, 671, 675,
1755 679, 683, 685, 686, 692, 696, 698, 702, 704, 705,
1756 717, 719, 721, 726, 728, 730, 733, 737, 738, 740,
1757 742, 744, 746, 748, 750, 752, 754, 756, 758, 760,
1758 764, 768, 771, 774, 778, 781, 787, 792, 794, 800,
1759 802, 804, 806, 808, 810, 812, 815, 817, 821, 824,
1760 827, 831, 835, 838, 839, 841, 844, 847, 851, 861,
1761 871, 880, 896, 898, 900, 907, 913, 916, 919, 926,
1762 934, 939, 944, 951, 958, 959, 960, 964, 967, 971,
1763 974, 976, 982, 988, 995, 1002, 1009, 1016, 1021, 1028,
1764 1033, 1038, 1045, 1052, 1055, 1065, 1067, 1069, 1070, 1074,
1765 1081, 1085, 1092, 1095, 1101, 1109, 1115, 1120, 1125
Dan Gohmanf4423b12008-04-19 00:24:39 +00001766};
1767
1768/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1769static const yytype_int16 yyrhs[] =
1770{
Chris Lattner740e7092008-10-15 06:16:57 +00001771 220, 0, -1, 75, -1, 76, -1, 77, -1, 78,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001772 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
1773 -1, 87, -1, 88, -1, 89, -1, 84, -1, 85,
1774 -1, 86, -1, 120, -1, 121, -1, 122, -1, 123,
1775 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
1776 -1, 129, -1, 130, -1, 131, -1, 94, -1, 95,
1777 -1, 96, -1, 97, -1, 98, -1, 99, -1, 100,
1778 -1, 101, -1, 102, -1, 103, -1, 104, -1, 105,
1779 -1, 106, -1, 107, -1, 108, -1, 109, -1, 110,
1780 -1, 111, -1, 112, -1, 113, -1, 100, -1, 101,
Chris Lattner740e7092008-10-15 06:16:57 +00001781 -1, 102, -1, 103, -1, 26, -1, 27, -1, 19,
1782 -1, 22, -1, 24, -1, 179, -1, -1, 55, 159,
1783 4, 160, -1, -1, 179, 161, -1, -1, 7, 161,
1784 -1, 20, -1, 23, -1, 186, -1, -1, 184, 161,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001785 -1, 42, -1, 44, -1, 43, -1, 45, -1, 47,
1786 -1, 49, -1, 46, -1, 48, -1, 51, -1, -1,
1787 156, -1, 157, -1, 158, -1, -1, 46, -1, 48,
1788 -1, -1, 42, -1, 43, -1, 44, -1, 47, -1,
1789 -1, 44, -1, 42, -1, -1, 63, -1, 64, -1,
1790 65, -1, 66, -1, 67, -1, 62, 4, -1, 142,
1791 -1, 121, -1, 141, -1, 122, -1, 144, -1, 145,
1792 -1, 147, -1, 148, -1, 149, -1, 54, 4, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00001793 -1, 195, 194, -1, 144, -1, 142, -1, 141, -1,
1794 -1, 197, 196, -1, 143, -1, 146, -1, 144, -1,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001795 142, -1, 141, -1, 150, -1, 151, -1, 154, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00001796 155, -1, 153, -1, -1, 199, 198, -1, -1, 152,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001797 22, -1, -1, 54, 4, -1, -1, 162, 54, 4,
Chris Lattner740e7092008-10-15 06:16:57 +00001798 -1, 34, 22, -1, -1, 203, -1, -1, 162, 206,
1799 205, -1, 203, -1, 54, 4, -1, 11, -1, 12,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001800 -1, 13, -1, 16, -1, 15, -1, 14, -1, 17,
Chris Lattner740e7092008-10-15 06:16:57 +00001801 -1, 50, -1, 207, -1, 208, 181, 163, -1, 242,
1802 -1, 164, 4, -1, 208, 159, 212, 160, 199, -1,
1803 10, 159, 212, 160, 199, -1, 165, 4, 166, 208,
1804 167, -1, 168, 4, 166, 208, 169, -1, 170, 213,
1805 171, -1, 170, 171, -1, 168, 170, 213, 171, 169,
1806 -1, 168, 170, 171, 169, -1, 208, 195, -1, 208,
1807 -1, 10, -1, 209, -1, 211, 162, 209, -1, 211,
1808 -1, 211, 162, 39, -1, 39, -1, -1, 208, -1,
1809 213, 162, 208, -1, 208, 165, 216, 167, -1, 208,
1810 165, 167, -1, 208, 172, 22, -1, 208, 168, 216,
1811 169, -1, 208, 170, 216, 171, -1, 208, 170, 171,
1812 -1, 208, 168, 170, 216, 171, 169, -1, 208, 168,
1813 170, 171, 169, -1, 208, 40, -1, 208, 41, -1,
1814 208, 242, -1, 208, 215, -1, 208, 25, -1, 208,
1815 3, -1, 208, 5, -1, 208, 4, -1, 208, 6,
1816 -1, 208, 26, -1, 208, 27, -1, 208, 9, -1,
1817 176, 159, 214, 38, 208, 160, -1, 119, 159, 214,
1818 254, 160, -1, 133, 159, 214, 162, 214, 162, 214,
1819 160, -1, 174, 159, 214, 162, 214, 160, -1, 175,
1820 159, 214, 162, 214, 160, -1, 90, 177, 159, 214,
1821 162, 214, 160, -1, 91, 178, 159, 214, 162, 214,
1822 160, -1, 92, 177, 159, 214, 162, 214, 160, -1,
1823 93, 178, 159, 214, 162, 214, 160, -1, 135, 159,
1824 214, 162, 214, 160, -1, 136, 159, 214, 162, 214,
1825 162, 214, 160, -1, 137, 159, 214, 162, 214, 162,
1826 214, 160, -1, 139, 159, 214, 255, 160, -1, 140,
1827 159, 214, 162, 214, 255, 160, -1, 216, 162, 214,
1828 -1, 214, -1, 32, -1, 33, -1, 37, -1, -1,
1829 210, 242, -1, 125, 159, 219, 38, 208, 160, -1,
1830 221, -1, -1, 222, -1, 221, 222, -1, -1, 31,
1831 223, 238, -1, -1, 30, 224, 239, -1, 60, 59,
1832 228, -1, 182, 18, 208, -1, 182, 18, 10, -1,
1833 -1, 185, 189, 218, 217, 214, 181, 225, 205, -1,
1834 -1, 185, 187, 189, 218, 217, 214, 181, 226, 205,
1835 -1, -1, 185, 188, 189, 218, 217, 208, 181, 227,
1836 205, -1, 185, 189, 35, 192, 219, -1, 52, 229,
1837 -1, 56, 161, 230, -1, 22, -1, 53, 161, 22,
1838 -1, 68, 161, 22, -1, 165, 231, 167, -1, 231,
1839 162, 22, -1, 22, -1, -1, 232, 162, 208, 195,
1840 180, -1, 208, 195, 180, -1, 232, -1, 232, 162,
1841 39, -1, 39, -1, -1, 193, 197, 210, 184, 159,
1842 233, 160, 199, 204, 201, 200, -1, 28, -1, 170,
1843 -1, 191, 189, 234, 235, -1, 29, -1, 171, -1,
1844 246, 237, -1, 190, 189, 234, -1, -1, 61, -1,
Chris Lattnerf9078f92008-10-15 06:03:48 +00001845 3, -1, 4, -1, 5, -1, 6, -1, 9, -1,
1846 26, -1, 27, -1, 40, -1, 41, -1, 25, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00001847 168, 216, 169, -1, 165, 216, 167, -1, 165, 167,
1848 -1, 172, 22, -1, 170, 216, 171, -1, 170, 171,
1849 -1, 168, 170, 216, 171, 169, -1, 168, 170, 171,
1850 169, -1, 215, -1, 59, 240, 22, 162, 22, -1,
1851 7, -1, 8, -1, 179, -1, 184, -1, 242, -1,
1852 241, -1, 208, 243, -1, 244, -1, 245, 162, 244,
1853 -1, 246, 247, -1, 236, 247, -1, 248, 182, 249,
1854 -1, 248, 183, 249, -1, 248, 251, -1, -1, 21,
1855 -1, 69, 245, -1, 69, 10, -1, 70, 17, 243,
1856 -1, 70, 11, 243, 162, 17, 243, 162, 17, 243,
1857 -1, 71, 11, 243, 162, 17, 243, 165, 250, 167,
1858 -1, 71, 11, 243, 162, 17, 243, 165, 167, -1,
1859 72, 193, 197, 210, 243, 159, 253, 160, 199, 38,
1860 17, 243, 73, 17, 243, -1, 73, -1, 74, -1,
1861 250, 11, 241, 162, 17, 243, -1, 11, 241, 162,
1862 17, 243, -1, 182, 257, -1, 183, 257, -1, 208,
1863 165, 243, 162, 243, 167, -1, 252, 162, 165, 243,
1864 162, 243, 167, -1, 208, 195, 243, 195, -1, 17,
1865 195, 243, 195, -1, 253, 162, 208, 195, 243, 195,
1866 -1, 253, 162, 17, 195, 243, 195, -1, -1, -1,
1867 254, 162, 244, -1, 162, 4, -1, 255, 162, 4,
1868 -1, 58, 57, -1, 57, -1, 174, 208, 243, 162,
1869 243, -1, 175, 208, 243, 162, 243, -1, 90, 177,
1870 208, 243, 162, 243, -1, 91, 178, 208, 243, 162,
1871 243, -1, 92, 177, 208, 243, 162, 243, -1, 93,
1872 178, 208, 243, 162, 243, -1, 176, 244, 38, 208,
1873 -1, 133, 244, 162, 244, 162, 244, -1, 134, 244,
1874 162, 208, -1, 135, 244, 162, 244, -1, 136, 244,
1875 162, 244, 162, 244, -1, 137, 244, 162, 244, 162,
1876 244, -1, 132, 252, -1, 256, 193, 197, 210, 243,
1877 159, 253, 160, 199, -1, 259, -1, 36, -1, -1,
1878 114, 208, 202, -1, 114, 208, 162, 11, 243, 202,
1879 -1, 115, 208, 202, -1, 115, 208, 162, 11, 243,
1880 202, -1, 116, 244, -1, 258, 117, 208, 243, 202,
1881 -1, 258, 118, 244, 162, 208, 243, 202, -1, 138,
1882 208, 243, 162, 4, -1, 119, 208, 243, 254, -1,
1883 139, 208, 243, 255, -1, 140, 208, 243, 162, 208,
1884 243, 255, -1
Dan Gohmanf4423b12008-04-19 00:24:39 +00001885};
1886
1887/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1888static const yytype_uint16 yyrline[] =
1889{
Nuno Lopesf05ff662008-10-15 11:20:21 +00001890 0, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146,
1891 1146, 1147, 1147, 1147, 1147, 1147, 1147, 1148, 1148, 1148,
1892 1148, 1148, 1148, 1149, 1149, 1149, 1149, 1149, 1149, 1152,
1893 1152, 1153, 1153, 1154, 1154, 1155, 1155, 1156, 1156, 1160,
1894 1160, 1161, 1161, 1162, 1162, 1163, 1163, 1164, 1164, 1165,
1895 1165, 1166, 1166, 1167, 1168, 1171, 1171, 1171, 1172, 1172,
1896 1174, 1175, 1179, 1183, 1188, 1194, 1194, 1196, 1197, 1202,
1897 1208, 1209, 1210, 1211, 1212, 1213, 1217, 1218, 1219, 1223,
1898 1224, 1225, 1226, 1230, 1231, 1232, 1236, 1237, 1238, 1239,
1899 1240, 1244, 1245, 1246, 1249, 1250, 1251, 1252, 1253, 1254,
1900 1255, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270,
1901 1271, 1275, 1276, 1281, 1282, 1283, 1286, 1287, 1293, 1294,
1902 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1305, 1306,
1903 1312, 1313, 1320, 1321, 1327, 1328, 1337, 1345, 1346, 1351,
1904 1352, 1353, 1358, 1371, 1371, 1371, 1371, 1371, 1371, 1371,
1905 1374, 1378, 1382, 1389, 1394, 1402, 1437, 1468, 1473, 1483,
1906 1493, 1497, 1507, 1514, 1523, 1530, 1535, 1540, 1547, 1548,
1907 1555, 1562, 1570, 1576, 1588, 1616, 1632, 1659, 1687, 1713,
1908 1733, 1759, 1779, 1791, 1798, 1864, 1874, 1884, 1895, 1908,
1909 1919, 1933, 1940, 1947, 1965, 1977, 1998, 2006, 2012, 2023,
1910 2028, 2033, 2038, 2043, 2049, 2055, 2061, 2069, 2080, 2084,
1911 2092, 2092, 2095, 2095, 2098, 2110, 2131, 2136, 2144, 2145,
1912 2149, 2149, 2153, 2153, 2156, 2159, 2183, 2195, 2194, 2206,
1913 2205, 2215, 2214, 2225, 2265, 2268, 2274, 2284, 2288, 2293,
1914 2295, 2300, 2305, 2314, 2324, 2335, 2339, 2348, 2357, 2362,
1915 2511, 2511, 2513, 2522, 2522, 2524, 2529, 2541, 2545, 2550,
1916 2554, 2558, 2563, 2568, 2572, 2576, 2580, 2584, 2588, 2592,
1917 2614, 2636, 2642, 2655, 2667, 2672, 2684, 2690, 2694, 2704,
1918 2708, 2712, 2717, 2724, 2724, 2730, 2739, 2744, 2749, 2753,
1919 2762, 2771, 2784, 2793, 2797, 2805, 2825, 2829, 2834, 2845,
1920 2864, 2873, 2977, 2981, 2988, 2999, 3012, 3021, 3034, 3045,
1921 3055, 3066, 3074, 3084, 3091, 3094, 3095, 3103, 3109, 3118,
1922 3122, 3127, 3143, 3160, 3172, 3184, 3198, 3212, 3224, 3245,
1923 3252, 3258, 3264, 3270, 3285, 3395, 3400, 3404, 3411, 3418,
1924 3428, 3435, 3445, 3453, 3467, 3484, 3498, 3513, 3528
Dan Gohmanf4423b12008-04-19 00:24:39 +00001925};
1926#endif
1927
1928#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1929/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1930 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1931static const char *const yytname[] =
1932{
1933 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1934 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1935 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1936 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1937 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1938 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1939 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1940 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001941 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "COMMON", "OPAQUE",
Dan Gohmanf4423b12008-04-19 00:24:39 +00001942 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1943 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1944 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Dale Johannesendfe8c842008-09-26 19:32:34 +00001945 "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
1946 "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
1947 "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "VICMP",
1948 "VFCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1949 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1950 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1951 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1952 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1953 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1954 "GETRESULT", "EXTRACTVALUE", "INSERTVALUE", "SIGNEXT", "ZEROEXT",
1955 "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST",
Devang Patel652203f2008-09-29 20:49:50 +00001956 "READNONE", "READONLY", "GC", "OPTSIZE", "NOINLINE", "ALWAYSINLINE",
1957 "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'",
1958 "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'",
1959 "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates",
Chris Lattner740e7092008-10-15 06:16:57 +00001960 "FPredicates", "LocalName", "OptLocalName", "OptAddrSpace",
Chris Lattnerf9078f92008-10-15 06:03:48 +00001961 "OptLocalAssign", "LocalNumber", "GlobalName", "OptGlobalAssign",
1962 "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1963 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1964 "AliasLinkage", "OptCallingConv", "Attribute", "OptAttributes",
1965 "RetAttr", "OptRetAttrs", "FuncAttr", "OptFuncAttrs", "OptGC",
1966 "OptAlign", "OptCAlign", "SectionString", "OptSection",
Devang Patel652203f2008-09-29 20:49:50 +00001967 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1968 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1969 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "ThreadLocal",
1970 "AliaseeRef", "Module", "DefinitionList", "Definition", "@1", "@2", "@3",
1971 "@4", "@5", "AsmBlock", "TargetDefinition", "LibrariesDefinition",
1972 "LibList", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1973 "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect",
1974 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1975 "ReturnedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1976 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ParamList",
1977 "IndexList", "ConstantIndexList", "OptTailCall", "InstVal",
Chris Lattner15bd0952008-08-29 17:20:18 +00001978 "OptVolatile", "MemoryInst", 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00001979};
1980#endif
1981
1982# ifdef YYPRINT
1983/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1984 token YYLEX-NUM. */
1985static const yytype_uint16 yytoknum[] =
1986{
1987 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1988 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1989 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1990 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1991 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1992 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1993 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1994 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1995 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1996 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1997 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1998 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1999 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2000 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2001 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Devang Patel652203f2008-09-29 20:49:50 +00002002 405, 406, 407, 408, 409, 410, 411, 412, 413, 40,
2003 41, 61, 44, 42, 92, 91, 120, 93, 60, 62,
2004 123, 125, 99
Dan Gohmanf4423b12008-04-19 00:24:39 +00002005};
2006# endif
2007
2008/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002009static const yytype_uint16 yyr1[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002010{
Devang Patel652203f2008-09-29 20:49:50 +00002011 0, 173, 174, 174, 174, 174, 174, 174, 174, 174,
2012 174, 175, 175, 175, 175, 175, 175, 176, 176, 176,
2013 176, 176, 176, 176, 176, 176, 176, 176, 176, 177,
2014 177, 177, 177, 177, 177, 177, 177, 177, 177, 178,
2015 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
Chris Lattner740e7092008-10-15 06:16:57 +00002016 178, 178, 178, 178, 178, 179, 179, 179, 180, 180,
2017 181, 181, 182, 182, 183, 184, 184, 185, 185, 186,
2018 187, 187, 187, 187, 187, 187, 188, 188, 188, 189,
2019 189, 189, 189, 190, 190, 190, 191, 191, 191, 191,
2020 191, 192, 192, 192, 193, 193, 193, 193, 193, 193,
2021 193, 194, 194, 194, 194, 194, 194, 194, 194, 194,
2022 194, 195, 195, 196, 196, 196, 197, 197, 198, 198,
2023 198, 198, 198, 198, 198, 198, 198, 198, 199, 199,
2024 200, 200, 201, 201, 202, 202, 203, 204, 204, 205,
2025 205, 206, 206, 207, 207, 207, 207, 207, 207, 207,
2026 208, 208, 208, 208, 208, 208, 208, 208, 208, 208,
2027 208, 208, 208, 209, 210, 210, 211, 211, 212, 212,
2028 212, 212, 213, 213, 214, 214, 214, 214, 214, 214,
2029 214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
2030 214, 214, 214, 214, 215, 215, 215, 215, 215, 215,
2031 215, 215, 215, 215, 215, 215, 215, 215, 216, 216,
2032 217, 217, 218, 218, 219, 219, 220, 220, 221, 221,
2033 223, 222, 224, 222, 222, 222, 222, 225, 222, 226,
2034 222, 227, 222, 222, 222, 222, 228, 229, 229, 230,
2035 231, 231, 231, 232, 232, 233, 233, 233, 233, 234,
2036 235, 235, 236, 237, 237, 238, 239, 240, 240, 241,
2037 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2038 241, 241, 241, 241, 241, 241, 241, 241, 241, 242,
2039 242, 242, 242, 243, 243, 244, 245, 245, 246, 246,
2040 247, 247, 248, 248, 248, 249, 249, 249, 249, 249,
2041 249, 249, 249, 249, 250, 250, 251, 251, 252, 252,
2042 253, 253, 253, 253, 253, 254, 254, 255, 255, 256,
2043 256, 257, 257, 257, 257, 257, 257, 257, 257, 257,
2044 257, 257, 257, 257, 257, 257, 258, 258, 259, 259,
2045 259, 259, 259, 259, 259, 259, 259, 259, 259
Dan Gohmanf4423b12008-04-19 00:24:39 +00002046};
2047
2048/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2049static const yytype_uint8 yyr2[] =
2050{
2051 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2052 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2053 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2054 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2055 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Chris Lattner740e7092008-10-15 06:16:57 +00002056 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
2057 4, 0, 2, 0, 2, 1, 1, 1, 0, 2,
2058 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
2059 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
2060 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
2061 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2062 2, 0, 2, 1, 1, 1, 0, 2, 1, 1,
2063 1, 1, 1, 1, 1, 1, 1, 1, 0, 2,
2064 0, 2, 0, 2, 0, 3, 2, 0, 1, 0,
2065 3, 1, 2, 1, 1, 1, 1, 1, 1, 1,
2066 1, 1, 3, 1, 2, 5, 5, 5, 5, 3,
2067 2, 5, 4, 2, 1, 1, 1, 3, 1, 3,
2068 1, 0, 1, 3, 4, 3, 3, 4, 4, 3,
2069 6, 5, 2, 2, 2, 2, 2, 2, 2, 2,
2070 2, 2, 2, 2, 6, 5, 8, 6, 6, 7,
2071 7, 7, 7, 6, 8, 8, 5, 7, 3, 1,
2072 1, 1, 1, 0, 2, 6, 1, 0, 1, 2,
2073 0, 3, 0, 3, 3, 3, 3, 0, 8, 0,
2074 9, 0, 9, 5, 2, 3, 1, 3, 3, 3,
2075 3, 1, 0, 5, 3, 1, 3, 1, 0, 11,
2076 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
2077 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
2078 3, 2, 2, 3, 2, 5, 4, 1, 5, 1,
2079 1, 1, 1, 1, 1, 2, 1, 3, 2, 2,
2080 3, 3, 2, 0, 1, 2, 2, 3, 9, 9,
2081 8, 15, 1, 1, 6, 5, 2, 2, 6, 7,
2082 4, 4, 6, 6, 0, 0, 3, 2, 3, 2,
2083 1, 5, 5, 6, 6, 6, 6, 4, 6, 4,
2084 4, 6, 6, 2, 9, 1, 1, 0, 3, 6,
2085 3, 6, 2, 5, 7, 5, 4, 4, 7
Dan Gohmanf4423b12008-04-19 00:24:39 +00002086};
2087
2088/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2089 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2090 means the default is an error. */
2091static const yytype_uint16 yydefact[] =
2092{
Chris Lattner740e7092008-10-15 06:16:57 +00002093 68, 55, 65, 56, 66, 57, 222, 220, 0, 0,
2094 0, 0, 0, 0, 79, 67, 0, 68, 218, 83,
2095 86, 0, 0, 234, 0, 0, 62, 0, 69, 70,
2096 72, 71, 73, 76, 74, 77, 75, 78, 80, 81,
2097 82, 79, 79, 213, 1, 219, 84, 85, 79, 223,
2098 87, 88, 89, 90, 79, 293, 221, 293, 0, 0,
2099 242, 235, 236, 224, 279, 280, 226, 143, 144, 145,
2100 148, 147, 146, 149, 150, 0, 0, 0, 0, 281,
2101 282, 151, 225, 153, 213, 213, 91, 212, 0, 94,
2102 94, 294, 289, 63, 253, 254, 255, 288, 237, 238,
2103 241, 0, 171, 154, 0, 0, 0, 0, 160, 172,
2104 0, 0, 171, 0, 0, 0, 93, 92, 0, 210,
2105 211, 0, 0, 95, 96, 97, 98, 99, 116, 256,
2106 0, 0, 337, 337, 292, 0, 239, 170, 111, 166,
2107 168, 0, 0, 0, 0, 0, 0, 159, 0, 0,
2108 152, 0, 0, 165, 0, 164, 0, 233, 61, 61,
2109 100, 0, 250, 251, 252, 64, 336, 320, 0, 0,
2110 0, 0, 94, 302, 303, 2, 3, 4, 5, 6,
2111 7, 8, 9, 10, 14, 15, 16, 11, 12, 13,
2112 0, 0, 0, 0, 0, 0, 0, 0, 17, 18,
2113 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
Nate Begemanac80ade2008-05-12 19:01:56 +00002114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002115 0, 0, 290, 94, 306, 0, 335, 291, 307, 240,
2116 163, 0, 128, 61, 61, 162, 0, 173, 0, 128,
2117 61, 61, 0, 214, 187, 189, 188, 190, 193, 186,
2118 191, 192, 182, 183, 0, 0, 0, 0, 0, 0,
2119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2120 0, 0, 185, 184, 227, 115, 114, 113, 117, 0,
2121 319, 296, 61, 286, 295, 0, 0, 0, 116, 29,
2122 30, 31, 32, 33, 34, 35, 36, 37, 38, 0,
2123 53, 54, 49, 50, 51, 52, 39, 40, 41, 42,
2124 43, 44, 45, 46, 47, 48, 0, 0, 0, 134,
2125 134, 342, 61, 61, 333, 0, 0, 0, 0, 0,
2126 61, 61, 61, 61, 61, 0, 116, 0, 0, 0,
2127 102, 104, 103, 101, 105, 106, 107, 108, 109, 112,
2128 169, 167, 156, 157, 158, 161, 60, 155, 229, 231,
2129 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2130 0, 0, 175, 209, 0, 0, 0, 179, 0, 176,
2131 0, 0, 0, 139, 0, 259, 260, 261, 262, 263,
2132 268, 264, 265, 266, 267, 257, 0, 0, 0, 0,
2133 277, 284, 283, 285, 0, 0, 297, 0, 0, 61,
2134 61, 61, 61, 0, 338, 0, 340, 315, 0, 0,
2135 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2136 0, 0, 61, 0, 110, 122, 121, 118, 120, 119,
2137 123, 124, 127, 125, 126, 129, 139, 139, 0, 0,
2138 0, 0, 0, 315, 0, 0, 0, 0, 0, 0,
2139 0, 174, 160, 172, 0, 177, 178, 0, 0, 0,
2140 0, 228, 248, 258, 0, 271, 0, 0, 0, 274,
2141 0, 272, 287, 0, 0, 0, 0, 0, 0, 0,
2142 0, 0, 0, 346, 0, 0, 0, 329, 330, 0,
2143 0, 0, 0, 347, 0, 0, 0, 327, 0, 134,
2144 0, 230, 232, 61, 0, 0, 0, 0, 0, 0,
2145 0, 0, 0, 0, 0, 208, 181, 0, 0, 0,
2146 0, 0, 0, 141, 139, 247, 111, 245, 0, 0,
2147 270, 160, 0, 269, 273, 0, 0, 0, 0, 0,
2148 0, 0, 134, 135, 134, 0, 0, 0, 0, 0,
2149 0, 345, 317, 0, 61, 321, 322, 0, 0, 343,
2150 61, 215, 0, 0, 0, 0, 195, 0, 0, 0,
2151 0, 206, 0, 180, 0, 0, 61, 136, 142, 140,
2152 59, 0, 128, 0, 276, 0, 0, 0, 314, 323,
2153 324, 325, 326, 339, 341, 316, 0, 0, 328, 331,
2154 332, 318, 0, 314, 134, 0, 0, 0, 0, 0,
2155 203, 0, 0, 0, 197, 198, 194, 58, 244, 246,
2156 111, 137, 278, 275, 0, 0, 111, 111, 0, 308,
2157 0, 348, 0, 344, 199, 200, 201, 202, 0, 0,
2158 0, 207, 59, 138, 132, 0, 0, 300, 0, 0,
2159 0, 128, 0, 309, 128, 196, 204, 205, 243, 0,
2160 130, 298, 0, 0, 299, 102, 104, 111, 111, 0,
2161 111, 111, 334, 133, 0, 249, 0, 0, 311, 310,
2162 0, 0, 0, 131, 0, 0, 0, 111, 111, 305,
2163 0, 0, 313, 312, 304, 0, 0, 301
Dan Gohmanf4423b12008-04-19 00:24:39 +00002164};
2165
2166/* YYDEFGOTO[NTERM-NUM]. */
2167static const yytype_int16 yydefgoto[] =
2168{
Chris Lattner740e7092008-10-15 06:16:57 +00002169 -1, 269, 270, 271, 299, 316, 79, 628, 113, 12,
2170 133, 80, 14, 15, 41, 42, 43, 48, 54, 118,
2171 128, 349, 230, 278, 161, 445, 352, 685, 670, 414,
2172 533, 654, 471, 534, 81, 158, 139, 156, 140, 141,
2173 110, 373, 400, 374, 121, 88, 157, 16, 17, 18,
2174 20, 19, 383, 446, 447, 63, 23, 61, 101, 537,
2175 538, 129, 164, 55, 96, 56, 49, 474, 401, 83,
2176 403, 283, 284, 57, 92, 93, 222, 658, 134, 324,
2177 638, 493, 503, 223, 224, 225, 226
Dan Gohmanf4423b12008-04-19 00:24:39 +00002178};
2179
2180/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2181 STATE-NUM. */
Chris Lattner740e7092008-10-15 06:16:57 +00002182#define YYPACT_NINF -624
Dan Gohmanf4423b12008-04-19 00:24:39 +00002183static const yytype_int16 yypact[] =
2184{
Chris Lattner740e7092008-10-15 06:16:57 +00002185 815, -624, -624, -624, -624, -624, -624, -624, 14, -114,
2186 16, -73, 78, -31, 299, -624, 163, 2187, -624, 164,
2187 80, 19, 22, -624, 2, 179, -624, 1912, -624, -624,
2188 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2189 -624, 68, 68, 201, -624, -624, -624, -624, 68, -624,
2190 -624, -624, -624, -624, 68, 200, -624, 5, 215, 222,
2191 225, -624, -624, -624, -624, -624, 117, -624, -624, -624,
2192 -624, -624, -624, -624, -624, 264, 277, 7, 49, -624,
2193 -624, -624, -12, -624, 252, 252, 198, -624, 79, 231,
2194 231, -624, -624, 83, -624, -624, -624, -624, -624, -624,
2195 -624, -21, 649, -624, 138, 149, 627, 117, -624, -12,
2196 -120, 159, 649, 158, 79, 79, -624, -624, 1557, -624,
2197 -624, 2012, 320, -624, -624, -624, -624, -624, -624, -624,
2198 -13, 173, 2237, 2237, -624, 313, -624, -624, -12, -624,
2199 174, 177, 2012, 2012, 169, -118, 2012, -624, 336, 191,
2200 -624, 2012, 2012, 117, 193, -12, 226, -624, 1296, 308,
2201 -624, 1516, -624, -624, -624, -624, -624, -624, 307, 2031,
2202 108, 357, 231, -624, -624, -624, -624, -624, -624, -624,
2203 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2204 454, 958, 454, 958, 2012, 2012, 2012, 2012, -624, -624,
2205 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2206 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2207 2012, 2012, -624, 231, -624, 55, -624, -624, -624, -624,
2208 161, 1748, -624, -23, -41, -624, 203, -12, 214, -624,
2209 308, -20, 1557, -624, -624, -624, -624, -624, -624, -624,
2210 -624, -624, -624, -624, 454, 958, 454, 958, 216, 217,
2211 218, 220, 221, 224, 227, 1789, 2076, 732, 351, 228,
2212 229, 230, -624, -624, -624, -624, -624, -624, -624, 109,
2213 -624, 117, 956, -624, 219, 1466, 1466, 1466, -624, -624,
2214 -624, -624, -624, -624, -624, -624, -624, -624, -624, 2012,
2215 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2216 -624, -624, -624, -624, -624, -624, 2012, 2012, 2012, -10,
2217 3, -624, 956, -17, 223, 237, 238, 239, 240, 241,
2218 956, 956, 956, 956, 956, 352, -624, 2012, 2012, 387,
2219 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2220 -624, -624, 539, -624, -624, -624, -624, 539, -624, 158,
2221 354, 234, 248, 249, 250, 2012, 2012, 2012, 2012, 2012,
2222 2012, 2012, -624, -624, 42, 1006, -121, -624, -116, -624,
2223 2012, 2012, 2012, 253, 251, -624, -624, -624, -624, -624,
2224 -624, -624, -624, -624, -624, 353, 1807, 2094, 1175, 390,
2225 -624, -624, -624, -624, 2012, 255, -624, 256, 1516, 956,
2226 956, 956, 956, 20, -624, 29, -624, -624, 1466, 254,
2227 2012, 2012, 2012, 2012, 2012, 258, 259, 261, 262, 263,
2228 2012, 1516, 956, 266, -624, -624, -624, -624, -624, -624,
2229 -624, -624, -624, -624, -624, -624, 253, 253, 2012, 2012,
2230 2012, 2012, 2012, -624, 269, 270, 272, 273, 259, 274,
2231 2012, -624, 268, 1126, -84, -624, -624, 280, 281, 406,
2232 -5, -624, 1830, -624, 423, -624, 61, 1345, -56, -624,
2233 -77, -624, -624, 430, 431, 1466, 288, 290, 291, 292,
2234 1466, 455, 1466, 296, 298, 1466, 300, -12, -624, 301,
2235 302, 457, 461, 306, 2012, 1466, 1466, -12, 1466, 311,
2236 2012, -624, -624, -1, 312, 314, 317, 319, 101, 2012,
2237 2012, 2012, 2012, 112, 2012, -624, -624, 318, 2012, 2012,
2238 2012, 453, 478, -624, 253, -624, -12, 321, 326, 327,
2239 -624, 323, -67, -624, -624, 1466, 1466, 329, 1466, 1466,
2240 1466, 1466, 311, -624, 311, 2012, 1466, 328, 2012, 2012,
2241 2012, -624, -624, 489, 956, -624, -624, 335, 441, -624,
2242 956, -624, 2012, 2012, 2012, 2012, -624, 334, 337, 339,
2243 340, -624, 259, -624, 343, 345, 15, -624, -624, -624,
2244 178, 1848, -624, 484, -624, 338, 350, 349, 2117, -624,
2245 -624, -624, -624, -624, -624, -624, 348, 1466, -624, -624,
2246 -624, -624, 259, 2117, 311, 356, 359, 360, 361, 2012,
2247 -624, 2012, 2012, 115, -624, -624, -624, -624, -624, -624,
2248 -12, 116, -624, -624, 505, -7, 59, -12, 118, -624,
2249 358, 306, 124, -624, -624, -624, -624, -624, 363, 364,
2250 366, -624, 178, -624, 473, 1466, 1614, -624, -6, 802,
2251 802, -624, 2135, -624, -624, -624, -624, -624, -624, 526,
2252 379, -624, 374, 1614, -624, 378, 380, -624, -624, 442,
2253 59, -12, 539, -624, 516, -624, 523, 396, 161, 161,
2254 524, 802, 802, -624, 1466, 525, 1466, -624, -624, -624,
2255 1466, 486, 161, 161, -624, 543, 1466, -624
Dan Gohmanf4423b12008-04-19 00:24:39 +00002256};
2257
2258/* YYPGOTO[NTERM-NUM]. */
2259static const yytype_int16 yypgoto[] =
2260{
Chris Lattner740e7092008-10-15 06:16:57 +00002261 -624, 132, 155, 181, -165, -154, 0, -86, -143, 474,
2262 -624, 6, -624, -624, -624, -624, 67, -624, -624, -624,
2263 -142, -624, -499, -624, -252, -624, -231, -624, -624, -313,
2264 -63, -624, -434, -624, -624, -26, 342, -152, -624, 458,
2265 463, -11, -156, -242, 202, 244, 332, -624, -624, 554,
2266 -624, -624, -624, -624, -624, -624, -624, -624, -624, -624,
2267 -624, 485, -624, -624, -624, -624, -624, -624, -623, -79,
2268 213, -193, -624, -624, 520, -624, 445, -624, -624, -624,
2269 -34, 129, -448, -624, 456, -624, -624
Dan Gohmanf4423b12008-04-19 00:24:39 +00002270};
2271
2272/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2273 positive, shift that token. If negative, reduce the rule which
2274 number is the opposite. If zero, do what YYDEFACT says.
2275 If YYTABLE_NINF, syntax error. */
Chris Lattner740e7092008-10-15 06:16:57 +00002276#define YYTABLE_NINF -218
Dan Gohmanf4423b12008-04-19 00:24:39 +00002277static const yytype_int16 yytable[] =
2278{
Chris Lattner740e7092008-10-15 06:16:57 +00002279 11, 82, 272, 321, 656, 673, 13, 416, 357, 279,
2280 523, 105, 511, 512, 111, 162, 274, 11, 325, 326,
2281 327, 328, 329, 13, 376, 378, 91, 317, 335, 531,
2282 288, 490, 111, 672, 94, 111, 408, 590, 111, 318,
2283 492, 460, 146, 111, 146, 111, 460, 24, 465, 532,
2284 687, 147, 109, 236, 111, 466, 64, 65, 111, 107,
2285 67, 68, 69, 70, 71, 72, 73, 21, 1, 2,
2286 111, 3, 4, 5, 491, 25, 138, 243, 460, 273,
2287 109, 336, 22, 491, 431, 460, 138, 527, 26, 361,
2288 131, 363, 155, 11, 544, 460, 27, 358, 359, 74,
2289 589, 362, 1, 364, 595, 3, 460, 5, 84, 85,
2290 159, 119, 120, 543, -149, 89, 233, 234, 112, 285,
2291 237, 90, 50, 51, 52, 286, 241, 53, 354, 2,
2292 28, 652, 4, 464, 623, 155, 112, 659, 660, 112,
2293 240, 135, 112, 282, 353, 433, 136, 112, 418, 112,
2294 531, -61, 413, -61, 476, 478, 480, 163, 112, 571,
2295 657, 674, 112, 44, 641, 415, -61, 60, 319, 320,
2296 282, 322, 337, 338, 112, 626, 95, 106, 688, 689,
2297 58, 691, 692, 59, 323, 282, 282, 282, 282, 282,
2298 330, 331, 332, 333, 334, 282, 569, 1, 702, 703,
2299 3, 62, 5, 402, 460, 138, 402, 402, 402, 461,
2300 46, 482, 47, 75, 76, 339, 155, 77, -149, 78,
2301 108, 91, -149, 460, 38, 39, 40, 496, 540, 498,
2302 499, 500, 339, 64, 65, 542, 86, 98, 87, 603,
2303 116, 604, 117, 402, 99, 1, 2, 100, 3, 4,
2304 5, 402, 402, 402, 402, 402, 485, 435, 436, 437,
2305 438, 576, 439, 555, 219, 219, 440, 441, 103, 442,
2306 443, 444, 581, 409, 563, 651, 102, 563, 661, 508,
2307 662, 104, 340, 341, 664, 384, 662, 220, 220, 87,
2308 410, 411, 412, 122, 123, 124, 125, 126, 127, 340,
2309 341, 643, 342, 343, 142, 344, 345, 272, 346, 347,
2310 348, 432, 282, 221, 221, 143, 151, 152, 148, 342,
2311 343, 150, 344, 345, 160, 346, 347, 348, 114, 115,
2312 402, 402, 402, 402, 165, 229, 231, 232, 235, 402,
2313 238, 29, 30, 31, 32, 33, 34, 35, 36, 463,
2314 37, 239, 242, 402, 453, 454, 455, 456, 457, 458,
2315 459, 631, 605, 111, 280, 608, 609, 610, 287, 467,
2316 468, 469, 355, 379, 356, 365, 366, 367, 282, 368,
2317 369, 404, 155, 370, 273, 419, 371, 380, 381, 382,
2318 430, 434, 448, 449, 282, 497, 282, 282, 282, 420,
2319 421, 422, 423, 424, 507, 155, 402, 450, 451, 452,
2320 472, 402, 481, 402, 473, 470, 402, 483, 484, 495,
2321 501, 502, 513, 504, 505, 506, 402, 402, 510, 402,
2322 679, 519, 520, 682, 521, 522, 524, 526, 514, 515,
2323 516, 517, 528, 529, 530, 539, 536, 545, 546, 525,
2324 548, 463, 549, 550, 551, 38, 39, 40, 555, 553,
2325 556, 561, 558, 559, 560, 562, 402, 402, 563, 402,
2326 402, 402, 402, 568, 572, 587, 573, 402, 564, 574,
2327 690, 575, 588, 591, 570, 402, 592, 583, 598, 593,
2328 607, 402, 594, 611, 613, 491, 619, 620, 405, 406,
2329 407, 621, 622, 624, 586, 625, 632, 633, 577, 578,
2330 579, 580, 634, 582, 635, 639, 644, 584, 585, 645,
2331 646, 647, 655, 665, 666, 663, 667, 669, 402, 282,
2332 683, 684, 282, 282, 282, 417, 686, -18, 693, -19,
2333 694, 696, 700, 425, 426, 427, 428, 429, 289, 290,
2334 291, 292, 293, 294, 295, 296, 297, 298, 695, 705,
2335 706, 615, 616, 617, 618, 630, 668, 132, 653, 145,
2336 149, 45, 637, 351, 360, 130, 402, 97, 227, 642,
2337 402, 402, 518, 435, 436, 437, 438, 637, 439, 228,
2338 627, 0, 440, 441, 0, 442, 443, 444, 0, 0,
2339 0, 0, 0, 0, 0, 0, 0, 0, 648, 0,
2340 649, 650, 402, 402, 0, 402, 0, 402, 0, 0,
2341 0, 402, 486, 487, 488, 489, 0, 402, 0, 0,
2342 0, 494, 0, 0, 64, 65, 681, 107, 67, 68,
2343 69, 70, 71, 72, 73, 509, 1, 2, 0, 3,
2344 4, 5, 627, 0, 0, 0, 64, 65, 0, 107,
2345 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2346 0, 3, 4, 5, 0, 0, 0, 74, 0, 0,
2347 435, 436, 437, 438, 0, 439, 0, 0, 137, 440,
2348 441, 0, 442, 443, 444, 0, 0, 0, 547, 74,
2349 0, 0, 0, 552, 0, 554, 0, 0, 557, 0,
2350 0, 0, 0, 0, 0, 0, 0, 0, 565, 566,
2351 0, 567, 0, 0, 0, 0, 0, 0, 0, 0,
2352 0, 0, 0, 0, 0, 0, 0, 0, 0, 64,
2353 65, 0, 107, 67, 68, 69, 70, 71, 72, 73,
2354 0, 1, 2, 0, 3, 4, 5, 0, 596, 597,
2355 0, 599, 600, 601, 602, 0, 0, 0, 0, 606,
2356 0, 0, 0, 0, 0, 0, 0, 612, 0, 0,
2357 0, 0, 74, 614, 0, 0, 0, 0, 0, 0,
2358 0, 75, 76, 0, 0, 77, 0, 78, 144, 0,
2359 0, 0, 0, 0, 0, 385, 386, 387, 388, 64,
2360 65, 389, 0, 75, 76, -217, 0, 77, 0, 78,
2361 640, 1, 2, 0, 3, 4, 5, 390, 391, 392,
2362 0, 0, 0, -63, 1, 2, 0, 3, 4, 5,
2363 0, 0, 393, 394, 0, 6, 7, 0, 0, 0,
2364 0, 0, 0, 0, 0, 0, 339, 0, 0, 0,
2365 0, 395, 0, 0, 0, 0, 0, 8, 671, 0,
2366 0, 9, 677, 678, 0, 10, 0, 175, 176, 177,
2367 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2368 188, 189, 254, 255, 256, 257, 75, 76, 0, 0,
2369 77, 0, 78, 377, 697, 698, 0, 699, 0, 701,
2370 0, 0, 0, 704, 0, 0, 0, 0, 0, 707,
2371 0, 258, 198, 675, 676, 201, 202, 203, 204, 205,
2372 206, 207, 208, 209, 0, 259, 0, 260, 261, 262,
2373 0, 263, 264, 342, 343, 0, 344, 345, 0, 346,
2374 347, 348, 0, 0, 0, 0, 0, 0, 0, 385,
2375 386, 387, 388, 64, 65, 389, 0, 396, 0, 0,
2376 397, 0, 398, 0, 399, 1, 2, 0, 3, 4,
2377 5, 390, 391, 392, 300, 301, 0, 0, 0, 0,
2378 0, 0, 0, 0, 0, 0, 393, 394, 0, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002379 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002380 0, 111, 0, 64, 65, 395, 107, 67, 68, 69,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002381 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
Chris Lattner740e7092008-10-15 06:16:57 +00002382 5, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2383 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2384 0, 0, 0, 0, 0, 0, 74, 0, 302, 303,
2385 304, 305, 306, 307, 308, 309, 310, 311, 312, 313,
2386 314, 315, 0, 0, 0, 258, 198, 199, 200, 201,
2387 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2388 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002389 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002390 0, 0, 0, 0, 0, 112, 0, 0, 0, 0,
2391 0, 396, 0, 0, 397, 0, 398, 0, 399, 244,
2392 245, 246, 247, 64, 65, 248, 0, 0, 0, 0,
2393 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2394 5, 249, 250, 251, 0, 0, 0, 0, 0, 0,
2395 0, 0, 0, 0, 0, 0, 252, 253, 0, 0,
2396 75, 76, 0, 0, 77, 0, 78, 462, 0, 0,
2397 0, 111, 64, 65, 0, 107, 67, 68, 69, 70,
2398 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2399 0, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2400 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2401 0, 0, 0, 0, 0, 74, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002402 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002403 0, 0, 0, 0, 0, 258, 198, 199, 200, 201,
2404 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2405 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002406 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002407 0, 0, 0, 0, 0, 112, 0, 0, 0, -61,
2408 0, 265, 0, 0, 266, 0, 267, 0, 268, 244,
2409 245, 246, 247, 64, 65, 248, 0, 0, 0, 0,
2410 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2411 5, 249, 250, 251, 0, 0, 0, 0, 0, 0,
2412 0, 0, 0, 0, 0, 0, 252, 253, 0, 75,
2413 76, 0, 0, 77, 0, 78, 479, 0, 0, 0,
2414 0, 111, 64, 65, 0, 107, 67, 68, 69, 70,
2415 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2416 0, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2417 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2418 0, 0, 0, 0, 0, 74, 0, 0, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002419 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002420 0, 0, 0, 0, 0, 258, 198, 199, 200, 201,
2421 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2422 0, 260, 261, 262, 0, 263, 264, 0, 0, 0,
2423 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2424 0, 0, 0, 0, 0, 112, 0, 0, 0, 0,
2425 0, 265, 0, 0, 266, 0, 267, 0, 268, 385,
2426 386, 387, 388, 64, 65, 389, 0, 0, 0, 0,
2427 0, 0, 0, 0, 0, 1, 2, 0, 3, 4,
2428 5, 390, 391, 392, 0, 0, 0, 0, 0, 0,
2429 0, 0, 0, 0, 0, 0, 393, 394, 0, 75,
2430 76, 0, 0, 77, 0, 78, 541, 0, 0, 0,
2431 0, 0, 0, 64, 65, 395, 153, 67, 68, 69,
2432 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
2433 5, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2434 184, 185, 186, 187, 188, 189, 254, 255, 256, 257,
2435 0, 0, 0, 0, 64, 65, 74, 153, 67, 68,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002436 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
Chris Lattner740e7092008-10-15 06:16:57 +00002437 4, 5, 0, 0, 0, 258, 198, 199, 200, 201,
2438 202, 203, 204, 205, 206, 207, 208, 209, 0, 259,
2439 0, 260, 261, 262, 0, 263, 264, 74, 0, 0,
2440 0, 0, 0, 0, 0, 0, 0, 385, 386, 387,
2441 388, 0, 0, 389, 0, 0, 0, 0, 0, 0,
2442 0, 396, 0, 0, 397, 0, 398, 0, 399, 390,
2443 391, 392, 0, 0, 0, 0, 0, 0, 0, 0,
2444 0, 0, 0, 0, 393, 394, 0, 275, 276, 0,
2445 277, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2446 0, 0, 0, 395, 0, 0, 0, 0, 0, 0,
2447 75, 76, 154, 0, 77, 0, 78, 0, 0, 175,
2448 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2449 186, 187, 188, 189, 254, 255, 256, 257, 0, 0,
Devang Patel652203f2008-09-29 20:49:50 +00002450 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002451 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002452 0, 0, 0, 258, 198, 199, 200, 201, 202, 203,
2453 204, 205, 206, 207, 208, 209, 0, 259, 0, 260,
2454 261, 262, 0, 263, 264, 64, 65, 0, 107, 67,
2455 68, 69, 70, 71, 72, 73, 0, 1, 2, 0,
2456 3, 4, 5, 0, 0, 0, 0, 0, 0, 396,
2457 0, 0, 397, 0, 398, 0, 399, 350, 0, 0,
2458 0, 0, 0, 0, 0, 0, 64, 65, 74, 107,
2459 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2460 0, 3, 4, 5, 64, 65, 0, 107, 67, 68,
2461 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
2462 4, 5, 0, 0, 0, 0, 0, 64, 65, 74,
2463 107, 67, 68, 69, 70, 71, 72, 73, 0, 1,
2464 2, 0, 3, 4, 5, 64, 65, 74, 107, 67,
2465 68, 69, 70, 71, 72, 73, 0, 1, 2, 535,
2466 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2467 74, 0, 0, 0, 0, 0, 0, 629, 0, 0,
2468 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002469 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner740e7092008-10-15 06:16:57 +00002470 0, 0, 75, 76, 0, 0, 77, 0, 78, 64,
2471 65, 0, 66, 67, 68, 69, 70, 71, 72, 73,
2472 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2473 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2474 0, 0, 0, 75, 76, 0, 372, 77, 0, 78,
2475 0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
2476 0, 75, 76, 0, 475, 77, 0, 78, 0, 0,
2477 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2478 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2479 78, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2480 0, 0, 75, 76, 0, 0, 77, 0, 78, 64,
2481 65, 0, 107, 67, 68, 69, 70, 71, 72, 73,
2482 0, 1, 2, 0, 3, 4, 5, 0, 64, 65,
2483 0, 281, 67, 68, 69, 70, 71, 72, 73, 0,
2484 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2485 0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
2486 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2487 77, 74, 78, 64, 65, 0, 107, 67, 68, 69,
2488 70, 71, 72, 73, 0, 1, 2, 0, 3, 4,
2489 5, 64, 65, 0, 107, 67, 68, 69, 70, 71,
2490 72, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2491 0, 0, 0, 0, 64, 65, 74, 107, 67, 68,
2492 69, 70, 71, 72, 636, 0, 1, 2, 0, 3,
2493 4, 5, 64, 65, 74, 107, 67, 68, 69, 70,
2494 71, 72, 680, 0, 1, 2, 0, 3, 4, 5,
2495 0, 0, 0, 0, 0, 0, 0, 74, 0, 0,
2496 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2497 77, 0, 78, 0, 0, 74, 0, -216, 0, 0,
2498 0, 0, 0, 0, 0, 75, 76, 0, 0, 77,
2499 0, 78, 0, 0, 0, -63, 1, 2, 0, 3,
2500 4, 5, 0, 0, 0, 0, 0, 6, 7, 0,
2501 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2502 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
2503 75, 76, 0, 9, 77, 0, 375, 10, 0, 0,
2504 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2505 0, 0, 77, 0, 477, 0, 0, 0, 0, 0,
2506 0, 0, 0, 166, 0, 0, 0, 0, 0, 0,
2507 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
2508 0, 0, 0, 0, 167, 168, 0, 0, 0, 75,
2509 76, 0, 0, 77, 0, 78, 169, 170, 171, 172,
2510 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002511 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
Chris Lattner740e7092008-10-15 06:16:57 +00002512 193, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2513 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2514 0, 194, 195, 196, 0, 0, 197, 198, 199, 200,
2515 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
2516 211, 212, 213, 214, 215, 216, 217, 218
Dan Gohmanf4423b12008-04-19 00:24:39 +00002517};
2518
2519static const yytype_int16 yycheck[] =
2520{
Chris Lattner740e7092008-10-15 06:16:57 +00002521 0, 27, 158, 196, 11, 11, 0, 320, 239, 161,
2522 458, 4, 446, 447, 55, 28, 159, 17, 211, 212,
2523 213, 214, 215, 17, 266, 267, 21, 192, 221, 34,
2524 172, 11, 55, 656, 29, 55, 288, 536, 55, 193,
2525 11, 162, 162, 55, 162, 55, 162, 161, 169, 54,
2526 673, 171, 78, 171, 55, 171, 7, 8, 55, 10,
2527 11, 12, 13, 14, 15, 16, 17, 53, 19, 20,
2528 55, 22, 23, 24, 54, 59, 102, 156, 162, 158,
2529 106, 223, 68, 54, 336, 162, 112, 171, 161, 254,
2530 7, 256, 118, 93, 171, 162, 18, 240, 241, 50,
2531 534, 255, 19, 257, 171, 22, 162, 24, 41, 42,
2532 121, 32, 33, 169, 55, 48, 142, 143, 159, 11,
2533 146, 54, 42, 43, 44, 17, 152, 47, 169, 20,
2534 161, 630, 23, 375, 582, 161, 159, 636, 637, 159,
2535 151, 162, 159, 169, 167, 338, 167, 159, 165, 159,
2536 34, 163, 162, 163, 396, 397, 398, 170, 159, 160,
2537 167, 167, 159, 0, 612, 162, 163, 165, 194, 195,
2538 196, 197, 117, 118, 159, 160, 171, 170, 677, 678,
2539 161, 680, 681, 161, 210, 211, 212, 213, 214, 215,
2540 216, 217, 218, 219, 220, 221, 509, 19, 697, 698,
2541 22, 22, 24, 282, 162, 231, 285, 286, 287, 167,
2542 46, 404, 48, 164, 165, 54, 242, 168, 159, 170,
2543 171, 21, 163, 162, 156, 157, 158, 420, 167, 422,
2544 423, 424, 54, 7, 8, 477, 35, 22, 37, 552,
2545 42, 554, 44, 322, 22, 19, 20, 22, 22, 23,
2546 24, 330, 331, 332, 333, 334, 408, 141, 142, 143,
2547 144, 160, 146, 162, 132, 133, 150, 151, 4, 153,
2548 154, 155, 160, 299, 162, 160, 159, 162, 160, 431,
2549 162, 4, 121, 122, 160, 279, 162, 132, 133, 37,
2550 316, 317, 318, 62, 63, 64, 65, 66, 67, 121,
2551 122, 614, 141, 142, 166, 144, 145, 463, 147, 148,
2552 149, 337, 338, 132, 133, 166, 114, 115, 159, 141,
2553 142, 163, 144, 145, 4, 147, 148, 149, 84, 85,
2554 409, 410, 411, 412, 161, 22, 162, 160, 169, 418,
2555 4, 42, 43, 44, 45, 46, 47, 48, 49, 375,
2556 51, 160, 159, 432, 365, 366, 367, 368, 369, 370,
2557 371, 592, 555, 55, 57, 558, 559, 560, 11, 380,
2558 381, 382, 169, 22, 160, 159, 159, 159, 404, 159,
2559 159, 162, 408, 159, 463, 162, 159, 159, 159, 159,
2560 38, 4, 38, 159, 420, 421, 422, 423, 424, 162,
2561 162, 162, 162, 162, 430, 431, 485, 159, 159, 159,
2562 159, 490, 22, 492, 61, 162, 495, 162, 162, 165,
2563 162, 162, 448, 162, 162, 162, 505, 506, 162, 508,
2564 661, 162, 162, 664, 162, 162, 162, 169, 449, 450,
2565 451, 452, 162, 162, 38, 22, 472, 17, 17, 460,
2566 162, 477, 162, 162, 162, 156, 157, 158, 162, 4,
2567 162, 4, 162, 162, 162, 4, 545, 546, 162, 548,
2568 549, 550, 551, 162, 162, 22, 162, 556, 504, 162,
2569 38, 162, 4, 162, 510, 564, 160, 169, 159, 162,
2570 162, 570, 169, 4, 159, 54, 162, 160, 285, 286,
2571 287, 162, 162, 160, 530, 160, 22, 169, 519, 520,
2572 521, 522, 162, 524, 165, 167, 160, 528, 529, 160,
2573 160, 160, 17, 160, 160, 167, 160, 54, 607, 555,
2574 4, 152, 558, 559, 560, 322, 162, 159, 22, 159,
2575 17, 17, 17, 330, 331, 332, 333, 334, 94, 95,
2576 96, 97, 98, 99, 100, 101, 102, 103, 162, 73,
2577 17, 572, 573, 574, 575, 591, 652, 93, 631, 106,
2578 112, 17, 598, 231, 242, 90, 655, 57, 133, 613,
2579 659, 660, 453, 141, 142, 143, 144, 613, 146, 133,
2580 590, -1, 150, 151, -1, 153, 154, 155, -1, -1,
2581 -1, -1, -1, -1, -1, -1, -1, -1, 619, -1,
2582 621, 622, 691, 692, -1, 694, -1, 696, -1, -1,
2583 -1, 700, 409, 410, 411, 412, -1, 706, -1, -1,
2584 -1, 418, -1, -1, 7, 8, 662, 10, 11, 12,
2585 13, 14, 15, 16, 17, 432, 19, 20, -1, 22,
2586 23, 24, 652, -1, -1, -1, 7, 8, -1, 10,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002587 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Chris Lattner740e7092008-10-15 06:16:57 +00002588 -1, 22, 23, 24, -1, -1, -1, 50, -1, -1,
2589 141, 142, 143, 144, -1, 146, -1, -1, 39, 150,
2590 151, -1, 153, 154, 155, -1, -1, -1, 485, 50,
2591 -1, -1, -1, 490, -1, 492, -1, -1, 495, -1,
2592 -1, -1, -1, -1, -1, -1, -1, -1, 505, 506,
2593 -1, 508, -1, -1, -1, -1, -1, -1, -1, -1,
2594 -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
Devang Patel652203f2008-09-29 20:49:50 +00002595 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
Chris Lattner740e7092008-10-15 06:16:57 +00002596 -1, 19, 20, -1, 22, 23, 24, -1, 545, 546,
2597 -1, 548, 549, 550, 551, -1, -1, -1, -1, 556,
2598 -1, -1, -1, -1, -1, -1, -1, 564, -1, -1,
2599 -1, -1, 50, 570, -1, -1, -1, -1, -1, -1,
2600 -1, 164, 165, -1, -1, 168, -1, 170, 171, -1,
2601 -1, -1, -1, -1, -1, 3, 4, 5, 6, 7,
2602 8, 9, -1, 164, 165, 0, -1, 168, -1, 170,
2603 607, 19, 20, -1, 22, 23, 24, 25, 26, 27,
2604 -1, -1, -1, 18, 19, 20, -1, 22, 23, 24,
2605 -1, -1, 40, 41, -1, 30, 31, -1, -1, -1,
2606 -1, -1, -1, -1, -1, -1, 54, -1, -1, -1,
2607 -1, 59, -1, -1, -1, -1, -1, 52, 655, -1,
2608 -1, 56, 659, 660, -1, 60, -1, 75, 76, 77,
2609 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
2610 88, 89, 90, 91, 92, 93, 164, 165, -1, -1,
2611 168, -1, 170, 171, 691, 692, -1, 694, -1, 696,
2612 -1, -1, -1, 700, -1, -1, -1, -1, -1, 706,
2613 -1, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2614 128, 129, 130, 131, -1, 133, -1, 135, 136, 137,
2615 -1, 139, 140, 141, 142, -1, 144, 145, -1, 147,
2616 148, 149, -1, -1, -1, -1, -1, -1, -1, 3,
2617 4, 5, 6, 7, 8, 9, -1, 165, -1, -1,
2618 168, -1, 170, -1, 172, 19, 20, -1, 22, 23,
2619 24, 25, 26, 27, 26, 27, -1, -1, -1, -1,
2620 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002621 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002622 -1, 55, -1, 7, 8, 59, 10, 11, 12, 13,
2623 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2624 24, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2625 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2626 -1, -1, -1, -1, -1, -1, 50, -1, 100, 101,
2627 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
2628 112, 113, -1, -1, -1, 119, 120, 121, 122, 123,
2629 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2630 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
2631 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2632 -1, -1, -1, -1, -1, 159, -1, -1, -1, -1,
2633 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2634 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2635 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2636 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2637 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
2638 164, 165, -1, -1, 168, -1, 170, 171, -1, -1,
2639 -1, 55, 7, 8, -1, 10, 11, 12, 13, 14,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002640 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
Chris Lattner740e7092008-10-15 06:16:57 +00002641 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2642 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2643 -1, -1, -1, -1, -1, 50, -1, -1, -1, -1,
Devang Patel652203f2008-09-29 20:49:50 +00002644 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002645 -1, -1, -1, -1, -1, 119, 120, 121, 122, 123,
2646 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2647 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002648 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002649 -1, -1, -1, -1, -1, 159, -1, -1, -1, 163,
2650 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2651 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2652 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2653 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2654 -1, -1, -1, -1, -1, -1, 40, 41, -1, 164,
2655 165, -1, -1, 168, -1, 170, 171, -1, -1, -1,
2656 -1, 55, 7, 8, -1, 10, 11, 12, 13, 14,
2657 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2658 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2659 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2660 -1, -1, -1, -1, -1, 50, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002661 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002662 -1, -1, -1, -1, -1, 119, 120, 121, 122, 123,
2663 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2664 -1, 135, 136, 137, -1, 139, 140, -1, -1, -1,
2665 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2666 -1, -1, -1, -1, -1, 159, -1, -1, -1, -1,
2667 -1, 165, -1, -1, 168, -1, 170, -1, 172, 3,
2668 4, 5, 6, 7, 8, 9, -1, -1, -1, -1,
2669 -1, -1, -1, -1, -1, 19, 20, -1, 22, 23,
2670 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2671 -1, -1, -1, -1, -1, -1, 40, 41, -1, 164,
2672 165, -1, -1, 168, -1, 170, 171, -1, -1, -1,
2673 -1, -1, -1, 7, 8, 59, 10, 11, 12, 13,
2674 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2675 24, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2676 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2677 -1, -1, -1, -1, 7, 8, 50, 10, 11, 12,
2678 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2679 23, 24, -1, -1, -1, 119, 120, 121, 122, 123,
2680 124, 125, 126, 127, 128, 129, 130, 131, -1, 133,
2681 -1, 135, 136, 137, -1, 139, 140, 50, -1, -1,
2682 -1, -1, -1, -1, -1, -1, -1, 3, 4, 5,
2683 6, -1, -1, 9, -1, -1, -1, -1, -1, -1,
2684 -1, 165, -1, -1, 168, -1, 170, -1, 172, 25,
2685 26, 27, -1, -1, -1, -1, -1, -1, -1, -1,
2686 -1, -1, -1, -1, 40, 41, -1, 141, 142, -1,
2687 144, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2688 -1, -1, -1, 59, -1, -1, -1, -1, -1, -1,
2689 164, 165, 125, -1, 168, -1, 170, -1, -1, 75,
Chris Lattnerf9078f92008-10-15 06:03:48 +00002690 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2691 86, 87, 88, 89, 90, 91, 92, 93, -1, -1,
Chris Lattner740e7092008-10-15 06:16:57 +00002692 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2693 -1, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2694 -1, -1, -1, 119, 120, 121, 122, 123, 124, 125,
2695 126, 127, 128, 129, 130, 131, -1, 133, -1, 135,
2696 136, 137, -1, 139, 140, 7, 8, -1, 10, 11,
2697 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2698 22, 23, 24, -1, -1, -1, -1, -1, -1, 165,
2699 -1, -1, 168, -1, 170, -1, 172, 39, -1, -1,
2700 -1, -1, -1, -1, -1, -1, 7, 8, 50, 10,
2701 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2702 -1, 22, 23, 24, 7, 8, -1, 10, 11, 12,
2703 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2704 23, 24, -1, -1, -1, -1, -1, 7, 8, 50,
2705 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2706 20, -1, 22, 23, 24, 7, 8, 50, 10, 11,
2707 12, 13, 14, 15, 16, 17, -1, 19, 20, 39,
2708 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2709 50, -1, -1, -1, -1, -1, -1, 39, -1, -1,
2710 -1, -1, -1, -1, -1, -1, -1, -1, 50, -1,
2711 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2712 -1, -1, 164, 165, -1, -1, 168, -1, 170, 7,
2713 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2714 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2715 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2716 -1, -1, -1, 164, 165, -1, 167, 168, -1, 170,
2717 -1, -1, 50, -1, -1, -1, -1, -1, -1, -1,
2718 -1, 164, 165, -1, 167, 168, -1, 170, -1, -1,
2719 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2720 -1, -1, -1, -1, 164, 165, -1, -1, 168, -1,
2721 170, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2722 -1, -1, 164, 165, -1, -1, 168, -1, 170, 7,
2723 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2724 -1, 19, 20, -1, 22, 23, 24, -1, 7, 8,
2725 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2726 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2727 -1, -1, 50, -1, -1, -1, -1, -1, -1, -1,
2728 -1, -1, -1, -1, -1, -1, 164, 165, -1, -1,
2729 168, 50, 170, 7, 8, -1, 10, 11, 12, 13,
2730 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2731 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2732 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2733 -1, -1, -1, -1, 7, 8, 50, 10, 11, 12,
2734 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2735 23, 24, 7, 8, 50, 10, 11, 12, 13, 14,
2736 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2737 -1, -1, -1, -1, -1, -1, -1, 50, -1, -1,
2738 -1, -1, -1, -1, -1, -1, 164, 165, -1, -1,
2739 168, -1, 170, -1, -1, 50, -1, 0, -1, -1,
2740 -1, -1, -1, -1, -1, 164, 165, -1, -1, 168,
2741 -1, 170, -1, -1, -1, 18, 19, 20, -1, 22,
2742 23, 24, -1, -1, -1, -1, -1, 30, 31, -1,
2743 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2744 -1, -1, -1, -1, -1, -1, -1, -1, -1, 52,
2745 164, 165, -1, 56, 168, -1, 170, 60, -1, -1,
2746 -1, -1, -1, -1, -1, -1, -1, -1, 164, 165,
2747 -1, -1, 168, -1, 170, -1, -1, -1, -1, -1,
2748 -1, -1, -1, 36, -1, -1, -1, -1, -1, -1,
2749 -1, 164, 165, -1, -1, 168, -1, 170, -1, -1,
2750 -1, -1, -1, -1, 57, 58, -1, -1, -1, 164,
2751 165, -1, -1, 168, -1, 170, 69, 70, 71, 72,
2752 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2753 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2754 93, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2755 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2756 -1, 114, 115, 116, -1, -1, 119, 120, 121, 122,
2757 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
2758 133, 134, 135, 136, 137, 138, 139, 140
Dan Gohmanf4423b12008-04-19 00:24:39 +00002759};
2760
2761/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2762 symbol of state STATE-NUM. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002763static const yytype_uint16 yystos[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002764{
Dale Johannesenc7071cc2008-05-14 20:13:36 +00002765 0, 19, 20, 22, 23, 24, 30, 31, 52, 56,
Chris Lattner740e7092008-10-15 06:16:57 +00002766 60, 179, 182, 184, 185, 186, 220, 221, 222, 224,
2767 223, 53, 68, 229, 161, 59, 161, 18, 161, 42,
Devang Patel652203f2008-09-29 20:49:50 +00002768 43, 44, 45, 46, 47, 48, 49, 51, 156, 157,
Chris Lattner740e7092008-10-15 06:16:57 +00002769 158, 187, 188, 189, 0, 222, 46, 48, 190, 239,
2770 42, 43, 44, 47, 191, 236, 238, 246, 161, 161,
2771 165, 230, 22, 228, 7, 8, 10, 11, 12, 13,
2772 14, 15, 16, 17, 50, 164, 165, 168, 170, 179,
2773 184, 207, 208, 242, 189, 189, 35, 37, 218, 189,
2774 189, 21, 247, 248, 29, 171, 237, 247, 22, 22,
2775 22, 231, 159, 4, 4, 4, 170, 10, 171, 208,
2776 213, 55, 159, 181, 218, 218, 42, 44, 192, 32,
2777 33, 217, 62, 63, 64, 65, 66, 67, 193, 234,
2778 234, 7, 182, 183, 251, 162, 167, 39, 208, 209,
2779 211, 212, 166, 166, 171, 213, 162, 171, 159, 212,
2780 163, 217, 217, 10, 125, 208, 210, 219, 208, 214,
2781 4, 197, 28, 170, 235, 161, 36, 57, 58, 69,
2782 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2783 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2784 90, 91, 92, 93, 114, 115, 116, 119, 120, 121,
2785 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
2786 132, 133, 134, 135, 136, 137, 138, 139, 140, 174,
2787 175, 176, 249, 256, 257, 258, 259, 249, 257, 22,
2788 195, 162, 160, 208, 208, 169, 171, 208, 4, 160,
2789 214, 208, 159, 242, 3, 4, 5, 6, 9, 25,
2790 26, 27, 40, 41, 90, 91, 92, 93, 119, 133,
2791 135, 136, 137, 139, 140, 165, 168, 170, 172, 174,
2792 175, 176, 215, 242, 181, 141, 142, 144, 196, 210,
2793 57, 10, 208, 244, 245, 11, 17, 11, 193, 94,
2794 95, 96, 97, 98, 99, 100, 101, 102, 103, 177,
2795 26, 27, 100, 101, 102, 103, 104, 105, 106, 107,
2796 108, 109, 110, 111, 112, 113, 178, 177, 178, 208,
2797 208, 244, 208, 208, 252, 244, 244, 244, 244, 244,
2798 208, 208, 208, 208, 208, 244, 193, 117, 118, 54,
2799 121, 122, 141, 142, 144, 145, 147, 148, 149, 194,
2800 39, 209, 199, 167, 169, 169, 160, 199, 181, 181,
2801 219, 177, 178, 177, 178, 159, 159, 159, 159, 159,
2802 159, 159, 167, 214, 216, 170, 216, 171, 216, 22,
2803 159, 159, 159, 225, 184, 3, 4, 5, 6, 9,
2804 25, 26, 27, 40, 41, 59, 165, 168, 170, 172,
2805 215, 241, 242, 243, 162, 243, 243, 243, 197, 208,
2806 208, 208, 208, 162, 202, 162, 202, 243, 165, 162,
2807 162, 162, 162, 162, 162, 243, 243, 243, 243, 243,
2808 38, 197, 208, 244, 4, 141, 142, 143, 144, 146,
2809 150, 151, 153, 154, 155, 198, 226, 227, 38, 159,
2810 159, 159, 159, 214, 214, 214, 214, 214, 214, 214,
2811 162, 167, 171, 208, 216, 169, 171, 214, 214, 214,
2812 162, 205, 159, 61, 240, 167, 216, 170, 216, 171,
2813 216, 22, 244, 162, 162, 210, 243, 243, 243, 243,
2814 11, 54, 11, 254, 243, 165, 244, 208, 244, 244,
2815 244, 162, 162, 255, 162, 162, 162, 208, 210, 243,
2816 162, 205, 205, 208, 214, 214, 214, 214, 254, 162,
2817 162, 162, 162, 255, 162, 214, 169, 171, 162, 162,
2818 38, 34, 54, 203, 206, 39, 208, 232, 233, 22,
2819 167, 171, 216, 169, 171, 17, 17, 243, 162, 162,
2820 162, 162, 243, 4, 243, 162, 162, 243, 162, 162,
2821 162, 4, 4, 162, 208, 243, 243, 243, 162, 202,
2822 208, 160, 162, 162, 162, 162, 160, 214, 214, 214,
2823 214, 160, 214, 169, 214, 214, 208, 22, 4, 205,
2824 195, 162, 160, 162, 169, 171, 243, 243, 159, 243,
2825 243, 243, 243, 202, 202, 244, 243, 162, 244, 244,
2826 244, 4, 243, 159, 243, 214, 214, 214, 214, 162,
2827 160, 162, 162, 255, 160, 160, 160, 179, 180, 39,
2828 208, 199, 22, 169, 162, 165, 17, 208, 253, 167,
2829 243, 255, 253, 202, 160, 160, 160, 160, 214, 214,
2830 214, 160, 195, 203, 204, 17, 11, 167, 250, 195,
2831 195, 160, 162, 167, 160, 160, 160, 160, 180, 54,
2832 201, 243, 241, 11, 167, 121, 122, 243, 243, 199,
2833 17, 208, 199, 4, 152, 200, 162, 241, 195, 195,
2834 38, 195, 195, 22, 17, 162, 17, 243, 243, 243,
2835 17, 243, 195, 195, 243, 73, 17, 243
Dan Gohmanf4423b12008-04-19 00:24:39 +00002836};
David Greene718fda32007-08-01 03:59:32 +00002837
Reid Spencer68a24bd2005-08-27 18:50:39 +00002838#define yyerrok (yyerrstatus = 0)
2839#define yyclearin (yychar = YYEMPTY)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002840#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002841#define YYEOF 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00002842
Reid Spencer68a24bd2005-08-27 18:50:39 +00002843#define YYACCEPT goto yyacceptlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002844#define YYABORT goto yyabortlab
2845#define YYERROR goto yyerrorlab
2846
2847
2848/* Like YYERROR except do call yyerror. This remains here temporarily
2849 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002850 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00002851
Reid Spencer68a24bd2005-08-27 18:50:39 +00002852#define YYFAIL goto yyerrlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002853
Reid Spencer68a24bd2005-08-27 18:50:39 +00002854#define YYRECOVERING() (!!yyerrstatus)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002855
2856#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002857do \
2858 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002859 { \
2860 yychar = (Token); \
2861 yylval = (Value); \
2862 yytoken = YYTRANSLATE (yychar); \
2863 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002864 goto yybackup; \
2865 } \
2866 else \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002867 { \
2868 yyerror (YY_("syntax error: cannot back up")); \
2869 YYERROR; \
2870 } \
2871while (YYID (0))
2872
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002873
Reid Spencer68a24bd2005-08-27 18:50:39 +00002874#define YYTERROR 1
2875#define YYERRCODE 256
2876
Dan Gohmanf4423b12008-04-19 00:24:39 +00002877
2878/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2879 If N is 0, then set CURRENT to the empty location which ends
2880 the previous symbol: RHS[0] (always defined). */
2881
2882#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2883#ifndef YYLLOC_DEFAULT
2884# define YYLLOC_DEFAULT(Current, Rhs, N) \
2885 do \
2886 if (YYID (N)) \
2887 { \
2888 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2889 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2890 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2891 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2892 } \
2893 else \
2894 { \
2895 (Current).first_line = (Current).last_line = \
2896 YYRHSLOC (Rhs, 0).last_line; \
2897 (Current).first_column = (Current).last_column = \
2898 YYRHSLOC (Rhs, 0).last_column; \
2899 } \
2900 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002901#endif
2902
Dan Gohmanf4423b12008-04-19 00:24:39 +00002903
2904/* YY_LOCATION_PRINT -- Print the location on the stream.
2905 This macro was not mandated originally: define only if we know
2906 we won't break user code: when these are the locations we know. */
2907
2908#ifndef YY_LOCATION_PRINT
Nuno Lopes6ec8a252008-10-15 11:11:12 +00002909# if YYLTYPE_IS_TRIVIAL
Dan Gohmanf4423b12008-04-19 00:24:39 +00002910# define YY_LOCATION_PRINT(File, Loc) \
2911 fprintf (File, "%d.%d-%d.%d", \
2912 (Loc).first_line, (Loc).first_column, \
2913 (Loc).last_line, (Loc).last_column)
2914# else
2915# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2916# endif
2917#endif
2918
2919
2920/* YYLEX -- calling `yylex' with the right arguments. */
2921
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002922#ifdef YYLEX_PARAM
Dan Gohmanf4423b12008-04-19 00:24:39 +00002923# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002924#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002925# define YYLEX yylex ()
Gabor Greife64d2482008-04-06 23:07:54 +00002926#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002927
2928/* Enable debugging if requested. */
2929#if YYDEBUG
2930
2931# ifndef YYFPRINTF
2932# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2933# define YYFPRINTF fprintf
2934# endif
2935
2936# define YYDPRINTF(Args) \
2937do { \
2938 if (yydebug) \
2939 YYFPRINTF Args; \
2940} while (YYID (0))
2941
2942# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2943do { \
2944 if (yydebug) \
2945 { \
2946 YYFPRINTF (stderr, "%s ", Title); \
2947 yy_symbol_print (stderr, \
2948 Type, Value); \
2949 YYFPRINTF (stderr, "\n"); \
2950 } \
2951} while (YYID (0))
2952
2953
2954/*--------------------------------.
2955| Print this symbol on YYOUTPUT. |
2956`--------------------------------*/
2957
2958/*ARGSUSED*/
2959#if (defined __STDC__ || defined __C99__FUNC__ \
2960 || defined __cplusplus || defined _MSC_VER)
2961static void
2962yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greife64d2482008-04-06 23:07:54 +00002963#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002964static void
2965yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2966 FILE *yyoutput;
2967 int yytype;
2968 YYSTYPE const * const yyvaluep;
Gabor Greife64d2482008-04-06 23:07:54 +00002969#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002970{
2971 if (!yyvaluep)
2972 return;
2973# ifdef YYPRINT
2974 if (yytype < YYNTOKENS)
2975 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2976# else
2977 YYUSE (yyoutput);
2978# endif
2979 switch (yytype)
2980 {
2981 default:
2982 break;
2983 }
2984}
2985
2986
2987/*--------------------------------.
2988| Print this symbol on YYOUTPUT. |
2989`--------------------------------*/
2990
2991#if (defined __STDC__ || defined __C99__FUNC__ \
2992 || defined __cplusplus || defined _MSC_VER)
2993static void
2994yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2995#else
2996static void
2997yy_symbol_print (yyoutput, yytype, yyvaluep)
2998 FILE *yyoutput;
2999 int yytype;
3000 YYSTYPE const * const yyvaluep;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003001#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003002{
3003 if (yytype < YYNTOKENS)
3004 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3005 else
3006 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner38905612008-02-19 04:36:25 +00003007
Dan Gohmanf4423b12008-04-19 00:24:39 +00003008 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3009 YYFPRINTF (yyoutput, ")");
3010}
Chris Lattner38905612008-02-19 04:36:25 +00003011
Dan Gohmanf4423b12008-04-19 00:24:39 +00003012/*------------------------------------------------------------------.
3013| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3014| TOP (included). |
3015`------------------------------------------------------------------*/
Chris Lattner38905612008-02-19 04:36:25 +00003016
Dan Gohmanf4423b12008-04-19 00:24:39 +00003017#if (defined __STDC__ || defined __C99__FUNC__ \
3018 || defined __cplusplus || defined _MSC_VER)
3019static void
3020yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3021#else
3022static void
3023yy_stack_print (bottom, top)
3024 yytype_int16 *bottom;
3025 yytype_int16 *top;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003026#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003027{
3028 YYFPRINTF (stderr, "Stack now");
3029 for (; bottom <= top; ++bottom)
3030 YYFPRINTF (stderr, " %d", *bottom);
3031 YYFPRINTF (stderr, "\n");
3032}
Chris Lattner38905612008-02-19 04:36:25 +00003033
Dan Gohmanf4423b12008-04-19 00:24:39 +00003034# define YY_STACK_PRINT(Bottom, Top) \
3035do { \
3036 if (yydebug) \
3037 yy_stack_print ((Bottom), (Top)); \
3038} while (YYID (0))
Chris Lattner38905612008-02-19 04:36:25 +00003039
Dan Gohmanf4423b12008-04-19 00:24:39 +00003040
3041/*------------------------------------------------.
3042| Report that the YYRULE is going to be reduced. |
3043`------------------------------------------------*/
3044
3045#if (defined __STDC__ || defined __C99__FUNC__ \
3046 || defined __cplusplus || defined _MSC_VER)
3047static void
3048yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3049#else
3050static void
3051yy_reduce_print (yyvsp, yyrule)
3052 YYSTYPE *yyvsp;
3053 int yyrule;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003054#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003055{
3056 int yynrhs = yyr2[yyrule];
3057 int yyi;
3058 unsigned long int yylno = yyrline[yyrule];
3059 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3060 yyrule - 1, yylno);
3061 /* The symbols being reduced. */
3062 for (yyi = 0; yyi < yynrhs; yyi++)
3063 {
3064 fprintf (stderr, " $%d = ", yyi + 1);
3065 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3066 &(yyvsp[(yyi + 1) - (yynrhs)])
3067 );
3068 fprintf (stderr, "\n");
3069 }
3070}
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003071
Dan Gohmanf4423b12008-04-19 00:24:39 +00003072# define YY_REDUCE_PRINT(Rule) \
3073do { \
3074 if (yydebug) \
3075 yy_reduce_print (yyvsp, Rule); \
3076} while (YYID (0))
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003077
Dan Gohmanf4423b12008-04-19 00:24:39 +00003078/* Nonzero means print parse trace. It is left uninitialized so that
3079 multiple parsers can coexist. */
3080int yydebug;
3081#else /* !YYDEBUG */
3082# define YYDPRINTF(Args)
3083# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3084# define YY_STACK_PRINT(Bottom, Top)
3085# define YY_REDUCE_PRINT(Rule)
3086#endif /* !YYDEBUG */
3087
3088
3089/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003090#ifndef YYINITDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003091# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00003092#endif
3093
Dan Gohmanf4423b12008-04-19 00:24:39 +00003094/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3095 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00003096
Dan Gohmanf4423b12008-04-19 00:24:39 +00003097 Do not make this value too large; the results are undefined if
3098 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3099 evaluated with infinite-precision integer arithmetic. */
David Greene718fda32007-08-01 03:59:32 +00003100
Reid Spencer68a24bd2005-08-27 18:50:39 +00003101#ifndef YYMAXDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003102# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00003103#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003104
Reid Spencer68a24bd2005-08-27 18:50:39 +00003105
3106
Dan Gohmanf4423b12008-04-19 00:24:39 +00003107#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00003108
Dan Gohmanf4423b12008-04-19 00:24:39 +00003109# ifndef yystrlen
3110# if defined __GLIBC__ && defined _STRING_H
3111# define yystrlen strlen
3112# else
3113/* Return the length of YYSTR. */
3114#if (defined __STDC__ || defined __C99__FUNC__ \
3115 || defined __cplusplus || defined _MSC_VER)
3116static YYSIZE_T
3117yystrlen (const char *yystr)
Chris Lattner38905612008-02-19 04:36:25 +00003118#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003119static YYSIZE_T
3120yystrlen (yystr)
3121 const char *yystr;
3122#endif
3123{
3124 YYSIZE_T yylen;
3125 for (yylen = 0; yystr[yylen]; yylen++)
3126 continue;
3127 return yylen;
3128}
3129# endif
3130# endif
3131
3132# ifndef yystpcpy
3133# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3134# define yystpcpy stpcpy
3135# else
3136/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3137 YYDEST. */
3138#if (defined __STDC__ || defined __C99__FUNC__ \
3139 || defined __cplusplus || defined _MSC_VER)
3140static char *
3141yystpcpy (char *yydest, const char *yysrc)
3142#else
3143static char *
3144yystpcpy (yydest, yysrc)
3145 char *yydest;
3146 const char *yysrc;
3147#endif
3148{
3149 char *yyd = yydest;
3150 const char *yys = yysrc;
3151
3152 while ((*yyd++ = *yys++) != '\0')
3153 continue;
3154
3155 return yyd - 1;
3156}
3157# endif
3158# endif
3159
3160# ifndef yytnamerr
3161/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3162 quotes and backslashes, so that it's suitable for yyerror. The
3163 heuristic is that double-quoting is unnecessary unless the string
3164 contains an apostrophe, a comma, or backslash (other than
3165 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3166 null, do not copy; instead, return the length of what the result
3167 would have been. */
3168static YYSIZE_T
3169yytnamerr (char *yyres, const char *yystr)
3170{
3171 if (*yystr == '"')
3172 {
3173 YYSIZE_T yyn = 0;
3174 char const *yyp = yystr;
3175
3176 for (;;)
3177 switch (*++yyp)
3178 {
3179 case '\'':
3180 case ',':
3181 goto do_not_strip_quotes;
3182
3183 case '\\':
3184 if (*++yyp != '\\')
3185 goto do_not_strip_quotes;
3186 /* Fall through. */
3187 default:
3188 if (yyres)
3189 yyres[yyn] = *yyp;
3190 yyn++;
3191 break;
3192
3193 case '"':
3194 if (yyres)
3195 yyres[yyn] = '\0';
3196 return yyn;
3197 }
3198 do_not_strip_quotes: ;
3199 }
3200
3201 if (! yyres)
3202 return yystrlen (yystr);
3203
3204 return yystpcpy (yyres, yystr) - yyres;
3205}
3206# endif
3207
3208/* Copy into YYRESULT an error message about the unexpected token
3209 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3210 including the terminating null byte. If YYRESULT is null, do not
3211 copy anything; just return the number of bytes that would be
3212 copied. As a special case, return 0 if an ordinary "syntax error"
3213 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3214 size calculation. */
3215static YYSIZE_T
3216yysyntax_error (char *yyresult, int yystate, int yychar)
3217{
3218 int yyn = yypact[yystate];
3219
3220 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3221 return 0;
3222 else
3223 {
3224 int yytype = YYTRANSLATE (yychar);
3225 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3226 YYSIZE_T yysize = yysize0;
3227 YYSIZE_T yysize1;
3228 int yysize_overflow = 0;
3229 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3230 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3231 int yyx;
3232
3233# if 0
3234 /* This is so xgettext sees the translatable formats that are
3235 constructed on the fly. */
3236 YY_("syntax error, unexpected %s");
3237 YY_("syntax error, unexpected %s, expecting %s");
3238 YY_("syntax error, unexpected %s, expecting %s or %s");
3239 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3240 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3241# endif
3242 char *yyfmt;
3243 char const *yyf;
3244 static char const yyunexpected[] = "syntax error, unexpected %s";
3245 static char const yyexpecting[] = ", expecting %s";
3246 static char const yyor[] = " or %s";
3247 char yyformat[sizeof yyunexpected
3248 + sizeof yyexpecting - 1
3249 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3250 * (sizeof yyor - 1))];
3251 char const *yyprefix = yyexpecting;
3252
3253 /* Start YYX at -YYN if negative to avoid negative indexes in
3254 YYCHECK. */
3255 int yyxbegin = yyn < 0 ? -yyn : 0;
3256
3257 /* Stay within bounds of both yycheck and yytname. */
3258 int yychecklim = YYLAST - yyn + 1;
3259 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3260 int yycount = 1;
3261
3262 yyarg[0] = yytname[yytype];
3263 yyfmt = yystpcpy (yyformat, yyunexpected);
3264
3265 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3266 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3267 {
3268 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3269 {
3270 yycount = 1;
3271 yysize = yysize0;
3272 yyformat[sizeof yyunexpected - 1] = '\0';
3273 break;
3274 }
3275 yyarg[yycount++] = yytname[yyx];
3276 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3277 yysize_overflow |= (yysize1 < yysize);
3278 yysize = yysize1;
3279 yyfmt = yystpcpy (yyfmt, yyprefix);
3280 yyprefix = yyor;
3281 }
3282
3283 yyf = YY_(yyformat);
3284 yysize1 = yysize + yystrlen (yyf);
3285 yysize_overflow |= (yysize1 < yysize);
3286 yysize = yysize1;
3287
3288 if (yysize_overflow)
3289 return YYSIZE_MAXIMUM;
3290
3291 if (yyresult)
3292 {
3293 /* Avoid sprintf, as that infringes on the user's name space.
3294 Don't have undefined behavior even if the translation
3295 produced a string with the wrong number of "%s"s. */
3296 char *yyp = yyresult;
3297 int yyi = 0;
3298 while ((*yyp = *yyf) != '\0')
3299 {
3300 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3301 {
3302 yyp += yytnamerr (yyp, yyarg[yyi++]);
3303 yyf += 2;
3304 }
3305 else
3306 {
3307 yyp++;
3308 yyf++;
3309 }
3310 }
3311 }
3312 return yysize;
3313 }
3314}
3315#endif /* YYERROR_VERBOSE */
3316
3317
3318/*-----------------------------------------------.
3319| Release the memory associated to this symbol. |
3320`-----------------------------------------------*/
3321
3322/*ARGSUSED*/
3323#if (defined __STDC__ || defined __C99__FUNC__ \
3324 || defined __cplusplus || defined _MSC_VER)
3325static void
3326yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3327#else
3328static void
3329yydestruct (yymsg, yytype, yyvaluep)
3330 const char *yymsg;
3331 int yytype;
3332 YYSTYPE *yyvaluep;
3333#endif
3334{
3335 YYUSE (yyvaluep);
3336
3337 if (!yymsg)
3338 yymsg = "Deleting";
3339 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3340
3341 switch (yytype)
3342 {
3343
3344 default:
3345 break;
3346 }
3347}
3348
3349
3350/* Prevent warnings from -Wmissing-prototypes. */
3351
3352#ifdef YYPARSE_PARAM
3353#if defined __STDC__ || defined __cplusplus
3354int yyparse (void *YYPARSE_PARAM);
3355#else
3356int yyparse ();
3357#endif
3358#else /* ! YYPARSE_PARAM */
3359#if defined __STDC__ || defined __cplusplus
David Greene5fd22a82007-09-04 18:46:50 +00003360int yyparse (void);
Gabor Greife64d2482008-04-06 23:07:54 +00003361#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003362int yyparse ();
Scott Michel15dcd8e2008-01-30 03:10:00 +00003363#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003364#endif /* ! YYPARSE_PARAM */
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003365
Chris Lattner38905612008-02-19 04:36:25 +00003366
Dan Gohmanf4423b12008-04-19 00:24:39 +00003367
3368/* The look-ahead symbol. */
3369int yychar;
3370
3371/* The semantic value of the look-ahead symbol. */
3372YYSTYPE yylval;
3373
3374/* Number of syntax errors so far. */
3375int yynerrs;
3376
3377
3378
3379/*----------.
3380| yyparse. |
3381`----------*/
3382
3383#ifdef YYPARSE_PARAM
3384#if (defined __STDC__ || defined __C99__FUNC__ \
3385 || defined __cplusplus || defined _MSC_VER)
3386int
3387yyparse (void *YYPARSE_PARAM)
3388#else
3389int
3390yyparse (YYPARSE_PARAM)
3391 void *YYPARSE_PARAM;
3392#endif
3393#else /* ! YYPARSE_PARAM */
3394#if (defined __STDC__ || defined __C99__FUNC__ \
3395 || defined __cplusplus || defined _MSC_VER)
3396int
3397yyparse (void)
3398#else
3399int
3400yyparse ()
3401
Gabor Greife64d2482008-04-06 23:07:54 +00003402#endif
3403#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003404{
3405
3406 int yystate;
3407 int yyn;
3408 int yyresult;
3409 /* Number of tokens to shift before error messages enabled. */
3410 int yyerrstatus;
3411 /* Look-ahead token as an internal (translated) token number. */
3412 int yytoken = 0;
3413#if YYERROR_VERBOSE
3414 /* Buffer for error messages, and its allocated size. */
3415 char yymsgbuf[128];
3416 char *yymsg = yymsgbuf;
3417 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greife64d2482008-04-06 23:07:54 +00003418#endif
Chris Lattner38905612008-02-19 04:36:25 +00003419
Dan Gohmanf4423b12008-04-19 00:24:39 +00003420 /* Three stacks and their tools:
3421 `yyss': related to states,
3422 `yyvs': related to semantic values,
3423 `yyls': related to locations.
3424
3425 Refer to the stacks thru separate pointers, to allow yyoverflow
3426 to reallocate them elsewhere. */
3427
3428 /* The state stack. */
3429 yytype_int16 yyssa[YYINITDEPTH];
3430 yytype_int16 *yyss = yyssa;
3431 yytype_int16 *yyssp;
3432
3433 /* The semantic value stack. */
3434 YYSTYPE yyvsa[YYINITDEPTH];
3435 YYSTYPE *yyvs = yyvsa;
3436 YYSTYPE *yyvsp;
3437
3438
3439
3440#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3441
3442 YYSIZE_T yystacksize = YYINITDEPTH;
3443
3444 /* The variables used to return semantic value and location from the
3445 action routines. */
3446 YYSTYPE yyval;
3447
3448
3449 /* The number of symbols on the RHS of the reduced rule.
3450 Keep to zero when no symbol should be popped. */
3451 int yylen = 0;
3452
3453 YYDPRINTF ((stderr, "Starting parse\n"));
3454
Reid Spencer68a24bd2005-08-27 18:50:39 +00003455 yystate = 0;
3456 yyerrstatus = 0;
3457 yynerrs = 0;
3458 yychar = YYEMPTY; /* Cause a token to be read. */
3459
3460 /* Initialize stack pointers.
3461 Waste one element of value and location stack
3462 so that they stay on the same level as the state stack.
3463 The wasted elements are never initialized. */
3464
Dan Gohmanf4423b12008-04-19 00:24:39 +00003465 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003466 yyvsp = yyvs;
3467
Dan Gohmanf4423b12008-04-19 00:24:39 +00003468 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003469
Dan Gohmanf4423b12008-04-19 00:24:39 +00003470/*------------------------------------------------------------.
3471| yynewstate -- Push a new state, which is found in yystate. |
3472`------------------------------------------------------------*/
3473 yynewstate:
3474 /* In all cases, when you get here, the value and location stacks
3475 have just been pushed. So pushing a state here evens the stacks. */
3476 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003477
Dan Gohmanf4423b12008-04-19 00:24:39 +00003478 yysetstate:
3479 *yyssp = yystate;
3480
3481 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003482 {
3483 /* Get the current used size of the three stacks, in elements. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003484 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003485
3486#ifdef yyoverflow
Dan Gohmanf4423b12008-04-19 00:24:39 +00003487 {
3488 /* Give user a chance to reallocate the stack. Use copies of
3489 these so that the &'s don't force the real ones into
3490 memory. */
3491 YYSTYPE *yyvs1 = yyvs;
3492 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003493
Dan Gohmanf4423b12008-04-19 00:24:39 +00003494
3495 /* Each stack pointer address is followed by the size of the
3496 data in use in that stack, in bytes. This used to be a
3497 conditional around just the two extra args, but that might
3498 be undefined if yyoverflow is a macro. */
3499 yyoverflow (YY_("memory exhausted"),
3500 &yyss1, yysize * sizeof (*yyssp),
3501 &yyvs1, yysize * sizeof (*yyvsp),
3502
3503 &yystacksize);
3504
3505 yyss = yyss1;
3506 yyvs = yyvs1;
3507 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003508#else /* no yyoverflow */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003509# ifndef YYSTACK_RELOCATE
3510 goto yyexhaustedlab;
3511# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003512 /* Extend the stack our own way. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003513 if (YYMAXDEPTH <= yystacksize)
3514 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003515 yystacksize *= 2;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003516 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003517 yystacksize = YYMAXDEPTH;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003518
3519 {
3520 yytype_int16 *yyss1 = yyss;
3521 union yyalloc *yyptr =
3522 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3523 if (! yyptr)
3524 goto yyexhaustedlab;
3525 YYSTACK_RELOCATE (yyss);
3526 YYSTACK_RELOCATE (yyvs);
3527
3528# undef YYSTACK_RELOCATE
3529 if (yyss1 != yyssa)
3530 YYSTACK_FREE (yyss1);
3531 }
3532# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003533#endif /* no yyoverflow */
3534
Dan Gohmanf4423b12008-04-19 00:24:39 +00003535 yyssp = yyss + yysize - 1;
3536 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003537
3538
Dan Gohmanf4423b12008-04-19 00:24:39 +00003539 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3540 (unsigned long int) yystacksize));
3541
3542 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003543 YYABORT;
3544 }
3545
Dan Gohmanf4423b12008-04-19 00:24:39 +00003546 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003547
3548 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003549
Dan Gohmanf4423b12008-04-19 00:24:39 +00003550/*-----------.
3551| yybackup. |
3552`-----------*/
3553yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003554
Dan Gohmanf4423b12008-04-19 00:24:39 +00003555 /* Do appropriate processing given the current state. Read a
3556 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003557
Dan Gohmanf4423b12008-04-19 00:24:39 +00003558 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003559 yyn = yypact[yystate];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003560 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003561 goto yydefault;
3562
Dan Gohmanf4423b12008-04-19 00:24:39 +00003563 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003564
Dan Gohmanf4423b12008-04-19 00:24:39 +00003565 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003566 if (yychar == YYEMPTY)
3567 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003568 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003569 yychar = YYLEX;
3570 }
3571
Dan Gohmanf4423b12008-04-19 00:24:39 +00003572 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003573 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003574 yychar = yytoken = YYEOF;
3575 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003576 }
3577 else
3578 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003579 yytoken = YYTRANSLATE (yychar);
3580 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003581 }
3582
Dan Gohmanf4423b12008-04-19 00:24:39 +00003583 /* If the proper action on seeing token YYTOKEN is to reduce or to
3584 detect an error, take that action. */
3585 yyn += yytoken;
3586 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003587 goto yydefault;
3588 yyn = yytable[yyn];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003589 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003590 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003591 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003592 goto yyerrlab;
3593 yyn = -yyn;
3594 goto yyreduce;
3595 }
3596
3597 if (yyn == YYFINAL)
3598 YYACCEPT;
3599
Dan Gohmanf4423b12008-04-19 00:24:39 +00003600 /* Count tokens shifted since error; after three, turn off error
3601 status. */
3602 if (yyerrstatus)
3603 yyerrstatus--;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003604
Dan Gohmanf4423b12008-04-19 00:24:39 +00003605 /* Shift the look-ahead token. */
3606 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003607
Dan Gohmanf4423b12008-04-19 00:24:39 +00003608 /* Discard the shifted token unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003609 if (yychar != YYEOF)
3610 yychar = YYEMPTY;
3611
Gabor Greife64d2482008-04-06 23:07:54 +00003612 yystate = yyn;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003613 *++yyvsp = yylval;
3614
Reid Spencer68a24bd2005-08-27 18:50:39 +00003615 goto yynewstate;
3616
Gabor Greife64d2482008-04-06 23:07:54 +00003617
Dan Gohmanf4423b12008-04-19 00:24:39 +00003618/*-----------------------------------------------------------.
3619| yydefault -- do the default action for the current state. |
3620`-----------------------------------------------------------*/
3621yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003622 yyn = yydefact[yystate];
3623 if (yyn == 0)
3624 goto yyerrlab;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003625 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003626
Dan Gohmanf4423b12008-04-19 00:24:39 +00003627
3628/*-----------------------------.
3629| yyreduce -- Do a reduction. |
3630`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003631yyreduce:
Dan Gohmanf4423b12008-04-19 00:24:39 +00003632 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003633 yylen = yyr2[yyn];
3634
Dan Gohmanf4423b12008-04-19 00:24:39 +00003635 /* If YYLEN is nonzero, implement the default value of the action:
3636 `$$ = $1'.
3637
3638 Otherwise, the following line sets YYVAL to garbage.
3639 This behavior is undocumented and Bison
3640 users should not rely upon it. Assigning to YYVAL
3641 unconditionally makes the parser a bit smaller, and it avoids a
3642 GCC warning that YYVAL may be used uninitialized. */
3643 yyval = yyvsp[1-yylen];
3644
3645
3646 YY_REDUCE_PRINT (yyn);
3647 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003648 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003649 case 29:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003650#line 1152 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003651 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3652 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003653
Dan Gohmanf4423b12008-04-19 00:24:39 +00003654 case 30:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003655#line 1152 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003656 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3657 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003658
Dan Gohmanf4423b12008-04-19 00:24:39 +00003659 case 31:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003660#line 1153 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003661 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3662 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003663
Dan Gohmanf4423b12008-04-19 00:24:39 +00003664 case 32:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003665#line 1153 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003666 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3667 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003668
Dan Gohmanf4423b12008-04-19 00:24:39 +00003669 case 33:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003670#line 1154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003671 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3672 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003673
Dan Gohmanf4423b12008-04-19 00:24:39 +00003674 case 34:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003675#line 1154 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003676 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3677 break;
3678
3679 case 35:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003680#line 1155 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003681 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3682 break;
3683
3684 case 36:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003685#line 1155 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003686 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3687 break;
3688
3689 case 37:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003690#line 1156 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003691 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3692 break;
3693
3694 case 38:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003695#line 1156 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003696 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3697 break;
3698
3699 case 39:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003700#line 1160 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003701 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3702 break;
3703
3704 case 40:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003705#line 1160 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003706 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3707 break;
3708
3709 case 41:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003710#line 1161 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003711 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3712 break;
3713
3714 case 42:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003715#line 1161 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003716 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3717 break;
3718
3719 case 43:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003720#line 1162 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003721 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3722 break;
3723
3724 case 44:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003725#line 1162 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003726 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3727 break;
3728
3729 case 45:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003730#line 1163 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003731 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3732 break;
3733
3734 case 46:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003735#line 1163 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003736 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3737 break;
3738
3739 case 47:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003740#line 1164 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003741 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3742 break;
3743
3744 case 48:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003745#line 1164 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003746 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3747 break;
3748
3749 case 49:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003750#line 1165 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003751 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3752 break;
3753
3754 case 50:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003755#line 1165 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003756 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3757 break;
3758
3759 case 51:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003760#line 1166 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003761 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3762 break;
3763
3764 case 52:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003765#line 1166 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003766 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3767 break;
3768
3769 case 53:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003770#line 1167 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003771 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3772 break;
3773
3774 case 54:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003775#line 1168 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003776 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3777 break;
3778
Chris Lattner740e7092008-10-15 06:16:57 +00003779 case 59:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003780#line 1172 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003781 { (yyval.StrVal) = 0; ;}
3782 break;
3783
Chris Lattner740e7092008-10-15 06:16:57 +00003784 case 60:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003785#line 1174 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003786 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3787 break;
3788
Chris Lattner740e7092008-10-15 06:16:57 +00003789 case 61:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003790#line 1175 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003791 { (yyval.UIntVal)=0; ;}
3792 break;
3793
Chris Lattner740e7092008-10-15 06:16:57 +00003794 case 62:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003795#line 1179 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003796 {
3797 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003798 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003799 ;}
3800 break;
3801
Chris Lattner740e7092008-10-15 06:16:57 +00003802 case 63:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003803#line 1183 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003804 {
3805 (yyval.StrVal) = 0;
3806 CHECK_FOR_ERROR
3807 ;}
3808 break;
3809
3810 case 64:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003811#line 1188 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003812 {
3813 (yyval.UIntVal) = (yyvsp[(1) - (2)].UIntVal);
3814 CHECK_FOR_ERROR
3815;}
3816 break;
3817
Chris Lattnerf9078f92008-10-15 06:03:48 +00003818 case 68:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003819#line 1197 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003820 {
3821 (yyval.StrVal) = 0;
Christopher Lambbf3348d2007-12-12 08:45:45 +00003822 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003823 ;}
3824 break;
3825
Chris Lattnerf9078f92008-10-15 06:03:48 +00003826 case 69:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003827#line 1202 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003828 {
3829 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00003830 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003831 ;}
3832 break;
3833
Chris Lattner740e7092008-10-15 06:16:57 +00003834 case 70:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003835#line 1208 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003836 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3837 break;
3838
Chris Lattner740e7092008-10-15 06:16:57 +00003839 case 71:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003840#line 1209 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003841 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3842 break;
3843
Chris Lattner740e7092008-10-15 06:16:57 +00003844 case 72:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003845#line 1210 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003846 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3847 break;
3848
Chris Lattner740e7092008-10-15 06:16:57 +00003849 case 73:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003850#line 1211 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003851 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3852 break;
3853
Chris Lattner740e7092008-10-15 06:16:57 +00003854 case 74:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003855#line 1212 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003856 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3857 break;
3858
Chris Lattner740e7092008-10-15 06:16:57 +00003859 case 75:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003860#line 1213 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003861 { (yyval.Linkage) = GlobalValue::CommonLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003862 break;
3863
Chris Lattner740e7092008-10-15 06:16:57 +00003864 case 76:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003865#line 1217 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003866 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003867 break;
3868
Chris Lattner740e7092008-10-15 06:16:57 +00003869 case 77:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003870#line 1218 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003871 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003872 break;
3873
Chris Lattner740e7092008-10-15 06:16:57 +00003874 case 78:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003875#line 1219 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003876 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3877 break;
3878
3879 case 79:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003880#line 1223 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003881 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3882 break;
3883
3884 case 80:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003885#line 1224 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003886 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3887 break;
3888
3889 case 81:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003890#line 1225 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003891 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3892 break;
3893
3894 case 82:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003895#line 1226 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003896 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3897 break;
3898
3899 case 83:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003900#line 1230 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003901 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003902 break;
3903
Chris Lattnerf9078f92008-10-15 06:03:48 +00003904 case 84:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003905#line 1231 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003906 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003907 break;
3908
Chris Lattner740e7092008-10-15 06:16:57 +00003909 case 85:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003910#line 1232 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003911 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003912 break;
3913
Chris Lattner740e7092008-10-15 06:16:57 +00003914 case 86:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003915#line 1236 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003916 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3917 break;
3918
3919 case 87:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003920#line 1237 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003921 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3922 break;
3923
3924 case 88:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003925#line 1238 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003926 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3927 break;
3928
3929 case 89:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003930#line 1239 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003931 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3932 break;
3933
3934 case 90:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003935#line 1240 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003936 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3937 break;
3938
3939 case 91:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003940#line 1244 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003941 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3942 break;
3943
Chris Lattnerf9078f92008-10-15 06:03:48 +00003944 case 92:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003945#line 1245 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003946 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Chris Lattnerf9078f92008-10-15 06:03:48 +00003947 break;
3948
Chris Lattner15bd0952008-08-29 17:20:18 +00003949 case 93:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003950#line 1246 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003951 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003952 break;
3953
Chris Lattner740e7092008-10-15 06:16:57 +00003954 case 94:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003955#line 1249 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00003956 { (yyval.UIntVal) = CallingConv::C; ;}
3957 break;
3958
Chris Lattner740e7092008-10-15 06:16:57 +00003959 case 95:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003960#line 1250 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003961 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003962 break;
3963
Chris Lattner740e7092008-10-15 06:16:57 +00003964 case 96:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003965#line 1251 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003966 { (yyval.UIntVal) = CallingConv::Fast; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003967 break;
3968
Chris Lattner740e7092008-10-15 06:16:57 +00003969 case 97:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003970#line 1252 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003971 { (yyval.UIntVal) = CallingConv::Cold; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003972 break;
3973
Chris Lattner740e7092008-10-15 06:16:57 +00003974 case 98:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003975#line 1253 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003976 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003977 break;
3978
Chris Lattner740e7092008-10-15 06:16:57 +00003979 case 99:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003980#line 1254 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003981 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00003982 break;
3983
Chris Lattner740e7092008-10-15 06:16:57 +00003984 case 100:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003985#line 1255 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003986 {
3987 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003988 GEN_ERROR("Calling conv too large");
Dan Gohmanf4423b12008-04-19 00:24:39 +00003989 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003990 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003991 ;}
3992 break;
3993
Chris Lattner740e7092008-10-15 06:16:57 +00003994 case 101:
Nuno Lopesf05ff662008-10-15 11:20:21 +00003995#line 1262 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00003996 { (yyval.Attributes) = Attribute::ZExt; ;}
3997 break;
3998
3999 case 102:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004000#line 1263 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004001 { (yyval.Attributes) = Attribute::ZExt; ;}
4002 break;
4003
4004 case 103:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004005#line 1264 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004006 { (yyval.Attributes) = Attribute::SExt; ;}
4007 break;
4008
4009 case 104:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004010#line 1265 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004011 { (yyval.Attributes) = Attribute::SExt; ;}
4012 break;
4013
4014 case 105:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004015#line 1266 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004016 { (yyval.Attributes) = Attribute::InReg; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004017 break;
4018
Chris Lattner740e7092008-10-15 06:16:57 +00004019 case 106:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004020#line 1267 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004021 { (yyval.Attributes) = Attribute::StructRet; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004022 break;
4023
Chris Lattner740e7092008-10-15 06:16:57 +00004024 case 107:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004025#line 1268 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004026 { (yyval.Attributes) = Attribute::NoAlias; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004027 break;
4028
Chris Lattner740e7092008-10-15 06:16:57 +00004029 case 108:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004030#line 1269 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004031 { (yyval.Attributes) = Attribute::ByVal; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004032 break;
4033
Chris Lattner740e7092008-10-15 06:16:57 +00004034 case 109:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004035#line 1270 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004036 { (yyval.Attributes) = Attribute::Nest; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004037 break;
4038
Chris Lattner740e7092008-10-15 06:16:57 +00004039 case 110:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004040#line 1271 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004041 { (yyval.Attributes) =
4042 Attribute::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004043 break;
4044
Chris Lattner740e7092008-10-15 06:16:57 +00004045 case 111:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004046#line 1275 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004047 { (yyval.Attributes) = Attribute::None; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004048 break;
4049
Chris Lattner740e7092008-10-15 06:16:57 +00004050 case 112:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004051#line 1276 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesendfe8c842008-09-26 19:32:34 +00004052 {
4053 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4054 ;}
4055 break;
4056
Chris Lattner740e7092008-10-15 06:16:57 +00004057 case 113:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004058#line 1281 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004059 { (yyval.Attributes) = Attribute::InReg; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004060 break;
4061
Chris Lattner740e7092008-10-15 06:16:57 +00004062 case 114:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004063#line 1282 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004064 { (yyval.Attributes) = Attribute::ZExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004065 break;
4066
Chris Lattner740e7092008-10-15 06:16:57 +00004067 case 115:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004068#line 1283 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004069 { (yyval.Attributes) = Attribute::SExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004070 break;
4071
Chris Lattner740e7092008-10-15 06:16:57 +00004072 case 116:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004073#line 1286 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004074 { (yyval.Attributes) = Attribute::None; ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00004075 break;
4076
Chris Lattner740e7092008-10-15 06:16:57 +00004077 case 117:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004078#line 1287 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004079 {
4080 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4081 ;}
4082 break;
4083
Chris Lattner740e7092008-10-15 06:16:57 +00004084 case 118:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004085#line 1293 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004086 { (yyval.Attributes) = Attribute::NoReturn; ;}
4087 break;
4088
Chris Lattner740e7092008-10-15 06:16:57 +00004089 case 119:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004090#line 1294 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004091 { (yyval.Attributes) = Attribute::NoUnwind; ;}
4092 break;
4093
Chris Lattner740e7092008-10-15 06:16:57 +00004094 case 120:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004095#line 1295 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004096 { (yyval.Attributes) = Attribute::InReg; ;}
4097 break;
4098
Chris Lattner740e7092008-10-15 06:16:57 +00004099 case 121:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004100#line 1296 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004101 { (yyval.Attributes) = Attribute::ZExt; ;}
4102 break;
4103
Chris Lattner740e7092008-10-15 06:16:57 +00004104 case 122:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004105#line 1297 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004106 { (yyval.Attributes) = Attribute::SExt; ;}
4107 break;
4108
Chris Lattner740e7092008-10-15 06:16:57 +00004109 case 123:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004110#line 1298 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004111 { (yyval.Attributes) = Attribute::ReadNone; ;}
4112 break;
4113
Chris Lattner740e7092008-10-15 06:16:57 +00004114 case 124:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004115#line 1299 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004116 { (yyval.Attributes) = Attribute::ReadOnly; ;}
4117 break;
4118
Chris Lattner740e7092008-10-15 06:16:57 +00004119 case 125:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004120#line 1300 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner9fc4da42008-10-08 06:44:45 +00004121 { (yyval.Attributes) = Attribute::NoInline; ;}
Devang Patel652203f2008-09-29 20:49:50 +00004122 break;
4123
Chris Lattner740e7092008-10-15 06:16:57 +00004124 case 126:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004125#line 1301 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner9fc4da42008-10-08 06:44:45 +00004126 { (yyval.Attributes) = Attribute::AlwaysInline; ;}
Devang Patel652203f2008-09-29 20:49:50 +00004127 break;
4128
Chris Lattner740e7092008-10-15 06:16:57 +00004129 case 127:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004130#line 1302 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner9fc4da42008-10-08 06:44:45 +00004131 { (yyval.Attributes) = Attribute::OptimizeForSize; ;}
Devang Patel652203f2008-09-29 20:49:50 +00004132 break;
4133
Chris Lattner740e7092008-10-15 06:16:57 +00004134 case 128:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004135#line 1305 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00004136 { (yyval.Attributes) = Attribute::None; ;}
4137 break;
4138
Chris Lattner740e7092008-10-15 06:16:57 +00004139 case 129:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004140#line 1306 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004141 {
Devang Patel05988662008-09-25 21:00:45 +00004142 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
Chris Lattner15bd0952008-08-29 17:20:18 +00004143 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004144 break;
4145
Chris Lattner740e7092008-10-15 06:16:57 +00004146 case 130:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004147#line 1312 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld4980812008-09-02 20:52:40 +00004148 { (yyval.StrVal) = 0; ;}
4149 break;
4150
Chris Lattner740e7092008-10-15 06:16:57 +00004151 case 131:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004152#line 1313 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004153 {
4154 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4155 ;}
4156 break;
4157
Chris Lattner740e7092008-10-15 06:16:57 +00004158 case 132:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004159#line 1320 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004160 { (yyval.UIntVal) = 0; ;}
4161 break;
4162
Chris Lattner740e7092008-10-15 06:16:57 +00004163 case 133:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004164#line 1321 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004165 {
4166 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4167 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004168 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004169 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004170;}
4171 break;
4172
Chris Lattner740e7092008-10-15 06:16:57 +00004173 case 134:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004174#line 1327 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004175 { (yyval.UIntVal) = 0; ;}
4176 break;
4177
Chris Lattner740e7092008-10-15 06:16:57 +00004178 case 135:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004179#line 1328 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004180 {
4181 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4182 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lambbf3348d2007-12-12 08:45:45 +00004183 GEN_ERROR("Alignment must be a power of two");
4184 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004185;}
4186 break;
4187
Chris Lattner740e7092008-10-15 06:16:57 +00004188 case 136:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004189#line 1337 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004190 {
4191 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
4192 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004193 GEN_ERROR("Invalid character in section name");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004194 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004195 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004196;}
4197 break;
4198
Chris Lattner740e7092008-10-15 06:16:57 +00004199 case 137:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004200#line 1345 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004201 { (yyval.StrVal) = 0; ;}
4202 break;
4203
Chris Lattner740e7092008-10-15 06:16:57 +00004204 case 138:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004205#line 1346 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004206 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4207 break;
4208
Chris Lattner740e7092008-10-15 06:16:57 +00004209 case 139:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004210#line 1351 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00004211 {;}
4212 break;
4213
Chris Lattner740e7092008-10-15 06:16:57 +00004214 case 140:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004215#line 1352 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004216 {;}
4217 break;
4218
Chris Lattner740e7092008-10-15 06:16:57 +00004219 case 141:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004220#line 1353 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004221 {
4222 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4223 delete (yyvsp[(1) - (1)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004224 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004225 ;}
4226 break;
4227
Chris Lattner740e7092008-10-15 06:16:57 +00004228 case 142:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004229#line 1358 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004230 {
4231 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004232 GEN_ERROR("Alignment must be a power of two");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004233 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004234 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004235 ;}
4236 break;
4237
Chris Lattner740e7092008-10-15 06:16:57 +00004238 case 150:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004239#line 1374 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004240 {
4241 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004242 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004243 ;}
4244 break;
4245
Chris Lattner740e7092008-10-15 06:16:57 +00004246 case 151:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004247#line 1378 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004248 {
4249 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004250 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004251 ;}
4252 break;
4253
Chris Lattner740e7092008-10-15 06:16:57 +00004254 case 152:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004255#line 1382 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004256 { // Pointer type?
4257 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lambbf3348d2007-12-12 08:45:45 +00004258 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004259 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4260 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00004261 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004262 ;}
4263 break;
4264
Chris Lattner740e7092008-10-15 06:16:57 +00004265 case 153:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004266#line 1389 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004267 { // Named types are also simple types...
4268 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004269 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004270 (yyval.TypeVal) = new PATypeHolder(tmp);
4271 ;}
4272 break;
4273
Chris Lattner740e7092008-10-15 06:16:57 +00004274 case 154:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004275#line 1394 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004276 { // Type UpReference
4277 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004278 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohmanf4423b12008-04-19 00:24:39 +00004279 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4280 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004281 UR_OUT("New Upreference!\n");
4282 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004283 ;}
4284 break;
4285
Chris Lattner740e7092008-10-15 06:16:57 +00004286 case 155:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004287#line 1402 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004288 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004289 // Allow but ignore attributes on function types; this permits auto-upgrade.
4290 // FIXME: remove in LLVM 3.0.
Chris Lattnera925a142008-04-23 05:37:08 +00004291 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4292 if (!FunctionType::isValidReturnType(RetTy))
4293 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004294
Reid Spencer41dff5e2007-01-26 08:05:27 +00004295 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004296 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004297 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004298 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004299 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004300 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004301
Reid Spencer41dff5e2007-01-26 08:05:27 +00004302 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4303 if (isVarArg) Params.pop_back();
4304
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004305 for (unsigned i = 0; i != Params.size(); ++i)
4306 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4307 GEN_ERROR("Function arguments must be value types!");
4308
4309 CHECK_FOR_ERROR
4310
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004311 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004312 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
Eric Christopher2a5196f2008-09-24 04:55:49 +00004313 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Nuno Lopes8a88a372008-10-05 16:49:34 +00004314
4315 // Delete the argument list
4316 for (I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin() ; I != E; ++I ) {
4317 delete I->Ty;
4318 }
4319 delete (yyvsp[(3) - (5)].TypeWithAttrsList);
4320
Reid Spencere4d87aa2006-12-23 06:05:41 +00004321 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004322 ;}
4323 break;
4324
Chris Lattner740e7092008-10-15 06:16:57 +00004325 case 156:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004326#line 1437 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004327 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004328 // Allow but ignore attributes on function types; this permits auto-upgrade.
4329 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004330 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004331 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004332 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004333 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004334 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004335 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004336
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004337 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4338 if (isVarArg) Params.pop_back();
4339
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004340 for (unsigned i = 0; i != Params.size(); ++i)
4341 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4342 GEN_ERROR("Function arguments must be value types!");
4343
4344 CHECK_FOR_ERROR
4345
Dan Gohmanf4423b12008-04-19 00:24:39 +00004346 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
Eric Christopher2a5196f2008-09-24 04:55:49 +00004347 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Nuno Lopes8a88a372008-10-05 16:49:34 +00004348
4349 // Delete the argument list
4350 for (I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin() ; I != E; ++I ) {
4351 delete I->Ty;
4352 }
4353 delete (yyvsp[(3) - (5)].TypeWithAttrsList);
4354
Reid Spencer41dff5e2007-01-26 08:05:27 +00004355 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004356 ;}
4357 break;
4358
Chris Lattner740e7092008-10-15 06:16:57 +00004359 case 157:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004360#line 1468 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004361 { // Sized array type?
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004362 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (yyvsp[(2) - (5)].UInt64Val))));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004363 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004364 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004365 ;}
4366 break;
4367
Chris Lattner740e7092008-10-15 06:16:57 +00004368 case 158:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004369#line 1473 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004370 { // Vector type?
4371 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4372 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004373 GEN_ERROR("Unsigned result not equal to signed result");
4374 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4375 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004376 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4377 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004378 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004379 ;}
4380 break;
4381
Chris Lattner740e7092008-10-15 06:16:57 +00004382 case 159:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004383#line 1483 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004384 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004385 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004386 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4387 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004388 Elements.push_back(*I);
4389
Dan Gohmanf4423b12008-04-19 00:24:39 +00004390 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4391 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004392 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004393 ;}
4394 break;
4395
Chris Lattner740e7092008-10-15 06:16:57 +00004396 case 160:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004397#line 1493 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004398 { // Empty structure type?
4399 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004400 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004401 ;}
4402 break;
4403
Chris Lattner740e7092008-10-15 06:16:57 +00004404 case 161:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004405#line 1497 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004406 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004407 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004408 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4409 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004410 Elements.push_back(*I);
4411
Dan Gohmanf4423b12008-04-19 00:24:39 +00004412 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4413 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004414 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004415 ;}
4416 break;
4417
Chris Lattner740e7092008-10-15 06:16:57 +00004418 case 162:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004419#line 1507 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004420 { // Empty structure type?
4421 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004422 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004423 ;}
4424 break;
4425
Chris Lattner740e7092008-10-15 06:16:57 +00004426 case 163:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004427#line 1514 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004428 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004429 // Allow but ignore attributes on function types; this permits auto-upgrade.
4430 // FIXME: remove in LLVM 3.0.
Eric Christopher2a5196f2008-09-24 04:55:49 +00004431 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
Devang Patel05988662008-09-25 21:00:45 +00004432 (yyval.TypeWithAttrs).Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004433 ;}
4434 break;
4435
Chris Lattner740e7092008-10-15 06:16:57 +00004436 case 164:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004437#line 1523 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004438 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004439 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004440 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4441 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004442 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004443 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4444 ;}
4445 break;
4446
Chris Lattner740e7092008-10-15 06:16:57 +00004447 case 165:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004448#line 1530 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004449 {
4450 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4451 ;}
4452 break;
4453
Chris Lattner740e7092008-10-15 06:16:57 +00004454 case 166:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004455#line 1535 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004456 {
4457 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4458 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004459 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004460 ;}
4461 break;
4462
Chris Lattner740e7092008-10-15 06:16:57 +00004463 case 167:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004464#line 1540 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004465 {
4466 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004467 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004468 ;}
4469 break;
4470
Chris Lattner740e7092008-10-15 06:16:57 +00004471 case 169:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004472#line 1548 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004473 {
4474 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Devang Patel05988662008-09-25 21:00:45 +00004475 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004476 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004477 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004478 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004479 ;}
4480 break;
4481
Chris Lattner740e7092008-10-15 06:16:57 +00004482 case 170:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004483#line 1555 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004484 {
4485 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Devang Patel05988662008-09-25 21:00:45 +00004486 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004487 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004488 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004489 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004490 ;}
4491 break;
4492
Chris Lattner740e7092008-10-15 06:16:57 +00004493 case 171:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004494#line 1562 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004495 {
4496 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004497 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004498 ;}
4499 break;
4500
Chris Lattner740e7092008-10-15 06:16:57 +00004501 case 172:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004502#line 1570 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004503 {
4504 (yyval.TypeList) = new std::list<PATypeHolder>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004505 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004506 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004507 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004508 ;}
4509 break;
4510
Chris Lattner740e7092008-10-15 06:16:57 +00004511 case 173:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004512#line 1576 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004513 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00004514 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004515 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004516 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004517 ;}
4518 break;
4519
Chris Lattner740e7092008-10-15 06:16:57 +00004520 case 174:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004521#line 1588 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004522 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004523 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004524 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4525 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004526 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004527 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004528 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004529 const Type *ETy = ATy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004530 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004531
4532 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004533 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004534 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004535 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004536 utostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004537
4538 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004539 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4540 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004541 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004542 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004543 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004544 }
4545
Dan Gohmanf4423b12008-04-19 00:24:39 +00004546 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4547 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004548 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004549 ;}
4550 break;
4551
Chris Lattner740e7092008-10-15 06:16:57 +00004552 case 175:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004553#line 1616 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004554 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004555 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004556 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4557 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004558 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004559 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004560 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004561
Dan Gohman180c1692008-06-23 18:43:26 +00004562 uint64_t NumElements = ATy->getNumElements();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004563 if (NumElements != uint64_t(-1) && NumElements != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004564 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Mon P Wang28873102008-06-25 08:15:39 +00004565 " arguments, but has size of " + utostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004566 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4567 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004568 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004569 ;}
4570 break;
4571
Chris Lattner740e7092008-10-15 06:16:57 +00004572 case 176:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004573#line 1632 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004574 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004575 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004576 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4577 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004578 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004579 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004580 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004581
Dan Gohman180c1692008-06-23 18:43:26 +00004582 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004583 const Type *ETy = ATy->getElementType();
Mon P Wang28873102008-06-25 08:15:39 +00004584 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (3)].StrVal)->length())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004585 GEN_ERROR("Can't build string constant of size " +
Mon P Wang28873102008-06-25 08:15:39 +00004586 utostr((yyvsp[(3) - (3)].StrVal)->length()) +
4587 " when array has size " + utostr(NumElements) + "");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004588 std::vector<Constant*> Vals;
4589 if (ETy == Type::Int8Ty) {
Mon P Wang28873102008-06-25 08:15:39 +00004590 for (uint64_t i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004591 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004592 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004593 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004594 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4595 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004596 delete (yyvsp[(3) - (3)].StrVal);
4597 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4598 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004599 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004600 ;}
4601 break;
4602
Chris Lattner740e7092008-10-15 06:16:57 +00004603 case 177:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004604#line 1659 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004605 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004606 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004607 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4608 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004609 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004610 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004611 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004612 const Type *ETy = PTy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004613 unsigned NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004614
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004615 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004616 if (NumElements != unsigned(-1) && NumElements != (unsigned)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004617 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004618 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004619 utostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004620
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004621 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004622 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4623 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004624 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004625 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004626 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004627 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004628
Dan Gohmanf4423b12008-04-19 00:24:39 +00004629 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4630 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004631 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004632 ;}
4633 break;
4634
Chris Lattner740e7092008-10-15 06:16:57 +00004635 case 178:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004636#line 1687 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004637 {
4638 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004639 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004640 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004641 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004642
Dan Gohmanf4423b12008-04-19 00:24:39 +00004643 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004644 GEN_ERROR("Illegal number of initializers for structure type");
4645
4646 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004647 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4648 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004649 GEN_ERROR("Expected type '" +
4650 STy->getElementType(i)->getDescription() +
4651 "' for element #" + utostr(i) +
4652 " of structure initializer");
4653
4654 // Check to ensure that Type is not packed
4655 if (STy->isPacked())
4656 GEN_ERROR("Unpacked Initializer to vector type '" +
4657 STy->getDescription() + "'");
4658
Dan Gohmanf4423b12008-04-19 00:24:39 +00004659 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4660 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004661 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004662 ;}
4663 break;
4664
Chris Lattner740e7092008-10-15 06:16:57 +00004665 case 179:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004666#line 1713 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004667 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004668 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004669 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4670 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004671 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004672 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004673 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004674
4675 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004676 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004677
4678 // Check to ensure that Type is not packed
4679 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004680 GEN_ERROR("Unpacked Initializer to vector type '" +
4681 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004682
Dan Gohmanf4423b12008-04-19 00:24:39 +00004683 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4684 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004685 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004686 ;}
4687 break;
4688
Chris Lattner740e7092008-10-15 06:16:57 +00004689 case 180:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004690#line 1733 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004691 {
4692 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004693 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004694 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004695 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004696
Dan Gohmanf4423b12008-04-19 00:24:39 +00004697 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004698 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004699
4700 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004701 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4702 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004703 GEN_ERROR("Expected type '" +
4704 STy->getElementType(i)->getDescription() +
4705 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004706 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004707
4708 // Check to ensure that Type is packed
4709 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004710 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004711 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004712
Dan Gohmanf4423b12008-04-19 00:24:39 +00004713 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4714 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004715 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004716 ;}
4717 break;
4718
Chris Lattner740e7092008-10-15 06:16:57 +00004719 case 181:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004720#line 1759 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004721 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004722 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004723 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4724 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004725 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004726 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004727 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004728
4729 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004730 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004731
4732 // Check to ensure that Type is packed
4733 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004734 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004735 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004736
Dan Gohmanf4423b12008-04-19 00:24:39 +00004737 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4738 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004739 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004740 ;}
4741 break;
4742
Chris Lattner740e7092008-10-15 06:16:57 +00004743 case 182:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004744#line 1779 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004745 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004746 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004747 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4748 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004749 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004750 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004751 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004752
Dan Gohmanf4423b12008-04-19 00:24:39 +00004753 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4754 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004755 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004756 ;}
4757 break;
4758
Chris Lattner740e7092008-10-15 06:16:57 +00004759 case 183:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004760#line 1791 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004761 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004762 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004763 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4764 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4765 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004766 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004767 ;}
4768 break;
4769
Chris Lattner740e7092008-10-15 06:16:57 +00004770 case 184:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004771#line 1798 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004772 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004773 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004774 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4775 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004776 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004777 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004778
4779 // ConstExprs can exist in the body of a function, thus creating
4780 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004781 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004782 // symbol table instead of the module symbol table for the global symbol,
4783 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004784 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004785 //
4786 Function *SavedCurFn = CurFun.CurrentFunction;
4787 CurFun.CurrentFunction = 0;
4788
Dan Gohmanf4423b12008-04-19 00:24:39 +00004789 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004790 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004791
4792 CurFun.CurrentFunction = SavedCurFn;
4793
4794 // If this is an initializer for a constant pointer, which is referencing a
4795 // (currently) undefined variable, create a stub now that shall be replaced
4796 // in the future with the right type of variable.
4797 //
4798 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004799 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004800 const PointerType *PT = cast<PointerType>(Ty);
4801
4802 // First check to see if the forward references value is already created!
4803 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004804 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Eric Christopher2a5196f2008-09-24 04:55:49 +00004805
Reid Spencer68a24bd2005-08-27 18:50:39 +00004806 if (I != CurModule.GlobalRefs.end()) {
4807 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004808 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004809 } else {
4810 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004811 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4812 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4813 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004814 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004815
4816 // Create the forward referenced global.
4817 GlobalValue *GV;
Eric Christopher2a5196f2008-09-24 04:55:49 +00004818 if (const FunctionType *FTy =
Reid Spencer68a24bd2005-08-27 18:50:39 +00004819 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004820 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4821 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004822 } else {
4823 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004824 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004825 Name, CurModule.CurrentModule);
4826 }
4827
4828 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004829 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004830 V = GV;
4831 }
4832 }
4833
Dan Gohmanf4423b12008-04-19 00:24:39 +00004834 (yyval.ConstVal) = cast<GlobalValue>(V);
4835 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004836 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004837 ;}
4838 break;
4839
Chris Lattner740e7092008-10-15 06:16:57 +00004840 case 185:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004841#line 1864 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004842 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004843 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004844 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4845 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004846 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004847 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4848 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4849 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004850 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004851 ;}
4852 break;
4853
Chris Lattner740e7092008-10-15 06:16:57 +00004854 case 186:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004855#line 1874 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004856 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004857 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004858 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4859 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004860 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4861 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004862 (yyval.ConstVal) = Constant::getNullValue(Ty);
4863 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004864 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004865 ;}
4866 break;
4867
Chris Lattner740e7092008-10-15 06:16:57 +00004868 case 187:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004869#line 1884 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004870 { // integral constants
Chris Lattner740e7092008-10-15 06:16:57 +00004871 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4872 if (!ConstantInt::isValueValidForType(IT, (yyvsp[(2) - (2)].SInt64Val)))
4873 GEN_ERROR("Constant value doesn't fit in type");
4874 (yyval.ConstVal) = ConstantInt::get(IT, (yyvsp[(2) - (2)].SInt64Val), true);
4875 } else {
4876 GEN_ERROR("integer constant must have integer type");
4877 }
4878 delete (yyvsp[(1) - (2)].TypeVal);
4879 CHECK_FOR_ERROR
4880 ;}
4881 break;
4882
4883 case 188:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004884#line 1895 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004885 { // arbitrary precision integer constants
4886 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4887 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > IT->getBitWidth())
4888 GEN_ERROR("Constant value does not fit in type");
4889 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(IT->getBitWidth());
4890 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4891 } else {
4892 GEN_ERROR("integer constant must have integer type");
4893 }
4894 delete (yyvsp[(1) - (2)].TypeVal);
4895 delete (yyvsp[(2) - (2)].APIntVal);
4896 CHECK_FOR_ERROR
4897 ;}
4898 break;
4899
4900 case 189:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004901#line 1908 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004902 { // integral constants
4903 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4904 if (!ConstantInt::isValueValidForType(IT, (yyvsp[(2) - (2)].UInt64Val)))
4905 GEN_ERROR("Constant value doesn't fit in type");
4906 (yyval.ConstVal) = ConstantInt::get(IT, (yyvsp[(2) - (2)].UInt64Val), false);
4907 } else {
4908 GEN_ERROR("integer constant must have integer type");
4909 }
4910 delete (yyvsp[(1) - (2)].TypeVal);
4911 CHECK_FOR_ERROR
4912 ;}
4913 break;
4914
4915 case 190:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004916#line 1919 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004917 { // arbitrary precision integer constants
4918 if (IntegerType *IT = dyn_cast<IntegerType>((yyvsp[(1) - (2)].TypeVal)->get())) {
4919 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > IT->getBitWidth())
4920 GEN_ERROR("Constant value does not fit in type");
4921 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(IT->getBitWidth());
4922 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4923 } else {
4924 GEN_ERROR("integer constant must have integer type");
4925 }
4926
4927 delete (yyvsp[(2) - (2)].APIntVal);
4928 delete (yyvsp[(1) - (2)].TypeVal);
4929 CHECK_FOR_ERROR
4930 ;}
4931 break;
4932
4933 case 191:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004934#line 1933 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004935 { // Boolean constants
4936 if ((yyvsp[(1) - (2)].TypeVal)->get() != Type::Int1Ty)
4937 GEN_ERROR("Constant true must have type i1");
4938 (yyval.ConstVal) = ConstantInt::getTrue();
4939 delete (yyvsp[(1) - (2)].TypeVal);
4940 CHECK_FOR_ERROR
4941 ;}
4942 break;
4943
4944 case 192:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004945#line 1940 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner740e7092008-10-15 06:16:57 +00004946 { // Boolean constants
4947 if ((yyvsp[(1) - (2)].TypeVal)->get() != Type::Int1Ty)
4948 GEN_ERROR("Constant false must have type i1");
4949 (yyval.ConstVal) = ConstantInt::getFalse();
4950 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00004951 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004952 ;}
4953 break;
4954
Chris Lattnerf9078f92008-10-15 06:03:48 +00004955 case 193:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004956#line 1947 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004957 { // Floating point constants
Chris Lattner740e7092008-10-15 06:16:57 +00004958 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].TypeVal)->get(), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004959 GEN_ERROR("Floating point constant invalid for type");
Chris Lattner740e7092008-10-15 06:16:57 +00004960
Eric Christopher2a5196f2008-09-24 04:55:49 +00004961 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004962 // as double. Fix this here. Long double is done right.
Chris Lattner740e7092008-10-15 06:16:57 +00004963 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].TypeVal)->get()==Type::FloatTy) {
Dale Johannesen236bbd42008-10-09 23:01:34 +00004964 bool ignored;
4965 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
4966 &ignored);
4967 }
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004968 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Chris Lattner740e7092008-10-15 06:16:57 +00004969 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004970 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004971 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004972 ;}
4973 break;
4974
Chris Lattner740e7092008-10-15 06:16:57 +00004975 case 194:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004976#line 1965 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004977 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004978 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004979 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4980 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4981 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4982 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004983 GEN_ERROR("invalid cast opcode for cast from '" +
4984 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004985 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004986 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4987 delete (yyvsp[(5) - (6)].TypeVal);
4988 ;}
4989 break;
4990
Chris Lattner740e7092008-10-15 06:16:57 +00004991 case 195:
Nuno Lopesf05ff662008-10-15 11:20:21 +00004992#line 1977 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004993 {
4994 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004995 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004996
4997 const Type *IdxTy =
Dan Gohman041e2eb2008-05-15 19:50:34 +00004998 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004999 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00005000 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005001
Chris Lattnerf7469af2007-01-31 04:44:08 +00005002 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005003 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
5004 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005005 IdxVec.push_back(C);
5006 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005007 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005008
Dan Gohmanf4423b12008-04-19 00:24:39 +00005009 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005010
Dan Gohmanf4423b12008-04-19 00:24:39 +00005011 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00005012 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005013 ;}
5014 break;
5015
Chris Lattner740e7092008-10-15 06:16:57 +00005016 case 196:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005017#line 1998 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005018 {
5019 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005020 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005021 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005022 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005023 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005024 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005025 ;}
5026 break;
5027
Chris Lattner740e7092008-10-15 06:16:57 +00005028 case 197:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005029#line 2006 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005030 {
5031 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005032 GEN_ERROR("Binary operator types must match");
5033 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005034 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
5035 ;}
5036 break;
5037
Chris Lattner740e7092008-10-15 06:16:57 +00005038 case 198:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005039#line 2012 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005040 {
5041 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005042 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005043 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005044 if (!isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00005045 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005046 GEN_ERROR("Logical operator requires integral operands");
5047 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005048 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005049 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005050 ;}
5051 break;
5052
Chris Lattner740e7092008-10-15 06:16:57 +00005053 case 199:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005054#line 2023 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005055 {
5056 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005057 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005058 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5059 ;}
5060 break;
5061
Chris Lattner740e7092008-10-15 06:16:57 +00005062 case 200:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005063#line 2028 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005064 {
5065 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005066 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005067 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5068 ;}
5069 break;
5070
Chris Lattner740e7092008-10-15 06:16:57 +00005071 case 201:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005072#line 2033 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005073 {
5074 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5075 GEN_ERROR("vicmp operand types must match");
5076 (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5077 ;}
5078 break;
5079
Chris Lattner740e7092008-10-15 06:16:57 +00005080 case 202:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005081#line 2038 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005082 {
5083 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5084 GEN_ERROR("vfcmp operand types must match");
5085 (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5086 ;}
5087 break;
5088
Chris Lattner740e7092008-10-15 06:16:57 +00005089 case 203:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005090#line 2043 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005091 {
5092 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005093 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005094 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005095 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005096 ;}
5097 break;
5098
Chris Lattner740e7092008-10-15 06:16:57 +00005099 case 204:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005100#line 2049 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005101 {
5102 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005103 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005104 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005105 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005106 ;}
5107 break;
5108
Chris Lattner740e7092008-10-15 06:16:57 +00005109 case 205:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005110#line 2055 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005111 {
5112 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005113 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005114 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005115 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005116 ;}
5117 break;
5118
Chris Lattner740e7092008-10-15 06:16:57 +00005119 case 206:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005120#line 2061 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005121 {
5122 if (!isa<StructType>((yyvsp[(3) - (5)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (5)].ConstVal)->getType()))
5123 GEN_ERROR("ExtractValue requires an aggregate operand");
5124
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005125 (yyval.ConstVal) = ConstantExpr::getExtractValue((yyvsp[(3) - (5)].ConstVal), &(*(yyvsp[(4) - (5)].ConstantList))[0], (yyvsp[(4) - (5)].ConstantList)->size());
5126 delete (yyvsp[(4) - (5)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005127 CHECK_FOR_ERROR
5128 ;}
5129 break;
5130
Chris Lattner740e7092008-10-15 06:16:57 +00005131 case 207:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005132#line 2069 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005133 {
5134 if (!isa<StructType>((yyvsp[(3) - (7)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (7)].ConstVal)->getType()))
5135 GEN_ERROR("InsertValue requires an aggregate operand");
5136
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005137 (yyval.ConstVal) = ConstantExpr::getInsertValue((yyvsp[(3) - (7)].ConstVal), (yyvsp[(5) - (7)].ConstVal), &(*(yyvsp[(6) - (7)].ConstantList))[0], (yyvsp[(6) - (7)].ConstantList)->size());
5138 delete (yyvsp[(6) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005139 CHECK_FOR_ERROR
5140 ;}
5141 break;
5142
Chris Lattner740e7092008-10-15 06:16:57 +00005143 case 208:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005144#line 2080 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005145 {
5146 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005147 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005148 ;}
5149 break;
5150
Chris Lattner740e7092008-10-15 06:16:57 +00005151 case 209:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005152#line 2084 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005153 {
5154 (yyval.ConstVector) = new std::vector<Constant*>();
5155 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005156 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005157 ;}
5158 break;
5159
Chris Lattner740e7092008-10-15 06:16:57 +00005160 case 210:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005161#line 2092 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005162 { (yyval.BoolVal) = false; ;}
Nate Begemanac80ade2008-05-12 19:01:56 +00005163 break;
5164
Chris Lattner740e7092008-10-15 06:16:57 +00005165 case 211:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005166#line 2092 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005167 { (yyval.BoolVal) = true; ;}
5168 break;
5169
Chris Lattner740e7092008-10-15 06:16:57 +00005170 case 212:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005171#line 2095 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005172 { (yyval.BoolVal) = true; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005173 break;
5174
Chris Lattner740e7092008-10-15 06:16:57 +00005175 case 213:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005176#line 2095 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005177 { (yyval.BoolVal) = false; ;}
5178 break;
5179
Chris Lattner740e7092008-10-15 06:16:57 +00005180 case 214:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005181#line 2098 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005182 {
5183 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
5184 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00005185 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005186 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
5187 if (!Aliasee)
5188 GEN_ERROR("Aliases can be created only to global values");
5189
Dan Gohmanf4423b12008-04-19 00:24:39 +00005190 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005191 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005192 delete (yyvsp[(1) - (2)].TypeVal);
5193 ;}
5194 break;
5195
Chris Lattner740e7092008-10-15 06:16:57 +00005196 case 215:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005197#line 2110 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005198 {
5199 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
5200 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
5201 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005202 GEN_ERROR("invalid cast opcode for cast from '" +
5203 Val->getType()->getDescription() + "' to '" +
5204 DestTy->getDescription() + "'");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005205
Dan Gohmanf4423b12008-04-19 00:24:39 +00005206 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005207 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005208 delete (yyvsp[(5) - (6)].TypeVal);
5209 ;}
5210 break;
5211
Chris Lattner740e7092008-10-15 06:16:57 +00005212 case 216:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005213#line 2131 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005214 {
5215 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5216 CurModule.ModuleDone();
5217 CHECK_FOR_ERROR;
5218 ;}
5219 break;
5220
Chris Lattner740e7092008-10-15 06:16:57 +00005221 case 217:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005222#line 2136 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005223 {
5224 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5225 CurModule.ModuleDone();
5226 CHECK_FOR_ERROR;
5227 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005228 break;
5229
Chris Lattner740e7092008-10-15 06:16:57 +00005230 case 220:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005231#line 2149 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel652203f2008-09-29 20:49:50 +00005232 { CurFun.isDeclare = false; ;}
5233 break;
5234
Chris Lattner740e7092008-10-15 06:16:57 +00005235 case 221:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005236#line 2149 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005237 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005238 CurFun.FunctionDone();
5239 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005240 ;}
5241 break;
5242
Chris Lattner740e7092008-10-15 06:16:57 +00005243 case 222:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005244#line 2153 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005245 { CurFun.isDeclare = true; ;}
5246 break;
5247
Chris Lattner740e7092008-10-15 06:16:57 +00005248 case 223:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005249#line 2153 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005250 {
5251 CHECK_FOR_ERROR
5252 ;}
5253 break;
5254
Chris Lattner740e7092008-10-15 06:16:57 +00005255 case 224:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005256#line 2156 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005257 {
5258 CHECK_FOR_ERROR
5259 ;}
5260 break;
5261
Chris Lattner740e7092008-10-15 06:16:57 +00005262 case 225:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005263#line 2159 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005264 {
Reid Spencer14310612006-12-31 05:40:51 +00005265 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005266 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005267 // Eagerly resolve types. This is not an optimization, this is a
5268 // requirement that is due to the fact that we could have this:
5269 //
5270 // %list = type { %list * }
5271 // %list = type { %list * } ; repeated type decl
5272 //
5273 // If types are not resolved eagerly, then the two types will not be
5274 // determined to be the same type!
5275 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00005276 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005277
Dan Gohmanf4423b12008-04-19 00:24:39 +00005278 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00005279 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005280 // If this is a named type that is not a redefinition, add it to the slot
5281 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005282 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005283 }
Reid Spencera132e042006-12-03 05:46:11 +00005284
Dan Gohmanf4423b12008-04-19 00:24:39 +00005285 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005286 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005287 ;}
5288 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00005289
Chris Lattner740e7092008-10-15 06:16:57 +00005290 case 226:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005291#line 2183 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005292 {
5293 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
5294
5295 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005296 CHECK_FOR_ERROR
5297 // If this is a named type that is not a redefinition, add it to the slot
5298 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005299 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005300 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005301 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005302 ;}
5303 break;
5304
Chris Lattner740e7092008-10-15 06:16:57 +00005305 case 227:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005306#line 2195 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005307 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005308 /* "Externally Visible" Linkage */
Eric Christopher2a5196f2008-09-24 04:55:49 +00005309 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005310 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005311 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5312 (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 +00005313 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005314 ;}
5315 break;
5316
Chris Lattner740e7092008-10-15 06:16:57 +00005317 case 228:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005318#line 2202 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005319 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005320 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005321 ;}
5322 break;
5323
Chris Lattner740e7092008-10-15 06:16:57 +00005324 case 229:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005325#line 2206 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005326 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005327 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005328 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005329 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 +00005330 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005331 ;}
5332 break;
5333
Chris Lattner740e7092008-10-15 06:16:57 +00005334 case 230:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005335#line 2211 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005336 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005337 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005338 ;}
5339 break;
5340
Chris Lattner740e7092008-10-15 06:16:57 +00005341 case 231:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005342#line 2215 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005343 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005344 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005345 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5346 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 +00005347 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005348 delete (yyvsp[(6) - (7)].TypeVal);
5349 ;}
5350 break;
5351
Chris Lattner740e7092008-10-15 06:16:57 +00005352 case 232:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005353#line 2221 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005354 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005355 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005356 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005357 ;}
5358 break;
5359
Chris Lattner740e7092008-10-15 06:16:57 +00005360 case 233:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005361#line 2225 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005362 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005363 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005364 if ((yyvsp[(1) - (5)].StrVal)) {
5365 Name = *(yyvsp[(1) - (5)].StrVal);
5366 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005367 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005368 if (Name.empty())
5369 GEN_ERROR("Alias name cannot be empty");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005370
Dan Gohmanf4423b12008-04-19 00:24:39 +00005371 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005372 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005373 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005374
Dan Gohmanf4423b12008-04-19 00:24:39 +00005375 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005376 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005377 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005378 InsertValue(GA, CurModule.Values);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005379
5380
Chris Lattner569f7372007-09-10 23:24:14 +00005381 // If there was a forward reference of this alias, resolve it now.
Eric Christopher2a5196f2008-09-24 04:55:49 +00005382
Chris Lattner569f7372007-09-10 23:24:14 +00005383 ValID ID;
5384 if (!Name.empty())
5385 ID = ValID::createGlobalName(Name);
5386 else
5387 ID = ValID::createGlobalID(CurModule.Values.size()-1);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005388
Chris Lattner569f7372007-09-10 23:24:14 +00005389 if (GlobalValue *FWGV =
5390 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5391 // Replace uses of the fwdref with the actual alias.
5392 FWGV->replaceAllUsesWith(GA);
5393 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5394 GV->eraseFromParent();
5395 else
5396 cast<Function>(FWGV)->eraseFromParent();
5397 }
5398 ID.destroy();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005399
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005400 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005401 ;}
5402 break;
5403
Chris Lattner740e7092008-10-15 06:16:57 +00005404 case 234:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005405#line 2265 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerf9078f92008-10-15 06:03:48 +00005406 {
5407 CHECK_FOR_ERROR
5408 ;}
5409 break;
5410
Chris Lattner740e7092008-10-15 06:16:57 +00005411 case 235:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005412#line 2268 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005413 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005414 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005415 ;}
5416 break;
5417
Chris Lattner740e7092008-10-15 06:16:57 +00005418 case 236:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005419#line 2274 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005420 {
Chris Lattner66316012006-01-24 04:14:29 +00005421 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005422 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005423 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005424 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005425 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5426 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005427 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005428;}
5429 break;
5430
Chris Lattner740e7092008-10-15 06:16:57 +00005431 case 237:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005432#line 2284 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005433 {
5434 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5435 delete (yyvsp[(3) - (3)].StrVal);
5436 ;}
5437 break;
5438
Chris Lattner740e7092008-10-15 06:16:57 +00005439 case 238:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005440#line 2288 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005441 {
5442 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5443 delete (yyvsp[(3) - (3)].StrVal);
5444 ;}
5445 break;
5446
Chris Lattner740e7092008-10-15 06:16:57 +00005447 case 240:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005448#line 2295 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005449 {
5450 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5451 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005452 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005453 ;}
5454 break;
5455
Chris Lattner740e7092008-10-15 06:16:57 +00005456 case 241:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005457#line 2300 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005458 {
5459 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5460 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005461 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005462 ;}
5463 break;
5464
Chris Lattner740e7092008-10-15 06:16:57 +00005465 case 242:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005466#line 2305 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005467 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005468 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005469 ;}
5470 break;
5471
Chris Lattner740e7092008-10-15 06:16:57 +00005472 case 243:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005473#line 2314 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005474 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005475 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005476 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005477 if (!(*(yyvsp[(3) - (5)].TypeVal))->isFirstClassType())
5478 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005479 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 +00005480 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5481 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005482 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005483 ;}
5484 break;
5485
Chris Lattner740e7092008-10-15 06:16:57 +00005486 case 244:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005487#line 2324 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005488 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005489 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005490 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005491 if (!(*(yyvsp[(1) - (3)].TypeVal))->isFirstClassType())
5492 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005493 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 +00005494 (yyval.ArgList) = new ArgListType;
5495 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005496 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005497 ;}
5498 break;
5499
Chris Lattner740e7092008-10-15 06:16:57 +00005500 case 245:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005501#line 2335 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005502 {
5503 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005504 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005505 ;}
5506 break;
5507
Chris Lattner740e7092008-10-15 06:16:57 +00005508 case 246:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005509#line 2339 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005510 {
5511 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005512 struct ArgListEntry E;
5513 E.Ty = new PATypeHolder(Type::VoidTy);
5514 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005515 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005516 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005517 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005518 ;}
5519 break;
5520
Chris Lattner740e7092008-10-15 06:16:57 +00005521 case 247:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005522#line 2348 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005523 {
5524 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005525 struct ArgListEntry E;
5526 E.Ty = new PATypeHolder(Type::VoidTy);
5527 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005528 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005529 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005530 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005531 ;}
5532 break;
5533
Chris Lattner740e7092008-10-15 06:16:57 +00005534 case 248:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005535#line 2357 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005536 {
5537 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005538 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005539 ;}
5540 break;
5541
Chris Lattner740e7092008-10-15 06:16:57 +00005542 case 249:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005543#line 2363 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005544 {
Devang Patel652203f2008-09-29 20:49:50 +00005545 std::string FunctionName(*(yyvsp[(4) - (11)].StrVal));
5546 delete (yyvsp[(4) - (11)].StrVal); // Free strdup'd memory!
Eric Christopher2a5196f2008-09-24 04:55:49 +00005547
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005548 // Check the function result for abstractness if this is a define. We should
5549 // have no abstract types at this point
Devang Patel652203f2008-09-29 20:49:50 +00005550 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(3) - (11)].TypeVal)))
5551 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(3) - (11)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005552
Devang Patel652203f2008-09-29 20:49:50 +00005553 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (11)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00005554 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005555
Reid Spencer68a24bd2005-08-27 18:50:39 +00005556 std::vector<const Type*> ParamTypeList;
Devang Patel05988662008-09-25 21:00:45 +00005557 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00005558 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
5559 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00005560 Attributes RetAttrs = (yyvsp[(2) - (11)].Attributes);
5561 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None) {
5562 if ((yyvsp[(8) - (11)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005563 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00005564 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005565 }
Devang Patel652203f2008-09-29 20:49:50 +00005566 if ((yyvsp[(8) - (11)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00005567 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00005568 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00005569 }
Devang Patel652203f2008-09-29 20:49:50 +00005570 if ((yyvsp[(8) - (11)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00005571 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00005572 (yyvsp[(8) - (11)].Attributes) = (yyvsp[(8) - (11)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00005573 }
Dale Johannesene7261862008-09-26 23:46:20 +00005574 }
Devang Patel652203f2008-09-29 20:49:50 +00005575 if (RetAttrs != Attribute::None)
5576 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
5577 if ((yyvsp[(6) - (11)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005578 unsigned index = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005579 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin(); I != (yyvsp[(6) - (11)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005580 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005581 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5582 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005583 ParamTypeList.push_back(Ty);
Devang Patel05988662008-09-25 21:00:45 +00005584 if (Ty != Type::VoidTy && I->Attrs != Attribute::None)
5585 Attrs.push_back(AttributeWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005586 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005587 }
Devang Patel652203f2008-09-29 20:49:50 +00005588 if ((yyvsp[(8) - (11)].Attributes) != Attribute::None)
5589 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(8) - (11)].Attributes)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005590
5591 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5592 if (isVarArg) ParamTypeList.pop_back();
5593
Devang Patel05988662008-09-25 21:00:45 +00005594 AttrListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005595 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00005596 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005597
Devang Patel652203f2008-09-29 20:49:50 +00005598 FunctionType *FT = FunctionType::get(*(yyvsp[(3) - (11)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005599 const PointerType *PFT = PointerType::getUnqual(FT);
Devang Patel652203f2008-09-29 20:49:50 +00005600 delete (yyvsp[(3) - (11)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005601
5602 ValID ID;
5603 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005604 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005605 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005606 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005607 }
5608
5609 Function *Fn = 0;
5610 // See if this function was forward referenced. If so, recycle the object.
5611 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005612 // Move the function to the end of the list, from whereever it was
Reid Spencer68a24bd2005-08-27 18:50:39 +00005613 // previously inserted.
5614 Fn = cast<Function>(FWRef);
Devang Patel05988662008-09-25 21:00:45 +00005615 assert(Fn->getAttributes().isEmpty() &&
Chris Lattner58d74912008-03-12 17:45:29 +00005616 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005617 CurModule.CurrentModule->getFunctionList().remove(Fn);
5618 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5619 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005620 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005621 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005622 // The existing function doesn't have the same type. This is an overload
5623 // error.
5624 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Devang Patel05988662008-09-25 21:00:45 +00005625 } else if (Fn->getAttributes() != PAL) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005626 // The existing function doesn't have the same parameter attributes.
5627 // This is an overload error.
5628 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005629 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005630 // Neither the existing or the current function is a declaration and they
5631 // have the same name and same type. Clearly this is a redefinition.
5632 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005633 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005634 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005635 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5636 AI != AE; ++AI)
5637 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005638 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005639 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005640 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5641 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005642 InsertValue(Fn, CurModule.Values);
5643 }
5644
Nuno Lopes9e9631d2008-10-03 15:45:58 +00005645 ID.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005646 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005647
5648 if (CurFun.isDeclare) {
5649 // If we have declaration, always overwrite linkage. This will allow us to
5650 // correctly handle cases, when pointer to function is passed as argument to
5651 // another function.
5652 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005653 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005654 }
Devang Pateld4980812008-09-02 20:52:40 +00005655 Fn->setCallingConv((yyvsp[(1) - (11)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00005656 Fn->setAttributes(PAL);
Devang Patel652203f2008-09-29 20:49:50 +00005657 Fn->setAlignment((yyvsp[(10) - (11)].UIntVal));
5658 if ((yyvsp[(9) - (11)].StrVal)) {
5659 Fn->setSection(*(yyvsp[(9) - (11)].StrVal));
5660 delete (yyvsp[(9) - (11)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005661 }
Devang Patel652203f2008-09-29 20:49:50 +00005662 if ((yyvsp[(11) - (11)].StrVal)) {
5663 Fn->setGC((yyvsp[(11) - (11)].StrVal)->c_str());
5664 delete (yyvsp[(11) - (11)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005665 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005666
5667 // Add all of the arguments we parsed to the function...
Devang Patel652203f2008-09-29 20:49:50 +00005668 if ((yyvsp[(6) - (11)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005669 if (isVarArg) { // Nuke the last entry
Devang Patel652203f2008-09-29 20:49:50 +00005670 assert((yyvsp[(6) - (11)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(6) - (11)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005671 "Not a varargs marker!");
Devang Patel652203f2008-09-29 20:49:50 +00005672 delete (yyvsp[(6) - (11)].ArgList)->back().Ty;
5673 (yyvsp[(6) - (11)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005674 }
5675 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005676 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005677 unsigned Idx = 1;
Devang Patel652203f2008-09-29 20:49:50 +00005678 for (ArgListType::iterator I = (yyvsp[(6) - (11)].ArgList)->begin();
5679 I != (yyvsp[(6) - (11)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005680 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005681 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005682 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005683 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005684 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005685 }
Reid Spencera132e042006-12-03 05:46:11 +00005686
Devang Patel652203f2008-09-29 20:49:50 +00005687 delete (yyvsp[(6) - (11)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005688 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005689 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005690;}
5691 break;
5692
Chris Lattner740e7092008-10-15 06:16:57 +00005693 case 252:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005694#line 2513 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005695 {
5696 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005697
5698 // Make sure that we keep track of the linkage type even if there was a
5699 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005700 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5701 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5702;}
5703 break;
5704
Chris Lattner740e7092008-10-15 06:16:57 +00005705 case 255:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005706#line 2524 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005707 {
5708 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005709 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005710;}
5711 break;
5712
Chris Lattner740e7092008-10-15 06:16:57 +00005713 case 256:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005714#line 2529 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005715 {
5716 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5717 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5718 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005719 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005720 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005721 ;}
5722 break;
5723
Chris Lattner740e7092008-10-15 06:16:57 +00005724 case 257:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005725#line 2541 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005726 {
5727 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005728 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005729 ;}
5730 break;
5731
Chris Lattner740e7092008-10-15 06:16:57 +00005732 case 258:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005733#line 2545 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005734 {
5735 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005736 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005737 ;}
5738 break;
5739
Chris Lattner740e7092008-10-15 06:16:57 +00005740 case 259:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005741#line 2550 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005742 { // A reference to a direct constant
5743 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005744 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005745 ;}
5746 break;
5747
Chris Lattner740e7092008-10-15 06:16:57 +00005748 case 260:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005749#line 2554 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005750 {
5751 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005752 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005753 ;}
5754 break;
5755
Chris Lattner740e7092008-10-15 06:16:57 +00005756 case 261:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005757#line 2558 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005758 { // arbitrary precision integer constants
5759 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), true);
5760 delete (yyvsp[(1) - (1)].APIntVal);
5761 CHECK_FOR_ERROR
5762 ;}
5763 break;
5764
Chris Lattner740e7092008-10-15 06:16:57 +00005765 case 262:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005766#line 2563 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005767 { // arbitrary precision integer constants
5768 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), false);
5769 delete (yyvsp[(1) - (1)].APIntVal);
5770 CHECK_FOR_ERROR
5771 ;}
5772 break;
5773
Chris Lattner740e7092008-10-15 06:16:57 +00005774 case 263:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005775#line 2568 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005776 { // Perhaps it's an FP constant?
5777 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005778 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005779 ;}
5780 break;
5781
Chris Lattner740e7092008-10-15 06:16:57 +00005782 case 264:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005783#line 2572 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005784 {
5785 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005786 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005787 ;}
5788 break;
5789
Chris Lattner740e7092008-10-15 06:16:57 +00005790 case 265:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005791#line 2576 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005792 {
5793 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005794 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005795 ;}
5796 break;
5797
Chris Lattner740e7092008-10-15 06:16:57 +00005798 case 266:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005799#line 2580 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005800 {
5801 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005802 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005803 ;}
5804 break;
5805
Chris Lattner740e7092008-10-15 06:16:57 +00005806 case 267:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005807#line 2584 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005808 {
5809 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005810 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005811 ;}
5812 break;
5813
Chris Lattner740e7092008-10-15 06:16:57 +00005814 case 268:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005815#line 2588 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005816 { // A vector zero constant.
5817 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005818 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005819 ;}
5820 break;
5821
Chris Lattner740e7092008-10-15 06:16:57 +00005822 case 269:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005823#line 2592 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005824 { // Nonempty unsized packed vector
5825 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005826 unsigned NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005827
5828 if (!ETy->isInteger() && !ETy->isFloatingPoint())
5829 GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005830
Reid Spencer9d6565a2007-02-15 02:26:10 +00005831 VectorType* pt = VectorType::get(ETy, NumElements);
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005832 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
Eric Christopher2a5196f2008-09-24 04:55:49 +00005833
Reid Spencer68a24bd2005-08-27 18:50:39 +00005834 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005835 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5836 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005837 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005838 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005839 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005840 }
5841
Dan Gohmanf4423b12008-04-19 00:24:39 +00005842 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5843 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005844 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005845 ;}
5846 break;
5847
Chris Lattner740e7092008-10-15 06:16:57 +00005848 case 270:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005849#line 2614 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005850 { // Nonempty unsized arr
5851 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005852 uint64_t NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005853
5854 if (!ETy->isFirstClassType())
5855 GEN_ERROR("Invalid array element type: " + ETy->getDescription());
5856
5857 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5858 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
5859
5860 // Verify all elements are correct type!
5861 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5862 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005863 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005864 ETy->getDescription() +"' as required!\nIt is of type '"+
5865 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
5866 }
5867
5868 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, *(yyvsp[(2) - (3)].ConstVector)));
5869 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5870 CHECK_FOR_ERROR
5871 ;}
5872 break;
5873
Chris Lattner740e7092008-10-15 06:16:57 +00005874 case 271:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005875#line 2636 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005876 {
Dan Gohman180c1692008-06-23 18:43:26 +00005877 // Use undef instead of an array because it's inconvenient to determine
5878 // the element type at this point, there being no elements to examine.
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005879 (yyval.ValIDVal) = ValID::createUndef();
5880 CHECK_FOR_ERROR
5881 ;}
5882 break;
5883
Chris Lattner740e7092008-10-15 06:16:57 +00005884 case 272:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005885#line 2642 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005886 {
Dan Gohman180c1692008-06-23 18:43:26 +00005887 uint64_t NumElements = (yyvsp[(2) - (2)].StrVal)->length();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005888 const Type *ETy = Type::Int8Ty;
5889
5890 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5891
5892 std::vector<Constant*> Vals;
5893 for (unsigned i = 0; i < (yyvsp[(2) - (2)].StrVal)->length(); ++i)
5894 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(2) - (2)].StrVal))[i]));
5895 delete (yyvsp[(2) - (2)].StrVal);
5896 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, Vals));
5897 CHECK_FOR_ERROR
5898 ;}
5899 break;
5900
Chris Lattner740e7092008-10-15 06:16:57 +00005901 case 273:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005902#line 2655 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005903 {
5904 std::vector<const Type*> Elements((yyvsp[(2) - (3)].ConstVector)->size());
5905 for (unsigned i = 0, e = (yyvsp[(2) - (3)].ConstVector)->size(); i != e; ++i)
5906 Elements[i] = (*(yyvsp[(2) - (3)].ConstVector))[i]->getType();
5907
5908 const StructType *STy = StructType::get(Elements);
5909 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5910
5911 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(2) - (3)].ConstVector)));
5912 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5913 CHECK_FOR_ERROR
5914 ;}
5915 break;
5916
Chris Lattner740e7092008-10-15 06:16:57 +00005917 case 274:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005918#line 2667 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005919 {
5920 const StructType *STy = StructType::get(std::vector<const Type*>());
5921 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5922 CHECK_FOR_ERROR
5923 ;}
5924 break;
5925
Chris Lattner740e7092008-10-15 06:16:57 +00005926 case 275:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005927#line 2672 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005928 {
5929 std::vector<const Type*> Elements((yyvsp[(3) - (5)].ConstVector)->size());
5930 for (unsigned i = 0, e = (yyvsp[(3) - (5)].ConstVector)->size(); i != e; ++i)
5931 Elements[i] = (*(yyvsp[(3) - (5)].ConstVector))[i]->getType();
5932
5933 const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
5934 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5935
5936 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(3) - (5)].ConstVector)));
5937 delete PTy; delete (yyvsp[(3) - (5)].ConstVector);
5938 CHECK_FOR_ERROR
5939 ;}
5940 break;
5941
Chris Lattner740e7092008-10-15 06:16:57 +00005942 case 276:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005943#line 2684 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005944 {
5945 const StructType *STy = StructType::get(std::vector<const Type*>(),
5946 /*isPacked=*/true);
5947 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5948 CHECK_FOR_ERROR
5949 ;}
5950 break;
5951
Chris Lattner740e7092008-10-15 06:16:57 +00005952 case 277:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005953#line 2690 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005954 {
5955 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005956 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005957 ;}
5958 break;
5959
Chris Lattner740e7092008-10-15 06:16:57 +00005960 case 278:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005961#line 2694 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005962 {
5963 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5964 delete (yyvsp[(3) - (5)].StrVal);
5965 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005966 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005967 ;}
5968 break;
5969
Chris Lattner740e7092008-10-15 06:16:57 +00005970 case 279:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005971#line 2704 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005972 { // Is it an integer reference...?
5973 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005974 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005975 ;}
5976 break;
5977
Chris Lattner740e7092008-10-15 06:16:57 +00005978 case 280:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005979#line 2708 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005980 {
5981 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005982 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005983 ;}
5984 break;
5985
Chris Lattner740e7092008-10-15 06:16:57 +00005986 case 281:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005987#line 2712 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005988 { // Is it a named reference...?
5989 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5990 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005991 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005992 ;}
5993 break;
5994
Chris Lattner740e7092008-10-15 06:16:57 +00005995 case 282:
Nuno Lopesf05ff662008-10-15 11:20:21 +00005996#line 2717 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005997 { // Is it a named reference...?
5998 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5999 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00006000 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006001 ;}
6002 break;
6003
Chris Lattner740e7092008-10-15 06:16:57 +00006004 case 285:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006005#line 2730 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006006 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006007 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006008 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006009 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006010 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00006011 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006012 ;}
6013 break;
6014
Chris Lattner740e7092008-10-15 06:16:57 +00006015 case 286:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006016#line 2739 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006017 {
6018 (yyval.ValueList) = new std::vector<Value *>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00006019 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00006020 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006021 ;}
6022 break;
6023
Chris Lattner740e7092008-10-15 06:16:57 +00006024 case 287:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006025#line 2744 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006026 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006027 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00006028 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006029 ;}
6030 break;
6031
Chris Lattner740e7092008-10-15 06:16:57 +00006032 case 288:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006033#line 2749 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006034 {
6035 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006036 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006037 ;}
6038 break;
6039
Chris Lattner740e7092008-10-15 06:16:57 +00006040 case 289:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006041#line 2753 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006042 { // Do not allow functions with 0 basic blocks
Dan Gohmanf4423b12008-04-19 00:24:39 +00006043 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006044 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006045 ;}
6046 break;
6047
Chris Lattner740e7092008-10-15 06:16:57 +00006048 case 290:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006049#line 2762 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006050 {
6051 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006052 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006053 InsertValue((yyvsp[(3) - (3)].TermInstVal));
6054 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6055 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006056 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006057 ;}
6058 break;
6059
Chris Lattner740e7092008-10-15 06:16:57 +00006060 case 291:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006061#line 2771 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006062 {
6063 CHECK_FOR_ERROR
6064 int ValNum = InsertValue((yyvsp[(3) - (3)].TermInstVal));
6065 if (ValNum != (int)(yyvsp[(2) - (3)].UIntVal))
6066 GEN_ERROR("Result value number %" + utostr((yyvsp[(2) - (3)].UIntVal)) +
6067 " is incorrect, expected %" + utostr((unsigned)ValNum));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006068
Chris Lattner15bd0952008-08-29 17:20:18 +00006069 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6070 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
6071 CHECK_FOR_ERROR
6072;}
6073 break;
6074
Chris Lattner740e7092008-10-15 06:16:57 +00006075 case 292:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006076#line 2784 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006077 {
6078 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006079 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
6080 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00006081 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
6082 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
6083 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006084 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006085 ;}
6086 break;
Chris Lattner38905612008-02-19 04:36:25 +00006087
Chris Lattner740e7092008-10-15 06:16:57 +00006088 case 293:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006089#line 2793 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006090 { // Empty space between instruction lists
Chris Lattnercc81d152008-05-04 17:18:47 +00006091 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006092 CHECK_FOR_ERROR
6093 ;}
6094 break;
6095
Chris Lattner740e7092008-10-15 06:16:57 +00006096 case 294:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006097#line 2797 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnercc81d152008-05-04 17:18:47 +00006098 { // Labelled (named) basic block
6099 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
6100 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006101 CHECK_FOR_ERROR
Chris Lattnercc81d152008-05-04 17:18:47 +00006102
Dan Gohmanf4423b12008-04-19 00:24:39 +00006103 ;}
6104 break;
6105
Chris Lattner740e7092008-10-15 06:16:57 +00006106 case 295:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006107#line 2805 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006108 { // Return with a result...
6109 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
6110 assert(!VL.empty() && "Invalid ret operands!");
Dan Gohman1a570242008-07-23 00:54:54 +00006111 const Type *ReturnType = CurFun.CurrentFunction->getReturnType();
6112 if (VL.size() > 1 ||
6113 (isa<StructType>(ReturnType) &&
6114 (VL.empty() || VL[0]->getType() != ReturnType))) {
6115 Value *RV = UndefValue::get(ReturnType);
6116 for (unsigned i = 0, e = VL.size(); i != e; ++i) {
6117 Instruction *I = InsertValueInst::Create(RV, VL[i], i, "mrv");
6118 ((yyvsp[(-1) - (2)].BasicBlockVal))->getInstList().push_back(I);
6119 RV = I;
6120 }
6121 (yyval.TermInstVal) = ReturnInst::Create(RV);
6122 } else {
6123 (yyval.TermInstVal) = ReturnInst::Create(VL[0]);
6124 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006125 delete (yyvsp[(2) - (2)].ValueList);
6126 CHECK_FOR_ERROR
6127 ;}
6128 break;
6129
Chris Lattner740e7092008-10-15 06:16:57 +00006130 case 296:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006131#line 2825 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006132 { // Return with no result...
6133 (yyval.TermInstVal) = ReturnInst::Create();
6134 CHECK_FOR_ERROR
6135 ;}
6136 break;
6137
Chris Lattner740e7092008-10-15 06:16:57 +00006138 case 297:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006139#line 2829 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006140 { // Unconditional Branch...
6141 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6142 CHECK_FOR_ERROR
6143 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
6144 ;}
6145 break;
6146
Chris Lattner740e7092008-10-15 06:16:57 +00006147 case 298:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006148#line 2834 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006149 {
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006150 if (cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() != 1)
6151 GEN_ERROR("Branch condition must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006152 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6153 CHECK_FOR_ERROR
6154 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6155 CHECK_FOR_ERROR
6156 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6157 CHECK_FOR_ERROR
6158 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
6159 ;}
6160 break;
6161
Chris Lattner740e7092008-10-15 06:16:57 +00006162 case 299:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006163#line 2845 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006164 {
6165 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
6166 CHECK_FOR_ERROR
6167 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6168 CHECK_FOR_ERROR
6169 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6170 (yyval.TermInstVal) = S;
6171
6172 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6173 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00006174 for (; I != E; ++I) {
6175 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6176 S->addCase(CI, I->second);
6177 else
Reid Spencerb5334b02007-02-05 10:18:06 +00006178 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006179 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006180 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00006181 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006182 ;}
6183 break;
6184
Chris Lattner740e7092008-10-15 06:16:57 +00006185 case 300:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006186#line 2864 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006187 {
6188 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006189 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006190 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006191 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00006192 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006193 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006194 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006195 ;}
6196 break;
6197
Chris Lattner740e7092008-10-15 06:16:57 +00006198 case 301:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006199#line 2874 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006200 {
Reid Spencer3822ff52006-11-08 06:47:33 +00006201
Reid Spencer14310612006-12-31 05:40:51 +00006202 // Handle the short syntax
6203 const PointerType *PFTy = 0;
6204 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006205 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (15)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00006206 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6207 // Pull out the types of all of the arguments...
6208 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006209 ParamList::iterator I = (yyvsp[(7) - (15)].ParamList)->begin(), E = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006210 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006211 const Type *Ty = I->Val->getType();
6212 if (Ty == Type::VoidTy)
6213 GEN_ERROR("Short call syntax cannot be used with varargs");
6214 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006215 }
Eric Christopher2a5196f2008-09-24 04:55:49 +00006216
Devang Patel652203f2008-09-29 20:49:50 +00006217 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (15)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006218 GEN_ERROR("Invalid result type for LLVM function");
6219
Devang Patel652203f2008-09-29 20:49:50 +00006220 Ty = FunctionType::get((yyvsp[(4) - (15)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006221 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006222 }
6223
Devang Patel652203f2008-09-29 20:49:50 +00006224 delete (yyvsp[(4) - (15)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00006225
Devang Patel652203f2008-09-29 20:49:50 +00006226 Value *V = getVal(PFTy, (yyvsp[(5) - (15)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006227 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006228 BasicBlock *Normal = getBBVal((yyvsp[(12) - (15)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006229 CHECK_FOR_ERROR
Devang Patel652203f2008-09-29 20:49:50 +00006230 BasicBlock *Except = getBBVal((yyvsp[(15) - (15)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00006231 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00006232
Devang Patel05988662008-09-25 21:00:45 +00006233 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006234 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6235 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006236 Attributes RetAttrs = (yyvsp[(3) - (15)].Attributes);
6237 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None) {
6238 if ((yyvsp[(9) - (15)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006239 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006240 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006241 }
Devang Patel652203f2008-09-29 20:49:50 +00006242 if ((yyvsp[(9) - (15)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006243 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006244 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006245 }
Devang Patel652203f2008-09-29 20:49:50 +00006246 if ((yyvsp[(9) - (15)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006247 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006248 (yyvsp[(9) - (15)].Attributes) = (yyvsp[(9) - (15)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006249 }
Dale Johannesene7261862008-09-26 23:46:20 +00006250 }
Devang Patel652203f2008-09-29 20:49:50 +00006251 if (RetAttrs != Attribute::None)
6252 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006253
Reid Spencer14310612006-12-31 05:40:51 +00006254 // Check the arguments
6255 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006256 if ((yyvsp[(7) - (15)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00006257 // Make sure no arguments is a good thing!
6258 if (Ty->getNumParams() != 0)
6259 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006260 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006261 } else { // Has arguments?
6262 // Loop through FunctionType's arguments and ensure they are specified
6263 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00006264 FunctionType::param_iterator I = Ty->param_begin();
6265 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006266 ParamList::iterator ArgI = (yyvsp[(7) - (15)].ParamList)->begin(), ArgE = (yyvsp[(7) - (15)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006267 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006268
Duncan Sandsdc024672007-11-27 13:23:08 +00006269 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006270 if (ArgI->Val->getType() != *I)
6271 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006272 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006273 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006274 if (ArgI->Attrs != Attribute::None)
6275 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006276 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00006277
Reid Spencer14310612006-12-31 05:40:51 +00006278 if (Ty->isVarArg()) {
6279 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006280 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006281 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006282 if (ArgI->Attrs != Attribute::None)
6283 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006284 }
Reid Spencer14310612006-12-31 05:40:51 +00006285 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006286 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006287 }
Devang Patel652203f2008-09-29 20:49:50 +00006288 if ((yyvsp[(9) - (15)].Attributes) != Attribute::None)
6289 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (15)].Attributes)));
Devang Patel05988662008-09-25 21:00:45 +00006290 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006291 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006292 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006293
Reid Spencer14310612006-12-31 05:40:51 +00006294 // Create the InvokeInst
Dan Gohman041e2eb2008-05-15 19:50:34 +00006295 InvokeInst *II = InvokeInst::Create(V, Normal, Except,
6296 Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006297 II->setCallingConv((yyvsp[(2) - (15)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006298 II->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006299 (yyval.TermInstVal) = II;
Devang Patel652203f2008-09-29 20:49:50 +00006300 delete (yyvsp[(7) - (15)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006301 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006302 ;}
6303 break;
6304
Chris Lattner740e7092008-10-15 06:16:57 +00006305 case 302:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006306#line 2977 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006307 {
6308 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006309 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006310 ;}
6311 break;
6312
Chris Lattner740e7092008-10-15 06:16:57 +00006313 case 303:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006314#line 2981 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006315 {
6316 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006317 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006318 ;}
6319 break;
6320
Chris Lattner740e7092008-10-15 06:16:57 +00006321 case 304:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006322#line 2988 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006323 {
6324 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6325 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006326 CHECK_FOR_ERROR
6327 if (V == 0)
6328 GEN_ERROR("May only switch on a constant pool value");
6329
Dan Gohmanf4423b12008-04-19 00:24:39 +00006330 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006331 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006332 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6333 ;}
6334 break;
6335
Chris Lattner740e7092008-10-15 06:16:57 +00006336 case 305:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006337#line 2999 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006338 {
6339 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6340 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006341 CHECK_FOR_ERROR
6342
6343 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00006344 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006345
Dan Gohmanf4423b12008-04-19 00:24:39 +00006346 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006347 CHECK_FOR_ERROR
Eric Christopher2a5196f2008-09-24 04:55:49 +00006348 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006349 ;}
6350 break;
6351
Chris Lattner740e7092008-10-15 06:16:57 +00006352 case 306:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006353#line 3012 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006354 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006355 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00006356 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006357 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006358 InsertValue((yyvsp[(2) - (2)].InstVal));
6359 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006360 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006361 ;}
6362 break;
6363
Chris Lattner740e7092008-10-15 06:16:57 +00006364 case 307:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006365#line 3021 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006366 {
6367 CHECK_FOR_ERROR
6368 int ValNum = InsertValue((yyvsp[(2) - (2)].InstVal));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006369
Chris Lattner15bd0952008-08-29 17:20:18 +00006370 if (ValNum != (int)(yyvsp[(1) - (2)].UIntVal))
6371 GEN_ERROR("Result value number %" + utostr((yyvsp[(1) - (2)].UIntVal)) +
6372 " is incorrect, expected %" + utostr((unsigned)ValNum));
6373
6374 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6375 CHECK_FOR_ERROR
6376 ;}
6377 break;
6378
Chris Lattner740e7092008-10-15 06:16:57 +00006379 case 308:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006380#line 3034 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006381 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006382 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006383 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
6384 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
6385 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00006386 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006387 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006388 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006389 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6390 delete (yyvsp[(1) - (6)].TypeVal);
6391 ;}
6392 break;
6393
Chris Lattner740e7092008-10-15 06:16:57 +00006394 case 309:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006395#line 3045 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006396 {
6397 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6398 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006399 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006400 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006401 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006402 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6403 ;}
6404 break;
6405
Chris Lattner740e7092008-10-15 06:16:57 +00006406 case 310:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006407#line 3055 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006408 {
Devang Patel05988662008-09-25 21:00:45 +00006409 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006410 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006411 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006412 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00006413 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006414 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 +00006415 (yyval.ParamList)->push_back(E);
6416 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00006417 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006418 ;}
6419 break;
6420
Chris Lattner740e7092008-10-15 06:16:57 +00006421 case 311:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006422#line 3066 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006423 {
Devang Patel05988662008-09-25 21:00:45 +00006424 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006425 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00006426 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006427 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 +00006428 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00006429 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006430 ;}
6431 break;
6432
Chris Lattner740e7092008-10-15 06:16:57 +00006433 case 312:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006434#line 3074 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006435 {
Devang Patel05988662008-09-25 21:00:45 +00006436 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006437 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006438 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6439 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006440 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 +00006441 (yyval.ParamList)->push_back(E);
6442 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006443 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006444 ;}
6445 break;
6446
Chris Lattner740e7092008-10-15 06:16:57 +00006447 case 313:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006448#line 3084 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006449 {
Devang Patel05988662008-09-25 21:00:45 +00006450 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00006451 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006452 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 +00006453 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006454 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006455 ;}
6456 break;
6457
Chris Lattner740e7092008-10-15 06:16:57 +00006458 case 314:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006459#line 3091 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006460 { (yyval.ParamList) = new ParamList(); ;}
6461 break;
6462
Chris Lattner740e7092008-10-15 06:16:57 +00006463 case 315:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006464#line 3094 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006465 { (yyval.ValueList) = new std::vector<Value*>(); ;}
6466 break;
6467
Chris Lattner740e7092008-10-15 06:16:57 +00006468 case 316:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006469#line 3095 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006470 {
6471 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6472 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00006473 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006474 ;}
6475 break;
6476
Chris Lattner740e7092008-10-15 06:16:57 +00006477 case 317:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006478#line 3103 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006479 {
6480 (yyval.ConstantList) = new std::vector<unsigned>();
6481 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
6482 GEN_ERROR("Index " + utostr((yyvsp[(2) - (2)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6483 (yyval.ConstantList)->push_back((yyvsp[(2) - (2)].UInt64Val));
6484 ;}
6485 break;
6486
Chris Lattner740e7092008-10-15 06:16:57 +00006487 case 318:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006488#line 3109 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006489 {
6490 (yyval.ConstantList) = (yyvsp[(1) - (3)].ConstantList);
6491 if ((unsigned)(yyvsp[(3) - (3)].UInt64Val) != (yyvsp[(3) - (3)].UInt64Val))
6492 GEN_ERROR("Index " + utostr((yyvsp[(3) - (3)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6493 (yyval.ConstantList)->push_back((yyvsp[(3) - (3)].UInt64Val));
6494 CHECK_FOR_ERROR
6495 ;}
6496 break;
6497
Chris Lattner740e7092008-10-15 06:16:57 +00006498 case 319:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006499#line 3118 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006500 {
6501 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006502 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006503 ;}
6504 break;
6505
Chris Lattner740e7092008-10-15 06:16:57 +00006506 case 320:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006507#line 3122 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006508 {
6509 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006510 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006511 ;}
6512 break;
6513
Chris Lattner740e7092008-10-15 06:16:57 +00006514 case 321:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006515#line 3127 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006516 {
Reid Spencer14310612006-12-31 05:40:51 +00006517 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006518 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006519 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
Dan Gohmanf4423b12008-04-19 00:24:39 +00006520 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006521 GEN_ERROR(
6522 "Arithmetic operator requires integer, FP, or packed operands");
Eric Christopher2a5196f2008-09-24 04:55:49 +00006523 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006524 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006525 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006526 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006527 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006528 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006529 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006530 delete (yyvsp[(2) - (5)].TypeVal);
6531 ;}
6532 break;
6533
Chris Lattner740e7092008-10-15 06:16:57 +00006534 case 322:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006535#line 3143 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006536 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006537 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006538 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6539 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
Nate Begeman5bc1ea02008-07-29 15:49:41 +00006540 if (!isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00006541 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006542 GEN_ERROR("Logical operator requires integral operands");
6543 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006544 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006545 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006546 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006547 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006548 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006549 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006550 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006551 delete (yyvsp[(2) - (5)].TypeVal);
6552 ;}
6553 break;
6554
Chris Lattner740e7092008-10-15 06:16:57 +00006555 case 323:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006556#line 3160 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006557 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006558 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006559 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006560 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006561 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006562 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006563 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006564 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006565 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006566 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006567 delete (yyvsp[(3) - (6)].TypeVal);
6568 ;}
6569 break;
6570
Chris Lattner740e7092008-10-15 06:16:57 +00006571 case 324:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006572#line 3172 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006573 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006574 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006575 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006576 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006577 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006578 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006579 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006580 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006581 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006582 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006583 delete (yyvsp[(3) - (6)].TypeVal);
6584 ;}
6585 break;
6586
Chris Lattner740e7092008-10-15 06:16:57 +00006587 case 325:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006588#line 3184 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006589 {
6590 if (!UpRefs.empty())
6591 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6592 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6593 GEN_ERROR("Scalar types not supported by vicmp instruction");
6594 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6595 CHECK_FOR_ERROR
6596 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6597 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006598 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006599 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006600 GEN_ERROR("vicmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006601 delete (yyvsp[(3) - (6)].TypeVal);
6602 ;}
6603 break;
6604
Chris Lattner740e7092008-10-15 06:16:57 +00006605 case 326:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006606#line 3198 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006607 {
6608 if (!UpRefs.empty())
6609 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6610 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6611 GEN_ERROR("Scalar types not supported by vfcmp instruction");
6612 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6613 CHECK_FOR_ERROR
6614 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6615 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006616 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006617 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006618 GEN_ERROR("vfcmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006619 delete (yyvsp[(3) - (6)].TypeVal);
6620 ;}
6621 break;
6622
Chris Lattner740e7092008-10-15 06:16:57 +00006623 case 327:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006624#line 3212 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006625 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006626 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006627 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6628 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6629 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6630 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006631 GEN_ERROR("invalid cast opcode for cast from '" +
6632 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00006633 DestTy->getDescription() + "'");
Dan Gohmane4977cf2008-05-23 01:55:30 +00006634 (yyval.InstVal) = CastInst::Create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006635 delete (yyvsp[(4) - (4)].TypeVal);
6636 ;}
6637 break;
6638
Chris Lattner740e7092008-10-15 06:16:57 +00006639 case 328:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006640#line 3224 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006641 {
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006642 if (isa<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType())) {
6643 // vector select
6644 if (!isa<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType())
6645 || !isa<VectorType>((yyvsp[(6) - (6)].ValueVal)->getType()) )
6646 GEN_ERROR("vector select value types must be vector types");
6647 const VectorType* cond_type = cast<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType());
6648 const VectorType* select_type = cast<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType());
6649 if (cond_type->getElementType() != Type::Int1Ty)
6650 GEN_ERROR("vector select condition element type must be boolean");
6651 if (cond_type->getNumElements() != select_type->getNumElements())
6652 GEN_ERROR("vector select number of elements must be the same");
6653 } else {
6654 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
6655 GEN_ERROR("select condition must be boolean");
6656 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006657 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006658 GEN_ERROR("select value types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006659 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006660 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006661 ;}
6662 break;
6663
Chris Lattner740e7092008-10-15 06:16:57 +00006664 case 329:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006665#line 3245 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006666 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006667 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006668 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6669 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6670 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006671 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006672 ;}
6673 break;
6674
Chris Lattner740e7092008-10-15 06:16:57 +00006675 case 330:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006676#line 3252 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006677 {
6678 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006679 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006680 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006681 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006682 ;}
6683 break;
6684
Chris Lattner740e7092008-10-15 06:16:57 +00006685 case 331:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006686#line 3258 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006687 {
6688 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006689 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006690 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006691 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006692 ;}
6693 break;
6694
Chris Lattner740e7092008-10-15 06:16:57 +00006695 case 332:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006696#line 3264 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006697 {
6698 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006699 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006700 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006701 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006702 ;}
6703 break;
6704
Chris Lattner740e7092008-10-15 06:16:57 +00006705 case 333:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006706#line 3270 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006707 {
6708 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006709 if (!Ty->isFirstClassType())
6710 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006711 (yyval.InstVal) = PHINode::Create(Ty);
6712 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6713 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006714 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006715 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006716 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6717 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006718 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006719 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006720 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006721 ;}
6722 break;
6723
Chris Lattner740e7092008-10-15 06:16:57 +00006724 case 334:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006725#line 3286 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006726 {
Reid Spencer14310612006-12-31 05:40:51 +00006727
6728 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006729 const PointerType *PFTy = 0;
6730 const FunctionType *Ty = 0;
Devang Patel652203f2008-09-29 20:49:50 +00006731 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(4) - (9)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006732 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6733 // Pull out the types of all of the arguments...
6734 std::vector<const Type*> ParamTypes;
Devang Patel652203f2008-09-29 20:49:50 +00006735 ParamList::iterator I = (yyvsp[(7) - (9)].ParamList)->begin(), E = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006736 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006737 const Type *Ty = I->Val->getType();
6738 if (Ty == Type::VoidTy)
6739 GEN_ERROR("Short call syntax cannot be used with varargs");
6740 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006741 }
Chris Lattnera925a142008-04-23 05:37:08 +00006742
Devang Patel652203f2008-09-29 20:49:50 +00006743 if (!FunctionType::isValidReturnType(*(yyvsp[(4) - (9)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00006744 GEN_ERROR("Invalid result type for LLVM function");
6745
Devang Patel652203f2008-09-29 20:49:50 +00006746 Ty = FunctionType::get((yyvsp[(4) - (9)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006747 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006748 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006749
Devang Patel652203f2008-09-29 20:49:50 +00006750 Value *V = getVal(PFTy, (yyvsp[(5) - (9)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006751 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006752
Reid Spencer7780acb2007-04-16 06:56:07 +00006753 // Check for call to invalid intrinsic to avoid crashing later.
6754 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006755 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006756 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6757 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006758 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6759 theF->getName() + "'");
6760 }
6761
Devang Patel05988662008-09-25 21:00:45 +00006762 // Set up the Attributes for the function
6763 SmallVector<AttributeWithIndex, 8> Attrs;
Dale Johannesene7261862008-09-26 23:46:20 +00006764 //FIXME : In 3.0, stop accepting zext, sext and inreg as optional function
6765 //attributes.
Devang Patel652203f2008-09-29 20:49:50 +00006766 Attributes RetAttrs = (yyvsp[(3) - (9)].Attributes);
6767 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None) {
6768 if ((yyvsp[(9) - (9)].Attributes) & Attribute::ZExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006769 RetAttrs = RetAttrs | Attribute::ZExt;
Devang Patel652203f2008-09-29 20:49:50 +00006770 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::ZExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006771 }
Devang Patel652203f2008-09-29 20:49:50 +00006772 if ((yyvsp[(9) - (9)].Attributes) & Attribute::SExt) {
Dale Johannesene7261862008-09-26 23:46:20 +00006773 RetAttrs = RetAttrs | Attribute::SExt;
Devang Patel652203f2008-09-29 20:49:50 +00006774 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::SExt;
Dale Johannesene7261862008-09-26 23:46:20 +00006775 }
Devang Patel652203f2008-09-29 20:49:50 +00006776 if ((yyvsp[(9) - (9)].Attributes) & Attribute::InReg) {
Dale Johannesene7261862008-09-26 23:46:20 +00006777 RetAttrs = RetAttrs | Attribute::InReg;
Devang Patel652203f2008-09-29 20:49:50 +00006778 (yyvsp[(9) - (9)].Attributes) = (yyvsp[(9) - (9)].Attributes) ^ Attribute::InReg;
Dale Johannesene7261862008-09-26 23:46:20 +00006779 }
Dale Johannesene7261862008-09-26 23:46:20 +00006780 }
Devang Patel652203f2008-09-29 20:49:50 +00006781 if (RetAttrs != Attribute::None)
6782 Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
Dale Johannesene7261862008-09-26 23:46:20 +00006783
Eric Christopher2a5196f2008-09-24 04:55:49 +00006784 // Check the arguments
Reid Spencer14310612006-12-31 05:40:51 +00006785 ValueList Args;
Devang Patel652203f2008-09-29 20:49:50 +00006786 if ((yyvsp[(7) - (9)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006787 // Make sure no arguments is a good thing!
6788 if (Ty->getNumParams() != 0)
6789 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006790 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006791 } else { // Has arguments?
6792 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006793 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006794 FunctionType::param_iterator I = Ty->param_begin();
6795 FunctionType::param_iterator E = Ty->param_end();
Devang Patel652203f2008-09-29 20:49:50 +00006796 ParamList::iterator ArgI = (yyvsp[(7) - (9)].ParamList)->begin(), ArgE = (yyvsp[(7) - (9)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006797 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006798
Duncan Sandsdc024672007-11-27 13:23:08 +00006799 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006800 if (ArgI->Val->getType() != *I)
6801 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006802 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006803 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006804 if (ArgI->Attrs != Attribute::None)
6805 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006806 }
6807 if (Ty->isVarArg()) {
6808 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006809 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006810 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006811 if (ArgI->Attrs != Attribute::None)
6812 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006813 }
Reid Spencer14310612006-12-31 05:40:51 +00006814 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006815 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006816 }
Devang Patel652203f2008-09-29 20:49:50 +00006817 if ((yyvsp[(9) - (9)].Attributes) != Attribute::None)
6818 Attrs.push_back(AttributeWithIndex::get(~0, (yyvsp[(9) - (9)].Attributes)));
Duncan Sandsdc024672007-11-27 13:23:08 +00006819
Devang Patel05988662008-09-25 21:00:45 +00006820 // Finish off the Attributes and check them
6821 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006822 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006823 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006824
Reid Spencer14310612006-12-31 05:40:51 +00006825 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006826 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Devang Patel652203f2008-09-29 20:49:50 +00006827 CI->setTailCall((yyvsp[(1) - (9)].BoolVal));
6828 CI->setCallingConv((yyvsp[(2) - (9)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006829 CI->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006830 (yyval.InstVal) = CI;
Devang Patel652203f2008-09-29 20:49:50 +00006831 delete (yyvsp[(7) - (9)].ParamList);
6832 delete (yyvsp[(4) - (9)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006833 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006834 ;}
6835 break;
6836
Chris Lattner740e7092008-10-15 06:16:57 +00006837 case 335:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006838#line 3395 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006839 {
6840 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006841 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006842 ;}
6843 break;
6844
Chris Lattner740e7092008-10-15 06:16:57 +00006845 case 336:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006846#line 3400 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006847 {
6848 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006849 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006850 ;}
6851 break;
6852
Chris Lattner740e7092008-10-15 06:16:57 +00006853 case 337:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006854#line 3404 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006855 {
6856 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006857 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006858 ;}
6859 break;
6860
Chris Lattner740e7092008-10-15 06:16:57 +00006861 case 338:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006862#line 3411 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006863 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006864 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006865 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6866 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6867 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006868 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006869 ;}
6870 break;
6871
Chris Lattner740e7092008-10-15 06:16:57 +00006872 case 339:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006873#line 3418 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006874 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006875 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006876 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006877 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6878 GEN_ERROR("Malloc array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006879 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006880 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006881 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6882 delete (yyvsp[(2) - (6)].TypeVal);
6883 ;}
6884 break;
6885
Chris Lattner740e7092008-10-15 06:16:57 +00006886 case 340:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006887#line 3428 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006888 {
Reid Spencer14310612006-12-31 05:40:51 +00006889 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006890 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6891 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6892 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006893 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006894 ;}
6895 break;
6896
Chris Lattner740e7092008-10-15 06:16:57 +00006897 case 341:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006898#line 3435 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006899 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006900 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006901 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006902 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6903 GEN_ERROR("Alloca array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006904 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006905 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006906 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6907 delete (yyvsp[(2) - (6)].TypeVal);
6908 ;}
6909 break;
6910
Chris Lattner740e7092008-10-15 06:16:57 +00006911 case 342:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006912#line 3445 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006913 {
6914 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Eric Christopher2a5196f2008-09-24 04:55:49 +00006915 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006916 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6917 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006918 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006919 ;}
6920 break;
6921
Chris Lattner740e7092008-10-15 06:16:57 +00006922 case 343:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006923#line 3453 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006924 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006925 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006926 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6927 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006928 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006929 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6930 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006931 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006932 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6933 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006934 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006935 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6936 delete (yyvsp[(3) - (5)].TypeVal);
6937 ;}
6938 break;
6939
Chris Lattner740e7092008-10-15 06:16:57 +00006940 case 344:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006941#line 3467 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006942 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006943 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006944 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6945 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006946 if (!PT)
6947 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006948 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006949 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006950 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6951 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006952 "' into space of type '" + ElTy->getDescription() + "'");
6953
Dan Gohmanf4423b12008-04-19 00:24:39 +00006954 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006955 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006956 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6957 delete (yyvsp[(5) - (7)].TypeVal);
6958 ;}
6959 break;
6960
Chris Lattner740e7092008-10-15 06:16:57 +00006961 case 345:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006962#line 3484 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006963 {
Dan Gohman1a570242008-07-23 00:54:54 +00006964 if (!UpRefs.empty())
6965 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6966 if (!isa<StructType>((yyvsp[(2) - (5)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (5)].TypeVal)->get()))
6967 GEN_ERROR("getresult insn requires an aggregate operand");
6968 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].UInt64Val)))
6969 GEN_ERROR("Invalid getresult index for type '" +
6970 (*(yyvsp[(2) - (5)].TypeVal))->getDescription()+ "'");
6971
6972 Value *tmpVal = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Devang Patel5a970972008-02-19 22:27:01 +00006973 CHECK_FOR_ERROR
Dan Gohman1a570242008-07-23 00:54:54 +00006974 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(5) - (5)].UInt64Val));
6975 delete (yyvsp[(2) - (5)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006976 ;}
6977 break;
6978
Chris Lattner740e7092008-10-15 06:16:57 +00006979 case 346:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006980#line 3498 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006981 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006982 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006983 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6984 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006985 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006986
Dan Gohman041e2eb2008-05-15 19:50:34 +00006987 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()))
Reid Spencer61c83e02006-08-18 08:43:06 +00006988 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006989 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6990 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006991 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006992 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006993 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006994 delete (yyvsp[(4) - (4)].ValueList);
6995 ;}
6996 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006997
Chris Lattner740e7092008-10-15 06:16:57 +00006998 case 347:
Nuno Lopesf05ff662008-10-15 11:20:21 +00006999#line 3513 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00007000 {
7001 if (!UpRefs.empty())
7002 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
7003 if (!isa<StructType>((yyvsp[(2) - (4)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (4)].TypeVal)->get()))
7004 GEN_ERROR("extractvalue insn requires an aggregate operand");
7005
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007006 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end()))
Dan Gohmane4977cf2008-05-23 01:55:30 +00007007 GEN_ERROR("Invalid extractvalue indices for type '" +
7008 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
7009 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
7010 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007011 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00007012 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007013 delete (yyvsp[(4) - (4)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007014 ;}
7015 break;
7016
Chris Lattner740e7092008-10-15 06:16:57 +00007017 case 348:
Nuno Lopesf05ff662008-10-15 11:20:21 +00007018#line 3528 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00007019 {
7020 if (!UpRefs.empty())
7021 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (7)].TypeVal))->getDescription());
7022 if (!isa<StructType>((yyvsp[(2) - (7)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (7)].TypeVal)->get()))
7023 GEN_ERROR("extractvalue insn requires an aggregate operand");
7024
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007025 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 +00007026 GEN_ERROR("Invalid insertvalue indices for type '" +
7027 (*(yyvsp[(2) - (7)].TypeVal))->getDescription()+ "'");
7028 Value* aggVal = getVal(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(3) - (7)].ValIDVal));
7029 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
7030 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007031 (yyval.InstVal) = InsertValueInst::Create(aggVal, tmpVal, (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00007032 delete (yyvsp[(2) - (7)].TypeVal);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007033 delete (yyvsp[(5) - (7)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00007034 delete (yyvsp[(7) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00007035 ;}
7036 break;
7037
Dan Gohmanf4423b12008-04-19 00:24:39 +00007038
7039/* Line 1267 of yacc.c. */
Nuno Lopesf05ff662008-10-15 11:20:21 +00007040#line 7041 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00007041 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00007042 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007043 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
7044
7045 YYPOPSTACK (yylen);
7046 yylen = 0;
7047 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007048
7049 *++yyvsp = yyval;
7050
7051
Dan Gohmanf4423b12008-04-19 00:24:39 +00007052 /* Now `shift' the result of the reduction. Determine what state
7053 that goes to, based on the state we popped back to and the rule
7054 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00007055
7056 yyn = yyr1[yyn];
7057
Dan Gohmanf4423b12008-04-19 00:24:39 +00007058 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
7059 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007060 yystate = yytable[yystate];
7061 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00007062 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00007063
7064 goto yynewstate;
7065
7066
Dan Gohmanf4423b12008-04-19 00:24:39 +00007067/*------------------------------------.
7068| yyerrlab -- here on detecting error |
7069`------------------------------------*/
7070yyerrlab:
7071 /* If not already recovering from an error, report this error. */
7072 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007073 {
7074 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007075#if ! YYERROR_VERBOSE
7076 yyerror (YY_("syntax error"));
7077#else
7078 {
7079 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
7080 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
7081 {
7082 YYSIZE_T yyalloc = 2 * yysize;
7083 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
7084 yyalloc = YYSTACK_ALLOC_MAXIMUM;
7085 if (yymsg != yymsgbuf)
7086 YYSTACK_FREE (yymsg);
7087 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
7088 if (yymsg)
7089 yymsg_alloc = yyalloc;
7090 else
7091 {
7092 yymsg = yymsgbuf;
7093 yymsg_alloc = sizeof yymsgbuf;
7094 }
7095 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00007096
Dan Gohmanf4423b12008-04-19 00:24:39 +00007097 if (0 < yysize && yysize <= yymsg_alloc)
7098 {
7099 (void) yysyntax_error (yymsg, yystate, yychar);
7100 yyerror (yymsg);
7101 }
7102 else
7103 {
7104 yyerror (YY_("syntax error"));
7105 if (yysize != 0)
7106 goto yyexhaustedlab;
7107 }
7108 }
7109#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007110 }
7111
Dan Gohmanf4423b12008-04-19 00:24:39 +00007112
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007113
7114 if (yyerrstatus == 3)
7115 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00007116 /* If just tried and failed to reuse look-ahead token after an
7117 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007118
Dan Gohmanf4423b12008-04-19 00:24:39 +00007119 if (yychar <= YYEOF)
7120 {
7121 /* Return failure if at end of input. */
7122 if (yychar == YYEOF)
7123 YYABORT;
7124 }
7125 else
7126 {
7127 yydestruct ("Error: discarding",
7128 yytoken, &yylval);
7129 yychar = YYEMPTY;
7130 }
7131 }
7132
7133 /* Else will try to reuse look-ahead token after shifting the error
7134 token. */
7135 goto yyerrlab1;
7136
7137
7138/*---------------------------------------------------.
7139| yyerrorlab -- error raised explicitly by YYERROR. |
7140`---------------------------------------------------*/
7141yyerrorlab:
7142
7143 /* Pacify compilers like GCC when the user code never invokes
7144 YYERROR and the label yyerrorlab therefore never appears in user
7145 code. */
7146 if (/*CONSTCOND*/ 0)
7147 goto yyerrorlab;
7148
7149 /* Do not reclaim the symbols of the rule which action triggered
7150 this YYERROR. */
7151 YYPOPSTACK (yylen);
7152 yylen = 0;
7153 YY_STACK_PRINT (yyss, yyssp);
7154 yystate = *yyssp;
7155 goto yyerrlab1;
7156
7157
7158/*-------------------------------------------------------------.
7159| yyerrlab1 -- common code for both syntax error and YYERROR. |
7160`-------------------------------------------------------------*/
7161yyerrlab1:
7162 yyerrstatus = 3; /* Each real token shifted decrements this. */
7163
7164 for (;;)
7165 {
7166 yyn = yypact[yystate];
7167 if (yyn != YYPACT_NINF)
7168 {
7169 yyn += YYTERROR;
7170 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7171 {
7172 yyn = yytable[yyn];
7173 if (0 < yyn)
7174 break;
7175 }
7176 }
7177
7178 /* Pop the current state because it cannot handle the error token. */
7179 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007180 YYABORT;
7181
Dale Johannesencdd509a2007-09-07 21:07:57 +00007182
Dan Gohmanf4423b12008-04-19 00:24:39 +00007183 yydestruct ("Error: popping",
7184 yystos[yystate], yyvsp);
7185 YYPOPSTACK (1);
7186 yystate = *yyssp;
7187 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007188 }
7189
7190 if (yyn == YYFINAL)
7191 YYACCEPT;
7192
Reid Spencer68a24bd2005-08-27 18:50:39 +00007193 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007194
7195
7196 /* Shift the error token. */
7197 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00007198
Reid Spencer68a24bd2005-08-27 18:50:39 +00007199 yystate = yyn;
7200 goto yynewstate;
7201
Gabor Greife64d2482008-04-06 23:07:54 +00007202
Dan Gohmanf4423b12008-04-19 00:24:39 +00007203/*-------------------------------------.
7204| yyacceptlab -- YYACCEPT comes here. |
7205`-------------------------------------*/
7206yyacceptlab:
7207 yyresult = 0;
7208 goto yyreturn;
7209
7210/*-----------------------------------.
7211| yyabortlab -- YYABORT comes here. |
7212`-----------------------------------*/
7213yyabortlab:
7214 yyresult = 1;
7215 goto yyreturn;
7216
7217#ifndef yyoverflow
7218/*-------------------------------------------------.
7219| yyexhaustedlab -- memory exhaustion comes here. |
7220`-------------------------------------------------*/
7221yyexhaustedlab:
7222 yyerror (YY_("memory exhausted"));
7223 yyresult = 2;
7224 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00007225#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00007226
7227yyreturn:
7228 if (yychar != YYEOF && yychar != YYEMPTY)
7229 yydestruct ("Cleanup: discarding lookahead",
7230 yytoken, &yylval);
7231 /* Do not reclaim the symbols of the rule which action triggered
7232 this YYABORT or YYACCEPT. */
7233 YYPOPSTACK (yylen);
7234 YY_STACK_PRINT (yyss, yyssp);
7235 while (yyssp != yyss)
7236 {
7237 yydestruct ("Cleanup: popping",
7238 yystos[*yyssp], yyvsp);
7239 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00007240 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007241#ifndef yyoverflow
7242 if (yyss != yyssa)
7243 YYSTACK_FREE (yyss);
7244#endif
7245#if YYERROR_VERBOSE
7246 if (yymsg != yymsgbuf)
7247 YYSTACK_FREE (yymsg);
7248#endif
7249 /* Make sure YYID is used. */
7250 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007251}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007252
7253
Nuno Lopesf05ff662008-10-15 11:20:21 +00007254#line 3547 "/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00007255
7256
Reid Spencer14310612006-12-31 05:40:51 +00007257// common code from the two 'RunVMAsmParser' functions
7258static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00007259 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00007260 // Check to make sure the parser succeeded
7261 if (yyparse()) {
7262 if (ParserResult)
7263 delete ParserResult;
7264 return 0;
7265 }
7266
Reid Spencer0d60b5a2007-03-30 01:37:39 +00007267 // Emit an error if there are any unresolved types left.
7268 if (!CurModule.LateResolveTypes.empty()) {
7269 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
7270 if (DID.Type == ValID::LocalName) {
7271 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
7272 } else {
7273 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
7274 }
7275 if (ParserResult)
7276 delete ParserResult;
7277 return 0;
7278 }
7279
7280 // Emit an error if there are any unresolved values left.
7281 if (!CurModule.LateResolveValues.empty()) {
7282 Value *V = CurModule.LateResolveValues.back();
7283 std::map<Value*, std::pair<ValID, int> >::iterator I =
7284 CurModule.PlaceHolderInfo.find(V);
7285
7286 if (I != CurModule.PlaceHolderInfo.end()) {
7287 ValID &DID = I->second.first;
7288 if (DID.Type == ValID::LocalName) {
7289 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
7290 } else {
7291 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
7292 }
7293 if (ParserResult)
7294 delete ParserResult;
7295 return 0;
7296 }
7297 }
7298
Reid Spencer14310612006-12-31 05:40:51 +00007299 // Check to make sure that parsing produced a result
7300 if (!ParserResult)
7301 return 0;
7302
7303 // Reset ParserResult variable while saving its value for the result.
7304 Module *Result = ParserResult;
7305 ParserResult = 0;
7306
7307 return Result;
7308}
7309
Reid Spencer61c83e02006-08-18 08:43:06 +00007310void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007311 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00007312 // TODO: column number in exception
7313 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00007314 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00007315 TriggerError = 1;
7316}
Reid Spencer68a24bd2005-08-27 18:50:39 +00007317
7318int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007319 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00007320 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00007321 if (yychar != YYEMPTY && yychar != 0) {
7322 errMsg += " while reading token: '";
Eric Christopher2a5196f2008-09-24 04:55:49 +00007323 errMsg += std::string(LLLgetTokenStart(),
Duncan Sandsdc024672007-11-27 13:23:08 +00007324 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
7325 }
Reid Spencer61c83e02006-08-18 08:43:06 +00007326 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007327 return 0;
7328}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007329