blob: 6e92514d1b71cf95da13cb85a9340617ba49d9b3 [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,
227 FNNOTE = 408,
228 INLINE = 409,
229 ALWAYS = 410,
230 NEVER = 411,
231 OPTIMIZEFORSIZE = 412,
232 DEFAULT = 413,
233 HIDDEN = 414,
234 PROTECTED = 415
Dan Gohmanf4423b12008-04-19 00:24:39 +0000235 };
236#endif
237/* Tokens. */
238#define ESINT64VAL 258
239#define EUINT64VAL 259
240#define ESAPINTVAL 260
241#define EUAPINTVAL 261
242#define LOCALVAL_ID 262
243#define GLOBALVAL_ID 263
244#define FPVAL 264
245#define VOID 265
246#define INTTYPE 266
247#define FLOAT 267
248#define DOUBLE 268
249#define X86_FP80 269
250#define FP128 270
251#define PPC_FP128 271
252#define LABEL 272
253#define TYPE 273
254#define LOCALVAR 274
255#define GLOBALVAR 275
256#define LABELSTR 276
257#define STRINGCONSTANT 277
258#define ATSTRINGCONSTANT 278
259#define PCTSTRINGCONSTANT 279
260#define ZEROINITIALIZER 280
261#define TRUETOK 281
262#define FALSETOK 282
263#define BEGINTOK 283
264#define ENDTOK 284
265#define DECLARE 285
266#define DEFINE 286
267#define GLOBAL 287
268#define CONSTANT 288
269#define SECTION 289
270#define ALIAS 290
271#define VOLATILE 291
272#define THREAD_LOCAL 292
273#define TO 293
274#define DOTDOTDOT 294
275#define NULL_TOK 295
276#define UNDEF 296
277#define INTERNAL 297
278#define LINKONCE 298
279#define WEAK 299
280#define APPENDING 300
281#define DLLIMPORT 301
282#define DLLEXPORT 302
283#define EXTERN_WEAK 303
Dale Johannesenc7071cc2008-05-14 20:13:36 +0000284#define COMMON 304
285#define OPAQUE 305
286#define EXTERNAL 306
287#define TARGET 307
288#define TRIPLE 308
289#define ALIGN 309
290#define ADDRSPACE 310
291#define DEPLIBS 311
292#define CALL 312
293#define TAIL 313
294#define ASM_TOK 314
295#define MODULE 315
296#define SIDEEFFECT 316
297#define CC_TOK 317
298#define CCC_TOK 318
299#define FASTCC_TOK 319
300#define COLDCC_TOK 320
301#define X86_STDCALLCC_TOK 321
302#define X86_FASTCALLCC_TOK 322
Dale Johannesendfe8c842008-09-26 19:32:34 +0000303#define DATALAYOUT 323
304#define RET 324
305#define BR 325
306#define SWITCH 326
307#define INVOKE 327
308#define UNWIND 328
309#define UNREACHABLE 329
310#define ADD 330
311#define SUB 331
312#define MUL 332
313#define UDIV 333
314#define SDIV 334
315#define FDIV 335
316#define UREM 336
317#define SREM 337
318#define FREM 338
319#define AND 339
320#define OR 340
321#define XOR 341
322#define SHL 342
323#define LSHR 343
324#define ASHR 344
325#define ICMP 345
326#define FCMP 346
327#define VICMP 347
328#define VFCMP 348
329#define EQ 349
330#define NE 350
331#define SLT 351
332#define SGT 352
333#define SLE 353
334#define SGE 354
335#define ULT 355
336#define UGT 356
337#define ULE 357
338#define UGE 358
339#define OEQ 359
340#define ONE 360
341#define OLT 361
342#define OGT 362
343#define OLE 363
344#define OGE 364
345#define ORD 365
346#define UNO 366
347#define UEQ 367
348#define UNE 368
349#define MALLOC 369
350#define ALLOCA 370
351#define FREE 371
352#define LOAD 372
353#define STORE 373
354#define GETELEMENTPTR 374
355#define TRUNC 375
356#define ZEXT 376
357#define SEXT 377
358#define FPTRUNC 378
359#define FPEXT 379
360#define BITCAST 380
361#define UITOFP 381
362#define SITOFP 382
363#define FPTOUI 383
364#define FPTOSI 384
365#define INTTOPTR 385
366#define PTRTOINT 386
367#define PHI_TOK 387
368#define SELECT 388
369#define VAARG 389
370#define EXTRACTELEMENT 390
371#define INSERTELEMENT 391
372#define SHUFFLEVECTOR 392
373#define GETRESULT 393
374#define EXTRACTVALUE 394
375#define INSERTVALUE 395
376#define SIGNEXT 396
377#define ZEROEXT 397
378#define NORETURN 398
379#define INREG 399
380#define SRET 400
381#define NOUNWIND 401
382#define NOALIAS 402
383#define BYVAL 403
384#define NEST 404
385#define READNONE 405
386#define READONLY 406
387#define GC 407
388#define FNNOTE 408
389#define INLINE 409
390#define ALWAYS 410
391#define NEVER 411
392#define OPTIMIZEFORSIZE 412
393#define DEFAULT 413
394#define HIDDEN 414
395#define PROTECTED 415
Dan Gohmanf4423b12008-04-19 00:24:39 +0000396
397
398
399
400/* Copy the first part of user declarations. */
Dale Johannesendfe8c842008-09-26 19:32:34 +0000401#line 14 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000402
403#include "ParserInternals.h"
404#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000405#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000406#include "llvm/Instructions.h"
407#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000408#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000409#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000410#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000411#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000412#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000413#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000414#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000415#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000416#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000417#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000418#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000419#include <utility>
420
Reid Spencere4f47592006-08-18 17:32:55 +0000421// The following is a gross hack. In order to rid the libAsmParser library of
422// exceptions, we have to have a way of getting the yyparse function to go into
423// an error situation. So, whenever we want an error to occur, the GenerateError
Eric Christopher2a5196f2008-09-24 04:55:49 +0000424// function (see bottom of file) sets TriggerError. Then, at the end of each
425// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
426// (a goto) to put YACC in error state. Furthermore, several calls to
Reid Spencere4f47592006-08-18 17:32:55 +0000427// GenerateError are made from inside productions and they must simulate the
428// previous exception behavior by exiting the production immediately. We have
429// replaced these with the GEN_ERROR macro which calls GeneratError and then
Eric Christopher2a5196f2008-09-24 04:55:49 +0000430// immediately invokes YYERROR. This would be so much cleaner if it was a
Reid Spencere4f47592006-08-18 17:32:55 +0000431// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000432static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000433#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000434#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
435
Reid Spencer68a24bd2005-08-27 18:50:39 +0000436int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
437int yylex(); // declaration" of xxx warnings.
438int yyparse();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000439using namespace llvm;
440
441static Module *ParserResult;
442
443// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
444// relating to upreferences in the input stream.
445//
446//#define DEBUG_UPREFS 1
447#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000448#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000449#else
450#define UR_OUT(X)
451#endif
452
453#define YYERROR_VERBOSE 1
454
Chris Lattnerb475c422005-11-12 18:22:38 +0000455static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000456
457
458// This contains info used when building the body of a function. It is
459// destroyed when the function is completed.
460//
461typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000462
Eric Christopher2a5196f2008-09-24 04:55:49 +0000463static void
Reid Spencer93c40032007-03-19 18:40:50 +0000464ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000465
466static struct PerModuleInfo {
467 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000468 ValueList Values; // Module level numbered definitions
469 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000470 std::vector<PATypeHolder> Types;
471 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000472
473 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000474 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000475 /// that we can resolve them later and print error messages as appropriate.
476 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
477
478 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
479 // references to global values. Global values may be referenced before they
480 // are defined, and if so, the temporary object that they represent is held
481 // here. This is used for forward references of GlobalValues.
482 //
483 typedef std::map<std::pair<const PointerType *,
484 ValID>, GlobalValue*> GlobalRefsType;
485 GlobalRefsType GlobalRefs;
486
487 void ModuleDone() {
488 // If we could not resolve some functions at function compilation time
489 // (calls to functions before they are defined), resolve them now... Types
490 // are resolved when the constant pool has been completely parsed.
491 //
492 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000493 if (TriggerError)
494 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000495
496 // Check to make sure that all global value forward references have been
497 // resolved!
498 //
499 if (!GlobalRefs.empty()) {
500 std::string UndefinedReferences = "Unresolved global references exist:\n";
501
502 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
503 I != E; ++I) {
504 UndefinedReferences += " " + I->first.first->getDescription() + " " +
505 I->first.second.getName() + "\n";
506 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000507 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000508 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000509 }
510
Chandler Carruth02202192007-08-04 01:56:21 +0000511 // Look for intrinsic functions and CallInst that need to be upgraded
512 for (Module::iterator FI = CurrentModule->begin(),
513 FE = CurrentModule->end(); FI != FE; )
514 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
515
Reid Spencer68a24bd2005-08-27 18:50:39 +0000516 Values.clear(); // Clear out function local definitions
517 Types.clear();
518 CurrentModule = 0;
519 }
520
Reid Spencer68a24bd2005-08-27 18:50:39 +0000521 // GetForwardRefForGlobal - Check to see if there is a forward reference
522 // for this global. If so, remove it from the GlobalRefs map and return it.
523 // If not, just return null.
524 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
525 // Check to see if there is a forward reference to this global variable...
526 // if there is, eliminate it and patch the reference to use the new def'n.
527 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
528 GlobalValue *Ret = 0;
529 if (I != GlobalRefs.end()) {
530 Ret = I->second;
531 GlobalRefs.erase(I);
532 }
533 return Ret;
534 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000535
536 bool TypeIsUnresolved(PATypeHolder* PATy) {
537 // If it isn't abstract, its resolved
538 const Type* Ty = PATy->get();
539 if (!Ty->isAbstract())
540 return false;
541 // Traverse the type looking for abstract types. If it isn't abstract then
Eric Christopher2a5196f2008-09-24 04:55:49 +0000542 // we don't need to traverse that leg of the type.
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000543 std::vector<const Type*> WorkList, SeenList;
544 WorkList.push_back(Ty);
545 while (!WorkList.empty()) {
546 const Type* Ty = WorkList.back();
547 SeenList.push_back(Ty);
548 WorkList.pop_back();
549 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
550 // Check to see if this is an unresolved type
551 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
552 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
553 for ( ; I != E; ++I) {
554 if (I->second.get() == OpTy)
555 return true;
556 }
557 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
558 const Type* TheTy = SeqTy->getElementType();
559 if (TheTy->isAbstract() && TheTy != Ty) {
Eric Christopher2a5196f2008-09-24 04:55:49 +0000560 std::vector<const Type*>::iterator I = SeenList.begin(),
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000561 E = SeenList.end();
562 for ( ; I != E; ++I)
563 if (*I == TheTy)
564 break;
565 if (I == E)
566 WorkList.push_back(TheTy);
567 }
568 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
569 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
570 const Type* TheTy = StrTy->getElementType(i);
571 if (TheTy->isAbstract() && TheTy != Ty) {
Eric Christopher2a5196f2008-09-24 04:55:49 +0000572 std::vector<const Type*>::iterator I = SeenList.begin(),
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000573 E = SeenList.end();
574 for ( ; I != E; ++I)
575 if (*I == TheTy)
576 break;
577 if (I == E)
578 WorkList.push_back(TheTy);
579 }
580 }
581 }
582 }
583 return false;
584 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000585} CurModule;
586
587static struct PerFunctionInfo {
588 Function *CurrentFunction; // Pointer to current function being created
589
Reid Spencer93c40032007-03-19 18:40:50 +0000590 ValueList Values; // Keep track of #'d definitions
591 unsigned NextValNum;
592 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000593 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000594 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000595 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000596
597 /// BBForwardRefs - When we see forward references to basic blocks, keep
598 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000599 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000600
601 inline PerFunctionInfo() {
602 CurrentFunction = 0;
603 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000604 Linkage = GlobalValue::ExternalLinkage;
605 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606 }
607
608 inline void FunctionStart(Function *M) {
609 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000610 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611 }
612
613 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000614 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000615 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000616 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000617 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000618 return;
619 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000620
621 // Resolve all forward references now.
622 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
623
624 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000625 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626 CurrentFunction = 0;
627 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000628 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000629 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000630 }
631} CurFun; // Info for the current function...
632
633static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
634
635
636//===----------------------------------------------------------------------===//
637// Code to handle definitions of all the types
638//===----------------------------------------------------------------------===//
639
Chris Lattner15bd0952008-08-29 17:20:18 +0000640/// InsertValue - Insert a value into the value table. If it is named, this
641/// returns -1, otherwise it returns the slot number for the value.
642static int InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
Reid Spencer93c40032007-03-19 18:40:50 +0000643 // Things that have names or are void typed don't get slot numbers
644 if (V->hasName() || (V->getType() == Type::VoidTy))
Chris Lattner15bd0952008-08-29 17:20:18 +0000645 return -1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646
Reid Spencer93c40032007-03-19 18:40:50 +0000647 // In the case of function values, we have to allow for the forward reference
648 // of basic blocks, which are included in the numbering. Consequently, we keep
Eric Christopher2a5196f2008-09-24 04:55:49 +0000649 // track of the next insertion location with NextValNum. When a BB gets
Reid Spencer93c40032007-03-19 18:40:50 +0000650 // inserted, it could change the size of the CurFun.Values vector.
651 if (&ValueTab == &CurFun.Values) {
652 if (ValueTab.size() <= CurFun.NextValNum)
653 ValueTab.resize(CurFun.NextValNum+1);
654 ValueTab[CurFun.NextValNum++] = V;
Chris Lattner15bd0952008-08-29 17:20:18 +0000655 return CurFun.NextValNum-1;
Eric Christopher2a5196f2008-09-24 04:55:49 +0000656 }
Reid Spencer93c40032007-03-19 18:40:50 +0000657 // For all other lists, its okay to just tack it on the back of the vector.
658 ValueTab.push_back(V);
Chris Lattner15bd0952008-08-29 17:20:18 +0000659 return ValueTab.size()-1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000660}
661
662static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
663 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000664 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000665 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000666 if (D.Num < CurModule.Types.size())
667 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000668 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000669 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000670 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000671 D.destroy(); // Free old strdup'd memory...
672 return N;
673 }
674 break;
675 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000676 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000677 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000678 }
679
680 // If we reached here, we referenced either a symbol that we don't know about
681 // or an id number that hasn't been read yet. We may be referencing something
682 // forward, so just create an entry to be resolved later and get to it...
683 //
684 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
685
686
687 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000688 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000689 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000690 return 0;
691 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000692 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000693 return 0;
694 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000695 }
696
Reid Spencer861d9d62006-11-28 07:29:44 +0000697 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000698 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000699 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000700
Reid Spencer861d9d62006-11-28 07:29:44 +0000701 Type *Typ = OpaqueType::get();
702 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
703 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000704 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000705
Reid Spencer93c40032007-03-19 18:40:50 +0000706// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000707// the provided ValID. If the value exists and has already been defined, return
708// it. Otherwise return null.
709//
Reid Spencer93c40032007-03-19 18:40:50 +0000710static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000711 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000712 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000713 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000714 return 0;
715 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000716
717 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000718 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000719 // Check that the number is within bounds.
Eric Christopher2a5196f2008-09-24 04:55:49 +0000720 if (D.Num >= CurFun.Values.size())
Reid Spencer93c40032007-03-19 18:40:50 +0000721 return 0;
722 Value *Result = CurFun.Values[D.Num];
723 if (Ty != Result->getType()) {
724 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +0000725 Result->getType()->getDescription() + "' does not match "
Reid Spencer93c40032007-03-19 18:40:50 +0000726 "expected type, '" + Ty->getDescription() + "'");
727 return 0;
728 }
729 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000730 }
731 case ValID::GlobalID: { // Is it a numbered definition?
Eric Christopher2a5196f2008-09-24 04:55:49 +0000732 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000733 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000734 Value *Result = CurModule.Values[D.Num];
735 if (Ty != Result->getType()) {
736 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +0000737 Result->getType()->getDescription() + "' does not match "
Reid Spencer93c40032007-03-19 18:40:50 +0000738 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000739 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000740 }
741 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000742 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000743
Reid Spencer41dff5e2007-01-26 08:05:27 +0000744 case ValID::LocalName: { // Is it a named definition?
Eric Christopher2a5196f2008-09-24 04:55:49 +0000745 if (!inFunctionScope())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000746 return 0;
747 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000748 Value *N = SymTab.lookup(D.getName());
Eric Christopher2a5196f2008-09-24 04:55:49 +0000749 if (N == 0)
Reid Spenceref9b9a72007-02-05 20:47:22 +0000750 return 0;
751 if (N->getType() != Ty)
752 return 0;
Eric Christopher2a5196f2008-09-24 04:55:49 +0000753
Reid Spencer41dff5e2007-01-26 08:05:27 +0000754 D.destroy(); // Free old strdup'd memory...
755 return N;
756 }
757 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000758 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000759 Value *N = SymTab.lookup(D.getName());
Eric Christopher2a5196f2008-09-24 04:55:49 +0000760 if (N == 0)
Reid Spenceref9b9a72007-02-05 20:47:22 +0000761 return 0;
762 if (N->getType() != Ty)
763 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000764
765 D.destroy(); // Free old strdup'd memory...
766 return N;
767 }
768
769 // Check to make sure that "Ty" is an integral type, and that our
770 // value will fit into the specified type...
771 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner38905612008-02-19 04:36:25 +0000772 if (!isa<IntegerType>(Ty) ||
773 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000774 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000775 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000776 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000777 return 0;
778 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000779 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000780
781 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000782 if (isa<IntegerType>(Ty) &&
783 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Reid Spencerb83eb642006-10-20 07:07:24 +0000784 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner38905612008-02-19 04:36:25 +0000785
786 if (!isa<IntegerType>(Ty) ||
787 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
788 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
789 "' is invalid or out of range for type '" +
790 Ty->getDescription() + "'");
791 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000792 }
Chris Lattner38905612008-02-19 04:36:25 +0000793 // This is really a signed reference. Transmogrify.
794 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000795
Chris Lattner1913b942008-07-11 00:30:39 +0000796 case ValID::ConstAPInt: // Is it an unsigned const pool reference?
797 if (!isa<IntegerType>(Ty)) {
798 GenerateError("Integral constant '" + D.getName() +
799 "' is invalid or out of range for type '" +
800 Ty->getDescription() + "'");
801 return 0;
802 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000803
Chris Lattner1913b942008-07-11 00:30:39 +0000804 {
805 APSInt Tmp = *D.ConstPoolInt;
806 Tmp.extOrTrunc(Ty->getPrimitiveSizeInBits());
807 return ConstantInt::get(Tmp);
808 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000809
Reid Spencer68a24bd2005-08-27 18:50:39 +0000810 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000811 if (!Ty->isFloatingPoint() ||
812 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000813 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000814 return 0;
815 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000816 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +0000817 // as double. Fix this here. Long double does not need this.
818 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
819 Ty==Type::FloatTy)
Dale Johannesencdd509a2007-09-07 21:07:57 +0000820 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000821 return ConstantFP::get(*D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000822
823 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000824 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000825 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000826 return 0;
827 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000828 return ConstantPointerNull::get(cast<PointerType>(Ty));
829
830 case ValID::ConstUndefVal: // Is it an undef value?
831 return UndefValue::get(Ty);
832
Chris Lattner7aa61892005-12-21 17:53:23 +0000833 case ValID::ConstZeroVal: // Is it a zero value?
834 return Constant::getNullValue(Ty);
Eric Christopher2a5196f2008-09-24 04:55:49 +0000835
Reid Spencer68a24bd2005-08-27 18:50:39 +0000836 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000837 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000838 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000839 return 0;
840 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000841 return D.ConstantValue;
842
Chris Lattner0e9c3762006-01-25 22:27:16 +0000843 case ValID::InlineAsmVal: { // Inline asm expression
844 const PointerType *PTy = dyn_cast<PointerType>(Ty);
845 const FunctionType *FTy =
846 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000847 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000848 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000849 return 0;
850 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000851 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
852 D.IAD->HasSideEffects);
853 D.destroy(); // Free InlineAsmDescriptor.
854 return IA;
855 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000856 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000857 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000858 return 0;
859 } // End of switch
860
Reid Spencera9720f52007-02-05 17:04:00 +0000861 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000862 return 0;
863}
864
Reid Spencer93c40032007-03-19 18:40:50 +0000865// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000866// value is not already defined, it "improvises" by creating a placeholder var
867// that looks and acts just like the requested variable. When the value is
868// defined later, all uses of the placeholder variable are replaced with the
869// real thing.
870//
871static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000872 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000873 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000874 return 0;
875 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000876
877 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000878 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000879 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000880 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000881
Reid Spencer5b7e7532006-09-28 19:28:24 +0000882 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Dan Gohmane4977cf2008-05-23 01:55:30 +0000883 GenerateError("Invalid use of a non-first-class type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000884 return 0;
885 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000886
887 // If we reached here, we referenced either a symbol that we don't know about
888 // or an id number that hasn't been read yet. We may be referencing something
889 // forward, so just create an entry to be resolved later and get to it...
890 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000891 switch (ID.Type) {
892 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000893 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000894 const PointerType *PTy = dyn_cast<PointerType>(Ty);
895 if (!PTy) {
896 GenerateError("Invalid type for reference to global" );
897 return 0;
898 }
899 const Type* ElTy = PTy->getElementType();
900 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greife64d2482008-04-06 23:07:54 +0000901 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000902 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000903 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
904 (Module*)0, false, PTy->getAddressSpace());
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000905 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000906 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000907 default:
908 V = new Argument(Ty);
909 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000910
Reid Spencer68a24bd2005-08-27 18:50:39 +0000911 // Remember where this forward reference came from. FIXME, shouldn't we try
912 // to recycle these things??
913 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsdc024672007-11-27 13:23:08 +0000914 LLLgetLineNo())));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000915
916 if (inFunctionScope())
917 InsertValue(V, CurFun.LateResolveValues);
918 else
919 InsertValue(V, CurModule.LateResolveValues);
920 return V;
921}
922
Reid Spencer93c40032007-03-19 18:40:50 +0000923/// defineBBVal - This is a definition of a new basic block with the specified
924/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Chris Lattnercc81d152008-05-04 17:18:47 +0000925static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000926 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000927
Reid Spencer68a24bd2005-08-27 18:50:39 +0000928 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000929
Reid Spencer93c40032007-03-19 18:40:50 +0000930 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000931
Reid Spencer93c40032007-03-19 18:40:50 +0000932 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
933 if (BBI != CurFun.BBForwardRefs.end()) {
934 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000935 // The forward declaration could have been inserted anywhere in the
936 // function: insert it into the correct place now.
937 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
938 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000939
Reid Spencer66728ef2007-03-20 01:13:36 +0000940 // We're about to erase the entry, save the key so we can clean it up.
941 ValID Tmp = BBI->first;
942
Reid Spencer93c40032007-03-19 18:40:50 +0000943 // Erase the forward ref from the map as its no longer "forward"
944 CurFun.BBForwardRefs.erase(ID);
945
Eric Christopher2a5196f2008-09-24 04:55:49 +0000946 // The key has been removed from the map but so we don't want to leave
Reid Spencer66728ef2007-03-20 01:13:36 +0000947 // strdup'd memory around so destroy it too.
948 Tmp.destroy();
949
Reid Spencer93c40032007-03-19 18:40:50 +0000950 // If its a numbered definition, bump the number and set the BB value.
951 if (ID.Type == ValID::LocalID) {
952 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
953 InsertValue(BB);
954 }
Eric Christopher2a5196f2008-09-24 04:55:49 +0000955 } else {
956 // We haven't seen this BB before and its first mention is a definition.
Devang Patel67909432008-03-03 18:58:47 +0000957 // Just create it and return it.
958 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greife64d2482008-04-06 23:07:54 +0000959 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel67909432008-03-03 18:58:47 +0000960 if (ID.Type == ValID::LocalID) {
961 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
962 InsertValue(BB);
963 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000964 }
Reid Spencer93c40032007-03-19 18:40:50 +0000965
Devang Patel67909432008-03-03 18:58:47 +0000966 ID.destroy();
Reid Spencer93c40032007-03-19 18:40:50 +0000967 return BB;
968}
969
970/// getBBVal - get an existing BB value or create a forward reference for it.
Eric Christopher2a5196f2008-09-24 04:55:49 +0000971///
Reid Spencer93c40032007-03-19 18:40:50 +0000972static BasicBlock *getBBVal(const ValID &ID) {
973 assert(inFunctionScope() && "Can't get basic block at global scope!");
974
975 BasicBlock *BB = 0;
976
977 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
978 if (BBI != CurFun.BBForwardRefs.end()) {
979 BB = BBI->second;
980 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000981 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000982 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000983 if (N) {
Reid Spencer93c40032007-03-19 18:40:50 +0000984 if (N->getType()->getTypeID() == Type::LabelTyID)
985 BB = cast<BasicBlock>(N);
986 else
987 GenerateError("Reference to label '" + Name + "' is actually of type '"+
988 N->getType()->getDescription() + "'");
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000989 }
Reid Spencer93c40032007-03-19 18:40:50 +0000990 } else if (ID.Type == ValID::LocalID) {
991 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
992 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
993 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
994 else
Eric Christopher2a5196f2008-09-24 04:55:49 +0000995 GenerateError("Reference to label '%" + utostr(ID.Num) +
996 "' is actually of type '"+
Reid Spencer93c40032007-03-19 18:40:50 +0000997 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
998 }
999 } else {
1000 GenerateError("Illegal label reference " + ID.getName());
1001 return 0;
1002 }
1003
1004 // If its already been defined, return it now.
1005 if (BB) {
1006 ID.destroy(); // Free strdup'd memory.
1007 return BB;
1008 }
1009
1010 // Otherwise, this block has not been seen before, create it.
1011 std::string Name;
1012 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001013 Name = ID.getName();
Gabor Greife64d2482008-04-06 23:07:54 +00001014 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Reid Spencer93c40032007-03-19 18:40:50 +00001015
1016 // Insert it in the forward refs map.
1017 CurFun.BBForwardRefs[ID] = BB;
1018
Reid Spencer68a24bd2005-08-27 18:50:39 +00001019 return BB;
1020}
1021
1022
1023//===----------------------------------------------------------------------===//
1024// Code to handle forward references in instructions
1025//===----------------------------------------------------------------------===//
1026//
1027// This code handles the late binding needed with statements that reference
1028// values not defined yet... for example, a forward branch, or the PHI node for
1029// a loop body.
1030//
1031// This keeps a table (CurFun.LateResolveValues) of all such forward references
1032// and back patchs after we are done.
1033//
1034
1035// ResolveDefinitions - If we could not resolve some defs at parsing
1036// time (forward branches, phi functions for loops, etc...) resolve the
1037// defs now...
1038//
Eric Christopher2a5196f2008-09-24 04:55:49 +00001039static void
Reid Spencer93c40032007-03-19 18:40:50 +00001040ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001041 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +00001042 while (!LateResolvers.empty()) {
1043 Value *V = LateResolvers.back();
1044 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001045
Reid Spencer93c40032007-03-19 18:40:50 +00001046 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1047 CurModule.PlaceHolderInfo.find(V);
1048 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001049
Reid Spencer93c40032007-03-19 18:40:50 +00001050 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001051
Reid Spencer93c40032007-03-19 18:40:50 +00001052 Value *TheRealValue = getExistingVal(V->getType(), DID);
1053 if (TriggerError)
1054 return;
1055 if (TheRealValue) {
1056 V->replaceAllUsesWith(TheRealValue);
1057 delete V;
1058 CurModule.PlaceHolderInfo.erase(PHI);
1059 } else if (FutureLateResolvers) {
1060 // Functions have their unresolved items forwarded to the module late
1061 // resolver table
1062 InsertValue(V, *FutureLateResolvers);
1063 } else {
1064 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1065 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1066 "' of type '" + V->getType()->getDescription() + "'",
1067 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001068 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001069 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001070 GenerateError("Reference to an invalid definition: #" +
1071 itostr(DID.Num) + " of type '" +
1072 V->getType()->getDescription() + "'",
1073 PHI->second.second);
1074 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001075 }
1076 }
1077 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001078 LateResolvers.clear();
1079}
1080
1081// ResolveTypeTo - A brand new type was just declared. This means that (if
1082// name is not null) things referencing Name can be resolved. Otherwise, things
1083// refering to the number can be resolved. Do this now.
1084//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001085static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001086 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001087 if (Name)
1088 D = ValID::createLocalName(*Name);
Eric Christopher2a5196f2008-09-24 04:55:49 +00001089 else
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001090 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001091
Reid Spencer861d9d62006-11-28 07:29:44 +00001092 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001093 CurModule.LateResolveTypes.find(D);
1094 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001095 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001096 CurModule.LateResolveTypes.erase(I);
1097 }
1098}
1099
1100// setValueName - Set the specified value to the name given. The name may be
1101// null potentially, in which case this is a noop. The string passed in is
1102// assumed to be a malloc'd string buffer, and is free'd by this function.
1103//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001104static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001105 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001106 std::string Name(*NameStr); // Copy string
1107 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001108
Reid Spencer41dff5e2007-01-26 08:05:27 +00001109 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001110 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001111 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001112 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001113
Reid Spencera9720f52007-02-05 17:04:00 +00001114 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001115 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1116 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001117 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001118 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001119 return;
1120 }
1121
1122 // Set the name.
1123 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001124}
1125
1126/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1127/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001128static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001129ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001130 GlobalValue::LinkageTypes Linkage,
1131 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001132 bool isConstantGlobal, const Type *Ty,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001133 Constant *Initializer, bool IsThreadLocal,
1134 unsigned AddressSpace = 0) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001135 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001136 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001137 return 0;
1138 }
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001139 if (Ty == Type::LabelTy) {
1140 GenerateError("Cannot declare global vars of label type");
1141 return 0;
1142 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001143
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001144 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001145
1146 std::string Name;
1147 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001148 Name = *NameStr; // Copy string
1149 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001150 }
1151
1152 // See if this global value was forward referenced. If so, recycle the
1153 // object.
1154 ValID ID;
1155 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001156 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001157 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001158 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001159 }
1160
1161 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1162 // Move the global to the end of the list, from whereever it was
1163 // previously inserted.
1164 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1165 CurModule.CurrentModule->getGlobalList().remove(GV);
1166 CurModule.CurrentModule->getGlobalList().push_back(GV);
1167 GV->setInitializer(Initializer);
1168 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001169 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001170 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001171 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001172 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001173 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001174 }
1175
Reid Spenceref9b9a72007-02-05 20:47:22 +00001176 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001177 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001178 // if the global we're parsing has an initializer (is a definition) and
1179 // has external linkage.
1180 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1181 // If there is already a global with external linkage with this name
1182 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1183 // If we allow this GVar to get created, it will be renamed in the
1184 // symbol table because it conflicts with an existing GVar. We can't
1185 // allow redefinition of GVars whose linking indicates that their name
1186 // must stay the same. Issue the error.
1187 GenerateError("Redefinition of global variable named '" + Name +
1188 "' of type '" + Ty->getDescription() + "'");
1189 return 0;
1190 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001191 }
1192
1193 // Otherwise there is no existing GV to use, create one now.
1194 GlobalVariable *GV =
1195 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001196 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001197 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001198 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001199 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001200}
1201
1202// setTypeName - Set the specified type to the name given. The name may be
1203// null potentially, in which case this is a noop. The string passed in is
1204// assumed to be a malloc'd string buffer, and is freed by this function.
1205//
1206// This function returns true if the type has already been defined, but is
1207// allowed to be redefined in the specified context. If the name is a new name
1208// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001209static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001210 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001211 if (NameStr == 0) return false;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001212
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001213 std::string Name(*NameStr); // Copy string
1214 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001215
1216 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001217 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001218 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001219 return false;
1220 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001221
1222 // Set the type name, checking for conflicts as we do so.
1223 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1224
1225 if (AlreadyExists) { // Inserting a name that is already defined???
1226 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001227 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001228
1229 // There is only one case where this is allowed: when we are refining an
1230 // opaque type. In this case, Existing will be an opaque type.
1231 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1232 // We ARE replacing an opaque type!
1233 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1234 return true;
1235 }
1236
1237 // Otherwise, this is an attempt to redefine a type. That's okay if
1238 // the redefinition is identical to the original. This will be so if
1239 // Existing and T point to the same Type object. In this one case we
1240 // allow the equivalent redefinition.
1241 if (Existing == T) return true; // Yes, it's equal.
1242
1243 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001244 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001245 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001246 }
1247
1248 return false;
1249}
1250
1251//===----------------------------------------------------------------------===//
1252// Code for handling upreferences in type names...
1253//
1254
1255// TypeContains - Returns true if Ty directly contains E in it.
1256//
1257static bool TypeContains(const Type *Ty, const Type *E) {
1258 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1259 E) != Ty->subtype_end();
1260}
1261
1262namespace {
1263 struct UpRefRecord {
1264 // NestingLevel - The number of nesting levels that need to be popped before
1265 // this type is resolved.
1266 unsigned NestingLevel;
1267
1268 // LastContainedTy - This is the type at the current binding level for the
1269 // type. Every time we reduce the nesting level, this gets updated.
1270 const Type *LastContainedTy;
1271
1272 // UpRefTy - This is the actual opaque type that the upreference is
1273 // represented with.
1274 OpaqueType *UpRefTy;
1275
1276 UpRefRecord(unsigned NL, OpaqueType *URTy)
1277 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1278 };
1279}
1280
1281// UpRefs - A list of the outstanding upreferences that need to be resolved.
1282static std::vector<UpRefRecord> UpRefs;
1283
1284/// HandleUpRefs - Every time we finish a new layer of types, this function is
1285/// called. It loops through the UpRefs vector, which is a list of the
1286/// currently active types. For each type, if the up reference is contained in
1287/// the newly completed type, we decrement the level count. When the level
1288/// count reaches zero, the upreferenced type is the type that is passed in:
1289/// thus we can complete the cycle.
1290///
1291static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001292 // If Ty isn't abstract, or if there are no up-references in it, then there is
1293 // nothing to resolve here.
1294 if (!ty->isAbstract() || UpRefs.empty()) return ty;
Eric Christopher2a5196f2008-09-24 04:55:49 +00001295
Reid Spencer68a24bd2005-08-27 18:50:39 +00001296 PATypeHolder Ty(ty);
1297 UR_OUT("Type '" << Ty->getDescription() <<
1298 "' newly formed. Resolving upreferences.\n" <<
1299 UpRefs.size() << " upreferences active!\n");
1300
1301 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1302 // to zero), we resolve them all together before we resolve them to Ty. At
1303 // the end of the loop, if there is anything to resolve to Ty, it will be in
1304 // this variable.
1305 OpaqueType *TypeToResolve = 0;
1306
1307 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1308 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1309 << UpRefs[i].second->getDescription() << ") = "
1310 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1311 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1312 // Decrement level of upreference
1313 unsigned Level = --UpRefs[i].NestingLevel;
1314 UpRefs[i].LastContainedTy = Ty;
1315 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1316 if (Level == 0) { // Upreference should be resolved!
1317 if (!TypeToResolve) {
1318 TypeToResolve = UpRefs[i].UpRefTy;
1319 } else {
1320 UR_OUT(" * Resolving upreference for "
1321 << UpRefs[i].second->getDescription() << "\n";
1322 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1323 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1324 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1325 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1326 }
1327 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1328 --i; // Do not skip the next element...
1329 }
1330 }
1331 }
1332
1333 if (TypeToResolve) {
1334 UR_OUT(" * Resolving upreference for "
1335 << UpRefs[i].second->getDescription() << "\n";
1336 std::string OldName = TypeToResolve->getDescription());
1337 TypeToResolve->refineAbstractTypeTo(Ty);
1338 }
1339
1340 return Ty;
1341}
1342
Reid Spencer68a24bd2005-08-27 18:50:39 +00001343//===----------------------------------------------------------------------===//
1344// RunVMAsmParser - Define an interface to this parser
1345//===----------------------------------------------------------------------===//
1346//
Reid Spencer14310612006-12-31 05:40:51 +00001347static Module* RunParser(Module * M);
1348
Duncan Sandsdc024672007-11-27 13:23:08 +00001349Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1350 InitLLLexer(MB);
1351 Module *M = RunParser(new Module(LLLgetFilename()));
1352 FreeLexer();
1353 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001354}
1355
1356
Dan Gohmanf4423b12008-04-19 00:24:39 +00001357
1358/* Enabling traces. */
1359#ifndef YYDEBUG
1360# define YYDEBUG 0
1361#endif
1362
1363/* Enabling verbose error messages. */
1364#ifdef YYERROR_VERBOSE
1365# undef YYERROR_VERBOSE
1366# define YYERROR_VERBOSE 1
1367#else
1368# define YYERROR_VERBOSE 0
1369#endif
1370
1371/* Enabling the token table. */
1372#ifndef YYTOKEN_TABLE
1373# define YYTOKEN_TABLE 0
1374#endif
1375
1376#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1377typedef union YYSTYPE
Dale Johannesendfe8c842008-09-26 19:32:34 +00001378#line 970 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001379{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001380 llvm::Module *ModuleVal;
1381 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001382 llvm::BasicBlock *BasicBlockVal;
1383 llvm::TerminatorInst *TermInstVal;
1384 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001385 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001386
Reid Spencera132e042006-12-03 05:46:11 +00001387 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001388 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001389 llvm::PATypeHolder *TypeVal;
1390 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001391 std::vector<llvm::Value*> *ValueList;
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001392 std::vector<unsigned> *ConstantList;
Reid Spencer14310612006-12-31 05:40:51 +00001393 llvm::ArgListType *ArgList;
1394 llvm::TypeWithAttrs TypeWithAttrs;
1395 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001396 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001397
Reid Spencer68a24bd2005-08-27 18:50:39 +00001398 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001399 std::list<std::pair<llvm::Value*,
1400 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001401 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001402 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001403
1404 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001405 llvm::GlobalValue::VisibilityTypes Visibility;
Devang Patel05988662008-09-25 21:00:45 +00001406 llvm::Attributes Attributes;
Reid Spencer38c91a92007-02-28 02:24:54 +00001407 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001408 int64_t SInt64Val;
1409 uint64_t UInt64Val;
1410 int SIntVal;
1411 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001412 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001413 bool BoolVal;
1414
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001415 std::string *StrVal; // This memory must be deleted
1416 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001417
Reid Spencera132e042006-12-03 05:46:11 +00001418 llvm::Instruction::BinaryOps BinaryOpVal;
1419 llvm::Instruction::TermOps TermOpVal;
1420 llvm::Instruction::MemoryOps MemOpVal;
1421 llvm::Instruction::CastOps CastOpVal;
1422 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001423 llvm::ICmpInst::Predicate IPredicate;
1424 llvm::FCmpInst::Predicate FPredicate;
Dan Gohmanf4423b12008-04-19 00:24:39 +00001425}
Dan Gohman180c1692008-06-23 18:43:26 +00001426/* Line 193 of yacc.c. */
Dale Johannesendfe8c842008-09-26 19:32:34 +00001427#line 1428 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001428 YYSTYPE;
1429# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1430# define YYSTYPE_IS_DECLARED 1
1431# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001432#endif
1433
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001434
Reid Spencer68a24bd2005-08-27 18:50:39 +00001435
Dan Gohmanf4423b12008-04-19 00:24:39 +00001436/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001437
1438
Dan Gohmanf4423b12008-04-19 00:24:39 +00001439/* Line 216 of yacc.c. */
Dale Johannesendfe8c842008-09-26 19:32:34 +00001440#line 1441 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001441
Dan Gohmanf4423b12008-04-19 00:24:39 +00001442#ifdef short
1443# undef short
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001444#endif
1445
Dan Gohmanf4423b12008-04-19 00:24:39 +00001446#ifdef YYTYPE_UINT8
1447typedef YYTYPE_UINT8 yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001448#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00001449typedef unsigned char yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001450#endif
1451
Dan Gohmanf4423b12008-04-19 00:24:39 +00001452#ifdef YYTYPE_INT8
1453typedef YYTYPE_INT8 yytype_int8;
1454#elif (defined __STDC__ || defined __C99__FUNC__ \
1455 || defined __cplusplus || defined _MSC_VER)
1456typedef signed char yytype_int8;
1457#else
1458typedef short int yytype_int8;
1459#endif
1460
1461#ifdef YYTYPE_UINT16
1462typedef YYTYPE_UINT16 yytype_uint16;
1463#else
1464typedef unsigned short int yytype_uint16;
1465#endif
1466
1467#ifdef YYTYPE_INT16
1468typedef YYTYPE_INT16 yytype_int16;
1469#else
1470typedef short int yytype_int16;
1471#endif
1472
1473#ifndef YYSIZE_T
1474# ifdef __SIZE_TYPE__
1475# define YYSIZE_T __SIZE_TYPE__
1476# elif defined size_t
1477# define YYSIZE_T size_t
1478# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1479 || defined __cplusplus || defined _MSC_VER)
1480# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1481# define YYSIZE_T size_t
1482# else
1483# define YYSIZE_T unsigned int
1484# endif
1485#endif
1486
1487#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1488
1489#ifndef YY_
Dan Gohman180c1692008-06-23 18:43:26 +00001490# if defined YYENABLE_NLS && YYENABLE_NLS
Dan Gohmanf4423b12008-04-19 00:24:39 +00001491# if ENABLE_NLS
1492# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1493# define YY_(msgid) dgettext ("bison-runtime", msgid)
1494# endif
1495# endif
1496# ifndef YY_
1497# define YY_(msgid) msgid
1498# endif
1499#endif
1500
1501/* Suppress unused-variable warnings by "using" E. */
1502#if ! defined lint || defined __GNUC__
1503# define YYUSE(e) ((void) (e))
1504#else
1505# define YYUSE(e) /* empty */
1506#endif
1507
1508/* Identity function, used to suppress warnings about constant conditions. */
1509#ifndef lint
1510# define YYID(n) (n)
1511#else
1512#if (defined __STDC__ || defined __C99__FUNC__ \
1513 || defined __cplusplus || defined _MSC_VER)
1514static int
1515YYID (int i)
1516#else
1517static int
1518YYID (i)
1519 int i;
1520#endif
1521{
1522 return i;
1523}
1524#endif
1525
1526#if ! defined yyoverflow || YYERROR_VERBOSE
1527
1528/* The parser invokes alloca or malloc; define the necessary symbols. */
1529
1530# ifdef YYSTACK_USE_ALLOCA
1531# if YYSTACK_USE_ALLOCA
1532# ifdef __GNUC__
1533# define YYSTACK_ALLOC __builtin_alloca
1534# elif defined __BUILTIN_VA_ARG_INCR
1535# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1536# elif defined _AIX
1537# define YYSTACK_ALLOC __alloca
1538# elif defined _MSC_VER
1539# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1540# define alloca _alloca
1541# else
1542# define YYSTACK_ALLOC alloca
1543# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1544 || defined __cplusplus || defined _MSC_VER)
1545# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1546# ifndef _STDLIB_H
1547# define _STDLIB_H 1
1548# endif
1549# endif
1550# endif
1551# endif
1552# endif
1553
1554# ifdef YYSTACK_ALLOC
1555 /* Pacify GCC's `empty if-body' warning. */
1556# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1557# ifndef YYSTACK_ALLOC_MAXIMUM
1558 /* The OS might guarantee only one guard page at the bottom of the stack,
1559 and a page size can be as small as 4096 bytes. So we cannot safely
1560 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1561 to allow for a few compiler-allocated temporary stack slots. */
1562# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1563# endif
1564# else
1565# define YYSTACK_ALLOC YYMALLOC
1566# define YYSTACK_FREE YYFREE
1567# ifndef YYSTACK_ALLOC_MAXIMUM
1568# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1569# endif
1570# if (defined __cplusplus && ! defined _STDLIB_H \
1571 && ! ((defined YYMALLOC || defined malloc) \
1572 && (defined YYFREE || defined free)))
1573# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1574# ifndef _STDLIB_H
1575# define _STDLIB_H 1
1576# endif
1577# endif
1578# ifndef YYMALLOC
1579# define YYMALLOC malloc
1580# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1581 || defined __cplusplus || defined _MSC_VER)
1582void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1583# endif
1584# endif
1585# ifndef YYFREE
1586# define YYFREE free
1587# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1588 || defined __cplusplus || defined _MSC_VER)
1589void free (void *); /* INFRINGES ON USER NAME SPACE */
1590# endif
1591# endif
1592# endif
1593#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1594
1595
1596#if (! defined yyoverflow \
1597 && (! defined __cplusplus \
1598 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1599
1600/* A type that is properly aligned for any stack member. */
1601union yyalloc
1602{
1603 yytype_int16 yyss;
1604 YYSTYPE yyvs;
1605 };
1606
1607/* The size of the maximum gap between one aligned stack and the next. */
1608# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1609
1610/* The size of an array large to enough to hold all stacks, each with
1611 N elements. */
1612# define YYSTACK_BYTES(N) \
1613 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1614 + YYSTACK_GAP_MAXIMUM)
1615
1616/* Copy COUNT objects from FROM to TO. The source and destination do
1617 not overlap. */
1618# ifndef YYCOPY
1619# if defined __GNUC__ && 1 < __GNUC__
1620# define YYCOPY(To, From, Count) \
1621 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1622# else
1623# define YYCOPY(To, From, Count) \
1624 do \
1625 { \
1626 YYSIZE_T yyi; \
1627 for (yyi = 0; yyi < (Count); yyi++) \
1628 (To)[yyi] = (From)[yyi]; \
1629 } \
1630 while (YYID (0))
1631# endif
1632# endif
1633
1634/* Relocate STACK from its old location to the new one. The
1635 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1636 elements in the stack, and YYPTR gives the new location of the
1637 stack. Advance YYPTR to a properly aligned location for the next
1638 stack. */
1639# define YYSTACK_RELOCATE(Stack) \
1640 do \
1641 { \
1642 YYSIZE_T yynewbytes; \
1643 YYCOPY (&yyptr->Stack, Stack, yysize); \
1644 Stack = &yyptr->Stack; \
1645 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1646 yyptr += yynewbytes / sizeof (*yyptr); \
1647 } \
1648 while (YYID (0))
1649
1650#endif
1651
1652/* YYFINAL -- State number of the termination state. */
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001653#define YYFINAL 44
Dan Gohmanf4423b12008-04-19 00:24:39 +00001654/* YYLAST -- Last index in YYTABLE. */
Dale Johannesendfe8c842008-09-26 19:32:34 +00001655#define YYLAST 2344
Dan Gohmanf4423b12008-04-19 00:24:39 +00001656
1657/* YYNTOKENS -- Number of terminals. */
Dale Johannesendfe8c842008-09-26 19:32:34 +00001658#define YYNTOKENS 175
Dan Gohmanf4423b12008-04-19 00:24:39 +00001659/* YYNNTS -- Number of nonterminals. */
Devang Pateld4980812008-09-02 20:52:40 +00001660#define YYNNTS 90
Dan Gohmanf4423b12008-04-19 00:24:39 +00001661/* YYNRULES -- Number of rules. */
Dale Johannesendfe8c842008-09-26 19:32:34 +00001662#define YYNRULES 353
Dan Gohmanf4423b12008-04-19 00:24:39 +00001663/* YYNRULES -- Number of states. */
Dale Johannesendfe8c842008-09-26 19:32:34 +00001664#define YYNSTATES 720
Dan Gohmanf4423b12008-04-19 00:24:39 +00001665
1666/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1667#define YYUNDEFTOK 2
Dale Johannesendfe8c842008-09-26 19:32:34 +00001668#define YYMAXUTOK 415
Dan Gohmanf4423b12008-04-19 00:24:39 +00001669
1670#define YYTRANSLATE(YYX) \
1671 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1672
1673/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1674static const yytype_uint8 yytranslate[] =
1675{
1676 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1677 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1678 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1679 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001680 161, 162, 165, 2, 164, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001681 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001682 170, 163, 171, 2, 2, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001683 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1684 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001685 2, 167, 166, 169, 2, 2, 2, 2, 2, 174,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001686 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001688 168, 2, 2, 172, 2, 173, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001689 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1690 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1691 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1692 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1693 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1694 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1695 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1696 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1697 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1698 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1699 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1700 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1701 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1702 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1703 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1704 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1705 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1706 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1707 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1708 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1709 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1710 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1711 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1712 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1713 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1714 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1715 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Dan Gohmane4977cf2008-05-23 01:55:30 +00001716 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001717 155, 156, 157, 158, 159, 160
Dan Gohmanf4423b12008-04-19 00:24:39 +00001718};
1719
1720#if YYDEBUG
1721/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1722 YYRHS. */
1723static const yytype_uint16 yyprhs[] =
1724{
1725 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1726 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1727 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1728 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1729 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1730 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1731 119, 121, 123, 125, 127, 129, 130, 135, 136, 139,
Chris Lattner15bd0952008-08-29 17:20:18 +00001732 140, 143, 145, 147, 149, 150, 153, 155, 157, 159,
1733 161, 163, 165, 167, 169, 171, 172, 174, 176, 178,
1734 179, 181, 183, 184, 186, 188, 190, 192, 193, 195,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001735 197, 198, 200, 202, 204, 206, 208, 211, 213, 215,
1736 217, 219, 221, 223, 225, 227, 229, 232, 233, 236,
1737 238, 240, 242, 244, 246, 248, 250, 251, 254, 256,
1738 260, 264, 268, 270, 271, 276, 277, 280, 281, 284,
1739 285, 289, 292, 293, 295, 296, 300, 302, 305, 307,
1740 309, 311, 313, 315, 317, 319, 321, 323, 327, 329,
1741 332, 338, 344, 350, 356, 360, 363, 369, 374, 377,
1742 379, 381, 383, 387, 389, 393, 395, 396, 398, 402,
1743 407, 411, 415, 420, 425, 429, 436, 442, 445, 448,
1744 451, 454, 457, 460, 463, 466, 469, 472, 475, 478,
1745 485, 491, 500, 507, 514, 522, 530, 538, 546, 553,
1746 562, 571, 577, 585, 589, 591, 593, 595, 597, 598,
1747 601, 608, 610, 611, 613, 616, 617, 621, 622, 626,
1748 630, 634, 638, 639, 648, 649, 659, 660, 670, 676,
1749 679, 683, 685, 689, 693, 697, 701, 703, 704, 710,
1750 714, 716, 720, 722, 723, 735, 737, 739, 744, 746,
1751 748, 751, 755, 756, 758, 760, 762, 764, 766, 768,
1752 770, 772, 774, 776, 778, 782, 786, 789, 792, 796,
1753 799, 805, 810, 812, 818, 820, 822, 824, 826, 828,
1754 830, 833, 835, 839, 842, 845, 849, 853, 856, 857,
1755 859, 862, 865, 869, 879, 889, 898, 913, 915, 917,
1756 924, 930, 933, 936, 943, 951, 956, 961, 968, 975,
1757 976, 977, 981, 984, 988, 991, 993, 999, 1005, 1012,
1758 1019, 1026, 1033, 1038, 1045, 1050, 1055, 1062, 1069, 1072,
1759 1081, 1083, 1085, 1086, 1090, 1097, 1101, 1108, 1111, 1117,
1760 1125, 1131, 1136, 1141
Dan Gohmanf4423b12008-04-19 00:24:39 +00001761};
1762
1763/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1764static const yytype_int16 yyrhs[] =
1765{
Dale Johannesendfe8c842008-09-26 19:32:34 +00001766 225, 0, -1, 75, -1, 76, -1, 77, -1, 78,
1767 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
1768 -1, 87, -1, 88, -1, 89, -1, 84, -1, 85,
1769 -1, 86, -1, 120, -1, 121, -1, 122, -1, 123,
1770 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
1771 -1, 129, -1, 130, -1, 131, -1, 94, -1, 95,
1772 -1, 96, -1, 97, -1, 98, -1, 99, -1, 100,
1773 -1, 101, -1, 102, -1, 103, -1, 104, -1, 105,
1774 -1, 106, -1, 107, -1, 108, -1, 109, -1, 110,
1775 -1, 111, -1, 112, -1, 113, -1, 100, -1, 101,
1776 -1, 102, -1, 103, -1, 26, -1, 27, -1, 11,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001777 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001778 -1, 19, -1, 22, -1, 24, -1, 183, -1, -1,
1779 55, 161, 4, 162, -1, -1, 183, 163, -1, -1,
1780 7, 163, -1, 20, -1, 23, -1, 190, -1, -1,
1781 188, 163, -1, 42, -1, 44, -1, 43, -1, 45,
Chris Lattner15bd0952008-08-29 17:20:18 +00001782 -1, 47, -1, 49, -1, 46, -1, 48, -1, 51,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001783 -1, -1, 158, -1, 159, -1, 160, -1, -1, 46,
Chris Lattner15bd0952008-08-29 17:20:18 +00001784 -1, 48, -1, -1, 42, -1, 43, -1, 44, -1,
1785 47, -1, -1, 44, -1, 42, -1, -1, 63, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00001786 64, -1, 65, -1, 66, -1, 67, -1, 62, 4,
1787 -1, 142, -1, 121, -1, 141, -1, 122, -1, 144,
1788 -1, 145, -1, 147, -1, 148, -1, 149, -1, 54,
1789 4, -1, -1, 199, 198, -1, 143, -1, 146, -1,
1790 144, -1, 142, -1, 141, -1, 150, -1, 151, -1,
1791 -1, 201, 200, -1, 203, -1, 202, 164, 203, -1,
1792 154, 163, 156, -1, 154, 163, 155, -1, 157, -1,
1793 -1, 153, 161, 202, 162, -1, -1, 152, 22, -1,
1794 -1, 54, 4, -1, -1, 164, 54, 4, -1, 34,
1795 22, -1, -1, 208, -1, -1, 164, 211, 210, -1,
1796 208, -1, 54, 4, -1, 11, -1, 12, -1, 13,
1797 -1, 16, -1, 15, -1, 14, -1, 17, -1, 50,
1798 -1, 212, -1, 213, 185, 165, -1, 247, -1, 166,
1799 4, -1, 213, 161, 217, 162, 201, -1, 10, 161,
1800 217, 162, 201, -1, 167, 4, 168, 213, 169, -1,
1801 170, 4, 168, 213, 171, -1, 172, 218, 173, -1,
1802 172, 173, -1, 170, 172, 218, 173, 171, -1, 170,
1803 172, 173, 171, -1, 213, 199, -1, 213, -1, 10,
1804 -1, 214, -1, 216, 164, 214, -1, 216, -1, 216,
1805 164, 39, -1, 39, -1, -1, 213, -1, 218, 164,
1806 213, -1, 213, 167, 221, 169, -1, 213, 167, 169,
1807 -1, 213, 174, 22, -1, 213, 170, 221, 171, -1,
1808 213, 172, 221, 173, -1, 213, 172, 173, -1, 213,
1809 170, 172, 221, 173, 171, -1, 213, 170, 172, 173,
1810 171, -1, 213, 40, -1, 213, 41, -1, 213, 247,
1811 -1, 213, 220, -1, 213, 25, -1, 181, 3, -1,
1812 181, 5, -1, 181, 4, -1, 181, 6, -1, 11,
1813 26, -1, 11, 27, -1, 182, 9, -1, 178, 161,
1814 219, 38, 213, 162, -1, 119, 161, 219, 259, 162,
1815 -1, 133, 161, 219, 164, 219, 164, 219, 162, -1,
1816 176, 161, 219, 164, 219, 162, -1, 177, 161, 219,
1817 164, 219, 162, -1, 90, 179, 161, 219, 164, 219,
1818 162, -1, 91, 180, 161, 219, 164, 219, 162, -1,
1819 92, 179, 161, 219, 164, 219, 162, -1, 93, 180,
1820 161, 219, 164, 219, 162, -1, 135, 161, 219, 164,
1821 219, 162, -1, 136, 161, 219, 164, 219, 164, 219,
1822 162, -1, 137, 161, 219, 164, 219, 164, 219, 162,
1823 -1, 139, 161, 219, 260, 162, -1, 140, 161, 219,
1824 164, 219, 260, 162, -1, 221, 164, 219, -1, 219,
1825 -1, 32, -1, 33, -1, 37, -1, -1, 215, 247,
1826 -1, 125, 161, 224, 38, 213, 162, -1, 226, -1,
1827 -1, 227, -1, 226, 227, -1, -1, 31, 228, 243,
1828 -1, -1, 30, 229, 244, -1, 60, 59, 233, -1,
1829 186, 18, 213, -1, 186, 18, 10, -1, -1, 189,
1830 193, 223, 222, 219, 185, 230, 210, -1, -1, 189,
1831 191, 193, 223, 222, 219, 185, 231, 210, -1, -1,
1832 189, 192, 193, 223, 222, 213, 185, 232, 210, -1,
1833 189, 193, 35, 196, 224, -1, 52, 234, -1, 56,
1834 163, 235, -1, 22, -1, 53, 163, 22, -1, 68,
1835 163, 22, -1, 167, 236, 169, -1, 236, 164, 22,
1836 -1, 22, -1, -1, 237, 164, 213, 199, 184, -1,
1837 213, 199, 184, -1, 237, -1, 237, 164, 39, -1,
1838 39, -1, -1, 197, 215, 188, 161, 238, 162, 201,
1839 209, 206, 205, 204, -1, 28, -1, 172, -1, 195,
1840 193, 239, 240, -1, 29, -1, 173, -1, 251, 242,
1841 -1, 194, 193, 239, -1, -1, 61, -1, 3, -1,
1842 4, -1, 5, -1, 6, -1, 9, -1, 26, -1,
1843 27, -1, 40, -1, 41, -1, 25, -1, 170, 221,
1844 171, -1, 167, 221, 169, -1, 167, 169, -1, 174,
1845 22, -1, 172, 221, 173, -1, 172, 173, -1, 170,
1846 172, 221, 173, 171, -1, 170, 172, 173, 171, -1,
1847 220, -1, 59, 245, 22, 164, 22, -1, 7, -1,
1848 8, -1, 183, -1, 188, -1, 247, -1, 246, -1,
1849 213, 248, -1, 249, -1, 250, 164, 249, -1, 251,
1850 252, -1, 241, 252, -1, 253, 186, 254, -1, 253,
1851 187, 254, -1, 253, 256, -1, -1, 21, -1, 69,
1852 250, -1, 69, 10, -1, 70, 17, 248, -1, 70,
1853 11, 248, 164, 17, 248, 164, 17, 248, -1, 71,
1854 181, 248, 164, 17, 248, 167, 255, 169, -1, 71,
1855 181, 248, 164, 17, 248, 167, 169, -1, 72, 197,
1856 215, 248, 161, 258, 162, 201, 38, 17, 248, 73,
1857 17, 248, -1, 73, -1, 74, -1, 255, 181, 246,
1858 164, 17, 248, -1, 181, 246, 164, 17, 248, -1,
1859 186, 262, -1, 187, 262, -1, 213, 167, 248, 164,
1860 248, 169, -1, 257, 164, 167, 248, 164, 248, 169,
1861 -1, 213, 199, 248, 199, -1, 17, 199, 248, 199,
1862 -1, 258, 164, 213, 199, 248, 199, -1, 258, 164,
1863 17, 199, 248, 199, -1, -1, -1, 259, 164, 249,
1864 -1, 164, 4, -1, 260, 164, 4, -1, 58, 57,
1865 -1, 57, -1, 176, 213, 248, 164, 248, -1, 177,
1866 213, 248, 164, 248, -1, 90, 179, 213, 248, 164,
1867 248, -1, 91, 180, 213, 248, 164, 248, -1, 92,
1868 179, 213, 248, 164, 248, -1, 93, 180, 213, 248,
1869 164, 248, -1, 178, 249, 38, 213, -1, 133, 249,
1870 164, 249, 164, 249, -1, 134, 249, 164, 213, -1,
1871 135, 249, 164, 249, -1, 136, 249, 164, 249, 164,
1872 249, -1, 137, 249, 164, 249, 164, 249, -1, 132,
1873 257, -1, 261, 197, 215, 248, 161, 258, 162, 201,
1874 -1, 264, -1, 36, -1, -1, 114, 213, 207, -1,
1875 114, 213, 164, 11, 248, 207, -1, 115, 213, 207,
1876 -1, 115, 213, 164, 11, 248, 207, -1, 116, 249,
1877 -1, 263, 117, 213, 248, 207, -1, 263, 118, 249,
1878 164, 213, 248, 207, -1, 138, 213, 248, 164, 4,
1879 -1, 119, 213, 248, 259, -1, 139, 213, 248, 260,
1880 -1, 140, 213, 248, 164, 213, 248, 260, -1
Dan Gohmanf4423b12008-04-19 00:24:39 +00001881};
1882
1883/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1884static const yytype_uint16 yyrline[] =
1885{
Dale Johannesendfe8c842008-09-26 19:32:34 +00001886 0, 1140, 1140, 1140, 1140, 1140, 1140, 1140, 1140, 1140,
1887 1140, 1141, 1141, 1141, 1141, 1141, 1141, 1142, 1142, 1142,
1888 1142, 1142, 1142, 1143, 1143, 1143, 1143, 1143, 1143, 1146,
1889 1146, 1147, 1147, 1148, 1148, 1149, 1149, 1150, 1150, 1154,
1890 1154, 1155, 1155, 1156, 1156, 1157, 1157, 1158, 1158, 1159,
1891 1159, 1160, 1160, 1161, 1162, 1167, 1168, 1168, 1168, 1168,
1892 1168, 1170, 1170, 1170, 1171, 1171, 1173, 1174, 1178, 1182,
1893 1187, 1193, 1193, 1195, 1196, 1201, 1207, 1208, 1209, 1210,
1894 1211, 1212, 1216, 1217, 1218, 1222, 1223, 1224, 1225, 1229,
1895 1230, 1231, 1235, 1236, 1237, 1238, 1239, 1243, 1244, 1245,
1896 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1261, 1262, 1263,
1897 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1274, 1275, 1280,
1898 1281, 1282, 1283, 1284, 1285, 1286, 1289, 1290, 1295, 1296,
1899 1309, 1310, 1311, 1314, 1315, 1320, 1321, 1328, 1329, 1335,
1900 1336, 1345, 1353, 1354, 1359, 1360, 1361, 1366, 1379, 1379,
1901 1379, 1379, 1379, 1379, 1379, 1382, 1386, 1390, 1397, 1402,
1902 1410, 1439, 1464, 1469, 1479, 1489, 1493, 1503, 1510, 1519,
1903 1526, 1531, 1536, 1543, 1544, 1551, 1558, 1566, 1572, 1584,
1904 1612, 1628, 1655, 1683, 1709, 1729, 1755, 1775, 1787, 1794,
1905 1860, 1870, 1880, 1886, 1896, 1902, 1912, 1918, 1924, 1937,
1906 1949, 1970, 1978, 1984, 1995, 2000, 2005, 2010, 2015, 2021,
1907 2027, 2033, 2041, 2052, 2056, 2064, 2064, 2067, 2067, 2070,
1908 2082, 2103, 2108, 2116, 2117, 2121, 2121, 2125, 2125, 2128,
1909 2131, 2155, 2167, 2166, 2178, 2177, 2187, 2186, 2197, 2237,
1910 2240, 2246, 2256, 2260, 2265, 2267, 2272, 2277, 2286, 2296,
1911 2307, 2311, 2320, 2329, 2334, 2466, 2466, 2468, 2477, 2477,
1912 2479, 2484, 2496, 2500, 2505, 2509, 2513, 2518, 2523, 2527,
1913 2531, 2535, 2539, 2543, 2547, 2569, 2591, 2597, 2610, 2622,
1914 2627, 2639, 2645, 2649, 2659, 2663, 2667, 2672, 2679, 2679,
1915 2685, 2694, 2699, 2704, 2708, 2717, 2726, 2739, 2748, 2752,
1916 2760, 2780, 2784, 2789, 2800, 2819, 2828, 2914, 2918, 2925,
1917 2936, 2949, 2958, 2971, 2982, 2992, 3003, 3011, 3021, 3028,
1918 3031, 3032, 3040, 3046, 3055, 3059, 3064, 3080, 3097, 3109,
1919 3121, 3135, 3149, 3161, 3182, 3189, 3195, 3201, 3207, 3222,
1920 3312, 3317, 3321, 3328, 3335, 3345, 3352, 3362, 3370, 3384,
1921 3401, 3415, 3430, 3445
Dan Gohmanf4423b12008-04-19 00:24:39 +00001922};
1923#endif
1924
1925#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1926/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1927 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1928static const char *const yytname[] =
1929{
1930 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1931 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1932 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1933 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1934 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1935 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1936 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1937 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001938 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "COMMON", "OPAQUE",
Dan Gohmanf4423b12008-04-19 00:24:39 +00001939 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1940 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1941 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Dale Johannesendfe8c842008-09-26 19:32:34 +00001942 "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
1943 "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
1944 "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "VICMP",
1945 "VFCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1946 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1947 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1948 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1949 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1950 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1951 "GETRESULT", "EXTRACTVALUE", "INSERTVALUE", "SIGNEXT", "ZEROEXT",
1952 "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST",
1953 "READNONE", "READONLY", "GC", "FNNOTE", "INLINE", "ALWAYS", "NEVER",
1954 "OPTIMIZEFORSIZE", "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='",
1955 "','", "'*'", "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'",
1956 "'c'", "$accept", "ArithmeticOps", "LogicalOps", "CastOps",
Devang Pateld4980812008-09-02 20:52:40 +00001957 "IPredicates", "FPredicates", "IntType", "FPType", "LocalName",
1958 "OptLocalName", "OptAddrSpace", "OptLocalAssign", "LocalNumber",
1959 "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1960 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
Devang Patel05988662008-09-25 21:00:45 +00001961 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "Attribute",
1962 "OptAttributes", "FuncAttr", "OptFuncAttrs", "FuncNoteList", "FuncNote",
Devang Pateld4980812008-09-02 20:52:40 +00001963 "OptFuncNotes", "OptGC", "OptAlign", "OptCAlign", "SectionString",
Chris Lattner15bd0952008-08-29 17:20:18 +00001964 "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "PrimType",
1965 "Types", "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI",
1966 "TypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1967 "ThreadLocal", "AliaseeRef", "Module", "DefinitionList", "Definition",
1968 "@1", "@2", "@3", "@4", "@5", "AsmBlock", "TargetDefinition",
1969 "LibrariesDefinition", "LibList", "ArgListH", "ArgList",
1970 "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", "Function",
1971 "FunctionProto", "OptSideEffect", "ConstValueRef", "SymbolicValueRef",
1972 "ValueRef", "ResolvedVal", "ReturnedVal", "BasicBlockList", "BasicBlock",
1973 "InstructionList", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
1974 "ParamList", "IndexList", "ConstantIndexList", "OptTailCall", "InstVal",
1975 "OptVolatile", "MemoryInst", 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00001976};
1977#endif
1978
1979# ifdef YYPRINT
1980/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1981 token YYLEX-NUM. */
1982static const yytype_uint16 yytoknum[] =
1983{
1984 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1985 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1986 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1987 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1988 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1989 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1990 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1991 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1992 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1993 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1994 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1995 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1996 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1997 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1998 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Devang Pateld4980812008-09-02 20:52:40 +00001999 405, 406, 407, 408, 409, 410, 411, 412, 413, 414,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002000 415, 40, 41, 61, 44, 42, 92, 91, 120, 93,
2001 60, 62, 123, 125, 99
Dan Gohmanf4423b12008-04-19 00:24:39 +00002002};
2003# endif
2004
2005/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002006static const yytype_uint16 yyr1[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002007{
Dale Johannesendfe8c842008-09-26 19:32:34 +00002008 0, 175, 176, 176, 176, 176, 176, 176, 176, 176,
2009 176, 177, 177, 177, 177, 177, 177, 178, 178, 178,
2010 178, 178, 178, 178, 178, 178, 178, 178, 178, 179,
Devang Pateld4980812008-09-02 20:52:40 +00002011 179, 179, 179, 179, 179, 179, 179, 179, 179, 180,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002012 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
2013 180, 180, 180, 180, 180, 181, 182, 182, 182, 182,
2014 182, 183, 183, 183, 184, 184, 185, 185, 186, 186,
2015 187, 188, 188, 189, 189, 190, 191, 191, 191, 191,
2016 191, 191, 192, 192, 192, 193, 193, 193, 193, 194,
2017 194, 194, 195, 195, 195, 195, 195, 196, 196, 196,
2018 197, 197, 197, 197, 197, 197, 197, 198, 198, 198,
2019 198, 198, 198, 198, 198, 198, 198, 199, 199, 200,
2020 200, 200, 200, 200, 200, 200, 201, 201, 202, 202,
2021 203, 203, 203, 204, 204, 205, 205, 206, 206, 207,
2022 207, 208, 209, 209, 210, 210, 211, 211, 212, 212,
2023 212, 212, 212, 212, 212, 213, 213, 213, 213, 213,
2024 213, 213, 213, 213, 213, 213, 213, 213, 214, 215,
2025 215, 216, 216, 217, 217, 217, 217, 218, 218, 219,
2026 219, 219, 219, 219, 219, 219, 219, 219, 219, 219,
2027 219, 219, 219, 219, 219, 219, 219, 219, 219, 220,
Devang Pateld4980812008-09-02 20:52:40 +00002028 220, 220, 220, 220, 220, 220, 220, 220, 220, 220,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002029 220, 220, 220, 221, 221, 222, 222, 223, 223, 224,
2030 224, 225, 225, 226, 226, 228, 227, 229, 227, 227,
2031 227, 227, 230, 227, 231, 227, 232, 227, 227, 227,
2032 227, 233, 234, 234, 235, 236, 236, 236, 237, 237,
2033 238, 238, 238, 238, 239, 240, 240, 241, 242, 242,
2034 243, 244, 245, 245, 246, 246, 246, 246, 246, 246,
2035 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
2036 246, 246, 246, 246, 247, 247, 247, 247, 248, 248,
2037 249, 250, 250, 251, 251, 252, 252, 253, 253, 253,
2038 254, 254, 254, 254, 254, 254, 254, 254, 254, 255,
2039 255, 256, 256, 257, 257, 258, 258, 258, 258, 258,
2040 259, 259, 260, 260, 261, 261, 262, 262, 262, 262,
2041 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
2042 262, 263, 263, 264, 264, 264, 264, 264, 264, 264,
2043 264, 264, 264, 264
Dan Gohmanf4423b12008-04-19 00:24:39 +00002044};
2045
2046/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2047static const yytype_uint8 yyr2[] =
2048{
2049 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2050 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2051 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2052 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2053 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2054 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2055 1, 1, 1, 1, 1, 0, 4, 0, 2, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002056 2, 1, 1, 1, 0, 2, 1, 1, 1, 1,
2057 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,
2058 1, 1, 0, 1, 1, 1, 1, 0, 1, 1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002059 0, 1, 1, 1, 1, 1, 2, 1, 1, 1,
2060 1, 1, 1, 1, 1, 1, 2, 0, 2, 1,
2061 1, 1, 1, 1, 1, 1, 0, 2, 1, 3,
2062 3, 3, 1, 0, 4, 0, 2, 0, 2, 0,
2063 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
2064 1, 1, 1, 1, 1, 1, 1, 3, 1, 2,
2065 5, 5, 5, 5, 3, 2, 5, 4, 2, 1,
2066 1, 1, 3, 1, 3, 1, 0, 1, 3, 4,
2067 3, 3, 4, 4, 3, 6, 5, 2, 2, 2,
2068 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
2069 5, 8, 6, 6, 7, 7, 7, 7, 6, 8,
2070 8, 5, 7, 3, 1, 1, 1, 1, 0, 2,
2071 6, 1, 0, 1, 2, 0, 3, 0, 3, 3,
2072 3, 3, 0, 8, 0, 9, 0, 9, 5, 2,
2073 3, 1, 3, 3, 3, 3, 1, 0, 5, 3,
2074 1, 3, 1, 0, 11, 1, 1, 4, 1, 1,
2075 2, 3, 0, 1, 1, 1, 1, 1, 1, 1,
2076 1, 1, 1, 1, 3, 3, 2, 2, 3, 2,
2077 5, 4, 1, 5, 1, 1, 1, 1, 1, 1,
2078 2, 1, 3, 2, 2, 3, 3, 2, 0, 1,
2079 2, 2, 3, 9, 9, 8, 14, 1, 1, 6,
2080 5, 2, 2, 6, 7, 4, 4, 6, 6, 0,
2081 0, 3, 2, 3, 2, 1, 5, 5, 6, 6,
2082 6, 6, 4, 6, 4, 4, 6, 6, 2, 8,
2083 1, 1, 0, 3, 6, 3, 6, 2, 5, 7,
2084 5, 4, 4, 7
Dan Gohmanf4423b12008-04-19 00:24:39 +00002085};
2086
2087/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2088 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2089 means the default is an error. */
2090static const yytype_uint16 yydefact[] =
2091{
Dale Johannesendfe8c842008-09-26 19:32:34 +00002092 74, 61, 71, 62, 72, 63, 227, 225, 0, 0,
2093 0, 0, 0, 0, 85, 73, 0, 74, 223, 89,
2094 92, 0, 0, 239, 0, 0, 68, 0, 75, 76,
Chris Lattner15bd0952008-08-29 17:20:18 +00002095 78, 77, 79, 82, 80, 83, 81, 84, 86, 87,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002096 88, 85, 85, 218, 1, 224, 90, 91, 85, 228,
2097 93, 94, 95, 96, 85, 298, 226, 298, 0, 0,
2098 247, 240, 241, 229, 284, 285, 231, 148, 149, 150,
2099 153, 152, 151, 154, 155, 0, 0, 0, 0, 286,
2100 287, 156, 230, 158, 218, 218, 97, 217, 0, 100,
2101 100, 299, 294, 69, 258, 259, 260, 293, 242, 243,
2102 246, 0, 176, 159, 0, 0, 0, 0, 165, 177,
2103 0, 0, 176, 0, 0, 0, 99, 98, 0, 215,
2104 216, 0, 0, 101, 102, 103, 104, 105, 0, 261,
2105 0, 0, 342, 342, 297, 0, 244, 175, 117, 171,
2106 173, 0, 0, 0, 0, 0, 0, 164, 0, 0,
2107 157, 0, 0, 170, 0, 169, 0, 238, 148, 149,
2108 150, 153, 152, 151, 0, 0, 67, 67, 106, 0,
2109 255, 256, 257, 70, 341, 325, 0, 0, 0, 0,
2110 100, 307, 308, 2, 3, 4, 5, 6, 7, 8,
2111 9, 10, 14, 15, 16, 11, 12, 13, 0, 0,
2112 0, 0, 0, 0, 0, 0, 17, 18, 19, 20,
2113 21, 22, 23, 24, 25, 26, 27, 28, 0, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002115 295, 100, 311, 0, 340, 296, 312, 245, 168, 0,
2116 126, 67, 67, 167, 0, 178, 0, 126, 67, 67,
2117 0, 219, 196, 197, 192, 194, 193, 195, 198, 191,
2118 187, 188, 0, 0, 0, 0, 0, 0, 0, 0,
Dan Gohmane4977cf2008-05-23 01:55:30 +00002119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002120 190, 189, 232, 0, 324, 301, 67, 291, 300, 0,
2121 0, 55, 0, 0, 29, 30, 31, 32, 33, 34,
2122 35, 36, 37, 38, 0, 53, 54, 49, 50, 51,
2123 52, 39, 40, 41, 42, 43, 44, 45, 46, 47,
2124 48, 0, 0, 0, 139, 139, 347, 67, 67, 338,
2125 0, 0, 0, 0, 0, 67, 67, 67, 67, 67,
2126 0, 0, 0, 0, 0, 108, 110, 109, 107, 111,
2127 112, 113, 114, 115, 118, 174, 172, 161, 162, 163,
2128 166, 66, 160, 234, 236, 0, 0, 0, 0, 0,
2129 0, 0, 0, 0, 0, 0, 0, 180, 214, 0,
2130 0, 0, 184, 0, 181, 0, 0, 0, 144, 253,
2131 264, 265, 266, 267, 268, 273, 269, 270, 271, 272,
2132 262, 0, 0, 0, 0, 282, 289, 288, 290, 0,
2133 0, 302, 0, 0, 67, 67, 67, 67, 0, 343,
2134 0, 345, 320, 0, 0, 0, 0, 0, 0, 0,
2135 0, 0, 0, 0, 0, 0, 0, 67, 0, 116,
2136 123, 122, 119, 121, 120, 124, 125, 127, 144, 144,
2137 0, 0, 0, 0, 0, 320, 0, 0, 0, 0,
2138 0, 0, 0, 179, 165, 177, 0, 182, 183, 0,
2139 0, 0, 0, 233, 252, 117, 250, 0, 263, 0,
2140 276, 0, 0, 0, 279, 0, 277, 292, 0, 0,
2141 0, 0, 0, 0, 0, 0, 0, 0, 351, 0,
2142 0, 0, 334, 335, 0, 0, 0, 0, 352, 0,
2143 0, 0, 332, 0, 139, 0, 235, 237, 67, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002145 213, 186, 0, 0, 0, 0, 0, 0, 146, 144,
2146 65, 0, 126, 0, 275, 165, 0, 274, 278, 0,
2147 0, 319, 0, 0, 0, 0, 139, 140, 139, 0,
2148 0, 0, 0, 0, 0, 350, 322, 0, 67, 326,
2149 327, 319, 0, 348, 67, 220, 0, 0, 0, 0,
2150 200, 0, 0, 0, 0, 211, 0, 185, 0, 0,
2151 67, 141, 147, 145, 64, 249, 251, 117, 142, 0,
2152 281, 0, 0, 0, 117, 117, 0, 328, 329, 330,
2153 331, 344, 346, 321, 0, 0, 333, 336, 337, 323,
2154 0, 0, 139, 0, 0, 0, 0, 0, 208, 0,
2155 0, 0, 202, 203, 199, 65, 143, 137, 283, 280,
2156 0, 0, 0, 0, 126, 0, 313, 0, 353, 126,
2157 349, 204, 205, 206, 207, 0, 0, 0, 212, 248,
2158 0, 135, 0, 305, 0, 0, 108, 110, 117, 117,
2159 0, 117, 117, 314, 339, 201, 209, 210, 138, 0,
2160 133, 303, 0, 304, 0, 316, 315, 0, 0, 0,
2161 136, 0, 254, 0, 0, 0, 117, 117, 0, 0,
2162 0, 0, 318, 317, 0, 132, 0, 128, 310, 0,
2163 0, 0, 134, 0, 309, 0, 131, 130, 129, 306
Dan Gohmanf4423b12008-04-19 00:24:39 +00002164};
2165
2166/* YYDEFGOTO[NTERM-NUM]. */
2167static const yytype_int16 yydefgoto[] =
2168{
Dale Johannesendfe8c842008-09-26 19:32:34 +00002169 -1, 277, 278, 279, 304, 321, 164, 165, 79, 595,
2170 113, 12, 133, 80, 14, 15, 41, 42, 43, 48,
2171 54, 118, 128, 354, 238, 447, 357, 706, 707, 692,
2172 680, 661, 419, 538, 637, 473, 539, 81, 166, 139,
2173 156, 140, 141, 110, 378, 405, 379, 121, 88, 157,
2174 16, 17, 18, 20, 19, 388, 448, 449, 63, 23,
2175 61, 101, 476, 477, 129, 172, 55, 96, 56, 49,
2176 479, 406, 83, 408, 287, 288, 57, 92, 93, 230,
2177 665, 134, 329, 606, 498, 508, 231, 232, 233, 234
Dan Gohmanf4423b12008-04-19 00:24:39 +00002178};
2179
2180/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2181 STATE-NUM. */
Dale Johannesendfe8c842008-09-26 19:32:34 +00002182#define YYPACT_NINF -628
Dan Gohmanf4423b12008-04-19 00:24:39 +00002183static const yytype_int16 yypact[] =
2184{
Dale Johannesendfe8c842008-09-26 19:32:34 +00002185 655, -628, -628, -628, -628, -628, -628, -628, 5, -121,
2186 42, -97, 97, 28, 2, -628, 124, 982, -628, 94,
2187 237, 69, 82, -628, 68, 231, -628, 1809, -628, -628,
2188 -628, -628, -628, -628, -628, -628, -628, -628, -628, -628,
2189 -628, 110, 110, 188, -628, -628, -628, -628, 110, -628,
2190 -628, -628, -628, -628, 110, 240, -628, -10, 243, 278,
2191 283, -628, -628, -628, -628, -628, 152, -628, -628, -628,
2192 -628, -628, -628, -628, -628, 318, 327, 3, 536, -628,
2193 -628, -628, 23, -628, 288, 288, 185, -628, 182, 210,
2194 210, -628, -628, 72, -628, -628, -628, -628, -628, -628,
2195 -628, -46, 1554, -628, 169, 189, 730, 152, -628, 23,
2196 -130, 192, 1554, 195, 182, 182, -628, -628, 1598, -628,
2197 -628, 1850, 366, -628, -628, -628, -628, -628, 1905, -628,
2198 -14, 211, 2204, 2204, -628, 356, -628, -628, 23, -628,
2199 222, 232, 1934, 1934, 225, -109, 1934, -628, 393, 242,
2200 -628, 1850, 1934, 152, 245, 23, 321, -628, 236, 389,
2201 398, 399, 402, 403, 305, 404, 1378, 360, -628, 134,
2202 -628, -628, -628, -628, -628, -628, 361, 1975, 92, 409,
2203 210, -628, -628, -628, -628, -628, -628, -628, -628, -628,
2204 -628, -628, -628, -628, -628, -628, -628, -628, 400, 464,
2205 400, 464, 1934, 1934, 1934, 1934, -628, -628, -628, -628,
2206 -628, -628, -628, -628, -628, -628, -628, -628, 1934, 1934,
2207 1934, 1934, 1934, 1934, 1934, 1934, 1934, 1934, 1934, 1934,
2208 -628, 210, -628, 131, -628, -628, -628, -628, 217, 1639,
2209 -628, -40, -16, -628, 252, 23, 263, -628, 360, -34,
2210 1598, -628, -628, -628, -628, -628, -628, -628, -628, -628,
2211 -628, -628, 400, 464, 400, 464, 265, 266, 270, 272,
2212 273, 282, 284, 1680, 2016, 848, 422, 285, 286, 292,
2213 -628, -628, -628, 293, -628, 152, 798, -628, 291, 970,
2214 970, -628, 970, 1905, -628, -628, -628, -628, -628, -628,
2215 -628, -628, -628, -628, 1934, -628, -628, -628, -628, -628,
2216 -628, -628, -628, -628, -628, -628, -628, -628, -628, -628,
2217 -628, 1934, 1934, 1934, 56, 86, -628, 798, -39, 294,
2218 295, 296, 297, 298, 299, 798, 798, 798, 798, 798,
2219 411, 1905, 1934, 1934, 453, -628, -628, -628, -628, -628,
2220 -628, -628, -628, -628, -628, -628, -628, 148, -628, -628,
2221 -628, -628, 148, -628, 195, 427, 306, 309, 314, 315,
2222 1850, 1850, 1850, 1850, 1850, 1850, 1850, -628, -628, -5,
2223 1424, -90, -628, -108, -628, 1850, 1850, 1850, 302, 1721,
2224 -628, -628, -628, -628, -628, -628, -628, -628, -628, -628,
2225 416, 1739, 2034, 1469, 456, -628, -628, -628, -628, 1934,
2226 316, -628, 317, 970, 798, 798, 798, 798, 29, -628,
2227 43, -628, -628, 970, 319, 1934, 1934, 1934, 1934, 1934,
2228 328, 342, 349, 350, 357, 1934, 970, 798, 358, -628,
2229 -628, -628, -628, -628, -628, -628, -628, -628, 302, 302,
2230 1934, 1850, 1850, 1850, 1850, -628, 359, 362, 364, 365,
2231 342, 367, 1850, -628, 311, 1243, -75, -628, -628, 368,
2232 371, 482, 7, -628, -628, 23, 375, 379, -628, 502,
2233 -628, 62, 1513, -57, -628, -69, -628, -628, 513, 525,
2234 396, 390, 414, 415, 418, 970, 559, 970, 419, 420,
2235 970, 421, 23, -628, 423, 424, 576, 589, 431, 1934,
2236 970, 970, 23, 435, 433, 1934, -628, -628, 4, 436,
2237 437, 438, 439, 142, 1850, 1850, 1850, 1850, 150, 1850,
2238 -628, -628, 434, 1850, 1850, 1934, 582, 602, -628, 302,
2239 363, 1768, -628, 445, -628, 440, -65, -628, -628, 970,
2240 970, 2075, 970, 970, 970, 970, 433, -628, 433, 1934,
2241 970, 446, 1934, 1934, 1934, -628, -628, 608, 798, -628,
2242 -628, 2075, 561, -628, 798, -628, 1850, 1850, 1850, 1850,
2243 -628, 449, 454, 457, 458, -628, 342, -628, 455, 461,
2244 12, -628, -628, -628, -628, -628, -628, 23, -7, 598,
2245 -628, 459, 460, 462, 45, 23, 156, -628, -628, -628,
2246 -628, -628, -628, -628, 463, 970, -628, -628, -628, -628,
2247 342, 157, 433, 465, 469, 471, 474, 1850, -628, 1850,
2248 1850, 205, -628, -628, -628, 363, -628, 571, -628, -628,
2249 609, -2, 642, 642, -628, 2100, -628, 468, 431, -628,
2250 -628, -628, -628, -628, -628, 476, 477, 478, -628, -628,
2251 648, 501, 970, -628, 1108, -1, 493, 495, -628, -628,
2252 39, 45, 23, -628, 148, -628, -628, -628, -628, 635,
2253 505, -628, 496, -628, 1108, 217, 217, 646, 642, 642,
2254 -628, 498, -628, 653, 507, 970, -628, -628, 50, 970,
2255 659, 599, 217, 217, 517, -628, 215, -628, -628, 970,
2256 664, 191, -628, 50, -628, 970, -628, -628, -628, -628
Dan Gohmanf4423b12008-04-19 00:24:39 +00002257};
2258
2259/* YYPGOTO[NTERM-NUM]. */
2260static const yytype_int16 yypgoto[] =
2261{
Dale Johannesendfe8c842008-09-26 19:32:34 +00002262 -628, 248, 256, 258, -180, -175, -177, -628, 0, 49,
2263 -143, 594, -628, 18, -628, -628, -628, -628, 71, -628,
2264 -628, -628, -144, -628, -345, -628, -239, -628, -25, -628,
2265 -628, -628, -292, 91, -628, -386, -628, -628, -26, 451,
2266 -122, -628, 579, 587, 65, -163, -270, 235, 308, 447,
2267 -628, -628, 681, -628, -628, -628, -628, -628, -628, -628,
2268 -628, -628, -628, -628, 610, -628, -628, -628, -628, -628,
2269 -628, -627, -81, -267, -191, -628, -628, 647, -628, 566,
2270 -628, -628, -628, 139, 250, -448, -628, 580, -628, -628
Dan Gohmanf4423b12008-04-19 00:24:39 +00002271};
2272
2273/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2274 positive, shift that token. If negative, reduce the rule which
2275 number is the opposite. If zero, do what YYDEFACT says.
2276 If YYTABLE_NINF, syntax error. */
Dale Johannesendfe8c842008-09-26 19:32:34 +00002277#define YYTABLE_NINF -223
Dan Gohmanf4423b12008-04-19 00:24:39 +00002278static const yytype_int16 yytable[] =
2279{
Dale Johannesendfe8c842008-09-26 19:32:34 +00002280 11, 82, 292, 280, 381, 383, 169, 105, 362, 291,
2281 291, 91, 528, 326, 170, 111, 111, 11, 13, 94,
2282 322, 111, 410, 411, 282, 412, 323, 536, 330, 331,
2283 332, 333, 334, 421, 146, 13, 293, 682, 340, 111,
2284 495, 536, 24, 147, 29, 30, 31, 32, 33, 34,
2285 35, 36, 109, 37, 497, 146, 462, 694, 21, 111,
2286 422, 537, 516, 517, 244, 468, 26, 111, 430, 431,
2287 432, 433, 434, 22, 462, 251, 138, 687, 111, 131,
2288 109, 467, 366, 496, 368, 281, 138, 341, 367, 462,
2289 369, 1, 155, 11, 3, 462, 5, 496, 532, 462,
2290 -154, 25, 155, 289, 548, 363, 364, 462, 601, 290,
2291 466, 111, 84, 85, 547, 27, 241, 242, 135, 89,
2292 245, 112, 112, 136, 44, 90, 249, 112, 423, 358,
2293 540, 481, 483, 485, 440, 441, 442, 443, 631, 444,
2294 46, 111, 47, 445, 446, 112, 490, 491, 492, 493,
2295 494, 286, 438, 593, 2, 359, 499, 4, 171, 462,
2296 38, 39, 40, 95, 463, 112, 575, 663, 683, 513,
2297 514, 413, 648, 112, 634, 106, 324, 325, 286, 327,
2298 440, 441, 442, 443, 112, 444, 167, 283, -67, 445,
2299 446, 28, 328, 286, 286, 286, 286, 286, 335, 336,
2300 337, 338, 339, 286, 704, 407, -154, 705, 407, 407,
2301 -154, 407, 546, 138, 119, 120, 248, 112, 487, 436,
2302 418, -67, 573, 86, 155, 87, 462, 116, 556, 117,
2303 558, 544, 58, 561, 501, 60, 503, 504, 505, -55,
2304 -55, -55, -55, 569, 570, 59, 407, 112, 342, 343,
2305 420, -67, 635, 62, 407, 407, 407, 407, 407, 642,
2306 643, 91, 252, 253, 611, 98, 612, 155, 38, 39,
2307 40, 344, 122, 123, 124, 125, 126, 127, 414, 50,
2308 51, 52, 602, 603, 53, 607, 608, 609, 610, 440,
2309 441, 442, 443, 614, 444, 415, 416, 417, 445, 446,
2310 99, 620, 280, 598, 580, 100, 559, 622, 254, 255,
2311 256, 257, 585, 102, 567, 155, 437, 286, 644, 649,
2312 645, 645, 103, 685, 686, 87, 688, 689, 64, 65,
2313 650, 104, 407, 407, 407, 407, 407, 142, 345, 346,
2314 1, 2, 407, 3, 4, 5, 716, 717, 647, 151,
2315 152, 702, 703, 148, 465, 407, 407, 143, 347, 348,
2316 150, 349, 350, 475, 351, 352, 353, 658, 613, 567,
2317 168, 616, 617, 618, 173, 668, 669, 712, 237, 713,
2318 227, 227, 1, 286, 281, 3, 239, 5, 228, 228,
2319 229, 229, 114, 115, 240, 681, 243, 246, -56, 286,
2320 502, 286, 286, 286, 247, 670, 250, -57, -60, 512,
2321 674, -59, -58, 258, 407, 111, 407, 344, 284, 407,
2322 291, 696, 697, 360, 518, 361, 370, 371, 701, 407,
2323 407, 372, 708, 373, 374, 455, 456, 457, 458, 459,
2324 460, 461, 714, 375, 384, 376, 385, 386, 719, 435,
2325 469, 470, 471, 387, 389, 409, 465, 439, 424, 425,
2326 426, 427, 428, 429, 664, 450, 472, 451, 407, 407,
2327 452, 407, 407, 407, 407, 453, 454, 478, 486, 407,
2328 488, 489, 531, 568, 345, 346, 500, 407, 684, 574,
2329 305, 306, 506, 407, 294, 295, 296, 297, 298, 299,
2330 300, 301, 302, 303, 347, 348, 507, 349, 350, 590,
2331 351, 352, 353, 509, 510, 597, 519, 520, 521, 522,
2332 535, 511, 515, 524, 543, 605, 525, 530, 526, 527,
2333 549, 529, 533, 286, 407, 534, 286, 286, 286, 541,
2334 594, 542, 550, 64, 65, 605, 107, 67, 68, 69,
2335 70, 71, 72, 73, 552, 1, 2, 551, 3, 4,
2336 5, 407, 407, 557, 307, 308, 309, 310, 311, 312,
2337 313, 314, 315, 316, 317, 318, 319, 320, 553, 554,
2338 565, 407, 555, 559, 560, 562, 74, 563, 564, 581,
2339 582, 583, 584, 566, 586, 567, 571, 572, 588, 589,
2340 576, 577, 578, 579, 591, 587, 592, 407, 407, 599,
2341 615, 600, 619, 627, 407, 496, 628, 632, 407, 672,
2342 638, 629, 630, 633, 640, 660, 662, 651, 407, 641,
2343 639, 652, 646, 653, 407, 594, 654, 673, 675, 676,
2344 677, 623, 624, 625, 626, 390, 391, 392, 393, 64,
2345 65, 394, 678, 679, -18, -222, -19, 690, 691, 698,
2346 693, 1, 2, 695, 3, 4, 5, 395, 396, 397,
2347 699, 700, 710, -69, 1, 2, 709, 3, 4, 5,
2348 711, 715, 398, 399, 659, 6, 7, 132, 718, 636,
2349 356, 149, 655, 145, 656, 657, 344, 365, 45, 235,
2350 130, 400, 75, 76, 97, 523, 77, 8, 78, 108,
2351 621, 9, 0, 236, 0, 10, 0, 183, 184, 185,
Devang Pateld4980812008-09-02 20:52:40 +00002352 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002353 196, 197, 262, 263, 264, 265, 0, 64, 65, 0,
2354 107, 67, 68, 69, 70, 71, 72, 73, 0, 1,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002355 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002356 0, 266, 206, 666, 667, 209, 210, 211, 212, 213,
2357 214, 215, 216, 217, 0, 267, 0, 268, 269, 270,
2358 74, 271, 272, 347, 348, 0, 349, 350, 0, 351,
2359 352, 353, 0, 0, 0, 0, 0, 0, 0, 0,
2360 0, 390, 391, 392, 393, 64, 65, 394, 0, 401,
2361 0, 0, 402, 0, 403, 0, 404, 1, 2, 0,
2362 3, 4, 5, 395, 396, 397, 0, 0, 0, 0,
2363 0, 0, 0, 0, 0, 0, 0, 0, 398, 399,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002364 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002365 0, 0, 0, 111, 0, 64, 65, 400, 107, 158,
2366 159, 160, 161, 162, 163, 73, 0, 1, 2, 0,
2367 3, 4, 5, 183, 184, 185, 186, 187, 188, 189,
2368 190, 191, 192, 193, 194, 195, 196, 197, 262, 263,
2369 264, 265, 0, 0, 0, 0, 75, 76, 74, 0,
2370 77, 0, 78, 144, 0, 0, 0, 0, 0, 0,
2371 0, 0, 0, 0, 0, 0, 0, 266, 206, 207,
2372 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
2373 0, 267, 0, 268, 269, 270, 0, 271, 272, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002374 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002375 0, 0, 0, 0, 0, 0, 0, 0, 0, 112,
2376 0, 0, 0, 0, 0, 401, 0, 0, 402, 0,
2377 403, 0, 404, 390, 391, 392, 393, 64, 65, 394,
2378 0, 0, -221, 0, 0, 0, 0, 0, 0, 1,
2379 2, 0, 3, 4, 5, 395, 396, 397, 0, 0,
2380 -69, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2381 398, 399, 6, 7, 75, 76, 0, 0, 77, 0,
2382 78, 382, 0, 0, 0, 0, 0, 0, 0, 400,
2383 0, 0, 0, 0, 8, 0, 0, 0, 9, 0,
2384 0, 0, 10, 0, 0, 183, 184, 185, 186, 187,
2385 188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
2386 262, 263, 264, 265, 0, 0, 0, 0, 0, 0,
Devang Pateld4980812008-09-02 20:52:40 +00002387 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002388 0, 0, 0, 0, 0, 0, 0, 0, 0, 266,
2389 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
2390 216, 217, 0, 267, 0, 268, 269, 270, 0, 271,
2391 272, 390, 391, 392, 393, 0, 0, 394, 0, 0,
Devang Pateld4980812008-09-02 20:52:40 +00002392 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002393 0, 0, 0, 395, 396, 397, 0, 401, 0, 0,
2394 402, 0, 403, 0, 404, 0, 0, 0, 398, 399,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002395 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002396 0, 0, 0, 0, 0, 0, 0, 400, 0, 0,
2397 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2398 0, 0, 0, 183, 184, 185, 186, 187, 188, 189,
2399 190, 191, 192, 193, 194, 195, 196, 197, 262, 263,
2400 264, 265, 0, 0, 0, 0, 0, 0, 0, 0,
2401 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2402 0, 0, 0, 0, 0, 0, 0, 266, 206, 207,
2403 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
2404 0, 267, 0, 268, 269, 270, 0, 271, 272, 0,
2405 64, 65, 0, 0, 0, 0, 0, 0, 0, 0,
2406 0, 0, 1, 2, 0, 3, 4, 5, 259, 0,
2407 0, 0, 0, 0, 0, 401, 0, 0, 402, 0,
2408 403, 0, 404, 260, 261, 0, 0, 0, 0, 0,
2409 0, 0, 0, 0, 0, 0, 0, 0, 111, 0,
2410 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2411 0, 0, 0, 0, 0, 0, 0, 0, 183, 184,
2412 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
2413 195, 196, 197, 262, 263, 264, 265, 0, 0, 0,
2414 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2415 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2416 0, 0, 266, 206, 207, 208, 209, 210, 211, 212,
2417 213, 214, 215, 216, 217, 0, 267, 0, 268, 269,
2418 270, 0, 271, 272, 0, 64, 65, 0, 0, 0,
2419 0, 0, 0, 0, 0, 0, 0, 1, 2, 0,
2420 3, 4, 5, 259, 112, 0, 0, 0, -67, 0,
2421 273, 0, 0, 274, 0, 275, 0, 276, 260, 261,
2422 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2423 0, 64, 65, 111, 107, 158, 159, 160, 161, 162,
2424 163, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2425 0, 0, 0, 183, 184, 185, 186, 187, 188, 189,
2426 190, 191, 192, 193, 194, 195, 196, 197, 262, 263,
2427 264, 265, 0, 0, 74, 0, 64, 65, 0, 107,
2428 158, 159, 160, 161, 162, 163, 73, 0, 1, 2,
2429 0, 3, 4, 5, 0, 0, 0, 266, 206, 207,
2430 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
2431 0, 267, 0, 268, 269, 270, 0, 271, 272, 74,
2432 64, 65, 0, 107, 158, 159, 160, 161, 162, 163,
2433 73, 0, 1, 2, 0, 3, 4, 5, 0, 112,
2434 0, 0, 0, 0, 0, 273, 0, 0, 274, 0,
2435 275, 0, 276, 0, 0, 0, 0, 0, 0, 0,
2436 0, 64, 65, 74, 107, 67, 68, 69, 70, 71,
Devang Pateld4980812008-09-02 20:52:40 +00002437 72, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2438 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002439 75, 76, 0, 137, 77, 0, 78, 464, 0, 0,
2440 0, 0, 0, 0, 74, 64, 65, 0, 153, 67,
2441 68, 69, 70, 71, 72, 73, 0, 1, 2, 0,
2442 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
Devang Pateld4980812008-09-02 20:52:40 +00002443 0, 0, 0, 0, 0, 75, 76, 0, 0, 77,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002444 0, 78, 484, 0, 0, 0, 64, 65, 74, 107,
2445 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002446 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002447 0, 0, 0, 0, 0, 0, 0, 0, 355, 75,
2448 76, 0, 0, 77, 0, 78, 545, 64, 65, 74,
2449 107, 158, 159, 160, 161, 162, 163, 73, 0, 1,
Devang Pateld4980812008-09-02 20:52:40 +00002450 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2451 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002452 75, 76, 0, 154, 77, 0, 78, 0, 64, 65,
2453 74, 107, 67, 68, 69, 70, 71, 72, 73, 0,
2454 1, 2, 0, 3, 4, 5, 64, 65, 0, 107,
2455 158, 159, 160, 161, 162, 163, 73, 0, 1, 2,
2456 474, 3, 4, 5, 75, 76, 0, 0, 77, 0,
2457 78, 74, 0, 0, 0, 64, 65, 0, 107, 67,
2458 68, 69, 70, 71, 72, 73, 0, 1, 2, 74,
2459 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2460 0, 0, 0, 0, 0, 75, 76, 596, 0, 77,
2461 0, 78, 0, 0, 0, 0, 64, 65, 74, 66,
2462 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2463 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2464 0, 0, 0, 0, 0, 0, 75, 76, 0, 377,
2465 77, 0, 78, 0, 0, 0, 0, 64, 65, 74,
2466 107, 158, 159, 160, 161, 162, 163, 73, 0, 1,
2467 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2468 0, 0, 0, 0, 0, 0, 0, 75, 76, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002469 0, 77, 0, 78, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002470 74, 0, 0, 0, 0, 75, 76, 0, 480, 77,
2471 0, 78, 64, 65, 0, 153, 67, 68, 69, 70,
2472 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2473 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2474 78, 64, 65, 0, 107, 67, 68, 69, 70, 71,
2475 72, 73, 0, 1, 2, 74, 3, 4, 5, 0,
2476 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2477 0, 0, 0, 0, 0, 75, 76, 0, 0, 77,
2478 0, 78, 64, 65, 74, 285, 67, 68, 69, 70,
2479 71, 72, 73, 0, 1, 2, 0, 3, 4, 5,
2480 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2481 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
2482 77, 0, 78, 64, 65, 74, 107, 158, 159, 160,
2483 161, 162, 163, 73, 0, 1, 2, 0, 3, 4,
2484 5, 64, 65, 0, 107, 158, 159, 160, 161, 162,
2485 163, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2486 0, 0, 0, 0, 0, 0, 74, 0, 0, 0,
2487 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
2488 0, 0, 64, 65, 74, 107, 67, 68, 69, 70,
2489 71, 72, 604, 0, 1, 2, 0, 3, 4, 5,
2490 75, 76, 0, 0, 77, 0, 78, 64, 65, 0,
2491 107, 67, 68, 69, 70, 71, 72, 671, 0, 1,
2492 2, 0, 3, 4, 5, 74, 0, 0, 0, 0,
2493 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2494 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
2495 74, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002496 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002497 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002498 0, 0, 75, 76, 0, 0, 77, 0, 380, 0,
2499 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2500 75, 76, 0, 0, 77, 0, 482, 0, 0, 0,
2501 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2502 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2503 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2504 174, 75, 76, 0, 0, 77, 0, 78, 0, 0,
2505 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2506 0, 175, 176, 0, 0, 0, 75, 76, 0, 0,
2507 77, 0, 78, 177, 178, 179, 180, 181, 182, 183,
2508 184, 185, 186, 187, 188, 189, 190, 191, 192, 193,
2509 194, 195, 196, 197, 198, 199, 200, 201, 0, 0,
2510 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2511 0, 0, 0, 0, 0, 0, 0, 0, 202, 203,
2512 204, 0, 0, 205, 206, 207, 208, 209, 210, 211,
2513 212, 213, 214, 215, 216, 217, 218, 219, 220, 221,
2514 222, 223, 224, 225, 226
Dan Gohmanf4423b12008-04-19 00:24:39 +00002515};
2516
2517static const yytype_int16 yycheck[] =
2518{
Dale Johannesendfe8c842008-09-26 19:32:34 +00002519 0, 27, 179, 166, 274, 275, 128, 4, 247, 11,
2520 11, 21, 460, 204, 28, 55, 55, 17, 0, 29,
2521 200, 55, 289, 290, 167, 292, 201, 34, 219, 220,
2522 221, 222, 223, 325, 164, 17, 180, 664, 229, 55,
2523 11, 34, 163, 173, 42, 43, 44, 45, 46, 47,
2524 48, 49, 78, 51, 11, 164, 164, 684, 53, 55,
2525 327, 54, 448, 449, 173, 173, 163, 55, 335, 336,
2526 337, 338, 339, 68, 164, 156, 102, 38, 55, 7,
2527 106, 171, 262, 54, 264, 166, 112, 231, 263, 164,
2528 265, 19, 118, 93, 22, 164, 24, 54, 173, 164,
2529 55, 59, 128, 11, 173, 248, 249, 164, 173, 17,
2530 380, 55, 41, 42, 171, 18, 142, 143, 164, 48,
2531 146, 161, 161, 169, 0, 54, 152, 161, 167, 169,
2532 475, 401, 402, 403, 141, 142, 143, 144, 586, 146,
2533 46, 55, 48, 150, 151, 161, 413, 414, 415, 416,
2534 417, 177, 343, 539, 20, 171, 423, 23, 172, 164,
2535 158, 159, 160, 173, 169, 161, 162, 169, 169, 436,
2536 437, 293, 620, 161, 162, 172, 202, 203, 204, 205,
2537 141, 142, 143, 144, 161, 146, 121, 169, 165, 150,
2538 151, 163, 218, 219, 220, 221, 222, 223, 224, 225,
2539 226, 227, 228, 229, 154, 286, 161, 157, 289, 290,
2540 165, 292, 482, 239, 32, 33, 151, 161, 409, 341,
2541 164, 165, 514, 35, 250, 37, 164, 42, 495, 44,
2542 497, 169, 163, 500, 425, 167, 427, 428, 429, 3,
2543 4, 5, 6, 510, 511, 163, 327, 161, 117, 118,
2544 164, 165, 597, 22, 335, 336, 337, 338, 339, 604,
2545 605, 21, 26, 27, 556, 22, 558, 293, 158, 159,
2546 160, 54, 62, 63, 64, 65, 66, 67, 304, 42,
2547 43, 44, 549, 550, 47, 552, 553, 554, 555, 141,
2548 142, 143, 144, 560, 146, 321, 322, 323, 150, 151,
2549 22, 568, 465, 542, 162, 22, 164, 574, 3, 4,
2550 5, 6, 162, 161, 164, 341, 342, 343, 162, 162,
2551 164, 164, 4, 668, 669, 37, 671, 672, 7, 8,
2552 622, 4, 413, 414, 415, 416, 417, 168, 121, 122,
2553 19, 20, 423, 22, 23, 24, 155, 156, 615, 114,
2554 115, 696, 697, 161, 380, 436, 437, 168, 141, 142,
2555 165, 144, 145, 389, 147, 148, 149, 162, 559, 164,
2556 4, 562, 563, 564, 163, 642, 643, 162, 22, 164,
2557 132, 133, 19, 409, 465, 22, 164, 24, 132, 133,
2558 132, 133, 84, 85, 162, 662, 171, 4, 9, 425,
2559 426, 427, 428, 429, 162, 644, 161, 9, 9, 435,
2560 649, 9, 9, 9, 495, 55, 497, 54, 57, 500,
2561 11, 688, 689, 171, 450, 162, 161, 161, 695, 510,
2562 511, 161, 699, 161, 161, 370, 371, 372, 373, 374,
2563 375, 376, 709, 161, 22, 161, 161, 161, 715, 38,
2564 385, 386, 387, 161, 161, 164, 482, 4, 164, 164,
2565 164, 164, 164, 164, 641, 38, 164, 161, 549, 550,
2566 161, 552, 553, 554, 555, 161, 161, 61, 22, 560,
2567 164, 164, 171, 509, 121, 122, 167, 568, 665, 515,
2568 26, 27, 164, 574, 94, 95, 96, 97, 98, 99,
2569 100, 101, 102, 103, 141, 142, 164, 144, 145, 535,
2570 147, 148, 149, 164, 164, 541, 451, 452, 453, 454,
2571 38, 164, 164, 164, 22, 551, 164, 462, 164, 164,
2572 17, 164, 164, 559, 615, 164, 562, 563, 564, 164,
2573 540, 162, 17, 7, 8, 571, 10, 11, 12, 13,
2574 14, 15, 16, 17, 164, 19, 20, 161, 22, 23,
2575 24, 642, 643, 4, 100, 101, 102, 103, 104, 105,
2576 106, 107, 108, 109, 110, 111, 112, 113, 164, 164,
2577 4, 662, 164, 164, 164, 164, 50, 164, 164, 524,
2578 525, 526, 527, 4, 529, 164, 161, 164, 533, 534,
2579 164, 164, 164, 164, 22, 171, 4, 688, 689, 164,
2580 164, 171, 4, 164, 695, 54, 162, 162, 699, 645,
2581 22, 164, 164, 162, 164, 54, 17, 162, 709, 167,
2582 171, 162, 169, 162, 715, 635, 162, 169, 162, 162,
2583 162, 576, 577, 578, 579, 3, 4, 5, 6, 7,
2584 8, 9, 4, 152, 161, 0, 161, 22, 153, 161,
2585 164, 19, 20, 17, 22, 23, 24, 25, 26, 27,
2586 17, 164, 73, 18, 19, 20, 17, 22, 23, 24,
2587 163, 17, 40, 41, 635, 30, 31, 93, 713, 598,
2588 239, 112, 627, 106, 629, 630, 54, 250, 17, 133,
2589 90, 59, 166, 167, 57, 455, 170, 52, 172, 173,
2590 571, 56, -1, 133, -1, 60, -1, 75, 76, 77,
2591 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
2592 88, 89, 90, 91, 92, 93, -1, 7, 8, -1,
2593 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2594 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2595 -1, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2596 128, 129, 130, 131, -1, 133, -1, 135, 136, 137,
2597 50, 139, 140, 141, 142, -1, 144, 145, -1, 147,
2598 148, 149, -1, -1, -1, -1, -1, -1, -1, -1,
2599 -1, 3, 4, 5, 6, 7, 8, 9, -1, 167,
2600 -1, -1, 170, -1, 172, -1, 174, 19, 20, -1,
2601 22, 23, 24, 25, 26, 27, -1, -1, -1, -1,
2602 -1, -1, -1, -1, -1, -1, -1, -1, 40, 41,
2603 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2604 -1, -1, -1, 55, -1, 7, 8, 59, 10, 11,
2605 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2606 22, 23, 24, 75, 76, 77, 78, 79, 80, 81,
2607 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2608 92, 93, -1, -1, -1, -1, 166, 167, 50, -1,
2609 170, -1, 172, 173, -1, -1, -1, -1, -1, -1,
2610 -1, -1, -1, -1, -1, -1, -1, 119, 120, 121,
2611 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
2612 -1, 133, -1, 135, 136, 137, -1, 139, 140, -1,
2613 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2614 -1, -1, -1, -1, -1, -1, -1, -1, -1, 161,
2615 -1, -1, -1, -1, -1, 167, -1, -1, 170, -1,
2616 172, -1, 174, 3, 4, 5, 6, 7, 8, 9,
2617 -1, -1, 0, -1, -1, -1, -1, -1, -1, 19,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002618 20, -1, 22, 23, 24, 25, 26, 27, -1, -1,
2619 18, 19, 20, -1, 22, 23, 24, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002620 40, 41, 30, 31, 166, 167, -1, -1, 170, -1,
2621 172, 173, -1, -1, -1, -1, -1, -1, -1, 59,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002622 -1, -1, -1, -1, 52, -1, -1, -1, 56, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002623 -1, -1, 60, -1, -1, 75, 76, 77, 78, 79,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002624 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002625 90, 91, 92, 93, -1, -1, -1, -1, -1, -1,
Devang Pateld4980812008-09-02 20:52:40 +00002626 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002627 -1, -1, -1, -1, -1, -1, -1, -1, -1, 119,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002628 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002629 130, 131, -1, 133, -1, 135, 136, 137, -1, 139,
2630 140, 3, 4, 5, 6, -1, -1, 9, -1, -1,
Dan Gohman81a0c0b2008-05-31 00:58:22 +00002631 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002632 -1, -1, -1, 25, 26, 27, -1, 167, -1, -1,
2633 170, -1, 172, -1, 174, -1, -1, -1, 40, 41,
Devang Pateld4980812008-09-02 20:52:40 +00002634 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002635 -1, -1, -1, -1, -1, -1, -1, 59, -1, -1,
Dan Gohmanf910eaa2008-06-09 14:45:02 +00002636 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002637 -1, -1, -1, 75, 76, 77, 78, 79, 80, 81,
Devang Pateld4980812008-09-02 20:52:40 +00002638 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002639 92, 93, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002640 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002641 -1, -1, -1, -1, -1, -1, -1, 119, 120, 121,
Devang Pateld4980812008-09-02 20:52:40 +00002642 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002643 -1, 133, -1, 135, 136, 137, -1, 139, 140, -1,
2644 7, 8, -1, -1, -1, -1, -1, -1, -1, -1,
2645 -1, -1, 19, 20, -1, 22, 23, 24, 25, -1,
2646 -1, -1, -1, -1, -1, 167, -1, -1, 170, -1,
2647 172, -1, 174, 40, 41, -1, -1, -1, -1, -1,
2648 -1, -1, -1, -1, -1, -1, -1, -1, 55, -1,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002649 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002650 -1, -1, -1, -1, -1, -1, -1, -1, 75, 76,
2651 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2652 87, 88, 89, 90, 91, 92, 93, -1, -1, -1,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002653 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Devang Pateld4980812008-09-02 20:52:40 +00002654 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002655 -1, -1, 119, 120, 121, 122, 123, 124, 125, 126,
2656 127, 128, 129, 130, 131, -1, 133, -1, 135, 136,
2657 137, -1, 139, 140, -1, 7, 8, -1, -1, -1,
2658 -1, -1, -1, -1, -1, -1, -1, 19, 20, -1,
2659 22, 23, 24, 25, 161, -1, -1, -1, 165, -1,
2660 167, -1, -1, 170, -1, 172, -1, 174, 40, 41,
2661 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2662 -1, 7, 8, 55, 10, 11, 12, 13, 14, 15,
2663 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2664 -1, -1, -1, 75, 76, 77, 78, 79, 80, 81,
2665 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2666 92, 93, -1, -1, 50, -1, 7, 8, -1, 10,
Devang Pateld4980812008-09-02 20:52:40 +00002667 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002668 -1, 22, 23, 24, -1, -1, -1, 119, 120, 121,
2669 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
2670 -1, 133, -1, 135, 136, 137, -1, 139, 140, 50,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002671 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002672 17, -1, 19, 20, -1, 22, 23, 24, -1, 161,
2673 -1, -1, -1, -1, -1, 167, -1, -1, 170, -1,
2674 172, -1, 174, -1, -1, -1, -1, -1, -1, -1,
2675 -1, 7, 8, 50, 10, 11, 12, 13, 14, 15,
Devang Pateld4980812008-09-02 20:52:40 +00002676 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2677 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002678 166, 167, -1, 39, 170, -1, 172, 173, -1, -1,
2679 -1, -1, -1, -1, 50, 7, 8, -1, 10, 11,
2680 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2681 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2682 -1, -1, -1, -1, -1, 166, 167, -1, -1, 170,
2683 -1, 172, 173, -1, -1, -1, 7, 8, 50, 10,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002684 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2685 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002686 -1, -1, -1, -1, -1, -1, -1, -1, 39, 166,
2687 167, -1, -1, 170, -1, 172, 173, 7, 8, 50,
Devang Pateld4980812008-09-02 20:52:40 +00002688 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2689 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2690 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002691 166, 167, -1, 125, 170, -1, 172, -1, 7, 8,
2692 50, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2693 19, 20, -1, 22, 23, 24, 7, 8, -1, 10,
2694 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2695 39, 22, 23, 24, 166, 167, -1, -1, 170, -1,
2696 172, 50, -1, -1, -1, 7, 8, -1, 10, 11,
2697 12, 13, 14, 15, 16, 17, -1, 19, 20, 50,
2698 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2699 -1, -1, -1, -1, -1, 166, 167, 39, -1, 170,
2700 -1, 172, -1, -1, -1, -1, 7, 8, 50, 10,
2701 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2702 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2703 -1, -1, -1, -1, -1, -1, 166, 167, -1, 169,
2704 170, -1, 172, -1, -1, -1, -1, 7, 8, 50,
2705 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2706 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2707 -1, -1, -1, -1, -1, -1, -1, 166, 167, -1,
2708 -1, 170, -1, 172, -1, -1, -1, -1, -1, -1,
2709 50, -1, -1, -1, -1, 166, 167, -1, 169, 170,
2710 -1, 172, 7, 8, -1, 10, 11, 12, 13, 14,
2711 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2712 -1, -1, -1, -1, 166, 167, -1, -1, 170, -1,
2713 172, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2714 16, 17, -1, 19, 20, 50, 22, 23, 24, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002715 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002716 -1, -1, -1, -1, -1, 166, 167, -1, -1, 170,
2717 -1, 172, 7, 8, 50, 10, 11, 12, 13, 14,
2718 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2719 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2720 -1, -1, -1, -1, -1, -1, 166, 167, -1, -1,
2721 170, -1, 172, 7, 8, 50, 10, 11, 12, 13,
2722 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2723 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2724 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2725 -1, -1, -1, -1, -1, -1, 50, -1, -1, -1,
2726 -1, 166, 167, -1, -1, 170, -1, 172, -1, -1,
2727 -1, -1, 7, 8, 50, 10, 11, 12, 13, 14,
2728 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2729 166, 167, -1, -1, 170, -1, 172, 7, 8, -1,
2730 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2731 20, -1, 22, 23, 24, 50, -1, -1, -1, -1,
2732 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2733 -1, 166, 167, -1, -1, 170, -1, 172, -1, -1,
2734 50, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002735 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerccef6b52008-09-23 21:18:31 +00002736 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002737 -1, -1, 166, 167, -1, -1, 170, -1, 172, -1,
2738 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2739 166, 167, -1, -1, 170, -1, 172, -1, -1, -1,
2740 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2741 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2742 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2743 36, 166, 167, -1, -1, 170, -1, 172, -1, -1,
2744 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2745 -1, 57, 58, -1, -1, -1, 166, 167, -1, -1,
2746 170, -1, 172, 69, 70, 71, 72, 73, 74, 75,
2747 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2748 86, 87, 88, 89, 90, 91, 92, 93, -1, -1,
2749 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2750 -1, -1, -1, -1, -1, -1, -1, -1, 114, 115,
2751 116, -1, -1, 119, 120, 121, 122, 123, 124, 125,
2752 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
2753 136, 137, 138, 139, 140
Dan Gohmanf4423b12008-04-19 00:24:39 +00002754};
2755
2756/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2757 symbol of state STATE-NUM. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002758static const yytype_uint16 yystos[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002759{
Dale Johannesenc7071cc2008-05-14 20:13:36 +00002760 0, 19, 20, 22, 23, 24, 30, 31, 52, 56,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002761 60, 183, 186, 188, 189, 190, 225, 226, 227, 229,
2762 228, 53, 68, 234, 163, 59, 163, 18, 163, 42,
2763 43, 44, 45, 46, 47, 48, 49, 51, 158, 159,
2764 160, 191, 192, 193, 0, 227, 46, 48, 194, 244,
2765 42, 43, 44, 47, 195, 241, 243, 251, 163, 163,
2766 167, 235, 22, 233, 7, 8, 10, 11, 12, 13,
2767 14, 15, 16, 17, 50, 166, 167, 170, 172, 183,
2768 188, 212, 213, 247, 193, 193, 35, 37, 223, 193,
2769 193, 21, 252, 253, 29, 173, 242, 252, 22, 22,
2770 22, 236, 161, 4, 4, 4, 172, 10, 173, 213,
2771 218, 55, 161, 185, 223, 223, 42, 44, 196, 32,
2772 33, 222, 62, 63, 64, 65, 66, 67, 197, 239,
2773 239, 7, 186, 187, 256, 164, 169, 39, 213, 214,
2774 216, 217, 168, 168, 173, 218, 164, 173, 161, 217,
2775 165, 222, 222, 10, 125, 213, 215, 224, 11, 12,
2776 13, 14, 15, 16, 181, 182, 213, 219, 4, 215,
2777 28, 172, 240, 163, 36, 57, 58, 69, 70, 71,
Chris Lattner15bd0952008-08-29 17:20:18 +00002778 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2779 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002780 92, 93, 114, 115, 116, 119, 120, 121, 122, 123,
Chris Lattner15bd0952008-08-29 17:20:18 +00002781 124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002782 134, 135, 136, 137, 138, 139, 140, 176, 177, 178,
2783 254, 261, 262, 263, 264, 254, 262, 22, 199, 164,
2784 162, 213, 213, 171, 173, 213, 4, 162, 219, 213,
2785 161, 247, 26, 27, 3, 4, 5, 6, 9, 25,
2786 40, 41, 90, 91, 92, 93, 119, 133, 135, 136,
2787 137, 139, 140, 167, 170, 172, 174, 176, 177, 178,
2788 220, 247, 185, 188, 57, 10, 213, 249, 250, 11,
2789 17, 11, 181, 197, 94, 95, 96, 97, 98, 99,
2790 100, 101, 102, 103, 179, 26, 27, 100, 101, 102,
Chris Lattner15bd0952008-08-29 17:20:18 +00002791 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
Dale Johannesendfe8c842008-09-26 19:32:34 +00002792 113, 180, 179, 180, 213, 213, 249, 213, 213, 257,
2793 249, 249, 249, 249, 249, 213, 213, 213, 213, 213,
2794 249, 197, 117, 118, 54, 121, 122, 141, 142, 144,
2795 145, 147, 148, 149, 198, 39, 214, 201, 169, 171,
2796 171, 162, 201, 185, 185, 224, 179, 180, 179, 180,
2797 161, 161, 161, 161, 161, 161, 161, 169, 219, 221,
2798 172, 221, 173, 221, 22, 161, 161, 161, 230, 161,
2799 3, 4, 5, 6, 9, 25, 26, 27, 40, 41,
2800 59, 167, 170, 172, 174, 220, 246, 247, 248, 164,
2801 248, 248, 248, 215, 213, 213, 213, 213, 164, 207,
2802 164, 207, 248, 167, 164, 164, 164, 164, 164, 164,
2803 248, 248, 248, 248, 248, 38, 215, 213, 249, 4,
2804 141, 142, 143, 144, 146, 150, 151, 200, 231, 232,
2805 38, 161, 161, 161, 161, 219, 219, 219, 219, 219,
2806 219, 219, 164, 169, 173, 213, 221, 171, 173, 219,
2807 219, 219, 164, 210, 39, 213, 237, 238, 61, 245,
2808 169, 221, 172, 221, 173, 221, 22, 249, 164, 164,
2809 248, 248, 248, 248, 248, 11, 54, 11, 259, 248,
2810 167, 249, 213, 249, 249, 249, 164, 164, 260, 164,
2811 164, 164, 213, 248, 248, 164, 210, 210, 213, 219,
2812 219, 219, 219, 259, 164, 164, 164, 164, 260, 164,
2813 219, 171, 173, 164, 164, 38, 34, 54, 208, 211,
2814 199, 164, 162, 22, 169, 173, 221, 171, 173, 17,
2815 17, 161, 164, 164, 164, 164, 248, 4, 248, 164,
2816 164, 248, 164, 164, 164, 4, 4, 164, 213, 248,
2817 248, 161, 164, 207, 213, 162, 164, 164, 164, 164,
2818 162, 219, 219, 219, 219, 162, 219, 171, 219, 219,
2819 213, 22, 4, 210, 183, 184, 39, 213, 201, 164,
2820 171, 173, 248, 248, 17, 213, 258, 248, 248, 248,
2821 248, 207, 207, 249, 248, 164, 249, 249, 249, 4,
2822 248, 258, 248, 219, 219, 219, 219, 164, 162, 164,
2823 164, 260, 162, 162, 162, 199, 208, 209, 22, 171,
2824 164, 167, 199, 199, 162, 164, 169, 248, 260, 162,
2825 207, 162, 162, 162, 162, 219, 219, 219, 162, 184,
2826 54, 206, 17, 169, 181, 255, 121, 122, 248, 248,
2827 201, 17, 213, 169, 201, 162, 162, 162, 4, 152,
2828 205, 248, 246, 169, 181, 199, 199, 38, 199, 199,
2829 22, 153, 204, 164, 246, 17, 248, 248, 161, 17,
2830 164, 248, 199, 199, 154, 157, 202, 203, 248, 17,
2831 73, 163, 162, 164, 248, 17, 155, 156, 203, 248
Dan Gohmanf4423b12008-04-19 00:24:39 +00002832};
David Greene718fda32007-08-01 03:59:32 +00002833
Reid Spencer68a24bd2005-08-27 18:50:39 +00002834#define yyerrok (yyerrstatus = 0)
2835#define yyclearin (yychar = YYEMPTY)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002836#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002837#define YYEOF 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00002838
Reid Spencer68a24bd2005-08-27 18:50:39 +00002839#define YYACCEPT goto yyacceptlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002840#define YYABORT goto yyabortlab
2841#define YYERROR goto yyerrorlab
2842
2843
2844/* Like YYERROR except do call yyerror. This remains here temporarily
2845 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002846 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00002847
Reid Spencer68a24bd2005-08-27 18:50:39 +00002848#define YYFAIL goto yyerrlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002849
Reid Spencer68a24bd2005-08-27 18:50:39 +00002850#define YYRECOVERING() (!!yyerrstatus)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002851
2852#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002853do \
2854 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002855 { \
2856 yychar = (Token); \
2857 yylval = (Value); \
2858 yytoken = YYTRANSLATE (yychar); \
2859 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002860 goto yybackup; \
2861 } \
2862 else \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002863 { \
2864 yyerror (YY_("syntax error: cannot back up")); \
2865 YYERROR; \
2866 } \
2867while (YYID (0))
2868
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002869
Reid Spencer68a24bd2005-08-27 18:50:39 +00002870#define YYTERROR 1
2871#define YYERRCODE 256
2872
Dan Gohmanf4423b12008-04-19 00:24:39 +00002873
2874/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2875 If N is 0, then set CURRENT to the empty location which ends
2876 the previous symbol: RHS[0] (always defined). */
2877
2878#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2879#ifndef YYLLOC_DEFAULT
2880# define YYLLOC_DEFAULT(Current, Rhs, N) \
2881 do \
2882 if (YYID (N)) \
2883 { \
2884 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2885 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2886 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2887 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2888 } \
2889 else \
2890 { \
2891 (Current).first_line = (Current).last_line = \
2892 YYRHSLOC (Rhs, 0).last_line; \
2893 (Current).first_column = (Current).last_column = \
2894 YYRHSLOC (Rhs, 0).last_column; \
2895 } \
2896 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002897#endif
2898
Dan Gohmanf4423b12008-04-19 00:24:39 +00002899
2900/* YY_LOCATION_PRINT -- Print the location on the stream.
2901 This macro was not mandated originally: define only if we know
2902 we won't break user code: when these are the locations we know. */
2903
2904#ifndef YY_LOCATION_PRINT
Dan Gohman180c1692008-06-23 18:43:26 +00002905# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
Dan Gohmanf4423b12008-04-19 00:24:39 +00002906# define YY_LOCATION_PRINT(File, Loc) \
2907 fprintf (File, "%d.%d-%d.%d", \
2908 (Loc).first_line, (Loc).first_column, \
2909 (Loc).last_line, (Loc).last_column)
2910# else
2911# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2912# endif
2913#endif
2914
2915
2916/* YYLEX -- calling `yylex' with the right arguments. */
2917
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002918#ifdef YYLEX_PARAM
Dan Gohmanf4423b12008-04-19 00:24:39 +00002919# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002920#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002921# define YYLEX yylex ()
Gabor Greife64d2482008-04-06 23:07:54 +00002922#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002923
2924/* Enable debugging if requested. */
2925#if YYDEBUG
2926
2927# ifndef YYFPRINTF
2928# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2929# define YYFPRINTF fprintf
2930# endif
2931
2932# define YYDPRINTF(Args) \
2933do { \
2934 if (yydebug) \
2935 YYFPRINTF Args; \
2936} while (YYID (0))
2937
2938# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2939do { \
2940 if (yydebug) \
2941 { \
2942 YYFPRINTF (stderr, "%s ", Title); \
2943 yy_symbol_print (stderr, \
2944 Type, Value); \
2945 YYFPRINTF (stderr, "\n"); \
2946 } \
2947} while (YYID (0))
2948
2949
2950/*--------------------------------.
2951| Print this symbol on YYOUTPUT. |
2952`--------------------------------*/
2953
2954/*ARGSUSED*/
2955#if (defined __STDC__ || defined __C99__FUNC__ \
2956 || defined __cplusplus || defined _MSC_VER)
2957static void
2958yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greife64d2482008-04-06 23:07:54 +00002959#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002960static void
2961yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2962 FILE *yyoutput;
2963 int yytype;
2964 YYSTYPE const * const yyvaluep;
Gabor Greife64d2482008-04-06 23:07:54 +00002965#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002966{
2967 if (!yyvaluep)
2968 return;
2969# ifdef YYPRINT
2970 if (yytype < YYNTOKENS)
2971 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2972# else
2973 YYUSE (yyoutput);
2974# endif
2975 switch (yytype)
2976 {
2977 default:
2978 break;
2979 }
2980}
2981
2982
2983/*--------------------------------.
2984| Print this symbol on YYOUTPUT. |
2985`--------------------------------*/
2986
2987#if (defined __STDC__ || defined __C99__FUNC__ \
2988 || defined __cplusplus || defined _MSC_VER)
2989static void
2990yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2991#else
2992static void
2993yy_symbol_print (yyoutput, yytype, yyvaluep)
2994 FILE *yyoutput;
2995 int yytype;
2996 YYSTYPE const * const yyvaluep;
Scott Michel15dcd8e2008-01-30 03:10:00 +00002997#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002998{
2999 if (yytype < YYNTOKENS)
3000 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3001 else
3002 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner38905612008-02-19 04:36:25 +00003003
Dan Gohmanf4423b12008-04-19 00:24:39 +00003004 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3005 YYFPRINTF (yyoutput, ")");
3006}
Chris Lattner38905612008-02-19 04:36:25 +00003007
Dan Gohmanf4423b12008-04-19 00:24:39 +00003008/*------------------------------------------------------------------.
3009| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3010| TOP (included). |
3011`------------------------------------------------------------------*/
Chris Lattner38905612008-02-19 04:36:25 +00003012
Dan Gohmanf4423b12008-04-19 00:24:39 +00003013#if (defined __STDC__ || defined __C99__FUNC__ \
3014 || defined __cplusplus || defined _MSC_VER)
3015static void
3016yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3017#else
3018static void
3019yy_stack_print (bottom, top)
3020 yytype_int16 *bottom;
3021 yytype_int16 *top;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003022#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003023{
3024 YYFPRINTF (stderr, "Stack now");
3025 for (; bottom <= top; ++bottom)
3026 YYFPRINTF (stderr, " %d", *bottom);
3027 YYFPRINTF (stderr, "\n");
3028}
Chris Lattner38905612008-02-19 04:36:25 +00003029
Dan Gohmanf4423b12008-04-19 00:24:39 +00003030# define YY_STACK_PRINT(Bottom, Top) \
3031do { \
3032 if (yydebug) \
3033 yy_stack_print ((Bottom), (Top)); \
3034} while (YYID (0))
Chris Lattner38905612008-02-19 04:36:25 +00003035
Dan Gohmanf4423b12008-04-19 00:24:39 +00003036
3037/*------------------------------------------------.
3038| Report that the YYRULE is going to be reduced. |
3039`------------------------------------------------*/
3040
3041#if (defined __STDC__ || defined __C99__FUNC__ \
3042 || defined __cplusplus || defined _MSC_VER)
3043static void
3044yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3045#else
3046static void
3047yy_reduce_print (yyvsp, yyrule)
3048 YYSTYPE *yyvsp;
3049 int yyrule;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003050#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003051{
3052 int yynrhs = yyr2[yyrule];
3053 int yyi;
3054 unsigned long int yylno = yyrline[yyrule];
3055 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3056 yyrule - 1, yylno);
3057 /* The symbols being reduced. */
3058 for (yyi = 0; yyi < yynrhs; yyi++)
3059 {
3060 fprintf (stderr, " $%d = ", yyi + 1);
3061 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3062 &(yyvsp[(yyi + 1) - (yynrhs)])
3063 );
3064 fprintf (stderr, "\n");
3065 }
3066}
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003067
Dan Gohmanf4423b12008-04-19 00:24:39 +00003068# define YY_REDUCE_PRINT(Rule) \
3069do { \
3070 if (yydebug) \
3071 yy_reduce_print (yyvsp, Rule); \
3072} while (YYID (0))
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003073
Dan Gohmanf4423b12008-04-19 00:24:39 +00003074/* Nonzero means print parse trace. It is left uninitialized so that
3075 multiple parsers can coexist. */
3076int yydebug;
3077#else /* !YYDEBUG */
3078# define YYDPRINTF(Args)
3079# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3080# define YY_STACK_PRINT(Bottom, Top)
3081# define YY_REDUCE_PRINT(Rule)
3082#endif /* !YYDEBUG */
3083
3084
3085/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003086#ifndef YYINITDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003087# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00003088#endif
3089
Dan Gohmanf4423b12008-04-19 00:24:39 +00003090/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3091 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00003092
Dan Gohmanf4423b12008-04-19 00:24:39 +00003093 Do not make this value too large; the results are undefined if
3094 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3095 evaluated with infinite-precision integer arithmetic. */
David Greene718fda32007-08-01 03:59:32 +00003096
Reid Spencer68a24bd2005-08-27 18:50:39 +00003097#ifndef YYMAXDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003098# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00003099#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003100
Reid Spencer68a24bd2005-08-27 18:50:39 +00003101
3102
Dan Gohmanf4423b12008-04-19 00:24:39 +00003103#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00003104
Dan Gohmanf4423b12008-04-19 00:24:39 +00003105# ifndef yystrlen
3106# if defined __GLIBC__ && defined _STRING_H
3107# define yystrlen strlen
3108# else
3109/* Return the length of YYSTR. */
3110#if (defined __STDC__ || defined __C99__FUNC__ \
3111 || defined __cplusplus || defined _MSC_VER)
3112static YYSIZE_T
3113yystrlen (const char *yystr)
Chris Lattner38905612008-02-19 04:36:25 +00003114#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003115static YYSIZE_T
3116yystrlen (yystr)
3117 const char *yystr;
3118#endif
3119{
3120 YYSIZE_T yylen;
3121 for (yylen = 0; yystr[yylen]; yylen++)
3122 continue;
3123 return yylen;
3124}
3125# endif
3126# endif
3127
3128# ifndef yystpcpy
3129# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3130# define yystpcpy stpcpy
3131# else
3132/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3133 YYDEST. */
3134#if (defined __STDC__ || defined __C99__FUNC__ \
3135 || defined __cplusplus || defined _MSC_VER)
3136static char *
3137yystpcpy (char *yydest, const char *yysrc)
3138#else
3139static char *
3140yystpcpy (yydest, yysrc)
3141 char *yydest;
3142 const char *yysrc;
3143#endif
3144{
3145 char *yyd = yydest;
3146 const char *yys = yysrc;
3147
3148 while ((*yyd++ = *yys++) != '\0')
3149 continue;
3150
3151 return yyd - 1;
3152}
3153# endif
3154# endif
3155
3156# ifndef yytnamerr
3157/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3158 quotes and backslashes, so that it's suitable for yyerror. The
3159 heuristic is that double-quoting is unnecessary unless the string
3160 contains an apostrophe, a comma, or backslash (other than
3161 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3162 null, do not copy; instead, return the length of what the result
3163 would have been. */
3164static YYSIZE_T
3165yytnamerr (char *yyres, const char *yystr)
3166{
3167 if (*yystr == '"')
3168 {
3169 YYSIZE_T yyn = 0;
3170 char const *yyp = yystr;
3171
3172 for (;;)
3173 switch (*++yyp)
3174 {
3175 case '\'':
3176 case ',':
3177 goto do_not_strip_quotes;
3178
3179 case '\\':
3180 if (*++yyp != '\\')
3181 goto do_not_strip_quotes;
3182 /* Fall through. */
3183 default:
3184 if (yyres)
3185 yyres[yyn] = *yyp;
3186 yyn++;
3187 break;
3188
3189 case '"':
3190 if (yyres)
3191 yyres[yyn] = '\0';
3192 return yyn;
3193 }
3194 do_not_strip_quotes: ;
3195 }
3196
3197 if (! yyres)
3198 return yystrlen (yystr);
3199
3200 return yystpcpy (yyres, yystr) - yyres;
3201}
3202# endif
3203
3204/* Copy into YYRESULT an error message about the unexpected token
3205 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3206 including the terminating null byte. If YYRESULT is null, do not
3207 copy anything; just return the number of bytes that would be
3208 copied. As a special case, return 0 if an ordinary "syntax error"
3209 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3210 size calculation. */
3211static YYSIZE_T
3212yysyntax_error (char *yyresult, int yystate, int yychar)
3213{
3214 int yyn = yypact[yystate];
3215
3216 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3217 return 0;
3218 else
3219 {
3220 int yytype = YYTRANSLATE (yychar);
3221 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3222 YYSIZE_T yysize = yysize0;
3223 YYSIZE_T yysize1;
3224 int yysize_overflow = 0;
3225 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3226 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3227 int yyx;
3228
3229# if 0
3230 /* This is so xgettext sees the translatable formats that are
3231 constructed on the fly. */
3232 YY_("syntax error, unexpected %s");
3233 YY_("syntax error, unexpected %s, expecting %s");
3234 YY_("syntax error, unexpected %s, expecting %s or %s");
3235 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3236 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3237# endif
3238 char *yyfmt;
3239 char const *yyf;
3240 static char const yyunexpected[] = "syntax error, unexpected %s";
3241 static char const yyexpecting[] = ", expecting %s";
3242 static char const yyor[] = " or %s";
3243 char yyformat[sizeof yyunexpected
3244 + sizeof yyexpecting - 1
3245 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3246 * (sizeof yyor - 1))];
3247 char const *yyprefix = yyexpecting;
3248
3249 /* Start YYX at -YYN if negative to avoid negative indexes in
3250 YYCHECK. */
3251 int yyxbegin = yyn < 0 ? -yyn : 0;
3252
3253 /* Stay within bounds of both yycheck and yytname. */
3254 int yychecklim = YYLAST - yyn + 1;
3255 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3256 int yycount = 1;
3257
3258 yyarg[0] = yytname[yytype];
3259 yyfmt = yystpcpy (yyformat, yyunexpected);
3260
3261 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3262 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3263 {
3264 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3265 {
3266 yycount = 1;
3267 yysize = yysize0;
3268 yyformat[sizeof yyunexpected - 1] = '\0';
3269 break;
3270 }
3271 yyarg[yycount++] = yytname[yyx];
3272 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3273 yysize_overflow |= (yysize1 < yysize);
3274 yysize = yysize1;
3275 yyfmt = yystpcpy (yyfmt, yyprefix);
3276 yyprefix = yyor;
3277 }
3278
3279 yyf = YY_(yyformat);
3280 yysize1 = yysize + yystrlen (yyf);
3281 yysize_overflow |= (yysize1 < yysize);
3282 yysize = yysize1;
3283
3284 if (yysize_overflow)
3285 return YYSIZE_MAXIMUM;
3286
3287 if (yyresult)
3288 {
3289 /* Avoid sprintf, as that infringes on the user's name space.
3290 Don't have undefined behavior even if the translation
3291 produced a string with the wrong number of "%s"s. */
3292 char *yyp = yyresult;
3293 int yyi = 0;
3294 while ((*yyp = *yyf) != '\0')
3295 {
3296 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3297 {
3298 yyp += yytnamerr (yyp, yyarg[yyi++]);
3299 yyf += 2;
3300 }
3301 else
3302 {
3303 yyp++;
3304 yyf++;
3305 }
3306 }
3307 }
3308 return yysize;
3309 }
3310}
3311#endif /* YYERROR_VERBOSE */
3312
3313
3314/*-----------------------------------------------.
3315| Release the memory associated to this symbol. |
3316`-----------------------------------------------*/
3317
3318/*ARGSUSED*/
3319#if (defined __STDC__ || defined __C99__FUNC__ \
3320 || defined __cplusplus || defined _MSC_VER)
3321static void
3322yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3323#else
3324static void
3325yydestruct (yymsg, yytype, yyvaluep)
3326 const char *yymsg;
3327 int yytype;
3328 YYSTYPE *yyvaluep;
3329#endif
3330{
3331 YYUSE (yyvaluep);
3332
3333 if (!yymsg)
3334 yymsg = "Deleting";
3335 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3336
3337 switch (yytype)
3338 {
3339
3340 default:
3341 break;
3342 }
3343}
3344
3345
3346/* Prevent warnings from -Wmissing-prototypes. */
3347
3348#ifdef YYPARSE_PARAM
3349#if defined __STDC__ || defined __cplusplus
3350int yyparse (void *YYPARSE_PARAM);
3351#else
3352int yyparse ();
3353#endif
3354#else /* ! YYPARSE_PARAM */
3355#if defined __STDC__ || defined __cplusplus
David Greene5fd22a82007-09-04 18:46:50 +00003356int yyparse (void);
Gabor Greife64d2482008-04-06 23:07:54 +00003357#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003358int yyparse ();
Scott Michel15dcd8e2008-01-30 03:10:00 +00003359#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003360#endif /* ! YYPARSE_PARAM */
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003361
Chris Lattner38905612008-02-19 04:36:25 +00003362
Dan Gohmanf4423b12008-04-19 00:24:39 +00003363
3364/* The look-ahead symbol. */
3365int yychar;
3366
3367/* The semantic value of the look-ahead symbol. */
3368YYSTYPE yylval;
3369
3370/* Number of syntax errors so far. */
3371int yynerrs;
3372
3373
3374
3375/*----------.
3376| yyparse. |
3377`----------*/
3378
3379#ifdef YYPARSE_PARAM
3380#if (defined __STDC__ || defined __C99__FUNC__ \
3381 || defined __cplusplus || defined _MSC_VER)
3382int
3383yyparse (void *YYPARSE_PARAM)
3384#else
3385int
3386yyparse (YYPARSE_PARAM)
3387 void *YYPARSE_PARAM;
3388#endif
3389#else /* ! YYPARSE_PARAM */
3390#if (defined __STDC__ || defined __C99__FUNC__ \
3391 || defined __cplusplus || defined _MSC_VER)
3392int
3393yyparse (void)
3394#else
3395int
3396yyparse ()
3397
Gabor Greife64d2482008-04-06 23:07:54 +00003398#endif
3399#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003400{
3401
3402 int yystate;
3403 int yyn;
3404 int yyresult;
3405 /* Number of tokens to shift before error messages enabled. */
3406 int yyerrstatus;
3407 /* Look-ahead token as an internal (translated) token number. */
3408 int yytoken = 0;
3409#if YYERROR_VERBOSE
3410 /* Buffer for error messages, and its allocated size. */
3411 char yymsgbuf[128];
3412 char *yymsg = yymsgbuf;
3413 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greife64d2482008-04-06 23:07:54 +00003414#endif
Chris Lattner38905612008-02-19 04:36:25 +00003415
Dan Gohmanf4423b12008-04-19 00:24:39 +00003416 /* Three stacks and their tools:
3417 `yyss': related to states,
3418 `yyvs': related to semantic values,
3419 `yyls': related to locations.
3420
3421 Refer to the stacks thru separate pointers, to allow yyoverflow
3422 to reallocate them elsewhere. */
3423
3424 /* The state stack. */
3425 yytype_int16 yyssa[YYINITDEPTH];
3426 yytype_int16 *yyss = yyssa;
3427 yytype_int16 *yyssp;
3428
3429 /* The semantic value stack. */
3430 YYSTYPE yyvsa[YYINITDEPTH];
3431 YYSTYPE *yyvs = yyvsa;
3432 YYSTYPE *yyvsp;
3433
3434
3435
3436#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3437
3438 YYSIZE_T yystacksize = YYINITDEPTH;
3439
3440 /* The variables used to return semantic value and location from the
3441 action routines. */
3442 YYSTYPE yyval;
3443
3444
3445 /* The number of symbols on the RHS of the reduced rule.
3446 Keep to zero when no symbol should be popped. */
3447 int yylen = 0;
3448
3449 YYDPRINTF ((stderr, "Starting parse\n"));
3450
Reid Spencer68a24bd2005-08-27 18:50:39 +00003451 yystate = 0;
3452 yyerrstatus = 0;
3453 yynerrs = 0;
3454 yychar = YYEMPTY; /* Cause a token to be read. */
3455
3456 /* Initialize stack pointers.
3457 Waste one element of value and location stack
3458 so that they stay on the same level as the state stack.
3459 The wasted elements are never initialized. */
3460
Dan Gohmanf4423b12008-04-19 00:24:39 +00003461 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003462 yyvsp = yyvs;
3463
Dan Gohmanf4423b12008-04-19 00:24:39 +00003464 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003465
Dan Gohmanf4423b12008-04-19 00:24:39 +00003466/*------------------------------------------------------------.
3467| yynewstate -- Push a new state, which is found in yystate. |
3468`------------------------------------------------------------*/
3469 yynewstate:
3470 /* In all cases, when you get here, the value and location stacks
3471 have just been pushed. So pushing a state here evens the stacks. */
3472 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003473
Dan Gohmanf4423b12008-04-19 00:24:39 +00003474 yysetstate:
3475 *yyssp = yystate;
3476
3477 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003478 {
3479 /* Get the current used size of the three stacks, in elements. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003480 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003481
3482#ifdef yyoverflow
Dan Gohmanf4423b12008-04-19 00:24:39 +00003483 {
3484 /* Give user a chance to reallocate the stack. Use copies of
3485 these so that the &'s don't force the real ones into
3486 memory. */
3487 YYSTYPE *yyvs1 = yyvs;
3488 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003489
Dan Gohmanf4423b12008-04-19 00:24:39 +00003490
3491 /* Each stack pointer address is followed by the size of the
3492 data in use in that stack, in bytes. This used to be a
3493 conditional around just the two extra args, but that might
3494 be undefined if yyoverflow is a macro. */
3495 yyoverflow (YY_("memory exhausted"),
3496 &yyss1, yysize * sizeof (*yyssp),
3497 &yyvs1, yysize * sizeof (*yyvsp),
3498
3499 &yystacksize);
3500
3501 yyss = yyss1;
3502 yyvs = yyvs1;
3503 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003504#else /* no yyoverflow */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003505# ifndef YYSTACK_RELOCATE
3506 goto yyexhaustedlab;
3507# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003508 /* Extend the stack our own way. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003509 if (YYMAXDEPTH <= yystacksize)
3510 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003511 yystacksize *= 2;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003512 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003513 yystacksize = YYMAXDEPTH;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003514
3515 {
3516 yytype_int16 *yyss1 = yyss;
3517 union yyalloc *yyptr =
3518 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3519 if (! yyptr)
3520 goto yyexhaustedlab;
3521 YYSTACK_RELOCATE (yyss);
3522 YYSTACK_RELOCATE (yyvs);
3523
3524# undef YYSTACK_RELOCATE
3525 if (yyss1 != yyssa)
3526 YYSTACK_FREE (yyss1);
3527 }
3528# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003529#endif /* no yyoverflow */
3530
Dan Gohmanf4423b12008-04-19 00:24:39 +00003531 yyssp = yyss + yysize - 1;
3532 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003533
3534
Dan Gohmanf4423b12008-04-19 00:24:39 +00003535 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3536 (unsigned long int) yystacksize));
3537
3538 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003539 YYABORT;
3540 }
3541
Dan Gohmanf4423b12008-04-19 00:24:39 +00003542 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003543
3544 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003545
Dan Gohmanf4423b12008-04-19 00:24:39 +00003546/*-----------.
3547| yybackup. |
3548`-----------*/
3549yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003550
Dan Gohmanf4423b12008-04-19 00:24:39 +00003551 /* Do appropriate processing given the current state. Read a
3552 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003553
Dan Gohmanf4423b12008-04-19 00:24:39 +00003554 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003555 yyn = yypact[yystate];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003556 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003557 goto yydefault;
3558
Dan Gohmanf4423b12008-04-19 00:24:39 +00003559 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003560
Dan Gohmanf4423b12008-04-19 00:24:39 +00003561 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003562 if (yychar == YYEMPTY)
3563 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003564 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003565 yychar = YYLEX;
3566 }
3567
Dan Gohmanf4423b12008-04-19 00:24:39 +00003568 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003569 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003570 yychar = yytoken = YYEOF;
3571 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003572 }
3573 else
3574 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003575 yytoken = YYTRANSLATE (yychar);
3576 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003577 }
3578
Dan Gohmanf4423b12008-04-19 00:24:39 +00003579 /* If the proper action on seeing token YYTOKEN is to reduce or to
3580 detect an error, take that action. */
3581 yyn += yytoken;
3582 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003583 goto yydefault;
3584 yyn = yytable[yyn];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003585 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003586 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003587 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003588 goto yyerrlab;
3589 yyn = -yyn;
3590 goto yyreduce;
3591 }
3592
3593 if (yyn == YYFINAL)
3594 YYACCEPT;
3595
Dan Gohmanf4423b12008-04-19 00:24:39 +00003596 /* Count tokens shifted since error; after three, turn off error
3597 status. */
3598 if (yyerrstatus)
3599 yyerrstatus--;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003600
Dan Gohmanf4423b12008-04-19 00:24:39 +00003601 /* Shift the look-ahead token. */
3602 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003603
Dan Gohmanf4423b12008-04-19 00:24:39 +00003604 /* Discard the shifted token unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003605 if (yychar != YYEOF)
3606 yychar = YYEMPTY;
3607
Gabor Greife64d2482008-04-06 23:07:54 +00003608 yystate = yyn;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003609 *++yyvsp = yylval;
3610
Reid Spencer68a24bd2005-08-27 18:50:39 +00003611 goto yynewstate;
3612
Gabor Greife64d2482008-04-06 23:07:54 +00003613
Dan Gohmanf4423b12008-04-19 00:24:39 +00003614/*-----------------------------------------------------------.
3615| yydefault -- do the default action for the current state. |
3616`-----------------------------------------------------------*/
3617yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003618 yyn = yydefact[yystate];
3619 if (yyn == 0)
3620 goto yyerrlab;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003621 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003622
Dan Gohmanf4423b12008-04-19 00:24:39 +00003623
3624/*-----------------------------.
3625| yyreduce -- Do a reduction. |
3626`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003627yyreduce:
Dan Gohmanf4423b12008-04-19 00:24:39 +00003628 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003629 yylen = yyr2[yyn];
3630
Dan Gohmanf4423b12008-04-19 00:24:39 +00003631 /* If YYLEN is nonzero, implement the default value of the action:
3632 `$$ = $1'.
3633
3634 Otherwise, the following line sets YYVAL to garbage.
3635 This behavior is undocumented and Bison
3636 users should not rely upon it. Assigning to YYVAL
3637 unconditionally makes the parser a bit smaller, and it avoids a
3638 GCC warning that YYVAL may be used uninitialized. */
3639 yyval = yyvsp[1-yylen];
3640
3641
3642 YY_REDUCE_PRINT (yyn);
3643 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003644 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003645 case 29:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003646#line 1146 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003647 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3648 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003649
Dan Gohmanf4423b12008-04-19 00:24:39 +00003650 case 30:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003651#line 1146 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003652 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3653 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003654
Dan Gohmanf4423b12008-04-19 00:24:39 +00003655 case 31:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003656#line 1147 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003657 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3658 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003659
Dan Gohmanf4423b12008-04-19 00:24:39 +00003660 case 32:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003661#line 1147 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003662 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3663 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003664
Dan Gohmanf4423b12008-04-19 00:24:39 +00003665 case 33:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003666#line 1148 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003667 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3668 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003669
Dan Gohmanf4423b12008-04-19 00:24:39 +00003670 case 34:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003671#line 1148 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003672 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3673 break;
3674
3675 case 35:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003676#line 1149 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003677 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3678 break;
3679
3680 case 36:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003681#line 1149 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003682 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3683 break;
3684
3685 case 37:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003686#line 1150 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003687 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3688 break;
3689
3690 case 38:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003691#line 1150 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003692 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3693 break;
3694
3695 case 39:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003696#line 1154 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003697 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3698 break;
3699
3700 case 40:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003701#line 1154 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003702 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3703 break;
3704
3705 case 41:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003706#line 1155 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003707 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3708 break;
3709
3710 case 42:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003711#line 1155 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003712 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3713 break;
3714
3715 case 43:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003716#line 1156 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003717 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3718 break;
3719
3720 case 44:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003721#line 1156 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003722 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3723 break;
3724
3725 case 45:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003726#line 1157 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003727 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3728 break;
3729
3730 case 46:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003731#line 1157 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003732 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3733 break;
3734
3735 case 47:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003736#line 1158 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003737 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3738 break;
3739
3740 case 48:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003741#line 1158 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003742 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3743 break;
3744
3745 case 49:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003746#line 1159 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003747 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3748 break;
3749
3750 case 50:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003751#line 1159 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003752 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3753 break;
3754
3755 case 51:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003756#line 1160 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003757 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3758 break;
3759
3760 case 52:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003761#line 1160 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003762 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3763 break;
3764
3765 case 53:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003766#line 1161 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003767 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3768 break;
3769
3770 case 54:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003771#line 1162 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003772 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3773 break;
3774
3775 case 65:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003776#line 1171 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003777 { (yyval.StrVal) = 0; ;}
3778 break;
3779
3780 case 66:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003781#line 1173 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003782 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3783 break;
3784
3785 case 67:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003786#line 1174 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003787 { (yyval.UIntVal)=0; ;}
3788 break;
3789
3790 case 68:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003791#line 1178 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003792 {
3793 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003794 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003795 ;}
3796 break;
3797
3798 case 69:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003799#line 1182 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003800 {
3801 (yyval.StrVal) = 0;
Christopher Lambbf3348d2007-12-12 08:45:45 +00003802 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003803 ;}
3804 break;
3805
Chris Lattner15bd0952008-08-29 17:20:18 +00003806 case 70:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003807#line 1187 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003808 {
Chris Lattner15bd0952008-08-29 17:20:18 +00003809 (yyval.UIntVal) = (yyvsp[(1) - (2)].UIntVal);
3810 CHECK_FOR_ERROR
3811;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003812 break;
3813
3814 case 74:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003815#line 1196 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003816 {
3817 (yyval.StrVal) = 0;
3818 CHECK_FOR_ERROR
3819 ;}
3820 break;
3821
3822 case 75:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003823#line 1201 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003824 {
3825 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00003826 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003827 ;}
3828 break;
3829
Chris Lattner15bd0952008-08-29 17:20:18 +00003830 case 76:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003831#line 1207 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003832 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3833 break;
3834
Chris Lattner15bd0952008-08-29 17:20:18 +00003835 case 77:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003836#line 1208 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003837 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3838 break;
3839
Chris Lattner15bd0952008-08-29 17:20:18 +00003840 case 78:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003841#line 1209 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003842 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3843 break;
3844
Chris Lattner15bd0952008-08-29 17:20:18 +00003845 case 79:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003846#line 1210 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003847 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3848 break;
3849
Chris Lattner15bd0952008-08-29 17:20:18 +00003850 case 80:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003851#line 1211 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003852 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3853 break;
3854
Chris Lattner15bd0952008-08-29 17:20:18 +00003855 case 81:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003856#line 1212 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003857 { (yyval.Linkage) = GlobalValue::CommonLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003858 break;
3859
Chris Lattner15bd0952008-08-29 17:20:18 +00003860 case 82:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003861#line 1216 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003862 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003863 break;
3864
Chris Lattner15bd0952008-08-29 17:20:18 +00003865 case 83:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003866#line 1217 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003867 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003868 break;
3869
Chris Lattner15bd0952008-08-29 17:20:18 +00003870 case 84:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003871#line 1218 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003872 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003873 break;
3874
Dan Gohmanf4423b12008-04-19 00:24:39 +00003875 case 85:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003876#line 1222 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003877 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003878 break;
3879
3880 case 86:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003881#line 1223 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003882 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003883 break;
3884
3885 case 87:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003886#line 1224 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003887 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003888 break;
3889
3890 case 88:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003891#line 1225 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003892 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003893 break;
3894
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003895 case 89:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003896#line 1229 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003897 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003898 break;
3899
3900 case 90:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003901#line 1230 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003902 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003903 break;
3904
3905 case 91:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003906#line 1231 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003907 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003908 break;
3909
3910 case 92:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003911#line 1235 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003912 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3913 break;
3914
Chris Lattner15bd0952008-08-29 17:20:18 +00003915 case 93:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003916#line 1236 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003917 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003918 break;
3919
Chris Lattner15bd0952008-08-29 17:20:18 +00003920 case 94:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003921#line 1237 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003922 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3923 break;
3924
3925 case 95:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003926#line 1238 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003927 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3928 break;
3929
3930 case 96:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003931#line 1239 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003932 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3933 break;
3934
3935 case 97:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003936#line 1243 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003937 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3938 break;
3939
3940 case 98:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003941#line 1244 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003942 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3943 break;
3944
Dan Gohmanf4423b12008-04-19 00:24:39 +00003945 case 99:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003946#line 1245 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003947 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003948 break;
3949
3950 case 100:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003951#line 1248 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003952 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003953 break;
3954
3955 case 101:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003956#line 1249 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003957 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003958 break;
3959
3960 case 102:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003961#line 1250 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003962 { (yyval.UIntVal) = CallingConv::Fast; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003963 break;
3964
3965 case 103:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003966#line 1251 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003967 { (yyval.UIntVal) = CallingConv::Cold; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003968 break;
3969
3970 case 104:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003971#line 1252 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003972 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003973 break;
3974
3975 case 105:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003976#line 1253 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00003977 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00003978 break;
3979
3980 case 106:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003981#line 1254 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003982 {
3983 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003984 GEN_ERROR("Calling conv too large");
Dan Gohmanf4423b12008-04-19 00:24:39 +00003985 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003986 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003987 ;}
3988 break;
3989
Dale Johannesendfe8c842008-09-26 19:32:34 +00003990 case 107:
3991#line 1261 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3992 { (yyval.Attributes) = Attribute::ZExt; ;}
3993 break;
3994
Dan Gohmanf4423b12008-04-19 00:24:39 +00003995 case 108:
Dale Johannesendfe8c842008-09-26 19:32:34 +00003996#line 1262 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00003997 { (yyval.Attributes) = Attribute::ZExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003998 break;
3999
4000 case 109:
Dale Johannesendfe8c842008-09-26 19:32:34 +00004001#line 1263 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4002 { (yyval.Attributes) = Attribute::SExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004003 break;
4004
4005 case 110:
Dale Johannesendfe8c842008-09-26 19:32:34 +00004006#line 1264 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004007 { (yyval.Attributes) = Attribute::SExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004008 break;
4009
4010 case 111:
Dale Johannesendfe8c842008-09-26 19:32:34 +00004011#line 1265 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004012 { (yyval.Attributes) = Attribute::InReg; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004013 break;
4014
Dale Johannesendfe8c842008-09-26 19:32:34 +00004015 case 112:
4016#line 1266 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004017 { (yyval.Attributes) = Attribute::StructRet; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004018 break;
4019
Dale Johannesendfe8c842008-09-26 19:32:34 +00004020 case 113:
4021#line 1267 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004022 { (yyval.Attributes) = Attribute::NoAlias; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004023 break;
4024
Dale Johannesendfe8c842008-09-26 19:32:34 +00004025 case 114:
4026#line 1268 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004027 { (yyval.Attributes) = Attribute::ByVal; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004028 break;
4029
Dale Johannesendfe8c842008-09-26 19:32:34 +00004030 case 115:
4031#line 1269 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004032 { (yyval.Attributes) = Attribute::Nest; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004033 break;
4034
Dale Johannesendfe8c842008-09-26 19:32:34 +00004035 case 116:
4036#line 1270 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004037 { (yyval.Attributes) =
4038 Attribute::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004039 break;
4040
Dale Johannesendfe8c842008-09-26 19:32:34 +00004041 case 117:
4042#line 1274 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004043 { (yyval.Attributes) = Attribute::None; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004044 break;
4045
Dale Johannesendfe8c842008-09-26 19:32:34 +00004046 case 118:
4047#line 1275 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4048 {
4049 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
4050 ;}
4051 break;
4052
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004053 case 119:
Dale Johannesendfe8c842008-09-26 19:32:34 +00004054#line 1280 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004055 { (yyval.Attributes) = Attribute::NoReturn; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004056 break;
4057
Dale Johannesendfe8c842008-09-26 19:32:34 +00004058 case 120:
4059#line 1281 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004060 { (yyval.Attributes) = Attribute::NoUnwind; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004061 break;
4062
Dale Johannesendfe8c842008-09-26 19:32:34 +00004063 case 121:
4064#line 1282 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004065 { (yyval.Attributes) = Attribute::InReg; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004066 break;
4067
Dale Johannesendfe8c842008-09-26 19:32:34 +00004068 case 122:
4069#line 1283 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004070 { (yyval.Attributes) = Attribute::ZExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004071 break;
4072
Dale Johannesendfe8c842008-09-26 19:32:34 +00004073 case 123:
4074#line 1284 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004075 { (yyval.Attributes) = Attribute::SExt; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004076 break;
4077
Dale Johannesendfe8c842008-09-26 19:32:34 +00004078 case 124:
4079#line 1285 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004080 { (yyval.Attributes) = Attribute::ReadNone; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004081 break;
4082
Dale Johannesendfe8c842008-09-26 19:32:34 +00004083 case 125:
4084#line 1286 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004085 { (yyval.Attributes) = Attribute::ReadOnly; ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004086 break;
4087
Dale Johannesendfe8c842008-09-26 19:32:34 +00004088 case 126:
4089#line 1289 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004090 { (yyval.Attributes) = Attribute::None; ;}
Chris Lattnerccef6b52008-09-23 21:18:31 +00004091 break;
4092
Dale Johannesendfe8c842008-09-26 19:32:34 +00004093 case 127:
4094#line 1290 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004095 {
Devang Patel05988662008-09-25 21:00:45 +00004096 (yyval.Attributes) = (yyvsp[(1) - (2)].Attributes) | (yyvsp[(2) - (2)].Attributes);
Chris Lattner15bd0952008-08-29 17:20:18 +00004097 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004098 break;
4099
Dale Johannesendfe8c842008-09-26 19:32:34 +00004100 case 128:
4101#line 1295 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004102 { (yyval.Attributes) = (yyvsp[(1) - (1)].Attributes); ;}
Chris Lattner15bd0952008-08-29 17:20:18 +00004103 break;
4104
Dale Johannesendfe8c842008-09-26 19:32:34 +00004105 case 129:
4106#line 1296 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00004107 {
Devang Patel05988662008-09-25 21:00:45 +00004108 unsigned tmp = (yyvsp[(1) - (3)].Attributes) | (yyvsp[(3) - (3)].Attributes);
4109 if ((yyvsp[(3) - (3)].Attributes) == Attribute::NoInline
4110 && ((yyvsp[(1) - (3)].Attributes) & Attribute::AlwaysInline))
Devang Pateld4980812008-09-02 20:52:40 +00004111 GEN_ERROR("Function Notes may include only one inline notes!")
Devang Patel05988662008-09-25 21:00:45 +00004112 if ((yyvsp[(3) - (3)].Attributes) == Attribute::AlwaysInline
4113 && ((yyvsp[(1) - (3)].Attributes) & Attribute::NoInline))
Devang Pateld4980812008-09-02 20:52:40 +00004114 GEN_ERROR("Function Notes may include only one inline notes!")
Devang Patel05988662008-09-25 21:00:45 +00004115 (yyval.Attributes) = tmp;
Eric Christopher2a5196f2008-09-24 04:55:49 +00004116 CHECK_FOR_ERROR
Devang Pateld4980812008-09-02 20:52:40 +00004117 ;}
4118 break;
4119
Dale Johannesendfe8c842008-09-26 19:32:34 +00004120 case 130:
4121#line 1309 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004122 { (yyval.Attributes) = Attribute::NoInline; ;}
Devang Pateld4980812008-09-02 20:52:40 +00004123 break;
4124
Dale Johannesendfe8c842008-09-26 19:32:34 +00004125 case 131:
4126#line 1310 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004127 { (yyval.Attributes) = Attribute::AlwaysInline; ;}
Devang Pateld4980812008-09-02 20:52:40 +00004128 break;
4129
Dale Johannesendfe8c842008-09-26 19:32:34 +00004130 case 132:
4131#line 1311 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004132 { (yyval.Attributes) = Attribute::OptimizeForSize; ;}
Devang Pateld4980812008-09-02 20:52:40 +00004133 break;
4134
Dale Johannesendfe8c842008-09-26 19:32:34 +00004135 case 133:
4136#line 1314 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Patel05988662008-09-25 21:00:45 +00004137 { (yyval.Attributes) = Attribute::None; ;}
Devang Pateld4980812008-09-02 20:52:40 +00004138 break;
4139
Dale Johannesendfe8c842008-09-26 19:32:34 +00004140 case 134:
4141#line 1315 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld4980812008-09-02 20:52:40 +00004142 {
Devang Patel05988662008-09-25 21:00:45 +00004143 (yyval.Attributes) = (yyvsp[(3) - (4)].Attributes);
Devang Pateld4980812008-09-02 20:52:40 +00004144 ;}
4145 break;
4146
Dale Johannesendfe8c842008-09-26 19:32:34 +00004147 case 135:
4148#line 1320 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Devang Pateld4980812008-09-02 20:52:40 +00004149 { (yyval.StrVal) = 0; ;}
4150 break;
4151
Dale Johannesendfe8c842008-09-26 19:32:34 +00004152 case 136:
4153#line 1321 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004154 {
4155 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4156 ;}
4157 break;
4158
Dale Johannesendfe8c842008-09-26 19:32:34 +00004159 case 137:
4160#line 1328 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004161 { (yyval.UIntVal) = 0; ;}
4162 break;
4163
Dale Johannesendfe8c842008-09-26 19:32:34 +00004164 case 138:
4165#line 1329 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004166 {
4167 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4168 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004169 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004170 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004171;}
4172 break;
4173
Dale Johannesendfe8c842008-09-26 19:32:34 +00004174 case 139:
4175#line 1335 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004176 { (yyval.UIntVal) = 0; ;}
4177 break;
4178
Dale Johannesendfe8c842008-09-26 19:32:34 +00004179 case 140:
4180#line 1336 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004181 {
4182 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4183 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lambbf3348d2007-12-12 08:45:45 +00004184 GEN_ERROR("Alignment must be a power of two");
4185 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004186;}
4187 break;
4188
Dale Johannesendfe8c842008-09-26 19:32:34 +00004189 case 141:
4190#line 1345 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004191 {
4192 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
4193 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004194 GEN_ERROR("Invalid character in section name");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004195 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004196 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004197;}
4198 break;
4199
Dale Johannesendfe8c842008-09-26 19:32:34 +00004200 case 142:
4201#line 1353 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004202 { (yyval.StrVal) = 0; ;}
4203 break;
4204
Dale Johannesendfe8c842008-09-26 19:32:34 +00004205 case 143:
4206#line 1354 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004207 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4208 break;
4209
Dale Johannesendfe8c842008-09-26 19:32:34 +00004210 case 144:
4211#line 1359 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4212 {;}
4213 break;
4214
Devang Pateld4980812008-09-02 20:52:40 +00004215 case 145:
Dale Johannesendfe8c842008-09-26 19:32:34 +00004216#line 1360 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00004217 {;}
4218 break;
4219
Devang Pateld4980812008-09-02 20:52:40 +00004220 case 146:
Dale Johannesendfe8c842008-09-26 19:32:34 +00004221#line 1361 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004222 {
4223 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4224 delete (yyvsp[(1) - (1)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004225 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004226 ;}
4227 break;
4228
Dale Johannesendfe8c842008-09-26 19:32:34 +00004229 case 147:
4230#line 1366 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004231 {
4232 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004233 GEN_ERROR("Alignment must be a power of two");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004234 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004235 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004236 ;}
4237 break;
4238
Dale Johannesendfe8c842008-09-26 19:32:34 +00004239 case 155:
4240#line 1382 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004241 {
4242 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004243 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004244 ;}
4245 break;
4246
Dale Johannesendfe8c842008-09-26 19:32:34 +00004247 case 156:
4248#line 1386 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004249 {
4250 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004251 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004252 ;}
4253 break;
4254
Dale Johannesendfe8c842008-09-26 19:32:34 +00004255 case 157:
4256#line 1390 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004257 { // Pointer type?
4258 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lambbf3348d2007-12-12 08:45:45 +00004259 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004260 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4261 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00004262 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004263 ;}
4264 break;
4265
Dale Johannesendfe8c842008-09-26 19:32:34 +00004266 case 158:
4267#line 1397 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004268 { // Named types are also simple types...
4269 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004270 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004271 (yyval.TypeVal) = new PATypeHolder(tmp);
4272 ;}
4273 break;
4274
Dale Johannesendfe8c842008-09-26 19:32:34 +00004275 case 159:
4276#line 1402 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004277 { // Type UpReference
4278 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004279 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohmanf4423b12008-04-19 00:24:39 +00004280 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4281 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004282 UR_OUT("New Upreference!\n");
4283 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004284 ;}
4285 break;
4286
Dale Johannesendfe8c842008-09-26 19:32:34 +00004287 case 160:
4288#line 1410 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004289 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004290 // Allow but ignore attributes on function types; this permits auto-upgrade.
4291 // FIXME: remove in LLVM 3.0.
Chris Lattnera925a142008-04-23 05:37:08 +00004292 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4293 if (!FunctionType::isValidReturnType(RetTy))
4294 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004295
Reid Spencer41dff5e2007-01-26 08:05:27 +00004296 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004297 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004298 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004299 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004300 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004301 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004302
Reid Spencer41dff5e2007-01-26 08:05:27 +00004303 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4304 if (isVarArg) Params.pop_back();
4305
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004306 for (unsigned i = 0; i != Params.size(); ++i)
4307 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4308 GEN_ERROR("Function arguments must be value types!");
4309
4310 CHECK_FOR_ERROR
4311
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004312 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004313 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4314 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
Eric Christopher2a5196f2008-09-24 04:55:49 +00004315 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004316 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004317 ;}
4318 break;
4319
Dale Johannesendfe8c842008-09-26 19:32:34 +00004320 case 161:
4321#line 1439 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004322 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004323 // Allow but ignore attributes on function types; this permits auto-upgrade.
4324 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004325 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004326 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004327 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004328 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004329 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004330 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004331
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004332 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4333 if (isVarArg) Params.pop_back();
4334
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004335 for (unsigned i = 0; i != Params.size(); ++i)
4336 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4337 GEN_ERROR("Function arguments must be value types!");
4338
4339 CHECK_FOR_ERROR
4340
Dan Gohmanf4423b12008-04-19 00:24:39 +00004341 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
4342 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
Eric Christopher2a5196f2008-09-24 04:55:49 +00004343 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004344 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004345 ;}
4346 break;
4347
Dale Johannesendfe8c842008-09-26 19:32:34 +00004348 case 162:
4349#line 1464 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004350 { // Sized array type?
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004351 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (yyvsp[(2) - (5)].UInt64Val))));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004352 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004353 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004354 ;}
4355 break;
4356
Dale Johannesendfe8c842008-09-26 19:32:34 +00004357 case 163:
4358#line 1469 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004359 { // Vector type?
4360 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4361 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004362 GEN_ERROR("Unsigned result not equal to signed result");
4363 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4364 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004365 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4366 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004367 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004368 ;}
4369 break;
4370
Dale Johannesendfe8c842008-09-26 19:32:34 +00004371 case 164:
4372#line 1479 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004373 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004374 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004375 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4376 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004377 Elements.push_back(*I);
4378
Dan Gohmanf4423b12008-04-19 00:24:39 +00004379 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4380 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004381 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004382 ;}
4383 break;
4384
Dale Johannesendfe8c842008-09-26 19:32:34 +00004385 case 165:
4386#line 1489 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004387 { // Empty structure type?
4388 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004389 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004390 ;}
4391 break;
4392
Dale Johannesendfe8c842008-09-26 19:32:34 +00004393 case 166:
4394#line 1493 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004395 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004396 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004397 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4398 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004399 Elements.push_back(*I);
4400
Dan Gohmanf4423b12008-04-19 00:24:39 +00004401 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4402 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004403 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004404 ;}
4405 break;
4406
Dale Johannesendfe8c842008-09-26 19:32:34 +00004407 case 167:
4408#line 1503 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004409 { // Empty structure type?
4410 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004411 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004412 ;}
4413 break;
4414
Dale Johannesendfe8c842008-09-26 19:32:34 +00004415 case 168:
4416#line 1510 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004417 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004418 // Allow but ignore attributes on function types; this permits auto-upgrade.
4419 // FIXME: remove in LLVM 3.0.
Eric Christopher2a5196f2008-09-24 04:55:49 +00004420 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
Devang Patel05988662008-09-25 21:00:45 +00004421 (yyval.TypeWithAttrs).Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004422 ;}
4423 break;
4424
Dale Johannesendfe8c842008-09-26 19:32:34 +00004425 case 169:
4426#line 1519 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004427 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004428 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004429 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4430 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004431 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004432 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4433 ;}
4434 break;
4435
Dale Johannesendfe8c842008-09-26 19:32:34 +00004436 case 170:
4437#line 1526 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004438 {
4439 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4440 ;}
4441 break;
4442
Dale Johannesendfe8c842008-09-26 19:32:34 +00004443 case 171:
4444#line 1531 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004445 {
4446 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4447 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004448 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004449 ;}
4450 break;
4451
Dale Johannesendfe8c842008-09-26 19:32:34 +00004452 case 172:
4453#line 1536 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004454 {
4455 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004456 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004457 ;}
4458 break;
4459
Dale Johannesendfe8c842008-09-26 19:32:34 +00004460 case 174:
4461#line 1544 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004462 {
4463 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Devang Patel05988662008-09-25 21:00:45 +00004464 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004465 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004466 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004467 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004468 ;}
4469 break;
4470
Dale Johannesendfe8c842008-09-26 19:32:34 +00004471 case 175:
4472#line 1551 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004473 {
4474 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Devang Patel05988662008-09-25 21:00:45 +00004475 TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +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
Dale Johannesendfe8c842008-09-26 19:32:34 +00004482 case 176:
4483#line 1558 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004484 {
4485 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004486 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004487 ;}
4488 break;
4489
Dale Johannesendfe8c842008-09-26 19:32:34 +00004490 case 177:
4491#line 1566 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004492 {
4493 (yyval.TypeList) = new std::list<PATypeHolder>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004494 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004495 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004496 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004497 ;}
4498 break;
4499
Dale Johannesendfe8c842008-09-26 19:32:34 +00004500 case 178:
4501#line 1572 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004502 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00004503 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004504 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004505 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004506 ;}
4507 break;
4508
Dale Johannesendfe8c842008-09-26 19:32:34 +00004509 case 179:
4510#line 1584 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004511 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004512 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004513 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4514 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004515 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004516 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004517 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004518 const Type *ETy = ATy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004519 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004520
4521 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004522 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004523 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004524 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004525 utostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004526
4527 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004528 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4529 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004530 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004531 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004532 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004533 }
4534
Dan Gohmanf4423b12008-04-19 00:24:39 +00004535 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4536 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004537 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004538 ;}
4539 break;
4540
Dale Johannesendfe8c842008-09-26 19:32:34 +00004541 case 180:
4542#line 1612 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004543 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004544 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004545 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4546 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004547 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004548 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004549 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004550
Dan Gohman180c1692008-06-23 18:43:26 +00004551 uint64_t NumElements = ATy->getNumElements();
Eric Christopher2a5196f2008-09-24 04:55:49 +00004552 if (NumElements != uint64_t(-1) && NumElements != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004553 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Mon P Wang28873102008-06-25 08:15:39 +00004554 " arguments, but has size of " + utostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004555 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4556 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004557 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004558 ;}
4559 break;
4560
Dale Johannesendfe8c842008-09-26 19:32:34 +00004561 case 181:
4562#line 1628 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004563 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004564 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004565 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4566 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004567 if (ATy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004568 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004569 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004570
Dan Gohman180c1692008-06-23 18:43:26 +00004571 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004572 const Type *ETy = ATy->getElementType();
Mon P Wang28873102008-06-25 08:15:39 +00004573 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (3)].StrVal)->length())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004574 GEN_ERROR("Can't build string constant of size " +
Mon P Wang28873102008-06-25 08:15:39 +00004575 utostr((yyvsp[(3) - (3)].StrVal)->length()) +
4576 " when array has size " + utostr(NumElements) + "");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004577 std::vector<Constant*> Vals;
4578 if (ETy == Type::Int8Ty) {
Mon P Wang28873102008-06-25 08:15:39 +00004579 for (uint64_t i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004580 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004581 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004582 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004583 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4584 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004585 delete (yyvsp[(3) - (3)].StrVal);
4586 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4587 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004588 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004589 ;}
4590 break;
4591
Dale Johannesendfe8c842008-09-26 19:32:34 +00004592 case 182:
4593#line 1655 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004594 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004595 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004596 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4597 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004598 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004599 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004600 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004601 const Type *ETy = PTy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004602 unsigned NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004603
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004604 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004605 if (NumElements != unsigned(-1) && NumElements != (unsigned)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004606 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004607 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004608 utostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004609
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004610 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004611 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4612 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004613 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004614 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004615 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004616 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004617
Dan Gohmanf4423b12008-04-19 00:24:39 +00004618 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4619 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004620 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004621 ;}
4622 break;
4623
Dale Johannesendfe8c842008-09-26 19:32:34 +00004624 case 183:
4625#line 1683 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004626 {
4627 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004628 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004629 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004630 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004631
Dan Gohmanf4423b12008-04-19 00:24:39 +00004632 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004633 GEN_ERROR("Illegal number of initializers for structure type");
4634
4635 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004636 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4637 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004638 GEN_ERROR("Expected type '" +
4639 STy->getElementType(i)->getDescription() +
4640 "' for element #" + utostr(i) +
4641 " of structure initializer");
4642
4643 // Check to ensure that Type is not packed
4644 if (STy->isPacked())
4645 GEN_ERROR("Unpacked Initializer to vector type '" +
4646 STy->getDescription() + "'");
4647
Dan Gohmanf4423b12008-04-19 00:24:39 +00004648 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4649 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004650 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004651 ;}
4652 break;
4653
Dale Johannesendfe8c842008-09-26 19:32:34 +00004654 case 184:
4655#line 1709 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004656 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004657 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004658 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4659 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004660 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004661 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004662 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004663
4664 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004665 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004666
4667 // Check to ensure that Type is not packed
4668 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004669 GEN_ERROR("Unpacked Initializer to vector type '" +
4670 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004671
Dan Gohmanf4423b12008-04-19 00:24:39 +00004672 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4673 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004674 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004675 ;}
4676 break;
4677
Dale Johannesendfe8c842008-09-26 19:32:34 +00004678 case 185:
4679#line 1729 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004680 {
4681 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004682 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004683 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004684 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004685
Dan Gohmanf4423b12008-04-19 00:24:39 +00004686 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004687 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004688
4689 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004690 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4691 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004692 GEN_ERROR("Expected type '" +
4693 STy->getElementType(i)->getDescription() +
4694 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004695 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004696
4697 // Check to ensure that Type is packed
4698 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004699 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004700 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004701
Dan Gohmanf4423b12008-04-19 00:24:39 +00004702 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4703 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004704 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004705 ;}
4706 break;
4707
Dale Johannesendfe8c842008-09-26 19:32:34 +00004708 case 186:
4709#line 1755 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004710 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004711 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004712 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4713 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004714 if (STy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004715 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004716 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004717
4718 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004719 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004720
4721 // Check to ensure that Type is packed
4722 if (!STy->isPacked())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004723 GEN_ERROR("Vector initializer to non-vector type '" +
Chris Lattner32980692007-02-19 07:44:24 +00004724 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004725
Dan Gohmanf4423b12008-04-19 00:24:39 +00004726 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4727 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004728 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004729 ;}
4730 break;
4731
Dale Johannesendfe8c842008-09-26 19:32:34 +00004732 case 187:
4733#line 1775 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004734 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004735 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004736 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4737 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004738 if (PTy == 0)
Eric Christopher2a5196f2008-09-24 04:55:49 +00004739 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004740 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004741
Dan Gohmanf4423b12008-04-19 00:24:39 +00004742 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4743 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004744 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004745 ;}
4746 break;
4747
Dale Johannesendfe8c842008-09-26 19:32:34 +00004748 case 188:
4749#line 1787 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004750 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004751 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004752 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4753 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4754 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004755 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004756 ;}
4757 break;
4758
Dale Johannesendfe8c842008-09-26 19:32:34 +00004759 case 189:
4760#line 1794 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004761 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004762 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004763 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4764 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004765 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004766 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004767
4768 // ConstExprs can exist in the body of a function, thus creating
4769 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004770 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004771 // symbol table instead of the module symbol table for the global symbol,
4772 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004773 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004774 //
4775 Function *SavedCurFn = CurFun.CurrentFunction;
4776 CurFun.CurrentFunction = 0;
4777
Dan Gohmanf4423b12008-04-19 00:24:39 +00004778 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004779 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004780
4781 CurFun.CurrentFunction = SavedCurFn;
4782
4783 // If this is an initializer for a constant pointer, which is referencing a
4784 // (currently) undefined variable, create a stub now that shall be replaced
4785 // in the future with the right type of variable.
4786 //
4787 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004788 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004789 const PointerType *PT = cast<PointerType>(Ty);
4790
4791 // First check to see if the forward references value is already created!
4792 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004793 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Eric Christopher2a5196f2008-09-24 04:55:49 +00004794
Reid Spencer68a24bd2005-08-27 18:50:39 +00004795 if (I != CurModule.GlobalRefs.end()) {
4796 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004797 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004798 } else {
4799 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004800 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4801 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4802 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004803 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004804
4805 // Create the forward referenced global.
4806 GlobalValue *GV;
Eric Christopher2a5196f2008-09-24 04:55:49 +00004807 if (const FunctionType *FTy =
Reid Spencer68a24bd2005-08-27 18:50:39 +00004808 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004809 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4810 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004811 } else {
4812 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004813 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004814 Name, CurModule.CurrentModule);
4815 }
4816
4817 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004818 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004819 V = GV;
4820 }
4821 }
4822
Dan Gohmanf4423b12008-04-19 00:24:39 +00004823 (yyval.ConstVal) = cast<GlobalValue>(V);
4824 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004825 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004826 ;}
4827 break;
4828
Dale Johannesendfe8c842008-09-26 19:32:34 +00004829 case 190:
4830#line 1860 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004831 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004832 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004833 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4834 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00004835 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004836 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4837 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4838 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004839 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004840 ;}
4841 break;
4842
Dale Johannesendfe8c842008-09-26 19:32:34 +00004843 case 191:
4844#line 1870 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004845 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004846 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004847 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4848 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004849 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4850 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004851 (yyval.ConstVal) = Constant::getNullValue(Ty);
4852 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004853 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004854 ;}
4855 break;
4856
Dale Johannesendfe8c842008-09-26 19:32:34 +00004857 case 192:
4858#line 1880 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004859 { // integral constants
4860 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004861 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004862 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004863 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004864 ;}
4865 break;
4866
Dale Johannesendfe8c842008-09-26 19:32:34 +00004867 case 193:
4868#line 1886 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004869 { // arbitrary precision integer constants
4870 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4871 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004872 GEN_ERROR("Constant value does not fit in type");
4873 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004874 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4875 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4876 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004877 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004878 ;}
4879 break;
4880
Dale Johannesendfe8c842008-09-26 19:32:34 +00004881 case 194:
4882#line 1896 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004883 { // integral constants
4884 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004885 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004886 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004887 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004888 ;}
4889 break;
4890
Dale Johannesendfe8c842008-09-26 19:32:34 +00004891 case 195:
4892#line 1902 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004893 { // arbitrary precision integer constants
4894 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4895 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004896 GEN_ERROR("Constant value does not fit in type");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004897 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004898 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4899 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4900 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004901 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004902 ;}
4903 break;
4904
Dale Johannesendfe8c842008-09-26 19:32:34 +00004905 case 196:
4906#line 1912 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004907 { // Boolean constants
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004908 if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
4909 GEN_ERROR("Constant true must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004910 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004911 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004912 ;}
4913 break;
4914
Dale Johannesendfe8c842008-09-26 19:32:34 +00004915 case 197:
4916#line 1918 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004917 { // Boolean constants
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004918 if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
4919 GEN_ERROR("Constant false must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004920 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004921 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004922 ;}
4923 break;
4924
Dale Johannesendfe8c842008-09-26 19:32:34 +00004925 case 198:
4926#line 1924 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004927 { // Floating point constants
4928 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004929 GEN_ERROR("Floating point constant invalid for type");
Eric Christopher2a5196f2008-09-24 04:55:49 +00004930 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004931 // as double. Fix this here. Long double is done right.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004932 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4933 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004934 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004935 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004936 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004937 ;}
4938 break;
4939
Dale Johannesendfe8c842008-09-26 19:32:34 +00004940 case 199:
4941#line 1937 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004942 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004943 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004944 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4945 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4946 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4947 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004948 GEN_ERROR("invalid cast opcode for cast from '" +
4949 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00004950 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004951 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4952 delete (yyvsp[(5) - (6)].TypeVal);
4953 ;}
4954 break;
4955
Dale Johannesendfe8c842008-09-26 19:32:34 +00004956 case 200:
4957#line 1949 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004958 {
4959 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004960 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004961
4962 const Type *IdxTy =
Dan Gohman041e2eb2008-05-15 19:50:34 +00004963 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004964 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004965 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004966
Chris Lattnerf7469af2007-01-31 04:44:08 +00004967 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004968 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4969 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004970 IdxVec.push_back(C);
4971 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004972 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004973
Dan Gohmanf4423b12008-04-19 00:24:39 +00004974 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004975
Dan Gohmanf4423b12008-04-19 00:24:39 +00004976 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004977 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004978 ;}
4979 break;
4980
Dale Johannesendfe8c842008-09-26 19:32:34 +00004981 case 201:
4982#line 1970 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004983 {
4984 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004985 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004986 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004987 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004988 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004989 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004990 ;}
4991 break;
4992
Dale Johannesendfe8c842008-09-26 19:32:34 +00004993 case 202:
4994#line 1978 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004995 {
4996 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004997 GEN_ERROR("Binary operator types must match");
4998 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004999 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
5000 ;}
5001 break;
5002
Dale Johannesendfe8c842008-09-26 19:32:34 +00005003 case 203:
5004#line 1984 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005005 {
5006 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005007 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005008 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005009 if (!isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00005010 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005011 GEN_ERROR("Logical operator requires integral operands");
5012 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005013 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005014 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005015 ;}
5016 break;
5017
Dale Johannesendfe8c842008-09-26 19:32:34 +00005018 case 204:
5019#line 1995 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005020 {
5021 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005022 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005023 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5024 ;}
5025 break;
5026
Dale Johannesendfe8c842008-09-26 19:32:34 +00005027 case 205:
5028#line 2000 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005029 {
5030 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005031 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005032 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5033 ;}
5034 break;
5035
Dale Johannesendfe8c842008-09-26 19:32:34 +00005036 case 206:
5037#line 2005 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005038 {
5039 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5040 GEN_ERROR("vicmp operand types must match");
5041 (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5042 ;}
5043 break;
5044
Dale Johannesendfe8c842008-09-26 19:32:34 +00005045 case 207:
5046#line 2010 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00005047 {
5048 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
5049 GEN_ERROR("vfcmp operand types must match");
5050 (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
5051 ;}
5052 break;
5053
Dale Johannesendfe8c842008-09-26 19:32:34 +00005054 case 208:
5055#line 2015 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005056 {
5057 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005058 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005059 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005060 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005061 ;}
5062 break;
5063
Dale Johannesendfe8c842008-09-26 19:32:34 +00005064 case 209:
5065#line 2021 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005066 {
5067 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005068 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005069 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005070 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005071 ;}
5072 break;
5073
Dale Johannesendfe8c842008-09-26 19:32:34 +00005074 case 210:
5075#line 2027 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005076 {
5077 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005078 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005079 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005080 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005081 ;}
5082 break;
5083
Dale Johannesendfe8c842008-09-26 19:32:34 +00005084 case 211:
5085#line 2033 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005086 {
5087 if (!isa<StructType>((yyvsp[(3) - (5)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (5)].ConstVal)->getType()))
5088 GEN_ERROR("ExtractValue requires an aggregate operand");
5089
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005090 (yyval.ConstVal) = ConstantExpr::getExtractValue((yyvsp[(3) - (5)].ConstVal), &(*(yyvsp[(4) - (5)].ConstantList))[0], (yyvsp[(4) - (5)].ConstantList)->size());
5091 delete (yyvsp[(4) - (5)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005092 CHECK_FOR_ERROR
5093 ;}
5094 break;
5095
Dale Johannesendfe8c842008-09-26 19:32:34 +00005096 case 212:
5097#line 2041 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005098 {
5099 if (!isa<StructType>((yyvsp[(3) - (7)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (7)].ConstVal)->getType()))
5100 GEN_ERROR("InsertValue requires an aggregate operand");
5101
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005102 (yyval.ConstVal) = ConstantExpr::getInsertValue((yyvsp[(3) - (7)].ConstVal), (yyvsp[(5) - (7)].ConstVal), &(*(yyvsp[(6) - (7)].ConstantList))[0], (yyvsp[(6) - (7)].ConstantList)->size());
5103 delete (yyvsp[(6) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005104 CHECK_FOR_ERROR
5105 ;}
5106 break;
5107
Dale Johannesendfe8c842008-09-26 19:32:34 +00005108 case 213:
5109#line 2052 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005110 {
5111 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005112 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005113 ;}
5114 break;
5115
Dale Johannesendfe8c842008-09-26 19:32:34 +00005116 case 214:
5117#line 2056 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005118 {
5119 (yyval.ConstVector) = new std::vector<Constant*>();
5120 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005121 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005122 ;}
5123 break;
5124
Dale Johannesendfe8c842008-09-26 19:32:34 +00005125 case 215:
5126#line 2064 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005127 { (yyval.BoolVal) = false; ;}
Nate Begemanac80ade2008-05-12 19:01:56 +00005128 break;
5129
Dale Johannesendfe8c842008-09-26 19:32:34 +00005130 case 216:
5131#line 2064 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5132 { (yyval.BoolVal) = true; ;}
5133 break;
5134
Devang Pateld4980812008-09-02 20:52:40 +00005135 case 217:
Dale Johannesendfe8c842008-09-26 19:32:34 +00005136#line 2067 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005137 { (yyval.BoolVal) = true; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005138 break;
5139
Devang Pateld4980812008-09-02 20:52:40 +00005140 case 218:
Dale Johannesendfe8c842008-09-26 19:32:34 +00005141#line 2067 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerccef6b52008-09-23 21:18:31 +00005142 { (yyval.BoolVal) = false; ;}
5143 break;
5144
Dale Johannesendfe8c842008-09-26 19:32:34 +00005145 case 219:
5146#line 2070 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005147 {
5148 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
5149 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00005150 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005151 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
5152 if (!Aliasee)
5153 GEN_ERROR("Aliases can be created only to global values");
5154
Dan Gohmanf4423b12008-04-19 00:24:39 +00005155 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005156 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005157 delete (yyvsp[(1) - (2)].TypeVal);
5158 ;}
5159 break;
5160
Dale Johannesendfe8c842008-09-26 19:32:34 +00005161 case 220:
5162#line 2082 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005163 {
5164 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
5165 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
5166 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005167 GEN_ERROR("invalid cast opcode for cast from '" +
5168 Val->getType()->getDescription() + "' to '" +
5169 DestTy->getDescription() + "'");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005170
Dan Gohmanf4423b12008-04-19 00:24:39 +00005171 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005172 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005173 delete (yyvsp[(5) - (6)].TypeVal);
5174 ;}
5175 break;
5176
Dale Johannesendfe8c842008-09-26 19:32:34 +00005177 case 221:
5178#line 2103 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5179 {
5180 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5181 CurModule.ModuleDone();
5182 CHECK_FOR_ERROR;
5183 ;}
5184 break;
5185
Devang Pateld4980812008-09-02 20:52:40 +00005186 case 222:
Dale Johannesendfe8c842008-09-26 19:32:34 +00005187#line 2108 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005188 {
5189 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5190 CurModule.ModuleDone();
5191 CHECK_FOR_ERROR;
5192 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005193 break;
5194
Dale Johannesendfe8c842008-09-26 19:32:34 +00005195 case 225:
5196#line 2121 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerccef6b52008-09-23 21:18:31 +00005197 { CurFun.isDeclare = false; ;}
5198 break;
5199
Dale Johannesendfe8c842008-09-26 19:32:34 +00005200 case 226:
5201#line 2121 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005202 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005203 CurFun.FunctionDone();
5204 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005205 ;}
5206 break;
5207
Dale Johannesendfe8c842008-09-26 19:32:34 +00005208 case 227:
5209#line 2125 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005210 { CurFun.isDeclare = true; ;}
5211 break;
5212
Dale Johannesendfe8c842008-09-26 19:32:34 +00005213 case 228:
5214#line 2125 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5215 {
5216 CHECK_FOR_ERROR
5217 ;}
5218 break;
5219
Devang Pateld4980812008-09-02 20:52:40 +00005220 case 229:
Dale Johannesendfe8c842008-09-26 19:32:34 +00005221#line 2128 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00005222 {
5223 CHECK_FOR_ERROR
5224 ;}
5225 break;
5226
Devang Pateld4980812008-09-02 20:52:40 +00005227 case 230:
Dale Johannesendfe8c842008-09-26 19:32:34 +00005228#line 2131 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005229 {
Reid Spencer14310612006-12-31 05:40:51 +00005230 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005231 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005232 // Eagerly resolve types. This is not an optimization, this is a
5233 // requirement that is due to the fact that we could have this:
5234 //
5235 // %list = type { %list * }
5236 // %list = type { %list * } ; repeated type decl
5237 //
5238 // If types are not resolved eagerly, then the two types will not be
5239 // determined to be the same type!
5240 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00005241 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005242
Dan Gohmanf4423b12008-04-19 00:24:39 +00005243 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00005244 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005245 // If this is a named type that is not a redefinition, add it to the slot
5246 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005247 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005248 }
Reid Spencera132e042006-12-03 05:46:11 +00005249
Dan Gohmanf4423b12008-04-19 00:24:39 +00005250 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005251 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005252 ;}
5253 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00005254
Dale Johannesendfe8c842008-09-26 19:32:34 +00005255 case 231:
5256#line 2155 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005257 {
5258 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
5259
5260 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005261 CHECK_FOR_ERROR
5262 // If this is a named type that is not a redefinition, add it to the slot
5263 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005264 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005265 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005266 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005267 ;}
5268 break;
5269
Dale Johannesendfe8c842008-09-26 19:32:34 +00005270 case 232:
5271#line 2167 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005272 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005273 /* "Externally Visible" Linkage */
Eric Christopher2a5196f2008-09-24 04:55:49 +00005274 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005275 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005276 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5277 (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 +00005278 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005279 ;}
5280 break;
5281
Dale Johannesendfe8c842008-09-26 19:32:34 +00005282 case 233:
5283#line 2174 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005284 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005285 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005286 ;}
5287 break;
5288
Dale Johannesendfe8c842008-09-26 19:32:34 +00005289 case 234:
5290#line 2178 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005291 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005292 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005293 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005294 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 +00005295 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005296 ;}
5297 break;
5298
Dale Johannesendfe8c842008-09-26 19:32:34 +00005299 case 235:
5300#line 2183 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005301 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005302 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005303 ;}
5304 break;
5305
Dale Johannesendfe8c842008-09-26 19:32:34 +00005306 case 236:
5307#line 2187 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005308 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005309 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005310 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5311 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 +00005312 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005313 delete (yyvsp[(6) - (7)].TypeVal);
5314 ;}
5315 break;
5316
Dale Johannesendfe8c842008-09-26 19:32:34 +00005317 case 237:
5318#line 2193 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005319 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005320 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005321 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005322 ;}
5323 break;
5324
Dale Johannesendfe8c842008-09-26 19:32:34 +00005325 case 238:
5326#line 2197 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005327 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005328 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005329 if ((yyvsp[(1) - (5)].StrVal)) {
5330 Name = *(yyvsp[(1) - (5)].StrVal);
5331 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005332 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005333 if (Name.empty())
5334 GEN_ERROR("Alias name cannot be empty");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005335
Dan Gohmanf4423b12008-04-19 00:24:39 +00005336 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005337 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005338 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005339
Dan Gohmanf4423b12008-04-19 00:24:39 +00005340 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005341 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005342 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005343 InsertValue(GA, CurModule.Values);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005344
5345
Chris Lattner569f7372007-09-10 23:24:14 +00005346 // If there was a forward reference of this alias, resolve it now.
Eric Christopher2a5196f2008-09-24 04:55:49 +00005347
Chris Lattner569f7372007-09-10 23:24:14 +00005348 ValID ID;
5349 if (!Name.empty())
5350 ID = ValID::createGlobalName(Name);
5351 else
5352 ID = ValID::createGlobalID(CurModule.Values.size()-1);
Eric Christopher2a5196f2008-09-24 04:55:49 +00005353
Chris Lattner569f7372007-09-10 23:24:14 +00005354 if (GlobalValue *FWGV =
5355 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5356 // Replace uses of the fwdref with the actual alias.
5357 FWGV->replaceAllUsesWith(GA);
5358 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5359 GV->eraseFromParent();
5360 else
5361 cast<Function>(FWGV)->eraseFromParent();
5362 }
5363 ID.destroy();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005364
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005365 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005366 ;}
5367 break;
5368
Dale Johannesendfe8c842008-09-26 19:32:34 +00005369 case 239:
5370#line 2237 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5371 {
5372 CHECK_FOR_ERROR
5373 ;}
5374 break;
5375
Chris Lattnerccef6b52008-09-23 21:18:31 +00005376 case 240:
Dale Johannesendfe8c842008-09-26 19:32:34 +00005377#line 2240 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005378 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005379 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005380 ;}
5381 break;
5382
Chris Lattnerccef6b52008-09-23 21:18:31 +00005383 case 241:
Dale Johannesendfe8c842008-09-26 19:32:34 +00005384#line 2246 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005385 {
Chris Lattner66316012006-01-24 04:14:29 +00005386 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005387 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005388 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005389 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005390 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5391 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005392 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005393;}
5394 break;
5395
Dale Johannesendfe8c842008-09-26 19:32:34 +00005396 case 242:
5397#line 2256 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005398 {
5399 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5400 delete (yyvsp[(3) - (3)].StrVal);
5401 ;}
5402 break;
5403
Dale Johannesendfe8c842008-09-26 19:32:34 +00005404 case 243:
5405#line 2260 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005406 {
5407 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5408 delete (yyvsp[(3) - (3)].StrVal);
5409 ;}
5410 break;
5411
Dale Johannesendfe8c842008-09-26 19:32:34 +00005412 case 245:
5413#line 2267 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005414 {
5415 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5416 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005417 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005418 ;}
5419 break;
5420
Dale Johannesendfe8c842008-09-26 19:32:34 +00005421 case 246:
5422#line 2272 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005423 {
5424 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5425 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005426 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005427 ;}
5428 break;
5429
Dale Johannesendfe8c842008-09-26 19:32:34 +00005430 case 247:
5431#line 2277 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005432 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005433 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005434 ;}
5435 break;
5436
Dale Johannesendfe8c842008-09-26 19:32:34 +00005437 case 248:
5438#line 2286 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005439 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005440 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005441 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005442 if (!(*(yyvsp[(3) - (5)].TypeVal))->isFirstClassType())
5443 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005444 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 +00005445 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5446 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005447 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005448 ;}
5449 break;
5450
Dale Johannesendfe8c842008-09-26 19:32:34 +00005451 case 249:
5452#line 2296 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005453 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005454 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005455 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005456 if (!(*(yyvsp[(1) - (3)].TypeVal))->isFirstClassType())
5457 GEN_ERROR("Argument types must be first-class");
Devang Patel05988662008-09-25 21:00:45 +00005458 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 +00005459 (yyval.ArgList) = new ArgListType;
5460 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005461 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005462 ;}
5463 break;
5464
Dale Johannesendfe8c842008-09-26 19:32:34 +00005465 case 250:
5466#line 2307 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005467 {
5468 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005469 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005470 ;}
5471 break;
5472
Dale Johannesendfe8c842008-09-26 19:32:34 +00005473 case 251:
5474#line 2311 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005475 {
5476 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005477 struct ArgListEntry E;
5478 E.Ty = new PATypeHolder(Type::VoidTy);
5479 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005480 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005481 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005482 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005483 ;}
5484 break;
5485
Dale Johannesendfe8c842008-09-26 19:32:34 +00005486 case 252:
5487#line 2320 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005488 {
5489 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005490 struct ArgListEntry E;
5491 E.Ty = new PATypeHolder(Type::VoidTy);
5492 E.Name = 0;
Devang Patel05988662008-09-25 21:00:45 +00005493 E.Attrs = Attribute::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005494 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005495 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005496 ;}
5497 break;
5498
Dale Johannesendfe8c842008-09-26 19:32:34 +00005499 case 253:
5500#line 2329 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005501 {
5502 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005503 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005504 ;}
5505 break;
5506
Dale Johannesendfe8c842008-09-26 19:32:34 +00005507 case 254:
5508#line 2335 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005509 {
Devang Pateld4980812008-09-02 20:52:40 +00005510 std::string FunctionName(*(yyvsp[(3) - (11)].StrVal));
5511 delete (yyvsp[(3) - (11)].StrVal); // Free strdup'd memory!
Eric Christopher2a5196f2008-09-24 04:55:49 +00005512
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005513 // Check the function result for abstractness if this is a define. We should
5514 // have no abstract types at this point
Devang Pateld4980812008-09-02 20:52:40 +00005515 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (11)].TypeVal)))
5516 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (11)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005517
Devang Pateld4980812008-09-02 20:52:40 +00005518 if (!FunctionType::isValidReturnType(*(yyvsp[(2) - (11)].TypeVal)))
Chris Lattnera925a142008-04-23 05:37:08 +00005519 GEN_ERROR("Invalid result type for LLVM function");
Eric Christopher2a5196f2008-09-24 04:55:49 +00005520
Reid Spencer68a24bd2005-08-27 18:50:39 +00005521 std::vector<const Type*> ParamTypeList;
Devang Patel05988662008-09-25 21:00:45 +00005522 SmallVector<AttributeWithIndex, 8> Attrs;
5523 if ((yyvsp[(7) - (11)].Attributes) != Attribute::None)
5524 Attrs.push_back(AttributeWithIndex::get(0, (yyvsp[(7) - (11)].Attributes)));
Devang Pateld4980812008-09-02 20:52:40 +00005525 if ((yyvsp[(5) - (11)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005526 unsigned index = 1;
Devang Pateld4980812008-09-02 20:52:40 +00005527 for (ArgListType::iterator I = (yyvsp[(5) - (11)].ArgList)->begin(); I != (yyvsp[(5) - (11)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005528 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005529 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5530 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005531 ParamTypeList.push_back(Ty);
Devang Patel05988662008-09-25 21:00:45 +00005532 if (Ty != Type::VoidTy && I->Attrs != Attribute::None)
5533 Attrs.push_back(AttributeWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005534 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005535 }
5536
5537 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5538 if (isVarArg) ParamTypeList.pop_back();
5539
Devang Patel05988662008-09-25 21:00:45 +00005540 AttrListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005541 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00005542 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005543
Devang Pateld4980812008-09-02 20:52:40 +00005544 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (11)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005545 const PointerType *PFT = PointerType::getUnqual(FT);
Devang Pateld4980812008-09-02 20:52:40 +00005546 delete (yyvsp[(2) - (11)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005547
5548 ValID ID;
5549 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005550 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005551 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005552 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005553 }
5554
5555 Function *Fn = 0;
5556 // See if this function was forward referenced. If so, recycle the object.
5557 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005558 // Move the function to the end of the list, from whereever it was
Reid Spencer68a24bd2005-08-27 18:50:39 +00005559 // previously inserted.
5560 Fn = cast<Function>(FWRef);
Devang Patel05988662008-09-25 21:00:45 +00005561 assert(Fn->getAttributes().isEmpty() &&
Chris Lattner58d74912008-03-12 17:45:29 +00005562 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005563 CurModule.CurrentModule->getFunctionList().remove(Fn);
5564 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5565 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005566 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005567 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005568 // The existing function doesn't have the same type. This is an overload
5569 // error.
5570 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Devang Patel05988662008-09-25 21:00:45 +00005571 } else if (Fn->getAttributes() != PAL) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005572 // The existing function doesn't have the same parameter attributes.
5573 // This is an overload error.
5574 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005575 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005576 // Neither the existing or the current function is a declaration and they
5577 // have the same name and same type. Clearly this is a redefinition.
5578 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005579 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005580 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005581 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5582 AI != AE; ++AI)
5583 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005584 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005585 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005586 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5587 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005588 InsertValue(Fn, CurModule.Values);
5589 }
5590
5591 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005592
5593 if (CurFun.isDeclare) {
5594 // If we have declaration, always overwrite linkage. This will allow us to
5595 // correctly handle cases, when pointer to function is passed as argument to
5596 // another function.
5597 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005598 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005599 }
Devang Pateld4980812008-09-02 20:52:40 +00005600 Fn->setCallingConv((yyvsp[(1) - (11)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00005601 Fn->setAttributes(PAL);
Devang Pateld4980812008-09-02 20:52:40 +00005602 Fn->setAlignment((yyvsp[(9) - (11)].UIntVal));
5603 if ((yyvsp[(8) - (11)].StrVal)) {
5604 Fn->setSection(*(yyvsp[(8) - (11)].StrVal));
5605 delete (yyvsp[(8) - (11)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005606 }
Devang Pateld4980812008-09-02 20:52:40 +00005607 if ((yyvsp[(10) - (11)].StrVal)) {
5608 Fn->setGC((yyvsp[(10) - (11)].StrVal)->c_str());
5609 delete (yyvsp[(10) - (11)].StrVal);
5610 }
Devang Patel05988662008-09-25 21:00:45 +00005611 if ((yyvsp[(11) - (11)].Attributes)) {
5612 Fn->setNotes((yyvsp[(11) - (11)].Attributes));
Chris Lattnere869eef2005-11-12 00:11:49 +00005613 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005614
5615 // Add all of the arguments we parsed to the function...
Devang Pateld4980812008-09-02 20:52:40 +00005616 if ((yyvsp[(5) - (11)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005617 if (isVarArg) { // Nuke the last entry
Devang Pateld4980812008-09-02 20:52:40 +00005618 assert((yyvsp[(5) - (11)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (11)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005619 "Not a varargs marker!");
Devang Pateld4980812008-09-02 20:52:40 +00005620 delete (yyvsp[(5) - (11)].ArgList)->back().Ty;
5621 (yyvsp[(5) - (11)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005622 }
5623 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005624 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005625 unsigned Idx = 1;
Eric Christopher2a5196f2008-09-24 04:55:49 +00005626 for (ArgListType::iterator I = (yyvsp[(5) - (11)].ArgList)->begin();
Devang Pateld4980812008-09-02 20:52:40 +00005627 I != (yyvsp[(5) - (11)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005628 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005629 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005630 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005631 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005632 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005633 }
Reid Spencera132e042006-12-03 05:46:11 +00005634
Devang Pateld4980812008-09-02 20:52:40 +00005635 delete (yyvsp[(5) - (11)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005636 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005637 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005638;}
5639 break;
5640
Dale Johannesendfe8c842008-09-26 19:32:34 +00005641 case 257:
5642#line 2468 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005643 {
5644 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005645
5646 // Make sure that we keep track of the linkage type even if there was a
5647 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005648 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5649 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5650;}
5651 break;
5652
Dale Johannesendfe8c842008-09-26 19:32:34 +00005653 case 260:
5654#line 2479 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005655 {
5656 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005657 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005658;}
5659 break;
5660
Dale Johannesendfe8c842008-09-26 19:32:34 +00005661 case 261:
5662#line 2484 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005663 {
5664 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5665 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5666 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005667 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005668 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005669 ;}
5670 break;
5671
Dale Johannesendfe8c842008-09-26 19:32:34 +00005672 case 262:
5673#line 2496 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005674 {
5675 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005676 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005677 ;}
5678 break;
5679
Dale Johannesendfe8c842008-09-26 19:32:34 +00005680 case 263:
5681#line 2500 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005682 {
5683 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005684 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005685 ;}
5686 break;
5687
Dale Johannesendfe8c842008-09-26 19:32:34 +00005688 case 264:
5689#line 2505 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005690 { // A reference to a direct constant
5691 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005692 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005693 ;}
5694 break;
5695
Dale Johannesendfe8c842008-09-26 19:32:34 +00005696 case 265:
5697#line 2509 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005698 {
5699 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005700 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005701 ;}
5702 break;
5703
Dale Johannesendfe8c842008-09-26 19:32:34 +00005704 case 266:
5705#line 2513 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005706 { // arbitrary precision integer constants
5707 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), true);
5708 delete (yyvsp[(1) - (1)].APIntVal);
5709 CHECK_FOR_ERROR
5710 ;}
5711 break;
5712
Dale Johannesendfe8c842008-09-26 19:32:34 +00005713 case 267:
5714#line 2518 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005715 { // arbitrary precision integer constants
5716 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), false);
5717 delete (yyvsp[(1) - (1)].APIntVal);
5718 CHECK_FOR_ERROR
5719 ;}
5720 break;
5721
Dale Johannesendfe8c842008-09-26 19:32:34 +00005722 case 268:
5723#line 2523 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005724 { // Perhaps it's an FP constant?
5725 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005726 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005727 ;}
5728 break;
5729
Dale Johannesendfe8c842008-09-26 19:32:34 +00005730 case 269:
5731#line 2527 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005732 {
5733 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005734 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005735 ;}
5736 break;
5737
Dale Johannesendfe8c842008-09-26 19:32:34 +00005738 case 270:
5739#line 2531 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005740 {
5741 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005742 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005743 ;}
5744 break;
5745
Dale Johannesendfe8c842008-09-26 19:32:34 +00005746 case 271:
5747#line 2535 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005748 {
5749 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005750 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005751 ;}
5752 break;
5753
Dale Johannesendfe8c842008-09-26 19:32:34 +00005754 case 272:
5755#line 2539 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005756 {
5757 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005758 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005759 ;}
5760 break;
5761
Dale Johannesendfe8c842008-09-26 19:32:34 +00005762 case 273:
5763#line 2543 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005764 { // A vector zero constant.
5765 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005766 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005767 ;}
5768 break;
5769
Dale Johannesendfe8c842008-09-26 19:32:34 +00005770 case 274:
5771#line 2547 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005772 { // Nonempty unsized packed vector
5773 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005774 unsigned NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005775
5776 if (!ETy->isInteger() && !ETy->isFloatingPoint())
5777 GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005778
Reid Spencer9d6565a2007-02-15 02:26:10 +00005779 VectorType* pt = VectorType::get(ETy, NumElements);
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005780 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
Eric Christopher2a5196f2008-09-24 04:55:49 +00005781
Reid Spencer68a24bd2005-08-27 18:50:39 +00005782 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005783 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5784 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005785 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005786 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005787 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005788 }
5789
Dan Gohmanf4423b12008-04-19 00:24:39 +00005790 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5791 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005792 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005793 ;}
5794 break;
5795
Dale Johannesendfe8c842008-09-26 19:32:34 +00005796 case 275:
5797#line 2569 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005798 { // Nonempty unsized arr
5799 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005800 uint64_t NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005801
5802 if (!ETy->isFirstClassType())
5803 GEN_ERROR("Invalid array element type: " + ETy->getDescription());
5804
5805 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5806 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
5807
5808 // Verify all elements are correct type!
5809 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5810 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Eric Christopher2a5196f2008-09-24 04:55:49 +00005811 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005812 ETy->getDescription() +"' as required!\nIt is of type '"+
5813 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
5814 }
5815
5816 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, *(yyvsp[(2) - (3)].ConstVector)));
5817 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5818 CHECK_FOR_ERROR
5819 ;}
5820 break;
5821
Dale Johannesendfe8c842008-09-26 19:32:34 +00005822 case 276:
5823#line 2591 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005824 {
Dan Gohman180c1692008-06-23 18:43:26 +00005825 // Use undef instead of an array because it's inconvenient to determine
5826 // the element type at this point, there being no elements to examine.
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005827 (yyval.ValIDVal) = ValID::createUndef();
5828 CHECK_FOR_ERROR
5829 ;}
5830 break;
5831
Dale Johannesendfe8c842008-09-26 19:32:34 +00005832 case 277:
5833#line 2597 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005834 {
Dan Gohman180c1692008-06-23 18:43:26 +00005835 uint64_t NumElements = (yyvsp[(2) - (2)].StrVal)->length();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005836 const Type *ETy = Type::Int8Ty;
5837
5838 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5839
5840 std::vector<Constant*> Vals;
5841 for (unsigned i = 0; i < (yyvsp[(2) - (2)].StrVal)->length(); ++i)
5842 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(2) - (2)].StrVal))[i]));
5843 delete (yyvsp[(2) - (2)].StrVal);
5844 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, Vals));
5845 CHECK_FOR_ERROR
5846 ;}
5847 break;
5848
Dale Johannesendfe8c842008-09-26 19:32:34 +00005849 case 278:
5850#line 2610 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005851 {
5852 std::vector<const Type*> Elements((yyvsp[(2) - (3)].ConstVector)->size());
5853 for (unsigned i = 0, e = (yyvsp[(2) - (3)].ConstVector)->size(); i != e; ++i)
5854 Elements[i] = (*(yyvsp[(2) - (3)].ConstVector))[i]->getType();
5855
5856 const StructType *STy = StructType::get(Elements);
5857 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5858
5859 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(2) - (3)].ConstVector)));
5860 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5861 CHECK_FOR_ERROR
5862 ;}
5863 break;
5864
Dale Johannesendfe8c842008-09-26 19:32:34 +00005865 case 279:
5866#line 2622 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005867 {
5868 const StructType *STy = StructType::get(std::vector<const Type*>());
5869 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5870 CHECK_FOR_ERROR
5871 ;}
5872 break;
5873
Dale Johannesendfe8c842008-09-26 19:32:34 +00005874 case 280:
5875#line 2627 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005876 {
5877 std::vector<const Type*> Elements((yyvsp[(3) - (5)].ConstVector)->size());
5878 for (unsigned i = 0, e = (yyvsp[(3) - (5)].ConstVector)->size(); i != e; ++i)
5879 Elements[i] = (*(yyvsp[(3) - (5)].ConstVector))[i]->getType();
5880
5881 const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
5882 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5883
5884 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(3) - (5)].ConstVector)));
5885 delete PTy; delete (yyvsp[(3) - (5)].ConstVector);
5886 CHECK_FOR_ERROR
5887 ;}
5888 break;
5889
Dale Johannesendfe8c842008-09-26 19:32:34 +00005890 case 281:
5891#line 2639 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005892 {
5893 const StructType *STy = StructType::get(std::vector<const Type*>(),
5894 /*isPacked=*/true);
5895 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5896 CHECK_FOR_ERROR
5897 ;}
5898 break;
5899
Dale Johannesendfe8c842008-09-26 19:32:34 +00005900 case 282:
5901#line 2645 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005902 {
5903 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005904 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005905 ;}
5906 break;
5907
Dale Johannesendfe8c842008-09-26 19:32:34 +00005908 case 283:
5909#line 2649 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005910 {
5911 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5912 delete (yyvsp[(3) - (5)].StrVal);
5913 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005914 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005915 ;}
5916 break;
5917
Dale Johannesendfe8c842008-09-26 19:32:34 +00005918 case 284:
5919#line 2659 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005920 { // Is it an integer reference...?
5921 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005922 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005923 ;}
5924 break;
5925
Dale Johannesendfe8c842008-09-26 19:32:34 +00005926 case 285:
5927#line 2663 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005928 {
5929 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005930 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005931 ;}
5932 break;
5933
Dale Johannesendfe8c842008-09-26 19:32:34 +00005934 case 286:
5935#line 2667 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005936 { // Is it a named reference...?
5937 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5938 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005939 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005940 ;}
5941 break;
5942
Dale Johannesendfe8c842008-09-26 19:32:34 +00005943 case 287:
5944#line 2672 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005945 { // Is it a named reference...?
5946 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5947 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005948 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005949 ;}
5950 break;
5951
Dale Johannesendfe8c842008-09-26 19:32:34 +00005952 case 290:
5953#line 2685 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005954 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005955 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005956 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00005957 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00005958 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005959 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005960 ;}
5961 break;
5962
Dale Johannesendfe8c842008-09-26 19:32:34 +00005963 case 291:
5964#line 2694 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005965 {
5966 (yyval.ValueList) = new std::vector<Value *>();
Eric Christopher2a5196f2008-09-24 04:55:49 +00005967 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005968 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005969 ;}
5970 break;
5971
Dale Johannesendfe8c842008-09-26 19:32:34 +00005972 case 292:
5973#line 2699 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005974 {
Eric Christopher2a5196f2008-09-24 04:55:49 +00005975 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005976 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005977 ;}
5978 break;
5979
Dale Johannesendfe8c842008-09-26 19:32:34 +00005980 case 293:
5981#line 2704 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005982 {
5983 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005984 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005985 ;}
5986 break;
5987
Dale Johannesendfe8c842008-09-26 19:32:34 +00005988 case 294:
5989#line 2708 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00005990 { // Do not allow functions with 0 basic blocks
Dan Gohmanf4423b12008-04-19 00:24:39 +00005991 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005992 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005993 ;}
5994 break;
5995
Dale Johannesendfe8c842008-09-26 19:32:34 +00005996 case 295:
5997#line 2717 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005998 {
5999 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006000 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006001 InsertValue((yyvsp[(3) - (3)].TermInstVal));
6002 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6003 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006004 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006005 ;}
6006 break;
6007
Dale Johannesendfe8c842008-09-26 19:32:34 +00006008 case 296:
6009#line 2726 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006010 {
6011 CHECK_FOR_ERROR
6012 int ValNum = InsertValue((yyvsp[(3) - (3)].TermInstVal));
6013 if (ValNum != (int)(yyvsp[(2) - (3)].UIntVal))
6014 GEN_ERROR("Result value number %" + utostr((yyvsp[(2) - (3)].UIntVal)) +
6015 " is incorrect, expected %" + utostr((unsigned)ValNum));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006016
Chris Lattner15bd0952008-08-29 17:20:18 +00006017 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
6018 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
6019 CHECK_FOR_ERROR
6020;}
6021 break;
6022
Dale Johannesendfe8c842008-09-26 19:32:34 +00006023 case 297:
6024#line 2739 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006025 {
6026 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006027 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
6028 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00006029 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
6030 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
6031 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006032 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006033 ;}
6034 break;
Chris Lattner38905612008-02-19 04:36:25 +00006035
Dale Johannesendfe8c842008-09-26 19:32:34 +00006036 case 298:
6037#line 2748 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006038 { // Empty space between instruction lists
Chris Lattnercc81d152008-05-04 17:18:47 +00006039 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006040 CHECK_FOR_ERROR
6041 ;}
6042 break;
6043
Dale Johannesendfe8c842008-09-26 19:32:34 +00006044 case 299:
6045#line 2752 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnercc81d152008-05-04 17:18:47 +00006046 { // Labelled (named) basic block
6047 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
6048 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006049 CHECK_FOR_ERROR
Chris Lattnercc81d152008-05-04 17:18:47 +00006050
Dan Gohmanf4423b12008-04-19 00:24:39 +00006051 ;}
6052 break;
6053
Dale Johannesendfe8c842008-09-26 19:32:34 +00006054 case 300:
6055#line 2760 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006056 { // Return with a result...
6057 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
6058 assert(!VL.empty() && "Invalid ret operands!");
Dan Gohman1a570242008-07-23 00:54:54 +00006059 const Type *ReturnType = CurFun.CurrentFunction->getReturnType();
6060 if (VL.size() > 1 ||
6061 (isa<StructType>(ReturnType) &&
6062 (VL.empty() || VL[0]->getType() != ReturnType))) {
6063 Value *RV = UndefValue::get(ReturnType);
6064 for (unsigned i = 0, e = VL.size(); i != e; ++i) {
6065 Instruction *I = InsertValueInst::Create(RV, VL[i], i, "mrv");
6066 ((yyvsp[(-1) - (2)].BasicBlockVal))->getInstList().push_back(I);
6067 RV = I;
6068 }
6069 (yyval.TermInstVal) = ReturnInst::Create(RV);
6070 } else {
6071 (yyval.TermInstVal) = ReturnInst::Create(VL[0]);
6072 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006073 delete (yyvsp[(2) - (2)].ValueList);
6074 CHECK_FOR_ERROR
6075 ;}
6076 break;
6077
Dale Johannesendfe8c842008-09-26 19:32:34 +00006078 case 301:
6079#line 2780 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006080 { // Return with no result...
6081 (yyval.TermInstVal) = ReturnInst::Create();
6082 CHECK_FOR_ERROR
6083 ;}
6084 break;
6085
Dale Johannesendfe8c842008-09-26 19:32:34 +00006086 case 302:
6087#line 2784 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006088 { // Unconditional Branch...
6089 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6090 CHECK_FOR_ERROR
6091 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
6092 ;}
6093 break;
6094
Dale Johannesendfe8c842008-09-26 19:32:34 +00006095 case 303:
6096#line 2789 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Eric Christopher2a5196f2008-09-24 04:55:49 +00006097 {
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006098 if (cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() != 1)
6099 GEN_ERROR("Branch condition must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006100 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6101 CHECK_FOR_ERROR
6102 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6103 CHECK_FOR_ERROR
6104 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6105 CHECK_FOR_ERROR
6106 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
6107 ;}
6108 break;
6109
Dale Johannesendfe8c842008-09-26 19:32:34 +00006110 case 304:
6111#line 2800 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006112 {
6113 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
6114 CHECK_FOR_ERROR
6115 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6116 CHECK_FOR_ERROR
6117 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6118 (yyval.TermInstVal) = S;
6119
6120 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6121 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00006122 for (; I != E; ++I) {
6123 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6124 S->addCase(CI, I->second);
6125 else
Reid Spencerb5334b02007-02-05 10:18:06 +00006126 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006127 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006128 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00006129 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006130 ;}
6131 break;
6132
Dale Johannesendfe8c842008-09-26 19:32:34 +00006133 case 305:
6134#line 2819 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006135 {
6136 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006137 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006138 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006139 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00006140 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006141 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006142 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006143 ;}
6144 break;
6145
Dale Johannesendfe8c842008-09-26 19:32:34 +00006146 case 306:
6147#line 2829 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006148 {
Reid Spencer3822ff52006-11-08 06:47:33 +00006149
Reid Spencer14310612006-12-31 05:40:51 +00006150 // Handle the short syntax
6151 const PointerType *PFTy = 0;
6152 const FunctionType *Ty = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006153 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00006154 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6155 // Pull out the types of all of the arguments...
6156 std::vector<const Type*> ParamTypes;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006157 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006158 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006159 const Type *Ty = I->Val->getType();
6160 if (Ty == Type::VoidTy)
6161 GEN_ERROR("Short call syntax cannot be used with varargs");
6162 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006163 }
Eric Christopher2a5196f2008-09-24 04:55:49 +00006164
Chris Lattnera925a142008-04-23 05:37:08 +00006165 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (14)].TypeVal)))
6166 GEN_ERROR("Invalid result type for LLVM function");
6167
Dan Gohmanf4423b12008-04-19 00:24:39 +00006168 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006169 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006170 }
6171
Dan Gohmanf4423b12008-04-19 00:24:39 +00006172 delete (yyvsp[(3) - (14)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00006173
Dan Gohmanf4423b12008-04-19 00:24:39 +00006174 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006175 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006176 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006177 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006178 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00006179 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00006180
Devang Patel05988662008-09-25 21:00:45 +00006181 SmallVector<AttributeWithIndex, 8> Attrs;
6182 if ((yyvsp[(8) - (14)].Attributes) != Attribute::None)
6183 Attrs.push_back(AttributeWithIndex::get(0, (yyvsp[(8) - (14)].Attributes)));
Duncan Sandsdc024672007-11-27 13:23:08 +00006184
Reid Spencer14310612006-12-31 05:40:51 +00006185 // Check the arguments
6186 ValueList Args;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006187 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00006188 // Make sure no arguments is a good thing!
6189 if (Ty->getNumParams() != 0)
6190 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006191 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006192 } else { // Has arguments?
6193 // Loop through FunctionType's arguments and ensure they are specified
6194 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00006195 FunctionType::param_iterator I = Ty->param_begin();
6196 FunctionType::param_iterator E = Ty->param_end();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006197 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006198 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006199
Duncan Sandsdc024672007-11-27 13:23:08 +00006200 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006201 if (ArgI->Val->getType() != *I)
6202 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006203 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006204 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006205 if (ArgI->Attrs != Attribute::None)
6206 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006207 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00006208
Reid Spencer14310612006-12-31 05:40:51 +00006209 if (Ty->isVarArg()) {
6210 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006211 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006212 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006213 if (ArgI->Attrs != Attribute::None)
6214 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006215 }
Reid Spencer14310612006-12-31 05:40:51 +00006216 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006217 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006218 }
Reid Spencer14310612006-12-31 05:40:51 +00006219
Devang Patel05988662008-09-25 21:00:45 +00006220 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006221 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006222 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006223
Reid Spencer14310612006-12-31 05:40:51 +00006224 // Create the InvokeInst
Dan Gohman041e2eb2008-05-15 19:50:34 +00006225 InvokeInst *II = InvokeInst::Create(V, Normal, Except,
6226 Args.begin(), Args.end());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006227 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006228 II->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006229 (yyval.TermInstVal) = II;
6230 delete (yyvsp[(6) - (14)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006231 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006232 ;}
6233 break;
6234
Dale Johannesendfe8c842008-09-26 19:32:34 +00006235 case 307:
6236#line 2914 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006237 {
6238 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006239 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006240 ;}
6241 break;
6242
Dale Johannesendfe8c842008-09-26 19:32:34 +00006243 case 308:
6244#line 2918 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006245 {
6246 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006247 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006248 ;}
6249 break;
6250
Dale Johannesendfe8c842008-09-26 19:32:34 +00006251 case 309:
6252#line 2925 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006253 {
6254 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6255 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006256 CHECK_FOR_ERROR
6257 if (V == 0)
6258 GEN_ERROR("May only switch on a constant pool value");
6259
Dan Gohmanf4423b12008-04-19 00:24:39 +00006260 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006261 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006262 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6263 ;}
6264 break;
6265
Dale Johannesendfe8c842008-09-26 19:32:34 +00006266 case 310:
6267#line 2936 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006268 {
6269 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6270 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006271 CHECK_FOR_ERROR
6272
6273 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00006274 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006275
Dan Gohmanf4423b12008-04-19 00:24:39 +00006276 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006277 CHECK_FOR_ERROR
Eric Christopher2a5196f2008-09-24 04:55:49 +00006278 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Dan Gohmanf4423b12008-04-19 00:24:39 +00006279 ;}
6280 break;
6281
Dale Johannesendfe8c842008-09-26 19:32:34 +00006282 case 311:
6283#line 2949 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006284 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006285 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00006286 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006287 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006288 InsertValue((yyvsp[(2) - (2)].InstVal));
6289 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006290 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006291 ;}
6292 break;
6293
Dale Johannesendfe8c842008-09-26 19:32:34 +00006294 case 312:
6295#line 2958 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner15bd0952008-08-29 17:20:18 +00006296 {
6297 CHECK_FOR_ERROR
6298 int ValNum = InsertValue((yyvsp[(2) - (2)].InstVal));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006299
Chris Lattner15bd0952008-08-29 17:20:18 +00006300 if (ValNum != (int)(yyvsp[(1) - (2)].UIntVal))
6301 GEN_ERROR("Result value number %" + utostr((yyvsp[(1) - (2)].UIntVal)) +
6302 " is incorrect, expected %" + utostr((unsigned)ValNum));
6303
6304 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6305 CHECK_FOR_ERROR
6306 ;}
6307 break;
6308
Dale Johannesendfe8c842008-09-26 19:32:34 +00006309 case 313:
6310#line 2971 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006311 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006312 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006313 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
6314 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
6315 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00006316 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006317 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006318 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006319 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6320 delete (yyvsp[(1) - (6)].TypeVal);
6321 ;}
6322 break;
6323
Dale Johannesendfe8c842008-09-26 19:32:34 +00006324 case 314:
6325#line 2982 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006326 {
6327 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6328 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006329 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006330 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006331 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006332 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6333 ;}
6334 break;
6335
Dale Johannesendfe8c842008-09-26 19:32:34 +00006336 case 315:
6337#line 2992 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006338 {
Devang Patel05988662008-09-25 21:00:45 +00006339 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006340 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006341 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006342 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00006343 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006344 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 +00006345 (yyval.ParamList)->push_back(E);
6346 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00006347 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006348 ;}
6349 break;
6350
Dale Johannesendfe8c842008-09-26 19:32:34 +00006351 case 316:
6352#line 3003 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006353 {
Devang Patel05988662008-09-25 21:00:45 +00006354 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006355 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00006356 (yyval.ParamList) = new ParamList();
Devang Patel05988662008-09-25 21:00:45 +00006357 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 +00006358 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00006359 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006360 ;}
6361 break;
6362
Dale Johannesendfe8c842008-09-26 19:32:34 +00006363 case 317:
6364#line 3011 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006365 {
Devang Patel05988662008-09-25 21:00:45 +00006366 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006367 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006368 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6369 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006370 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 +00006371 (yyval.ParamList)->push_back(E);
6372 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006373 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006374 ;}
6375 break;
6376
Dale Johannesendfe8c842008-09-26 19:32:34 +00006377 case 318:
6378#line 3021 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006379 {
Devang Patel05988662008-09-25 21:00:45 +00006380 // FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00006381 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
Devang Patel05988662008-09-25 21:00:45 +00006382 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 +00006383 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006384 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006385 ;}
6386 break;
6387
Dale Johannesendfe8c842008-09-26 19:32:34 +00006388 case 319:
6389#line 3028 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006390 { (yyval.ParamList) = new ParamList(); ;}
6391 break;
6392
Dale Johannesendfe8c842008-09-26 19:32:34 +00006393 case 320:
6394#line 3031 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006395 { (yyval.ValueList) = new std::vector<Value*>(); ;}
6396 break;
6397
Dale Johannesendfe8c842008-09-26 19:32:34 +00006398 case 321:
6399#line 3032 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006400 {
6401 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6402 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00006403 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006404 ;}
6405 break;
6406
Dale Johannesendfe8c842008-09-26 19:32:34 +00006407 case 322:
6408#line 3040 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006409 {
6410 (yyval.ConstantList) = new std::vector<unsigned>();
6411 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
6412 GEN_ERROR("Index " + utostr((yyvsp[(2) - (2)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6413 (yyval.ConstantList)->push_back((yyvsp[(2) - (2)].UInt64Val));
6414 ;}
6415 break;
6416
Dale Johannesendfe8c842008-09-26 19:32:34 +00006417 case 323:
6418#line 3046 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006419 {
6420 (yyval.ConstantList) = (yyvsp[(1) - (3)].ConstantList);
6421 if ((unsigned)(yyvsp[(3) - (3)].UInt64Val) != (yyvsp[(3) - (3)].UInt64Val))
6422 GEN_ERROR("Index " + utostr((yyvsp[(3) - (3)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6423 (yyval.ConstantList)->push_back((yyvsp[(3) - (3)].UInt64Val));
6424 CHECK_FOR_ERROR
6425 ;}
6426 break;
6427
Dale Johannesendfe8c842008-09-26 19:32:34 +00006428 case 324:
6429#line 3055 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006430 {
6431 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006432 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006433 ;}
6434 break;
6435
Dale Johannesendfe8c842008-09-26 19:32:34 +00006436 case 325:
6437#line 3059 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006438 {
6439 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006440 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006441 ;}
6442 break;
6443
Dale Johannesendfe8c842008-09-26 19:32:34 +00006444 case 326:
6445#line 3064 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006446 {
Reid Spencer14310612006-12-31 05:40:51 +00006447 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006448 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006449 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
Dan Gohmanf4423b12008-04-19 00:24:39 +00006450 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006451 GEN_ERROR(
6452 "Arithmetic operator requires integer, FP, or packed operands");
Eric Christopher2a5196f2008-09-24 04:55:49 +00006453 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006454 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006455 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006456 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006457 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006458 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006459 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006460 delete (yyvsp[(2) - (5)].TypeVal);
6461 ;}
6462 break;
6463
Dale Johannesendfe8c842008-09-26 19:32:34 +00006464 case 327:
6465#line 3080 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006466 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006467 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006468 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6469 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
Nate Begeman5bc1ea02008-07-29 15:49:41 +00006470 if (!isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00006471 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006472 GEN_ERROR("Logical operator requires integral operands");
6473 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006474 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006475 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006476 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006477 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006478 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006479 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006480 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006481 delete (yyvsp[(2) - (5)].TypeVal);
6482 ;}
6483 break;
6484
Dale Johannesendfe8c842008-09-26 19:32:34 +00006485 case 328:
6486#line 3097 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006487 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006488 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006489 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006490 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006491 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006492 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006493 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006494 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006495 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006496 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006497 delete (yyvsp[(3) - (6)].TypeVal);
6498 ;}
6499 break;
6500
Dale Johannesendfe8c842008-09-26 19:32:34 +00006501 case 329:
6502#line 3109 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006503 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006504 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006505 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006506 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006507 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006508 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006509 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006510 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006511 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006512 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006513 delete (yyvsp[(3) - (6)].TypeVal);
6514 ;}
6515 break;
6516
Dale Johannesendfe8c842008-09-26 19:32:34 +00006517 case 330:
6518#line 3121 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006519 {
6520 if (!UpRefs.empty())
6521 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6522 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6523 GEN_ERROR("Scalar types not supported by vicmp instruction");
6524 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6525 CHECK_FOR_ERROR
6526 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6527 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006528 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006529 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006530 GEN_ERROR("vicmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006531 delete (yyvsp[(3) - (6)].TypeVal);
6532 ;}
6533 break;
6534
Dale Johannesendfe8c842008-09-26 19:32:34 +00006535 case 331:
6536#line 3135 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006537 {
6538 if (!UpRefs.empty())
6539 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6540 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6541 GEN_ERROR("Scalar types not supported by vfcmp instruction");
6542 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6543 CHECK_FOR_ERROR
6544 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6545 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006546 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006547 if ((yyval.InstVal) == 0)
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006548 GEN_ERROR("vfcmp operator returned null");
Nate Begemanac80ade2008-05-12 19:01:56 +00006549 delete (yyvsp[(3) - (6)].TypeVal);
6550 ;}
6551 break;
6552
Dale Johannesendfe8c842008-09-26 19:32:34 +00006553 case 332:
6554#line 3149 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006555 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006556 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006557 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6558 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6559 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6560 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006561 GEN_ERROR("invalid cast opcode for cast from '" +
6562 Val->getType()->getDescription() + "' to '" +
Eric Christopher2a5196f2008-09-24 04:55:49 +00006563 DestTy->getDescription() + "'");
Dan Gohmane4977cf2008-05-23 01:55:30 +00006564 (yyval.InstVal) = CastInst::Create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006565 delete (yyvsp[(4) - (4)].TypeVal);
6566 ;}
6567 break;
6568
Dale Johannesendfe8c842008-09-26 19:32:34 +00006569 case 333:
6570#line 3161 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006571 {
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006572 if (isa<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType())) {
6573 // vector select
6574 if (!isa<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType())
6575 || !isa<VectorType>((yyvsp[(6) - (6)].ValueVal)->getType()) )
6576 GEN_ERROR("vector select value types must be vector types");
6577 const VectorType* cond_type = cast<VectorType>((yyvsp[(2) - (6)].ValueVal)->getType());
6578 const VectorType* select_type = cast<VectorType>((yyvsp[(4) - (6)].ValueVal)->getType());
6579 if (cond_type->getElementType() != Type::Int1Ty)
6580 GEN_ERROR("vector select condition element type must be boolean");
6581 if (cond_type->getNumElements() != select_type->getNumElements())
6582 GEN_ERROR("vector select number of elements must be the same");
6583 } else {
6584 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
6585 GEN_ERROR("select condition must be boolean");
6586 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006587 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmand8ee59b2008-09-09 01:13:24 +00006588 GEN_ERROR("select value types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006589 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006590 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006591 ;}
6592 break;
6593
Dale Johannesendfe8c842008-09-26 19:32:34 +00006594 case 334:
6595#line 3182 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006596 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006597 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006598 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6599 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6600 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006601 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006602 ;}
6603 break;
6604
Dale Johannesendfe8c842008-09-26 19:32:34 +00006605 case 335:
6606#line 3189 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006607 {
6608 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006609 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006610 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006611 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006612 ;}
6613 break;
6614
Dale Johannesendfe8c842008-09-26 19:32:34 +00006615 case 336:
6616#line 3195 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006617 {
6618 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006619 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006620 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006621 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006622 ;}
6623 break;
6624
Dale Johannesendfe8c842008-09-26 19:32:34 +00006625 case 337:
6626#line 3201 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006627 {
6628 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006629 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006630 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006631 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006632 ;}
6633 break;
6634
Dale Johannesendfe8c842008-09-26 19:32:34 +00006635 case 338:
6636#line 3207 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006637 {
6638 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006639 if (!Ty->isFirstClassType())
6640 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006641 (yyval.InstVal) = PHINode::Create(Ty);
6642 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6643 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
Eric Christopher2a5196f2008-09-24 04:55:49 +00006644 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006645 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006646 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6647 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006648 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006649 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006650 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006651 ;}
6652 break;
6653
Dale Johannesendfe8c842008-09-26 19:32:34 +00006654 case 339:
6655#line 3223 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006656 {
Reid Spencer14310612006-12-31 05:40:51 +00006657
6658 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006659 const PointerType *PFTy = 0;
6660 const FunctionType *Ty = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006661 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006662 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6663 // Pull out the types of all of the arguments...
6664 std::vector<const Type*> ParamTypes;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006665 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006666 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006667 const Type *Ty = I->Val->getType();
6668 if (Ty == Type::VoidTy)
6669 GEN_ERROR("Short call syntax cannot be used with varargs");
6670 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006671 }
Chris Lattnera925a142008-04-23 05:37:08 +00006672
6673 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (8)].TypeVal)))
6674 GEN_ERROR("Invalid result type for LLVM function");
6675
Dan Gohmanf4423b12008-04-19 00:24:39 +00006676 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006677 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006678 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006679
Dan Gohmanf4423b12008-04-19 00:24:39 +00006680 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006681 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006682
Reid Spencer7780acb2007-04-16 06:56:07 +00006683 // Check for call to invalid intrinsic to avoid crashing later.
6684 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006685 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006686 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6687 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006688 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6689 theF->getName() + "'");
6690 }
6691
Devang Patel05988662008-09-25 21:00:45 +00006692 // Set up the Attributes for the function
6693 SmallVector<AttributeWithIndex, 8> Attrs;
6694 if ((yyvsp[(8) - (8)].Attributes) != Attribute::None)
6695 Attrs.push_back(AttributeWithIndex::get(0, (yyvsp[(8) - (8)].Attributes)));
Eric Christopher2a5196f2008-09-24 04:55:49 +00006696 // Check the arguments
Reid Spencer14310612006-12-31 05:40:51 +00006697 ValueList Args;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006698 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006699 // Make sure no arguments is a good thing!
6700 if (Ty->getNumParams() != 0)
6701 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006702 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006703 } else { // Has arguments?
6704 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006705 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006706 FunctionType::param_iterator I = Ty->param_begin();
6707 FunctionType::param_iterator E = Ty->param_end();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006708 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006709 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006710
Duncan Sandsdc024672007-11-27 13:23:08 +00006711 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006712 if (ArgI->Val->getType() != *I)
6713 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006714 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006715 Args.push_back(ArgI->Val);
Devang Patel05988662008-09-25 21:00:45 +00006716 if (ArgI->Attrs != Attribute::None)
6717 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006718 }
6719 if (Ty->isVarArg()) {
6720 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006721 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006722 Args.push_back(ArgI->Val); // push the remaining varargs
Devang Patel05988662008-09-25 21:00:45 +00006723 if (ArgI->Attrs != Attribute::None)
6724 Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006725 }
Reid Spencer14310612006-12-31 05:40:51 +00006726 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006727 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006728 }
Duncan Sandsdc024672007-11-27 13:23:08 +00006729
Devang Patel05988662008-09-25 21:00:45 +00006730 // Finish off the Attributes and check them
6731 AttrListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006732 if (!Attrs.empty())
Devang Patel05988662008-09-25 21:00:45 +00006733 PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006734
Reid Spencer14310612006-12-31 05:40:51 +00006735 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006736 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006737 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6738 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
Devang Patel05988662008-09-25 21:00:45 +00006739 CI->setAttributes(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006740 (yyval.InstVal) = CI;
6741 delete (yyvsp[(6) - (8)].ParamList);
6742 delete (yyvsp[(3) - (8)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006743 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006744 ;}
6745 break;
6746
Dale Johannesendfe8c842008-09-26 19:32:34 +00006747 case 340:
6748#line 3312 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006749 {
6750 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006751 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006752 ;}
6753 break;
6754
Dale Johannesendfe8c842008-09-26 19:32:34 +00006755 case 341:
6756#line 3317 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006757 {
6758 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006759 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006760 ;}
6761 break;
6762
Dale Johannesendfe8c842008-09-26 19:32:34 +00006763 case 342:
6764#line 3321 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006765 {
6766 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006767 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006768 ;}
6769 break;
6770
Dale Johannesendfe8c842008-09-26 19:32:34 +00006771 case 343:
6772#line 3328 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006773 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006774 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006775 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6776 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6777 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006778 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006779 ;}
6780 break;
6781
Dale Johannesendfe8c842008-09-26 19:32:34 +00006782 case 344:
6783#line 3335 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006784 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006785 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006786 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006787 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6788 GEN_ERROR("Malloc array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006789 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006790 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006791 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6792 delete (yyvsp[(2) - (6)].TypeVal);
6793 ;}
6794 break;
6795
Dale Johannesendfe8c842008-09-26 19:32:34 +00006796 case 345:
6797#line 3345 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006798 {
Reid Spencer14310612006-12-31 05:40:51 +00006799 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006800 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6801 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6802 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006803 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006804 ;}
6805 break;
6806
Dale Johannesendfe8c842008-09-26 19:32:34 +00006807 case 346:
6808#line 3352 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006809 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006810 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006811 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006812 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6813 GEN_ERROR("Alloca array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006814 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006815 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006816 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6817 delete (yyvsp[(2) - (6)].TypeVal);
6818 ;}
6819 break;
6820
Dale Johannesendfe8c842008-09-26 19:32:34 +00006821 case 347:
6822#line 3362 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006823 {
6824 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Eric Christopher2a5196f2008-09-24 04:55:49 +00006825 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006826 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6827 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006828 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006829 ;}
6830 break;
6831
Dale Johannesendfe8c842008-09-26 19:32:34 +00006832 case 348:
6833#line 3370 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006834 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006835 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006836 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6837 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006838 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006839 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6840 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006841 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006842 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6843 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006844 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006845 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6846 delete (yyvsp[(3) - (5)].TypeVal);
6847 ;}
6848 break;
6849
Dale Johannesendfe8c842008-09-26 19:32:34 +00006850 case 349:
6851#line 3384 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006852 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006853 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006854 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6855 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006856 if (!PT)
6857 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006858 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006859 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006860 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6861 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006862 "' into space of type '" + ElTy->getDescription() + "'");
6863
Dan Gohmanf4423b12008-04-19 00:24:39 +00006864 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006865 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006866 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6867 delete (yyvsp[(5) - (7)].TypeVal);
6868 ;}
6869 break;
6870
Dale Johannesendfe8c842008-09-26 19:32:34 +00006871 case 350:
6872#line 3401 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006873 {
Dan Gohman1a570242008-07-23 00:54:54 +00006874 if (!UpRefs.empty())
6875 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6876 if (!isa<StructType>((yyvsp[(2) - (5)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (5)].TypeVal)->get()))
6877 GEN_ERROR("getresult insn requires an aggregate operand");
6878 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].UInt64Val)))
6879 GEN_ERROR("Invalid getresult index for type '" +
6880 (*(yyvsp[(2) - (5)].TypeVal))->getDescription()+ "'");
6881
6882 Value *tmpVal = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Devang Patel5a970972008-02-19 22:27:01 +00006883 CHECK_FOR_ERROR
Dan Gohman1a570242008-07-23 00:54:54 +00006884 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(5) - (5)].UInt64Val));
6885 delete (yyvsp[(2) - (5)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006886 ;}
6887 break;
6888
Dale Johannesendfe8c842008-09-26 19:32:34 +00006889 case 351:
6890#line 3415 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006891 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006892 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006893 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6894 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006895 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006896
Dan Gohman041e2eb2008-05-15 19:50:34 +00006897 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()))
Reid Spencer61c83e02006-08-18 08:43:06 +00006898 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006899 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6900 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006901 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006902 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006903 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006904 delete (yyvsp[(4) - (4)].ValueList);
6905 ;}
6906 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006907
Dale Johannesendfe8c842008-09-26 19:32:34 +00006908 case 352:
6909#line 3430 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00006910 {
6911 if (!UpRefs.empty())
6912 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6913 if (!isa<StructType>((yyvsp[(2) - (4)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (4)].TypeVal)->get()))
6914 GEN_ERROR("extractvalue insn requires an aggregate operand");
6915
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006916 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end()))
Dan Gohmane4977cf2008-05-23 01:55:30 +00006917 GEN_ERROR("Invalid extractvalue indices for type '" +
6918 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6919 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
6920 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006921 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006922 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006923 delete (yyvsp[(4) - (4)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00006924 ;}
6925 break;
6926
Dale Johannesendfe8c842008-09-26 19:32:34 +00006927 case 353:
6928#line 3445 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00006929 {
6930 if (!UpRefs.empty())
6931 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (7)].TypeVal))->getDescription());
6932 if (!isa<StructType>((yyvsp[(2) - (7)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (7)].TypeVal)->get()))
6933 GEN_ERROR("extractvalue insn requires an aggregate operand");
6934
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006935 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 +00006936 GEN_ERROR("Invalid insertvalue indices for type '" +
6937 (*(yyvsp[(2) - (7)].TypeVal))->getDescription()+ "'");
6938 Value* aggVal = getVal(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(3) - (7)].ValIDVal));
6939 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
6940 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006941 (yyval.InstVal) = InsertValueInst::Create(aggVal, tmpVal, (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end());
Eric Christopher2a5196f2008-09-24 04:55:49 +00006942 delete (yyvsp[(2) - (7)].TypeVal);
Dan Gohmane4977cf2008-05-23 01:55:30 +00006943 delete (yyvsp[(5) - (7)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006944 delete (yyvsp[(7) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00006945 ;}
6946 break;
6947
Dan Gohmanf4423b12008-04-19 00:24:39 +00006948
6949/* Line 1267 of yacc.c. */
Dale Johannesendfe8c842008-09-26 19:32:34 +00006950#line 6951 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006951 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00006952 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006953 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6954
6955 YYPOPSTACK (yylen);
6956 yylen = 0;
6957 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006958
6959 *++yyvsp = yyval;
6960
6961
Dan Gohmanf4423b12008-04-19 00:24:39 +00006962 /* Now `shift' the result of the reduction. Determine what state
6963 that goes to, based on the state we popped back to and the rule
6964 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006965
6966 yyn = yyr1[yyn];
6967
Dan Gohmanf4423b12008-04-19 00:24:39 +00006968 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6969 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006970 yystate = yytable[yystate];
6971 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00006972 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00006973
6974 goto yynewstate;
6975
6976
Dan Gohmanf4423b12008-04-19 00:24:39 +00006977/*------------------------------------.
6978| yyerrlab -- here on detecting error |
6979`------------------------------------*/
6980yyerrlab:
6981 /* If not already recovering from an error, report this error. */
6982 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006983 {
6984 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006985#if ! YYERROR_VERBOSE
6986 yyerror (YY_("syntax error"));
6987#else
6988 {
6989 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6990 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6991 {
6992 YYSIZE_T yyalloc = 2 * yysize;
6993 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6994 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6995 if (yymsg != yymsgbuf)
6996 YYSTACK_FREE (yymsg);
6997 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6998 if (yymsg)
6999 yymsg_alloc = yyalloc;
7000 else
7001 {
7002 yymsg = yymsgbuf;
7003 yymsg_alloc = sizeof yymsgbuf;
7004 }
7005 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00007006
Dan Gohmanf4423b12008-04-19 00:24:39 +00007007 if (0 < yysize && yysize <= yymsg_alloc)
7008 {
7009 (void) yysyntax_error (yymsg, yystate, yychar);
7010 yyerror (yymsg);
7011 }
7012 else
7013 {
7014 yyerror (YY_("syntax error"));
7015 if (yysize != 0)
7016 goto yyexhaustedlab;
7017 }
7018 }
7019#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007020 }
7021
Dan Gohmanf4423b12008-04-19 00:24:39 +00007022
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007023
7024 if (yyerrstatus == 3)
7025 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00007026 /* If just tried and failed to reuse look-ahead token after an
7027 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00007028
Dan Gohmanf4423b12008-04-19 00:24:39 +00007029 if (yychar <= YYEOF)
7030 {
7031 /* Return failure if at end of input. */
7032 if (yychar == YYEOF)
7033 YYABORT;
7034 }
7035 else
7036 {
7037 yydestruct ("Error: discarding",
7038 yytoken, &yylval);
7039 yychar = YYEMPTY;
7040 }
7041 }
7042
7043 /* Else will try to reuse look-ahead token after shifting the error
7044 token. */
7045 goto yyerrlab1;
7046
7047
7048/*---------------------------------------------------.
7049| yyerrorlab -- error raised explicitly by YYERROR. |
7050`---------------------------------------------------*/
7051yyerrorlab:
7052
7053 /* Pacify compilers like GCC when the user code never invokes
7054 YYERROR and the label yyerrorlab therefore never appears in user
7055 code. */
7056 if (/*CONSTCOND*/ 0)
7057 goto yyerrorlab;
7058
7059 /* Do not reclaim the symbols of the rule which action triggered
7060 this YYERROR. */
7061 YYPOPSTACK (yylen);
7062 yylen = 0;
7063 YY_STACK_PRINT (yyss, yyssp);
7064 yystate = *yyssp;
7065 goto yyerrlab1;
7066
7067
7068/*-------------------------------------------------------------.
7069| yyerrlab1 -- common code for both syntax error and YYERROR. |
7070`-------------------------------------------------------------*/
7071yyerrlab1:
7072 yyerrstatus = 3; /* Each real token shifted decrements this. */
7073
7074 for (;;)
7075 {
7076 yyn = yypact[yystate];
7077 if (yyn != YYPACT_NINF)
7078 {
7079 yyn += YYTERROR;
7080 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7081 {
7082 yyn = yytable[yyn];
7083 if (0 < yyn)
7084 break;
7085 }
7086 }
7087
7088 /* Pop the current state because it cannot handle the error token. */
7089 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007090 YYABORT;
7091
Dale Johannesencdd509a2007-09-07 21:07:57 +00007092
Dan Gohmanf4423b12008-04-19 00:24:39 +00007093 yydestruct ("Error: popping",
7094 yystos[yystate], yyvsp);
7095 YYPOPSTACK (1);
7096 yystate = *yyssp;
7097 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007098 }
7099
7100 if (yyn == YYFINAL)
7101 YYACCEPT;
7102
Reid Spencer68a24bd2005-08-27 18:50:39 +00007103 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007104
7105
7106 /* Shift the error token. */
7107 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00007108
Reid Spencer68a24bd2005-08-27 18:50:39 +00007109 yystate = yyn;
7110 goto yynewstate;
7111
Gabor Greife64d2482008-04-06 23:07:54 +00007112
Dan Gohmanf4423b12008-04-19 00:24:39 +00007113/*-------------------------------------.
7114| yyacceptlab -- YYACCEPT comes here. |
7115`-------------------------------------*/
7116yyacceptlab:
7117 yyresult = 0;
7118 goto yyreturn;
7119
7120/*-----------------------------------.
7121| yyabortlab -- YYABORT comes here. |
7122`-----------------------------------*/
7123yyabortlab:
7124 yyresult = 1;
7125 goto yyreturn;
7126
7127#ifndef yyoverflow
7128/*-------------------------------------------------.
7129| yyexhaustedlab -- memory exhaustion comes here. |
7130`-------------------------------------------------*/
7131yyexhaustedlab:
7132 yyerror (YY_("memory exhausted"));
7133 yyresult = 2;
7134 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00007135#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00007136
7137yyreturn:
7138 if (yychar != YYEOF && yychar != YYEMPTY)
7139 yydestruct ("Cleanup: discarding lookahead",
7140 yytoken, &yylval);
7141 /* Do not reclaim the symbols of the rule which action triggered
7142 this YYABORT or YYACCEPT. */
7143 YYPOPSTACK (yylen);
7144 YY_STACK_PRINT (yyss, yyssp);
7145 while (yyssp != yyss)
7146 {
7147 yydestruct ("Cleanup: popping",
7148 yystos[*yyssp], yyvsp);
7149 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00007150 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007151#ifndef yyoverflow
7152 if (yyss != yyssa)
7153 YYSTACK_FREE (yyss);
7154#endif
7155#if YYERROR_VERBOSE
7156 if (yymsg != yymsgbuf)
7157 YYSTACK_FREE (yymsg);
7158#endif
7159 /* Make sure YYID is used. */
7160 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007161}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007162
7163
Dale Johannesendfe8c842008-09-26 19:32:34 +00007164#line 3464 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00007165
7166
Reid Spencer14310612006-12-31 05:40:51 +00007167// common code from the two 'RunVMAsmParser' functions
7168static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00007169 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00007170 // Check to make sure the parser succeeded
7171 if (yyparse()) {
7172 if (ParserResult)
7173 delete ParserResult;
7174 return 0;
7175 }
7176
Reid Spencer0d60b5a2007-03-30 01:37:39 +00007177 // Emit an error if there are any unresolved types left.
7178 if (!CurModule.LateResolveTypes.empty()) {
7179 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
7180 if (DID.Type == ValID::LocalName) {
7181 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
7182 } else {
7183 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
7184 }
7185 if (ParserResult)
7186 delete ParserResult;
7187 return 0;
7188 }
7189
7190 // Emit an error if there are any unresolved values left.
7191 if (!CurModule.LateResolveValues.empty()) {
7192 Value *V = CurModule.LateResolveValues.back();
7193 std::map<Value*, std::pair<ValID, int> >::iterator I =
7194 CurModule.PlaceHolderInfo.find(V);
7195
7196 if (I != CurModule.PlaceHolderInfo.end()) {
7197 ValID &DID = I->second.first;
7198 if (DID.Type == ValID::LocalName) {
7199 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
7200 } else {
7201 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
7202 }
7203 if (ParserResult)
7204 delete ParserResult;
7205 return 0;
7206 }
7207 }
7208
Reid Spencer14310612006-12-31 05:40:51 +00007209 // Check to make sure that parsing produced a result
7210 if (!ParserResult)
7211 return 0;
7212
7213 // Reset ParserResult variable while saving its value for the result.
7214 Module *Result = ParserResult;
7215 ParserResult = 0;
7216
7217 return Result;
7218}
7219
Reid Spencer61c83e02006-08-18 08:43:06 +00007220void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007221 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00007222 // TODO: column number in exception
7223 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00007224 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00007225 TriggerError = 1;
7226}
Reid Spencer68a24bd2005-08-27 18:50:39 +00007227
7228int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007229 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00007230 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00007231 if (yychar != YYEMPTY && yychar != 0) {
7232 errMsg += " while reading token: '";
Eric Christopher2a5196f2008-09-24 04:55:49 +00007233 errMsg += std::string(LLLgetTokenStart(),
Duncan Sandsdc024672007-11-27 13:23:08 +00007234 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
7235 }
Reid Spencer61c83e02006-08-18 08:43:06 +00007236 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007237 return 0;
7238}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007239