blob: 4f45cfd1e45652440234ab1b697b91543ef2a4fe [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 Johannesen20ab78b2008-08-13 18:41:46 +0000142 X86_SSECALLCC_TOK = 323,
143 DATALAYOUT = 324,
144 RET = 325,
145 BR = 326,
146 SWITCH = 327,
147 INVOKE = 328,
148 UNWIND = 329,
149 UNREACHABLE = 330,
150 ADD = 331,
151 SUB = 332,
152 MUL = 333,
153 UDIV = 334,
154 SDIV = 335,
155 FDIV = 336,
156 UREM = 337,
157 SREM = 338,
158 FREM = 339,
159 AND = 340,
160 OR = 341,
161 XOR = 342,
162 SHL = 343,
163 LSHR = 344,
164 ASHR = 345,
165 ICMP = 346,
166 FCMP = 347,
167 VICMP = 348,
168 VFCMP = 349,
169 EQ = 350,
170 NE = 351,
171 SLT = 352,
172 SGT = 353,
173 SLE = 354,
174 SGE = 355,
175 ULT = 356,
176 UGT = 357,
177 ULE = 358,
178 UGE = 359,
179 OEQ = 360,
180 ONE = 361,
181 OLT = 362,
182 OGT = 363,
183 OLE = 364,
184 OGE = 365,
185 ORD = 366,
186 UNO = 367,
187 UEQ = 368,
188 UNE = 369,
189 MALLOC = 370,
190 ALLOCA = 371,
191 FREE = 372,
192 LOAD = 373,
193 STORE = 374,
194 GETELEMENTPTR = 375,
195 TRUNC = 376,
196 ZEXT = 377,
197 SEXT = 378,
198 FPTRUNC = 379,
199 FPEXT = 380,
200 BITCAST = 381,
201 UITOFP = 382,
202 SITOFP = 383,
203 FPTOUI = 384,
204 FPTOSI = 385,
205 INTTOPTR = 386,
206 PTRTOINT = 387,
207 PHI_TOK = 388,
208 SELECT = 389,
209 VAARG = 390,
210 EXTRACTELEMENT = 391,
211 INSERTELEMENT = 392,
212 SHUFFLEVECTOR = 393,
213 GETRESULT = 394,
214 EXTRACTVALUE = 395,
215 INSERTVALUE = 396,
216 SIGNEXT = 397,
217 ZEROEXT = 398,
218 NORETURN = 399,
219 INREG = 400,
220 SRET = 401,
221 NOUNWIND = 402,
222 NOALIAS = 403,
223 BYVAL = 404,
224 NEST = 405,
225 READNONE = 406,
226 READONLY = 407,
227 GC = 408,
228 DEFAULT = 409,
229 HIDDEN = 410,
230 PROTECTED = 411
Dan Gohmanf4423b12008-04-19 00:24:39 +0000231 };
232#endif
233/* Tokens. */
234#define ESINT64VAL 258
235#define EUINT64VAL 259
236#define ESAPINTVAL 260
237#define EUAPINTVAL 261
238#define LOCALVAL_ID 262
239#define GLOBALVAL_ID 263
240#define FPVAL 264
241#define VOID 265
242#define INTTYPE 266
243#define FLOAT 267
244#define DOUBLE 268
245#define X86_FP80 269
246#define FP128 270
247#define PPC_FP128 271
248#define LABEL 272
249#define TYPE 273
250#define LOCALVAR 274
251#define GLOBALVAR 275
252#define LABELSTR 276
253#define STRINGCONSTANT 277
254#define ATSTRINGCONSTANT 278
255#define PCTSTRINGCONSTANT 279
256#define ZEROINITIALIZER 280
257#define TRUETOK 281
258#define FALSETOK 282
259#define BEGINTOK 283
260#define ENDTOK 284
261#define DECLARE 285
262#define DEFINE 286
263#define GLOBAL 287
264#define CONSTANT 288
265#define SECTION 289
266#define ALIAS 290
267#define VOLATILE 291
268#define THREAD_LOCAL 292
269#define TO 293
270#define DOTDOTDOT 294
271#define NULL_TOK 295
272#define UNDEF 296
273#define INTERNAL 297
274#define LINKONCE 298
275#define WEAK 299
276#define APPENDING 300
277#define DLLIMPORT 301
278#define DLLEXPORT 302
279#define EXTERN_WEAK 303
Dale Johannesenc7071cc2008-05-14 20:13:36 +0000280#define COMMON 304
281#define OPAQUE 305
282#define EXTERNAL 306
283#define TARGET 307
284#define TRIPLE 308
285#define ALIGN 309
286#define ADDRSPACE 310
287#define DEPLIBS 311
288#define CALL 312
289#define TAIL 313
290#define ASM_TOK 314
291#define MODULE 315
292#define SIDEEFFECT 316
293#define CC_TOK 317
294#define CCC_TOK 318
295#define FASTCC_TOK 319
296#define COLDCC_TOK 320
297#define X86_STDCALLCC_TOK 321
298#define X86_FASTCALLCC_TOK 322
Dale Johannesen20ab78b2008-08-13 18:41:46 +0000299#define X86_SSECALLCC_TOK 323
300#define DATALAYOUT 324
301#define RET 325
302#define BR 326
303#define SWITCH 327
304#define INVOKE 328
305#define UNWIND 329
306#define UNREACHABLE 330
307#define ADD 331
308#define SUB 332
309#define MUL 333
310#define UDIV 334
311#define SDIV 335
312#define FDIV 336
313#define UREM 337
314#define SREM 338
315#define FREM 339
316#define AND 340
317#define OR 341
318#define XOR 342
319#define SHL 343
320#define LSHR 344
321#define ASHR 345
322#define ICMP 346
323#define FCMP 347
324#define VICMP 348
325#define VFCMP 349
326#define EQ 350
327#define NE 351
328#define SLT 352
329#define SGT 353
330#define SLE 354
331#define SGE 355
332#define ULT 356
333#define UGT 357
334#define ULE 358
335#define UGE 359
336#define OEQ 360
337#define ONE 361
338#define OLT 362
339#define OGT 363
340#define OLE 364
341#define OGE 365
342#define ORD 366
343#define UNO 367
344#define UEQ 368
345#define UNE 369
346#define MALLOC 370
347#define ALLOCA 371
348#define FREE 372
349#define LOAD 373
350#define STORE 374
351#define GETELEMENTPTR 375
352#define TRUNC 376
353#define ZEXT 377
354#define SEXT 378
355#define FPTRUNC 379
356#define FPEXT 380
357#define BITCAST 381
358#define UITOFP 382
359#define SITOFP 383
360#define FPTOUI 384
361#define FPTOSI 385
362#define INTTOPTR 386
363#define PTRTOINT 387
364#define PHI_TOK 388
365#define SELECT 389
366#define VAARG 390
367#define EXTRACTELEMENT 391
368#define INSERTELEMENT 392
369#define SHUFFLEVECTOR 393
370#define GETRESULT 394
371#define EXTRACTVALUE 395
372#define INSERTVALUE 396
373#define SIGNEXT 397
374#define ZEROEXT 398
375#define NORETURN 399
376#define INREG 400
377#define SRET 401
378#define NOUNWIND 402
379#define NOALIAS 403
380#define BYVAL 404
381#define NEST 405
382#define READNONE 406
383#define READONLY 407
384#define GC 408
385#define DEFAULT 409
386#define HIDDEN 410
387#define PROTECTED 411
Dan Gohmanf4423b12008-04-19 00:24:39 +0000388
389
390
391
392/* Copy the first part of user declarations. */
Chris Lattner15bd0952008-08-29 17:20:18 +0000393#line 14 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000394
395#include "ParserInternals.h"
396#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000397#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000398#include "llvm/Instructions.h"
399#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000400#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000401#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000402#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000403#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000404#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000405#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000406#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000407#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000408#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000409#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000410#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000411#include <utility>
412
Reid Spencere4f47592006-08-18 17:32:55 +0000413// The following is a gross hack. In order to rid the libAsmParser library of
414// exceptions, we have to have a way of getting the yyparse function to go into
415// an error situation. So, whenever we want an error to occur, the GenerateError
416// function (see bottom of file) sets TriggerError. Then, at the end of each
417// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
418// (a goto) to put YACC in error state. Furthermore, several calls to
419// GenerateError are made from inside productions and they must simulate the
420// previous exception behavior by exiting the production immediately. We have
421// replaced these with the GEN_ERROR macro which calls GeneratError and then
422// immediately invokes YYERROR. This would be so much cleaner if it was a
423// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000424static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000425#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000426#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
427
Reid Spencer68a24bd2005-08-27 18:50:39 +0000428int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
429int yylex(); // declaration" of xxx warnings.
430int yyparse();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000431using namespace llvm;
432
433static Module *ParserResult;
434
435// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
436// relating to upreferences in the input stream.
437//
438//#define DEBUG_UPREFS 1
439#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000440#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000441#else
442#define UR_OUT(X)
443#endif
444
445#define YYERROR_VERBOSE 1
446
Chris Lattnerb475c422005-11-12 18:22:38 +0000447static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000448
449
450// This contains info used when building the body of a function. It is
451// destroyed when the function is completed.
452//
453typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000454
Reid Spencer68a24bd2005-08-27 18:50:39 +0000455static void
Reid Spencer93c40032007-03-19 18:40:50 +0000456ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000457
458static struct PerModuleInfo {
459 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000460 ValueList Values; // Module level numbered definitions
461 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000462 std::vector<PATypeHolder> Types;
463 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000464
465 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000466 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000467 /// that we can resolve them later and print error messages as appropriate.
468 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
469
470 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
471 // references to global values. Global values may be referenced before they
472 // are defined, and if so, the temporary object that they represent is held
473 // here. This is used for forward references of GlobalValues.
474 //
475 typedef std::map<std::pair<const PointerType *,
476 ValID>, GlobalValue*> GlobalRefsType;
477 GlobalRefsType GlobalRefs;
478
479 void ModuleDone() {
480 // If we could not resolve some functions at function compilation time
481 // (calls to functions before they are defined), resolve them now... Types
482 // are resolved when the constant pool has been completely parsed.
483 //
484 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000485 if (TriggerError)
486 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000487
488 // Check to make sure that all global value forward references have been
489 // resolved!
490 //
491 if (!GlobalRefs.empty()) {
492 std::string UndefinedReferences = "Unresolved global references exist:\n";
493
494 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
495 I != E; ++I) {
496 UndefinedReferences += " " + I->first.first->getDescription() + " " +
497 I->first.second.getName() + "\n";
498 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000499 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000500 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000501 }
502
Chandler Carruth02202192007-08-04 01:56:21 +0000503 // Look for intrinsic functions and CallInst that need to be upgraded
504 for (Module::iterator FI = CurrentModule->begin(),
505 FE = CurrentModule->end(); FI != FE; )
506 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
507
Reid Spencer68a24bd2005-08-27 18:50:39 +0000508 Values.clear(); // Clear out function local definitions
509 Types.clear();
510 CurrentModule = 0;
511 }
512
Reid Spencer68a24bd2005-08-27 18:50:39 +0000513 // GetForwardRefForGlobal - Check to see if there is a forward reference
514 // for this global. If so, remove it from the GlobalRefs map and return it.
515 // If not, just return null.
516 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
517 // Check to see if there is a forward reference to this global variable...
518 // if there is, eliminate it and patch the reference to use the new def'n.
519 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
520 GlobalValue *Ret = 0;
521 if (I != GlobalRefs.end()) {
522 Ret = I->second;
523 GlobalRefs.erase(I);
524 }
525 return Ret;
526 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000527
528 bool TypeIsUnresolved(PATypeHolder* PATy) {
529 // If it isn't abstract, its resolved
530 const Type* Ty = PATy->get();
531 if (!Ty->isAbstract())
532 return false;
533 // Traverse the type looking for abstract types. If it isn't abstract then
534 // we don't need to traverse that leg of the type.
535 std::vector<const Type*> WorkList, SeenList;
536 WorkList.push_back(Ty);
537 while (!WorkList.empty()) {
538 const Type* Ty = WorkList.back();
539 SeenList.push_back(Ty);
540 WorkList.pop_back();
541 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
542 // Check to see if this is an unresolved type
543 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
544 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
545 for ( ; I != E; ++I) {
546 if (I->second.get() == OpTy)
547 return true;
548 }
549 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
550 const Type* TheTy = SeqTy->getElementType();
551 if (TheTy->isAbstract() && TheTy != Ty) {
552 std::vector<const Type*>::iterator I = SeenList.begin(),
553 E = SeenList.end();
554 for ( ; I != E; ++I)
555 if (*I == TheTy)
556 break;
557 if (I == E)
558 WorkList.push_back(TheTy);
559 }
560 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
561 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
562 const Type* TheTy = StrTy->getElementType(i);
563 if (TheTy->isAbstract() && TheTy != Ty) {
564 std::vector<const Type*>::iterator I = SeenList.begin(),
565 E = SeenList.end();
566 for ( ; I != E; ++I)
567 if (*I == TheTy)
568 break;
569 if (I == E)
570 WorkList.push_back(TheTy);
571 }
572 }
573 }
574 }
575 return false;
576 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000577} CurModule;
578
579static struct PerFunctionInfo {
580 Function *CurrentFunction; // Pointer to current function being created
581
Reid Spencer93c40032007-03-19 18:40:50 +0000582 ValueList Values; // Keep track of #'d definitions
583 unsigned NextValNum;
584 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000585 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000586 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000587 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000588
589 /// BBForwardRefs - When we see forward references to basic blocks, keep
590 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000591 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000592
593 inline PerFunctionInfo() {
594 CurrentFunction = 0;
595 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000596 Linkage = GlobalValue::ExternalLinkage;
597 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000598 }
599
600 inline void FunctionStart(Function *M) {
601 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000602 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000603 }
604
605 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000607 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000608 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000609 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000610 return;
611 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000612
613 // Resolve all forward references now.
614 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
615
616 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000617 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000618 CurrentFunction = 0;
619 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000620 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000621 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000622 }
623} CurFun; // Info for the current function...
624
625static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
626
627
628//===----------------------------------------------------------------------===//
629// Code to handle definitions of all the types
630//===----------------------------------------------------------------------===//
631
Chris Lattner15bd0952008-08-29 17:20:18 +0000632/// InsertValue - Insert a value into the value table. If it is named, this
633/// returns -1, otherwise it returns the slot number for the value.
634static int InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
Reid Spencer93c40032007-03-19 18:40:50 +0000635 // Things that have names or are void typed don't get slot numbers
636 if (V->hasName() || (V->getType() == Type::VoidTy))
Chris Lattner15bd0952008-08-29 17:20:18 +0000637 return -1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000638
Reid Spencer93c40032007-03-19 18:40:50 +0000639 // In the case of function values, we have to allow for the forward reference
640 // of basic blocks, which are included in the numbering. Consequently, we keep
641 // track of the next insertion location with NextValNum. When a BB gets
642 // inserted, it could change the size of the CurFun.Values vector.
643 if (&ValueTab == &CurFun.Values) {
644 if (ValueTab.size() <= CurFun.NextValNum)
645 ValueTab.resize(CurFun.NextValNum+1);
646 ValueTab[CurFun.NextValNum++] = V;
Chris Lattner15bd0952008-08-29 17:20:18 +0000647 return CurFun.NextValNum-1;
Reid Spencer93c40032007-03-19 18:40:50 +0000648 }
649 // For all other lists, its okay to just tack it on the back of the vector.
650 ValueTab.push_back(V);
Chris Lattner15bd0952008-08-29 17:20:18 +0000651 return ValueTab.size()-1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000652}
653
654static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
655 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000656 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000658 if (D.Num < CurModule.Types.size())
659 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000660 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000661 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000662 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000663 D.destroy(); // Free old strdup'd memory...
664 return N;
665 }
666 break;
667 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000668 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000669 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000670 }
671
672 // If we reached here, we referenced either a symbol that we don't know about
673 // or an id number that hasn't been read yet. We may be referencing something
674 // forward, so just create an entry to be resolved later and get to it...
675 //
676 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
677
678
679 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000680 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000681 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000682 return 0;
683 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000684 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000685 return 0;
686 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000687 }
688
Reid Spencer861d9d62006-11-28 07:29:44 +0000689 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000690 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000691 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000692
Reid Spencer861d9d62006-11-28 07:29:44 +0000693 Type *Typ = OpaqueType::get();
694 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
695 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000696 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000697
Reid Spencer93c40032007-03-19 18:40:50 +0000698// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000699// the provided ValID. If the value exists and has already been defined, return
700// it. Otherwise return null.
701//
Reid Spencer93c40032007-03-19 18:40:50 +0000702static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000703 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000704 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000705 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000706 return 0;
707 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000708
709 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000710 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000711 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000712 if (D.Num >= CurFun.Values.size())
713 return 0;
714 Value *Result = CurFun.Values[D.Num];
715 if (Ty != Result->getType()) {
716 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
717 Result->getType()->getDescription() + "' does not match "
718 "expected type, '" + Ty->getDescription() + "'");
719 return 0;
720 }
721 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000722 }
723 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000724 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000725 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000726 Value *Result = CurModule.Values[D.Num];
727 if (Ty != Result->getType()) {
728 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
729 Result->getType()->getDescription() + "' does not match "
730 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000731 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000732 }
733 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000734 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000735
736 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000737 if (!inFunctionScope())
738 return 0;
739 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000740 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000741 if (N == 0)
742 return 0;
743 if (N->getType() != Ty)
744 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000745
746 D.destroy(); // Free old strdup'd memory...
747 return N;
748 }
749 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000750 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000751 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000752 if (N == 0)
753 return 0;
754 if (N->getType() != Ty)
755 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000756
757 D.destroy(); // Free old strdup'd memory...
758 return N;
759 }
760
761 // Check to make sure that "Ty" is an integral type, and that our
762 // value will fit into the specified type...
763 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner38905612008-02-19 04:36:25 +0000764 if (!isa<IntegerType>(Ty) ||
765 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000766 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000767 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000768 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000769 return 0;
770 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000771 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000772
773 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000774 if (isa<IntegerType>(Ty) &&
775 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Reid Spencerb83eb642006-10-20 07:07:24 +0000776 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner38905612008-02-19 04:36:25 +0000777
778 if (!isa<IntegerType>(Ty) ||
779 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
780 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
781 "' is invalid or out of range for type '" +
782 Ty->getDescription() + "'");
783 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000784 }
Chris Lattner38905612008-02-19 04:36:25 +0000785 // This is really a signed reference. Transmogrify.
786 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000787
Chris Lattner1913b942008-07-11 00:30:39 +0000788 case ValID::ConstAPInt: // Is it an unsigned const pool reference?
789 if (!isa<IntegerType>(Ty)) {
790 GenerateError("Integral constant '" + D.getName() +
791 "' is invalid or out of range for type '" +
792 Ty->getDescription() + "'");
793 return 0;
794 }
795
796 {
797 APSInt Tmp = *D.ConstPoolInt;
798 Tmp.extOrTrunc(Ty->getPrimitiveSizeInBits());
799 return ConstantInt::get(Tmp);
800 }
801
Reid Spencer68a24bd2005-08-27 18:50:39 +0000802 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner38905612008-02-19 04:36:25 +0000803 if (!Ty->isFloatingPoint() ||
804 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000805 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000806 return 0;
807 }
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000808 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesenc72cd7e2007-09-11 18:33:39 +0000809 // as double. Fix this here. Long double does not need this.
810 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
811 Ty==Type::FloatTy)
Dale Johannesencdd509a2007-09-07 21:07:57 +0000812 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +0000813 return ConstantFP::get(*D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000814
815 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000816 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000817 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000818 return 0;
819 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000820 return ConstantPointerNull::get(cast<PointerType>(Ty));
821
822 case ValID::ConstUndefVal: // Is it an undef value?
823 return UndefValue::get(Ty);
824
Chris Lattner7aa61892005-12-21 17:53:23 +0000825 case ValID::ConstZeroVal: // Is it a zero value?
826 return Constant::getNullValue(Ty);
827
Reid Spencer68a24bd2005-08-27 18:50:39 +0000828 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000829 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000830 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000831 return 0;
832 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000833 return D.ConstantValue;
834
Chris Lattner0e9c3762006-01-25 22:27:16 +0000835 case ValID::InlineAsmVal: { // Inline asm expression
836 const PointerType *PTy = dyn_cast<PointerType>(Ty);
837 const FunctionType *FTy =
838 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000839 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000840 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000841 return 0;
842 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000843 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
844 D.IAD->HasSideEffects);
845 D.destroy(); // Free InlineAsmDescriptor.
846 return IA;
847 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000848 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000849 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000850 return 0;
851 } // End of switch
852
Reid Spencera9720f52007-02-05 17:04:00 +0000853 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000854 return 0;
855}
856
Reid Spencer93c40032007-03-19 18:40:50 +0000857// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000858// value is not already defined, it "improvises" by creating a placeholder var
859// that looks and acts just like the requested variable. When the value is
860// defined later, all uses of the placeholder variable are replaced with the
861// real thing.
862//
863static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000864 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000865 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000866 return 0;
867 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000868
869 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000870 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000871 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000872 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000873
Reid Spencer5b7e7532006-09-28 19:28:24 +0000874 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Dan Gohmane4977cf2008-05-23 01:55:30 +0000875 GenerateError("Invalid use of a non-first-class type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000876 return 0;
877 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000878
879 // If we reached here, we referenced either a symbol that we don't know about
880 // or an id number that hasn't been read yet. We may be referencing something
881 // forward, so just create an entry to be resolved later and get to it...
882 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000883 switch (ID.Type) {
884 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000885 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000886 const PointerType *PTy = dyn_cast<PointerType>(Ty);
887 if (!PTy) {
888 GenerateError("Invalid type for reference to global" );
889 return 0;
890 }
891 const Type* ElTy = PTy->getElementType();
892 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greife64d2482008-04-06 23:07:54 +0000893 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000894 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000895 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
896 (Module*)0, false, PTy->getAddressSpace());
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000897 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000898 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000899 default:
900 V = new Argument(Ty);
901 }
902
Reid Spencer68a24bd2005-08-27 18:50:39 +0000903 // Remember where this forward reference came from. FIXME, shouldn't we try
904 // to recycle these things??
905 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsdc024672007-11-27 13:23:08 +0000906 LLLgetLineNo())));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000907
908 if (inFunctionScope())
909 InsertValue(V, CurFun.LateResolveValues);
910 else
911 InsertValue(V, CurModule.LateResolveValues);
912 return V;
913}
914
Reid Spencer93c40032007-03-19 18:40:50 +0000915/// defineBBVal - This is a definition of a new basic block with the specified
916/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Chris Lattnercc81d152008-05-04 17:18:47 +0000917static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000918 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000919
Reid Spencer68a24bd2005-08-27 18:50:39 +0000920 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000921
Reid Spencer93c40032007-03-19 18:40:50 +0000922 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000923
Reid Spencer93c40032007-03-19 18:40:50 +0000924 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
925 if (BBI != CurFun.BBForwardRefs.end()) {
926 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000927 // The forward declaration could have been inserted anywhere in the
928 // function: insert it into the correct place now.
929 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
930 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000931
Reid Spencer66728ef2007-03-20 01:13:36 +0000932 // We're about to erase the entry, save the key so we can clean it up.
933 ValID Tmp = BBI->first;
934
Reid Spencer93c40032007-03-19 18:40:50 +0000935 // Erase the forward ref from the map as its no longer "forward"
936 CurFun.BBForwardRefs.erase(ID);
937
Reid Spencer66728ef2007-03-20 01:13:36 +0000938 // The key has been removed from the map but so we don't want to leave
939 // strdup'd memory around so destroy it too.
940 Tmp.destroy();
941
Reid Spencer93c40032007-03-19 18:40:50 +0000942 // If its a numbered definition, bump the number and set the BB value.
943 if (ID.Type == ValID::LocalID) {
944 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
945 InsertValue(BB);
946 }
Devang Patel67909432008-03-03 18:58:47 +0000947 } else {
948 // We haven't seen this BB before and its first mention is a definition.
949 // Just create it and return it.
950 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greife64d2482008-04-06 23:07:54 +0000951 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel67909432008-03-03 18:58:47 +0000952 if (ID.Type == ValID::LocalID) {
953 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
954 InsertValue(BB);
955 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000956 }
Reid Spencer93c40032007-03-19 18:40:50 +0000957
Devang Patel67909432008-03-03 18:58:47 +0000958 ID.destroy();
Reid Spencer93c40032007-03-19 18:40:50 +0000959 return BB;
960}
961
962/// getBBVal - get an existing BB value or create a forward reference for it.
963///
964static BasicBlock *getBBVal(const ValID &ID) {
965 assert(inFunctionScope() && "Can't get basic block at global scope!");
966
967 BasicBlock *BB = 0;
968
969 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
970 if (BBI != CurFun.BBForwardRefs.end()) {
971 BB = BBI->second;
972 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000973 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000974 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000975 if (N) {
Reid Spencer93c40032007-03-19 18:40:50 +0000976 if (N->getType()->getTypeID() == Type::LabelTyID)
977 BB = cast<BasicBlock>(N);
978 else
979 GenerateError("Reference to label '" + Name + "' is actually of type '"+
980 N->getType()->getDescription() + "'");
Anton Korobeynikovc70d7732008-02-20 12:10:37 +0000981 }
Reid Spencer93c40032007-03-19 18:40:50 +0000982 } else if (ID.Type == ValID::LocalID) {
983 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
984 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
985 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
986 else
987 GenerateError("Reference to label '%" + utostr(ID.Num) +
988 "' is actually of type '"+
989 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
990 }
991 } else {
992 GenerateError("Illegal label reference " + ID.getName());
993 return 0;
994 }
995
996 // If its already been defined, return it now.
997 if (BB) {
998 ID.destroy(); // Free strdup'd memory.
999 return BB;
1000 }
1001
1002 // Otherwise, this block has not been seen before, create it.
1003 std::string Name;
1004 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001005 Name = ID.getName();
Gabor Greife64d2482008-04-06 23:07:54 +00001006 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Reid Spencer93c40032007-03-19 18:40:50 +00001007
1008 // Insert it in the forward refs map.
1009 CurFun.BBForwardRefs[ID] = BB;
1010
Reid Spencer68a24bd2005-08-27 18:50:39 +00001011 return BB;
1012}
1013
1014
1015//===----------------------------------------------------------------------===//
1016// Code to handle forward references in instructions
1017//===----------------------------------------------------------------------===//
1018//
1019// This code handles the late binding needed with statements that reference
1020// values not defined yet... for example, a forward branch, or the PHI node for
1021// a loop body.
1022//
1023// This keeps a table (CurFun.LateResolveValues) of all such forward references
1024// and back patchs after we are done.
1025//
1026
1027// ResolveDefinitions - If we could not resolve some defs at parsing
1028// time (forward branches, phi functions for loops, etc...) resolve the
1029// defs now...
1030//
1031static void
Reid Spencer93c40032007-03-19 18:40:50 +00001032ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001033 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +00001034 while (!LateResolvers.empty()) {
1035 Value *V = LateResolvers.back();
1036 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001037
Reid Spencer93c40032007-03-19 18:40:50 +00001038 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1039 CurModule.PlaceHolderInfo.find(V);
1040 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001041
Reid Spencer93c40032007-03-19 18:40:50 +00001042 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001043
Reid Spencer93c40032007-03-19 18:40:50 +00001044 Value *TheRealValue = getExistingVal(V->getType(), DID);
1045 if (TriggerError)
1046 return;
1047 if (TheRealValue) {
1048 V->replaceAllUsesWith(TheRealValue);
1049 delete V;
1050 CurModule.PlaceHolderInfo.erase(PHI);
1051 } else if (FutureLateResolvers) {
1052 // Functions have their unresolved items forwarded to the module late
1053 // resolver table
1054 InsertValue(V, *FutureLateResolvers);
1055 } else {
1056 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1057 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1058 "' of type '" + V->getType()->getDescription() + "'",
1059 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001060 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001061 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001062 GenerateError("Reference to an invalid definition: #" +
1063 itostr(DID.Num) + " of type '" +
1064 V->getType()->getDescription() + "'",
1065 PHI->second.second);
1066 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001067 }
1068 }
1069 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001070 LateResolvers.clear();
1071}
1072
1073// ResolveTypeTo - A brand new type was just declared. This means that (if
1074// name is not null) things referencing Name can be resolved. Otherwise, things
1075// refering to the number can be resolved. Do this now.
1076//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001077static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001078 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001079 if (Name)
1080 D = ValID::createLocalName(*Name);
1081 else
1082 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001083
Reid Spencer861d9d62006-11-28 07:29:44 +00001084 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001085 CurModule.LateResolveTypes.find(D);
1086 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001087 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001088 CurModule.LateResolveTypes.erase(I);
1089 }
1090}
1091
1092// setValueName - Set the specified value to the name given. The name may be
1093// null potentially, in which case this is a noop. The string passed in is
1094// assumed to be a malloc'd string buffer, and is free'd by this function.
1095//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001096static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001097 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001098 std::string Name(*NameStr); // Copy string
1099 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001100
Reid Spencer41dff5e2007-01-26 08:05:27 +00001101 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001102 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001103 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001104 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001105
Reid Spencera9720f52007-02-05 17:04:00 +00001106 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001107 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1108 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001109 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001110 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001111 return;
1112 }
1113
1114 // Set the name.
1115 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001116}
1117
1118/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1119/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001120static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001121ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001122 GlobalValue::LinkageTypes Linkage,
1123 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001124 bool isConstantGlobal, const Type *Ty,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001125 Constant *Initializer, bool IsThreadLocal,
1126 unsigned AddressSpace = 0) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001127 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001128 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001129 return 0;
1130 }
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001131 if (Ty == Type::LabelTy) {
1132 GenerateError("Cannot declare global vars of label type");
1133 return 0;
1134 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001135
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001136 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001137
1138 std::string Name;
1139 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001140 Name = *NameStr; // Copy string
1141 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001142 }
1143
1144 // See if this global value was forward referenced. If so, recycle the
1145 // object.
1146 ValID ID;
1147 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001148 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001149 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001150 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001151 }
1152
1153 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1154 // Move the global to the end of the list, from whereever it was
1155 // previously inserted.
1156 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1157 CurModule.CurrentModule->getGlobalList().remove(GV);
1158 CurModule.CurrentModule->getGlobalList().push_back(GV);
1159 GV->setInitializer(Initializer);
1160 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001161 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001162 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001163 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001164 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001165 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001166 }
1167
Reid Spenceref9b9a72007-02-05 20:47:22 +00001168 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001169 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001170 // if the global we're parsing has an initializer (is a definition) and
1171 // has external linkage.
1172 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1173 // If there is already a global with external linkage with this name
1174 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1175 // If we allow this GVar to get created, it will be renamed in the
1176 // symbol table because it conflicts with an existing GVar. We can't
1177 // allow redefinition of GVars whose linking indicates that their name
1178 // must stay the same. Issue the error.
1179 GenerateError("Redefinition of global variable named '" + Name +
1180 "' of type '" + Ty->getDescription() + "'");
1181 return 0;
1182 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001183 }
1184
1185 // Otherwise there is no existing GV to use, create one now.
1186 GlobalVariable *GV =
1187 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001188 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001189 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001190 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001191 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001192}
1193
1194// setTypeName - Set the specified type to the name given. The name may be
1195// null potentially, in which case this is a noop. The string passed in is
1196// assumed to be a malloc'd string buffer, and is freed by this function.
1197//
1198// This function returns true if the type has already been defined, but is
1199// allowed to be redefined in the specified context. If the name is a new name
1200// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001201static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001202 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001203 if (NameStr == 0) return false;
1204
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001205 std::string Name(*NameStr); // Copy string
1206 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001207
1208 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001209 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001210 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001211 return false;
1212 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001213
1214 // Set the type name, checking for conflicts as we do so.
1215 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1216
1217 if (AlreadyExists) { // Inserting a name that is already defined???
1218 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001219 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001220
1221 // There is only one case where this is allowed: when we are refining an
1222 // opaque type. In this case, Existing will be an opaque type.
1223 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1224 // We ARE replacing an opaque type!
1225 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1226 return true;
1227 }
1228
1229 // Otherwise, this is an attempt to redefine a type. That's okay if
1230 // the redefinition is identical to the original. This will be so if
1231 // Existing and T point to the same Type object. In this one case we
1232 // allow the equivalent redefinition.
1233 if (Existing == T) return true; // Yes, it's equal.
1234
1235 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001236 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001237 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001238 }
1239
1240 return false;
1241}
1242
1243//===----------------------------------------------------------------------===//
1244// Code for handling upreferences in type names...
1245//
1246
1247// TypeContains - Returns true if Ty directly contains E in it.
1248//
1249static bool TypeContains(const Type *Ty, const Type *E) {
1250 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1251 E) != Ty->subtype_end();
1252}
1253
1254namespace {
1255 struct UpRefRecord {
1256 // NestingLevel - The number of nesting levels that need to be popped before
1257 // this type is resolved.
1258 unsigned NestingLevel;
1259
1260 // LastContainedTy - This is the type at the current binding level for the
1261 // type. Every time we reduce the nesting level, this gets updated.
1262 const Type *LastContainedTy;
1263
1264 // UpRefTy - This is the actual opaque type that the upreference is
1265 // represented with.
1266 OpaqueType *UpRefTy;
1267
1268 UpRefRecord(unsigned NL, OpaqueType *URTy)
1269 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1270 };
1271}
1272
1273// UpRefs - A list of the outstanding upreferences that need to be resolved.
1274static std::vector<UpRefRecord> UpRefs;
1275
1276/// HandleUpRefs - Every time we finish a new layer of types, this function is
1277/// called. It loops through the UpRefs vector, which is a list of the
1278/// currently active types. For each type, if the up reference is contained in
1279/// the newly completed type, we decrement the level count. When the level
1280/// count reaches zero, the upreferenced type is the type that is passed in:
1281/// thus we can complete the cycle.
1282///
1283static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001284 // If Ty isn't abstract, or if there are no up-references in it, then there is
1285 // nothing to resolve here.
1286 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1287
Reid Spencer68a24bd2005-08-27 18:50:39 +00001288 PATypeHolder Ty(ty);
1289 UR_OUT("Type '" << Ty->getDescription() <<
1290 "' newly formed. Resolving upreferences.\n" <<
1291 UpRefs.size() << " upreferences active!\n");
1292
1293 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1294 // to zero), we resolve them all together before we resolve them to Ty. At
1295 // the end of the loop, if there is anything to resolve to Ty, it will be in
1296 // this variable.
1297 OpaqueType *TypeToResolve = 0;
1298
1299 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1300 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1301 << UpRefs[i].second->getDescription() << ") = "
1302 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1303 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1304 // Decrement level of upreference
1305 unsigned Level = --UpRefs[i].NestingLevel;
1306 UpRefs[i].LastContainedTy = Ty;
1307 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1308 if (Level == 0) { // Upreference should be resolved!
1309 if (!TypeToResolve) {
1310 TypeToResolve = UpRefs[i].UpRefTy;
1311 } else {
1312 UR_OUT(" * Resolving upreference for "
1313 << UpRefs[i].second->getDescription() << "\n";
1314 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1315 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1316 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1317 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1318 }
1319 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1320 --i; // Do not skip the next element...
1321 }
1322 }
1323 }
1324
1325 if (TypeToResolve) {
1326 UR_OUT(" * Resolving upreference for "
1327 << UpRefs[i].second->getDescription() << "\n";
1328 std::string OldName = TypeToResolve->getDescription());
1329 TypeToResolve->refineAbstractTypeTo(Ty);
1330 }
1331
1332 return Ty;
1333}
1334
Reid Spencer68a24bd2005-08-27 18:50:39 +00001335//===----------------------------------------------------------------------===//
1336// RunVMAsmParser - Define an interface to this parser
1337//===----------------------------------------------------------------------===//
1338//
Reid Spencer14310612006-12-31 05:40:51 +00001339static Module* RunParser(Module * M);
1340
Duncan Sandsdc024672007-11-27 13:23:08 +00001341Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1342 InitLLLexer(MB);
1343 Module *M = RunParser(new Module(LLLgetFilename()));
1344 FreeLexer();
1345 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001346}
1347
1348
Dan Gohmanf4423b12008-04-19 00:24:39 +00001349
1350/* Enabling traces. */
1351#ifndef YYDEBUG
1352# define YYDEBUG 0
1353#endif
1354
1355/* Enabling verbose error messages. */
1356#ifdef YYERROR_VERBOSE
1357# undef YYERROR_VERBOSE
1358# define YYERROR_VERBOSE 1
1359#else
1360# define YYERROR_VERBOSE 0
1361#endif
1362
1363/* Enabling the token table. */
1364#ifndef YYTOKEN_TABLE
1365# define YYTOKEN_TABLE 0
1366#endif
1367
1368#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1369typedef union YYSTYPE
Chris Lattner15bd0952008-08-29 17:20:18 +00001370#line 970 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001371{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001372 llvm::Module *ModuleVal;
1373 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001374 llvm::BasicBlock *BasicBlockVal;
1375 llvm::TerminatorInst *TermInstVal;
1376 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001377 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001378
Reid Spencera132e042006-12-03 05:46:11 +00001379 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001380 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001381 llvm::PATypeHolder *TypeVal;
1382 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001383 std::vector<llvm::Value*> *ValueList;
Dan Gohman81a0c0b2008-05-31 00:58:22 +00001384 std::vector<unsigned> *ConstantList;
Reid Spencer14310612006-12-31 05:40:51 +00001385 llvm::ArgListType *ArgList;
1386 llvm::TypeWithAttrs TypeWithAttrs;
1387 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001388 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001389
Reid Spencer68a24bd2005-08-27 18:50:39 +00001390 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001391 std::list<std::pair<llvm::Value*,
1392 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001393 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001394 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001395
1396 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001397 llvm::GlobalValue::VisibilityTypes Visibility;
Dale Johannesen222ebf72008-02-19 21:40:51 +00001398 llvm::ParameterAttributes ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001399 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001400 int64_t SInt64Val;
1401 uint64_t UInt64Val;
1402 int SIntVal;
1403 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001404 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001405 bool BoolVal;
1406
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001407 std::string *StrVal; // This memory must be deleted
1408 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001409
Reid Spencera132e042006-12-03 05:46:11 +00001410 llvm::Instruction::BinaryOps BinaryOpVal;
1411 llvm::Instruction::TermOps TermOpVal;
1412 llvm::Instruction::MemoryOps MemOpVal;
1413 llvm::Instruction::CastOps CastOpVal;
1414 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001415 llvm::ICmpInst::Predicate IPredicate;
1416 llvm::FCmpInst::Predicate FPredicate;
Dan Gohmanf4423b12008-04-19 00:24:39 +00001417}
Dan Gohman180c1692008-06-23 18:43:26 +00001418/* Line 193 of yacc.c. */
Chris Lattner15bd0952008-08-29 17:20:18 +00001419#line 1420 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00001420 YYSTYPE;
1421# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1422# define YYSTYPE_IS_DECLARED 1
1423# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001424#endif
1425
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001426
Reid Spencer68a24bd2005-08-27 18:50:39 +00001427
Dan Gohmanf4423b12008-04-19 00:24:39 +00001428/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001429
1430
Dan Gohmanf4423b12008-04-19 00:24:39 +00001431/* Line 216 of yacc.c. */
Chris Lattner15bd0952008-08-29 17:20:18 +00001432#line 1433 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001433
Dan Gohmanf4423b12008-04-19 00:24:39 +00001434#ifdef short
1435# undef short
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001436#endif
1437
Dan Gohmanf4423b12008-04-19 00:24:39 +00001438#ifdef YYTYPE_UINT8
1439typedef YYTYPE_UINT8 yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001440#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00001441typedef unsigned char yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001442#endif
1443
Dan Gohmanf4423b12008-04-19 00:24:39 +00001444#ifdef YYTYPE_INT8
1445typedef YYTYPE_INT8 yytype_int8;
1446#elif (defined __STDC__ || defined __C99__FUNC__ \
1447 || defined __cplusplus || defined _MSC_VER)
1448typedef signed char yytype_int8;
1449#else
1450typedef short int yytype_int8;
1451#endif
1452
1453#ifdef YYTYPE_UINT16
1454typedef YYTYPE_UINT16 yytype_uint16;
1455#else
1456typedef unsigned short int yytype_uint16;
1457#endif
1458
1459#ifdef YYTYPE_INT16
1460typedef YYTYPE_INT16 yytype_int16;
1461#else
1462typedef short int yytype_int16;
1463#endif
1464
1465#ifndef YYSIZE_T
1466# ifdef __SIZE_TYPE__
1467# define YYSIZE_T __SIZE_TYPE__
1468# elif defined size_t
1469# define YYSIZE_T size_t
1470# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1471 || defined __cplusplus || defined _MSC_VER)
1472# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1473# define YYSIZE_T size_t
1474# else
1475# define YYSIZE_T unsigned int
1476# endif
1477#endif
1478
1479#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1480
1481#ifndef YY_
Dan Gohman180c1692008-06-23 18:43:26 +00001482# if defined YYENABLE_NLS && YYENABLE_NLS
Dan Gohmanf4423b12008-04-19 00:24:39 +00001483# if ENABLE_NLS
1484# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1485# define YY_(msgid) dgettext ("bison-runtime", msgid)
1486# endif
1487# endif
1488# ifndef YY_
1489# define YY_(msgid) msgid
1490# endif
1491#endif
1492
1493/* Suppress unused-variable warnings by "using" E. */
1494#if ! defined lint || defined __GNUC__
1495# define YYUSE(e) ((void) (e))
1496#else
1497# define YYUSE(e) /* empty */
1498#endif
1499
1500/* Identity function, used to suppress warnings about constant conditions. */
1501#ifndef lint
1502# define YYID(n) (n)
1503#else
1504#if (defined __STDC__ || defined __C99__FUNC__ \
1505 || defined __cplusplus || defined _MSC_VER)
1506static int
1507YYID (int i)
1508#else
1509static int
1510YYID (i)
1511 int i;
1512#endif
1513{
1514 return i;
1515}
1516#endif
1517
1518#if ! defined yyoverflow || YYERROR_VERBOSE
1519
1520/* The parser invokes alloca or malloc; define the necessary symbols. */
1521
1522# ifdef YYSTACK_USE_ALLOCA
1523# if YYSTACK_USE_ALLOCA
1524# ifdef __GNUC__
1525# define YYSTACK_ALLOC __builtin_alloca
1526# elif defined __BUILTIN_VA_ARG_INCR
1527# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1528# elif defined _AIX
1529# define YYSTACK_ALLOC __alloca
1530# elif defined _MSC_VER
1531# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1532# define alloca _alloca
1533# else
1534# define YYSTACK_ALLOC alloca
1535# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1536 || defined __cplusplus || defined _MSC_VER)
1537# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1538# ifndef _STDLIB_H
1539# define _STDLIB_H 1
1540# endif
1541# endif
1542# endif
1543# endif
1544# endif
1545
1546# ifdef YYSTACK_ALLOC
1547 /* Pacify GCC's `empty if-body' warning. */
1548# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1549# ifndef YYSTACK_ALLOC_MAXIMUM
1550 /* The OS might guarantee only one guard page at the bottom of the stack,
1551 and a page size can be as small as 4096 bytes. So we cannot safely
1552 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1553 to allow for a few compiler-allocated temporary stack slots. */
1554# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1555# endif
1556# else
1557# define YYSTACK_ALLOC YYMALLOC
1558# define YYSTACK_FREE YYFREE
1559# ifndef YYSTACK_ALLOC_MAXIMUM
1560# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1561# endif
1562# if (defined __cplusplus && ! defined _STDLIB_H \
1563 && ! ((defined YYMALLOC || defined malloc) \
1564 && (defined YYFREE || defined free)))
1565# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1566# ifndef _STDLIB_H
1567# define _STDLIB_H 1
1568# endif
1569# endif
1570# ifndef YYMALLOC
1571# define YYMALLOC malloc
1572# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1573 || defined __cplusplus || defined _MSC_VER)
1574void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1575# endif
1576# endif
1577# ifndef YYFREE
1578# define YYFREE free
1579# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1580 || defined __cplusplus || defined _MSC_VER)
1581void free (void *); /* INFRINGES ON USER NAME SPACE */
1582# endif
1583# endif
1584# endif
1585#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1586
1587
1588#if (! defined yyoverflow \
1589 && (! defined __cplusplus \
1590 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1591
1592/* A type that is properly aligned for any stack member. */
1593union yyalloc
1594{
1595 yytype_int16 yyss;
1596 YYSTYPE yyvs;
1597 };
1598
1599/* The size of the maximum gap between one aligned stack and the next. */
1600# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1601
1602/* The size of an array large to enough to hold all stacks, each with
1603 N elements. */
1604# define YYSTACK_BYTES(N) \
1605 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1606 + YYSTACK_GAP_MAXIMUM)
1607
1608/* Copy COUNT objects from FROM to TO. The source and destination do
1609 not overlap. */
1610# ifndef YYCOPY
1611# if defined __GNUC__ && 1 < __GNUC__
1612# define YYCOPY(To, From, Count) \
1613 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1614# else
1615# define YYCOPY(To, From, Count) \
1616 do \
1617 { \
1618 YYSIZE_T yyi; \
1619 for (yyi = 0; yyi < (Count); yyi++) \
1620 (To)[yyi] = (From)[yyi]; \
1621 } \
1622 while (YYID (0))
1623# endif
1624# endif
1625
1626/* Relocate STACK from its old location to the new one. The
1627 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1628 elements in the stack, and YYPTR gives the new location of the
1629 stack. Advance YYPTR to a properly aligned location for the next
1630 stack. */
1631# define YYSTACK_RELOCATE(Stack) \
1632 do \
1633 { \
1634 YYSIZE_T yynewbytes; \
1635 YYCOPY (&yyptr->Stack, Stack, yysize); \
1636 Stack = &yyptr->Stack; \
1637 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1638 yyptr += yynewbytes / sizeof (*yyptr); \
1639 } \
1640 while (YYID (0))
1641
1642#endif
1643
1644/* YYFINAL -- State number of the termination state. */
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001645#define YYFINAL 44
Dan Gohmanf4423b12008-04-19 00:24:39 +00001646/* YYLAST -- Last index in YYTABLE. */
Chris Lattner15bd0952008-08-29 17:20:18 +00001647#define YYLAST 2386
Dan Gohmanf4423b12008-04-19 00:24:39 +00001648
1649/* YYNTOKENS -- Number of terminals. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001650#define YYNTOKENS 171
Dan Gohmanf4423b12008-04-19 00:24:39 +00001651/* YYNNTS -- Number of nonterminals. */
Chris Lattner15bd0952008-08-29 17:20:18 +00001652#define YYNNTS 87
Dan Gohmanf4423b12008-04-19 00:24:39 +00001653/* YYNRULES -- Number of rules. */
Chris Lattner15bd0952008-08-29 17:20:18 +00001654#define YYNRULES 346
Dan Gohmanf4423b12008-04-19 00:24:39 +00001655/* YYNRULES -- Number of states. */
Chris Lattner15bd0952008-08-29 17:20:18 +00001656#define YYNSTATES 707
Dan Gohmanf4423b12008-04-19 00:24:39 +00001657
1658/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1659#define YYUNDEFTOK 2
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001660#define YYMAXUTOK 411
Dan Gohmanf4423b12008-04-19 00:24:39 +00001661
1662#define YYTRANSLATE(YYX) \
1663 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1664
1665/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1666static const yytype_uint8 yytranslate[] =
1667{
1668 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1669 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1670 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1671 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001672 157, 158, 161, 2, 160, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001673 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001674 166, 159, 167, 2, 2, 2, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001675 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1676 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001677 2, 163, 162, 165, 2, 2, 2, 2, 2, 170,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001678 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1679 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001680 164, 2, 2, 168, 2, 169, 2, 2, 2, 2,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001681 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1682 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1683 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1684 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1685 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1686 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1688 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1689 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, 1, 2, 3, 4,
1694 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1695 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1696 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1697 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1698 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1699 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1700 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1701 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1702 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1703 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1704 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1705 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1706 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1707 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Dan Gohmane4977cf2008-05-23 01:55:30 +00001708 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001709 155, 156
Dan Gohmanf4423b12008-04-19 00:24:39 +00001710};
1711
1712#if YYDEBUG
1713/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1714 YYRHS. */
1715static const yytype_uint16 yyprhs[] =
1716{
1717 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1718 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1719 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1720 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1721 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1722 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1723 119, 121, 123, 125, 127, 129, 130, 135, 136, 139,
Chris Lattner15bd0952008-08-29 17:20:18 +00001724 140, 143, 145, 147, 149, 150, 153, 155, 157, 159,
1725 161, 163, 165, 167, 169, 171, 172, 174, 176, 178,
1726 179, 181, 183, 184, 186, 188, 190, 192, 193, 195,
1727 197, 198, 200, 202, 204, 206, 208, 210, 213, 215,
1728 217, 219, 221, 223, 225, 227, 229, 231, 234, 235,
1729 238, 240, 242, 244, 246, 248, 250, 251, 254, 255,
1730 258, 259, 262, 263, 267, 270, 271, 273, 274, 278,
1731 280, 283, 285, 287, 289, 291, 293, 295, 297, 299,
1732 301, 305, 307, 310, 316, 322, 328, 334, 338, 341,
1733 347, 352, 355, 357, 359, 361, 365, 367, 371, 373,
1734 374, 376, 380, 385, 389, 393, 398, 403, 407, 414,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001735 420, 423, 426, 429, 432, 435, 438, 441, 444, 447,
Chris Lattner15bd0952008-08-29 17:20:18 +00001736 450, 453, 456, 463, 469, 478, 485, 492, 500, 508,
1737 516, 524, 531, 540, 549, 555, 563, 567, 569, 571,
1738 573, 575, 576, 579, 586, 588, 589, 591, 594, 595,
1739 599, 600, 604, 608, 612, 616, 617, 626, 627, 637,
1740 638, 648, 654, 657, 661, 663, 667, 671, 675, 679,
1741 681, 682, 688, 692, 694, 698, 700, 701, 712, 714,
1742 716, 721, 723, 725, 728, 732, 733, 735, 737, 739,
1743 741, 743, 745, 747, 749, 751, 753, 755, 759, 763,
1744 766, 769, 773, 776, 782, 787, 789, 795, 797, 799,
1745 801, 803, 805, 807, 810, 812, 816, 819, 822, 826,
1746 830, 833, 834, 836, 839, 842, 846, 856, 866, 875,
1747 890, 892, 894, 901, 907, 910, 913, 920, 928, 933,
1748 938, 945, 952, 953, 954, 958, 961, 965, 968, 970,
1749 976, 982, 989, 996, 1003, 1010, 1015, 1022, 1027, 1032,
1750 1039, 1046, 1049, 1058, 1060, 1062, 1063, 1067, 1074, 1078,
1751 1085, 1088, 1094, 1102, 1108, 1113, 1118
Dan Gohmanf4423b12008-04-19 00:24:39 +00001752};
1753
1754/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1755static const yytype_int16 yyrhs[] =
1756{
Chris Lattner15bd0952008-08-29 17:20:18 +00001757 218, 0, -1, 76, -1, 77, -1, 78, -1, 79,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001758 -1, 80, -1, 81, -1, 82, -1, 83, -1, 84,
1759 -1, 88, -1, 89, -1, 90, -1, 85, -1, 86,
1760 -1, 87, -1, 121, -1, 122, -1, 123, -1, 124,
1761 -1, 125, -1, 126, -1, 127, -1, 128, -1, 129,
1762 -1, 130, -1, 131, -1, 132, -1, 95, -1, 96,
1763 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1764 -1, 102, -1, 103, -1, 104, -1, 105, -1, 106,
1765 -1, 107, -1, 108, -1, 109, -1, 110, -1, 111,
1766 -1, 112, -1, 113, -1, 114, -1, 101, -1, 102,
1767 -1, 103, -1, 104, -1, 26, -1, 27, -1, 11,
Dan Gohmanf4423b12008-04-19 00:24:39 +00001768 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001769 -1, 19, -1, 22, -1, 24, -1, 179, -1, -1,
1770 55, 157, 4, 158, -1, -1, 179, 159, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00001771 7, 159, -1, 20, -1, 23, -1, 186, -1, -1,
1772 184, 159, -1, 42, -1, 44, -1, 43, -1, 45,
1773 -1, 47, -1, 49, -1, 46, -1, 48, -1, 51,
1774 -1, -1, 154, -1, 155, -1, 156, -1, -1, 46,
1775 -1, 48, -1, -1, 42, -1, 43, -1, 44, -1,
1776 47, -1, -1, 44, -1, 42, -1, -1, 63, -1,
1777 64, -1, 65, -1, 66, -1, 67, -1, 68, -1,
1778 62, 4, -1, 143, -1, 122, -1, 142, -1, 123,
1779 -1, 145, -1, 146, -1, 148, -1, 149, -1, 150,
1780 -1, 54, 4, -1, -1, 195, 194, -1, 144, -1,
1781 147, -1, 143, -1, 142, -1, 151, -1, 152, -1,
1782 -1, 197, 196, -1, -1, 153, 22, -1, -1, 54,
1783 4, -1, -1, 160, 54, 4, -1, 34, 22, -1,
1784 -1, 201, -1, -1, 160, 204, 203, -1, 201, -1,
1785 54, 4, -1, 11, -1, 12, -1, 13, -1, 16,
1786 -1, 15, -1, 14, -1, 17, -1, 50, -1, 205,
1787 -1, 206, 181, 161, -1, 240, -1, 162, 4, -1,
1788 206, 157, 210, 158, 197, -1, 10, 157, 210, 158,
1789 197, -1, 163, 4, 164, 206, 165, -1, 166, 4,
1790 164, 206, 167, -1, 168, 211, 169, -1, 168, 169,
1791 -1, 166, 168, 211, 169, 167, -1, 166, 168, 169,
1792 167, -1, 206, 195, -1, 206, -1, 10, -1, 207,
1793 -1, 209, 160, 207, -1, 209, -1, 209, 160, 39,
1794 -1, 39, -1, -1, 206, -1, 211, 160, 206, -1,
1795 206, 163, 214, 165, -1, 206, 163, 165, -1, 206,
1796 170, 22, -1, 206, 166, 214, 167, -1, 206, 168,
1797 214, 169, -1, 206, 168, 169, -1, 206, 166, 168,
1798 214, 169, 167, -1, 206, 166, 168, 169, 167, -1,
1799 206, 40, -1, 206, 41, -1, 206, 240, -1, 206,
1800 213, -1, 206, 25, -1, 177, 3, -1, 177, 5,
1801 -1, 177, 4, -1, 177, 6, -1, 11, 26, -1,
1802 11, 27, -1, 178, 9, -1, 174, 157, 212, 38,
1803 206, 158, -1, 120, 157, 212, 252, 158, -1, 134,
1804 157, 212, 160, 212, 160, 212, 158, -1, 172, 157,
1805 212, 160, 212, 158, -1, 173, 157, 212, 160, 212,
1806 158, -1, 91, 175, 157, 212, 160, 212, 158, -1,
1807 92, 176, 157, 212, 160, 212, 158, -1, 93, 175,
1808 157, 212, 160, 212, 158, -1, 94, 176, 157, 212,
1809 160, 212, 158, -1, 136, 157, 212, 160, 212, 158,
1810 -1, 137, 157, 212, 160, 212, 160, 212, 158, -1,
1811 138, 157, 212, 160, 212, 160, 212, 158, -1, 140,
1812 157, 212, 253, 158, -1, 141, 157, 212, 160, 212,
1813 253, 158, -1, 214, 160, 212, -1, 212, -1, 32,
1814 -1, 33, -1, 37, -1, -1, 208, 240, -1, 126,
1815 157, 217, 38, 206, 158, -1, 219, -1, -1, 220,
1816 -1, 219, 220, -1, -1, 31, 221, 236, -1, -1,
1817 30, 222, 237, -1, 60, 59, 226, -1, 182, 18,
1818 206, -1, 182, 18, 10, -1, -1, 185, 189, 216,
1819 215, 212, 181, 223, 203, -1, -1, 185, 187, 189,
1820 216, 215, 212, 181, 224, 203, -1, -1, 185, 188,
1821 189, 216, 215, 206, 181, 225, 203, -1, 185, 189,
1822 35, 192, 217, -1, 52, 227, -1, 56, 159, 228,
1823 -1, 22, -1, 53, 159, 22, -1, 69, 159, 22,
1824 -1, 163, 229, 165, -1, 229, 160, 22, -1, 22,
1825 -1, -1, 230, 160, 206, 195, 180, -1, 206, 195,
1826 180, -1, 230, -1, 230, 160, 39, -1, 39, -1,
1827 -1, 193, 208, 184, 157, 231, 158, 197, 202, 199,
1828 198, -1, 28, -1, 168, -1, 191, 189, 232, 233,
1829 -1, 29, -1, 169, -1, 244, 235, -1, 190, 189,
1830 232, -1, -1, 61, -1, 3, -1, 4, -1, 5,
1831 -1, 6, -1, 9, -1, 26, -1, 27, -1, 40,
1832 -1, 41, -1, 25, -1, 166, 214, 167, -1, 163,
1833 214, 165, -1, 163, 165, -1, 170, 22, -1, 168,
1834 214, 169, -1, 168, 169, -1, 166, 168, 214, 169,
1835 167, -1, 166, 168, 169, 167, -1, 213, -1, 59,
1836 238, 22, 160, 22, -1, 7, -1, 8, -1, 179,
1837 -1, 184, -1, 240, -1, 239, -1, 206, 241, -1,
1838 242, -1, 243, 160, 242, -1, 244, 245, -1, 234,
1839 245, -1, 246, 182, 247, -1, 246, 183, 247, -1,
1840 246, 249, -1, -1, 21, -1, 70, 243, -1, 70,
1841 10, -1, 71, 17, 241, -1, 71, 11, 241, 160,
1842 17, 241, 160, 17, 241, -1, 72, 177, 241, 160,
1843 17, 241, 163, 248, 165, -1, 72, 177, 241, 160,
1844 17, 241, 163, 165, -1, 73, 193, 208, 241, 157,
1845 251, 158, 197, 38, 17, 241, 74, 17, 241, -1,
1846 74, -1, 75, -1, 248, 177, 239, 160, 17, 241,
1847 -1, 177, 239, 160, 17, 241, -1, 182, 255, -1,
1848 183, 255, -1, 206, 163, 241, 160, 241, 165, -1,
1849 250, 160, 163, 241, 160, 241, 165, -1, 206, 195,
1850 241, 195, -1, 17, 195, 241, 195, -1, 251, 160,
1851 206, 195, 241, 195, -1, 251, 160, 17, 195, 241,
1852 195, -1, -1, -1, 252, 160, 242, -1, 160, 4,
1853 -1, 253, 160, 4, -1, 58, 57, -1, 57, -1,
1854 172, 206, 241, 160, 241, -1, 173, 206, 241, 160,
1855 241, -1, 91, 175, 206, 241, 160, 241, -1, 92,
1856 176, 206, 241, 160, 241, -1, 93, 175, 206, 241,
1857 160, 241, -1, 94, 176, 206, 241, 160, 241, -1,
1858 174, 242, 38, 206, -1, 134, 242, 160, 242, 160,
1859 242, -1, 135, 242, 160, 206, -1, 136, 242, 160,
1860 242, -1, 137, 242, 160, 242, 160, 242, -1, 138,
1861 242, 160, 242, 160, 242, -1, 133, 250, -1, 254,
1862 193, 208, 241, 157, 251, 158, 197, -1, 257, -1,
1863 36, -1, -1, 115, 206, 200, -1, 115, 206, 160,
1864 11, 241, 200, -1, 116, 206, 200, -1, 116, 206,
1865 160, 11, 241, 200, -1, 117, 242, -1, 256, 118,
1866 206, 241, 200, -1, 256, 119, 242, 160, 206, 241,
1867 200, -1, 139, 206, 241, 160, 4, -1, 120, 206,
1868 241, 252, -1, 140, 206, 241, 253, -1, 141, 206,
1869 241, 160, 206, 241, 253, -1
Dan Gohmanf4423b12008-04-19 00:24:39 +00001870};
1871
1872/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1873static const yytype_uint16 yyrline[] =
1874{
Chris Lattner15bd0952008-08-29 17:20:18 +00001875 0, 1136, 1136, 1136, 1136, 1136, 1136, 1136, 1136, 1136,
1876 1136, 1137, 1137, 1137, 1137, 1137, 1137, 1138, 1138, 1138,
1877 1138, 1138, 1138, 1139, 1139, 1139, 1139, 1139, 1139, 1142,
1878 1142, 1143, 1143, 1144, 1144, 1145, 1145, 1146, 1146, 1150,
1879 1150, 1151, 1151, 1152, 1152, 1153, 1153, 1154, 1154, 1155,
1880 1155, 1156, 1156, 1157, 1158, 1163, 1164, 1164, 1164, 1164,
1881 1164, 1166, 1166, 1166, 1167, 1167, 1169, 1170, 1174, 1178,
1882 1183, 1189, 1189, 1191, 1192, 1197, 1203, 1204, 1205, 1206,
1883 1207, 1208, 1212, 1213, 1214, 1218, 1219, 1220, 1221, 1225,
1884 1226, 1227, 1231, 1232, 1233, 1234, 1235, 1239, 1240, 1241,
1885 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1258, 1259,
1886 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1271, 1272,
1887 1277, 1278, 1279, 1280, 1281, 1282, 1285, 1286, 1291, 1292,
1888 1299, 1300, 1306, 1307, 1316, 1324, 1325, 1330, 1331, 1332,
1889 1337, 1350, 1350, 1350, 1350, 1350, 1350, 1350, 1353, 1357,
1890 1361, 1368, 1373, 1381, 1410, 1435, 1440, 1450, 1460, 1464,
1891 1474, 1481, 1490, 1497, 1502, 1507, 1514, 1515, 1522, 1529,
1892 1537, 1543, 1555, 1583, 1599, 1626, 1654, 1680, 1700, 1726,
1893 1746, 1758, 1765, 1831, 1841, 1851, 1857, 1867, 1873, 1883,
1894 1889, 1895, 1908, 1920, 1941, 1949, 1955, 1966, 1971, 1976,
1895 1981, 1986, 1992, 1998, 2004, 2012, 2023, 2027, 2035, 2035,
1896 2038, 2038, 2041, 2053, 2074, 2079, 2087, 2088, 2092, 2092,
1897 2096, 2096, 2099, 2102, 2126, 2138, 2137, 2149, 2148, 2158,
1898 2157, 2168, 2208, 2211, 2217, 2227, 2231, 2236, 2238, 2243,
1899 2248, 2257, 2267, 2278, 2282, 2291, 2300, 2305, 2434, 2434,
1900 2436, 2445, 2445, 2447, 2452, 2464, 2468, 2473, 2477, 2481,
1901 2486, 2491, 2495, 2499, 2503, 2507, 2511, 2515, 2537, 2559,
1902 2565, 2578, 2590, 2595, 2607, 2613, 2617, 2627, 2631, 2635,
1903 2640, 2647, 2647, 2653, 2662, 2667, 2672, 2676, 2685, 2694,
1904 2707, 2716, 2720, 2728, 2748, 2752, 2757, 2768, 2787, 2796,
1905 2882, 2886, 2893, 2904, 2917, 2926, 2939, 2950, 2960, 2971,
1906 2979, 2989, 2996, 2999, 3000, 3008, 3014, 3023, 3027, 3032,
1907 3048, 3065, 3079, 3093, 3107, 3121, 3133, 3141, 3148, 3154,
1908 3160, 3166, 3181, 3271, 3276, 3280, 3287, 3294, 3304, 3311,
1909 3321, 3329, 3343, 3360, 3374, 3389, 3404
Dan Gohmanf4423b12008-04-19 00:24:39 +00001910};
1911#endif
1912
1913#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1914/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1915 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1916static const char *const yytname[] =
1917{
1918 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1919 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1920 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1921 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1922 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1923 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1924 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1925 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
Dale Johannesenc7071cc2008-05-14 20:13:36 +00001926 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "COMMON", "OPAQUE",
Dan Gohmanf4423b12008-04-19 00:24:39 +00001927 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1928 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1929 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001930 "X86_SSECALLCC_TOK", "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE",
1931 "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV",
1932 "UREM", "SREM", "FREM", "AND", "OR", "XOR", "SHL", "LSHR", "ASHR",
1933 "ICMP", "FCMP", "VICMP", "VFCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE",
1934 "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE",
1935 "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE",
1936 "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST",
1937 "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT",
1938 "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT",
1939 "SHUFFLEVECTOR", "GETRESULT", "EXTRACTVALUE", "INSERTVALUE", "SIGNEXT",
1940 "ZEROEXT", "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL",
1941 "NEST", "READNONE", "READONLY", "GC", "DEFAULT", "HIDDEN", "PROTECTED",
1942 "'('", "')'", "'='", "','", "'*'", "'\\\\'", "'['", "'x'", "']'", "'<'",
1943 "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps", "LogicalOps",
1944 "CastOps", "IPredicates", "FPredicates", "IntType", "FPType",
1945 "LocalName", "OptLocalName", "OptAddrSpace", "OptLocalAssign",
Chris Lattner15bd0952008-08-29 17:20:18 +00001946 "LocalNumber", "GlobalName", "OptGlobalAssign", "GlobalAssign",
1947 "GVInternalLinkage", "GVExternalLinkage", "GVVisibilityStyle",
1948 "FunctionDeclareLinkage", "FunctionDefineLinkage", "AliasLinkage",
1949 "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr",
1950 "OptFuncAttrs", "OptGC", "OptAlign", "OptCAlign", "SectionString",
1951 "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "PrimType",
1952 "Types", "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI",
1953 "TypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1954 "ThreadLocal", "AliaseeRef", "Module", "DefinitionList", "Definition",
1955 "@1", "@2", "@3", "@4", "@5", "AsmBlock", "TargetDefinition",
1956 "LibrariesDefinition", "LibList", "ArgListH", "ArgList",
1957 "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", "Function",
1958 "FunctionProto", "OptSideEffect", "ConstValueRef", "SymbolicValueRef",
1959 "ValueRef", "ResolvedVal", "ReturnedVal", "BasicBlockList", "BasicBlock",
1960 "InstructionList", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
1961 "ParamList", "IndexList", "ConstantIndexList", "OptTailCall", "InstVal",
1962 "OptVolatile", "MemoryInst", 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00001963};
1964#endif
1965
1966# ifdef YYPRINT
1967/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1968 token YYLEX-NUM. */
1969static const yytype_uint16 yytoknum[] =
1970{
1971 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1972 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1973 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1974 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1975 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1976 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1977 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1978 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1979 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1980 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1981 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1982 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1983 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1984 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1985 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001986 405, 406, 407, 408, 409, 410, 411, 40, 41, 61,
1987 44, 42, 92, 91, 120, 93, 60, 62, 123, 125,
1988 99
Dan Gohmanf4423b12008-04-19 00:24:39 +00001989};
1990# endif
1991
1992/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001993static const yytype_uint16 yyr1[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00001994{
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001995 0, 171, 172, 172, 172, 172, 172, 172, 172, 172,
1996 172, 173, 173, 173, 173, 173, 173, 174, 174, 174,
Dan Gohmane4977cf2008-05-23 01:55:30 +00001997 174, 174, 174, 174, 174, 174, 174, 174, 174, 175,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00001998 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
1999 176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
2000 176, 176, 176, 176, 176, 177, 178, 178, 178, 178,
2001 178, 179, 179, 179, 180, 180, 181, 181, 182, 182,
Chris Lattner15bd0952008-08-29 17:20:18 +00002002 183, 184, 184, 185, 185, 186, 187, 187, 187, 187,
2003 187, 187, 188, 188, 188, 189, 189, 189, 189, 190,
2004 190, 190, 191, 191, 191, 191, 191, 192, 192, 192,
2005 193, 193, 193, 193, 193, 193, 193, 193, 194, 194,
2006 194, 194, 194, 194, 194, 194, 194, 194, 195, 195,
2007 196, 196, 196, 196, 196, 196, 197, 197, 198, 198,
2008 199, 199, 200, 200, 201, 202, 202, 203, 203, 204,
2009 204, 205, 205, 205, 205, 205, 205, 205, 206, 206,
2010 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
2011 206, 207, 208, 208, 209, 209, 210, 210, 210, 210,
2012 211, 211, 212, 212, 212, 212, 212, 212, 212, 212,
2013 212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
2014 212, 212, 213, 213, 213, 213, 213, 213, 213, 213,
2015 213, 213, 213, 213, 213, 213, 214, 214, 215, 215,
2016 216, 216, 217, 217, 218, 218, 219, 219, 221, 220,
2017 222, 220, 220, 220, 220, 223, 220, 224, 220, 225,
2018 220, 220, 220, 220, 226, 227, 227, 228, 229, 229,
2019 229, 230, 230, 231, 231, 231, 231, 232, 233, 233,
2020 234, 235, 235, 236, 237, 238, 238, 239, 239, 239,
2021 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
2022 239, 239, 239, 239, 239, 239, 239, 240, 240, 240,
2023 240, 241, 241, 242, 243, 243, 244, 244, 245, 245,
2024 246, 246, 246, 247, 247, 247, 247, 247, 247, 247,
2025 247, 247, 248, 248, 249, 249, 250, 250, 251, 251,
2026 251, 251, 251, 252, 252, 253, 253, 254, 254, 255,
2027 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
2028 255, 255, 255, 255, 256, 256, 257, 257, 257, 257,
2029 257, 257, 257, 257, 257, 257, 257
Dan Gohmanf4423b12008-04-19 00:24:39 +00002030};
2031
2032/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2033static const yytype_uint8 yyr2[] =
2034{
2035 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2036 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2037 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2038 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2039 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2040 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2041 1, 1, 1, 1, 1, 0, 4, 0, 2, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002042 2, 1, 1, 1, 0, 2, 1, 1, 1, 1,
2043 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,
2044 1, 1, 0, 1, 1, 1, 1, 0, 1, 1,
2045 0, 1, 1, 1, 1, 1, 1, 2, 1, 1,
2046 1, 1, 1, 1, 1, 1, 1, 2, 0, 2,
2047 1, 1, 1, 1, 1, 1, 0, 2, 0, 2,
2048 0, 2, 0, 3, 2, 0, 1, 0, 3, 1,
2049 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2050 3, 1, 2, 5, 5, 5, 5, 3, 2, 5,
2051 4, 2, 1, 1, 1, 3, 1, 3, 1, 0,
2052 1, 3, 4, 3, 3, 4, 4, 3, 6, 5,
Dale Johannesenc7071cc2008-05-14 20:13:36 +00002053 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner15bd0952008-08-29 17:20:18 +00002054 2, 2, 6, 5, 8, 6, 6, 7, 7, 7,
2055 7, 6, 8, 8, 5, 7, 3, 1, 1, 1,
2056 1, 0, 2, 6, 1, 0, 1, 2, 0, 3,
2057 0, 3, 3, 3, 3, 0, 8, 0, 9, 0,
2058 9, 5, 2, 3, 1, 3, 3, 3, 3, 1,
2059 0, 5, 3, 1, 3, 1, 0, 10, 1, 1,
2060 4, 1, 1, 2, 3, 0, 1, 1, 1, 1,
2061 1, 1, 1, 1, 1, 1, 1, 3, 3, 2,
2062 2, 3, 2, 5, 4, 1, 5, 1, 1, 1,
2063 1, 1, 1, 2, 1, 3, 2, 2, 3, 3,
2064 2, 0, 1, 2, 2, 3, 9, 9, 8, 14,
2065 1, 1, 6, 5, 2, 2, 6, 7, 4, 4,
2066 6, 6, 0, 0, 3, 2, 3, 2, 1, 5,
2067 5, 6, 6, 6, 6, 4, 6, 4, 4, 6,
2068 6, 2, 8, 1, 1, 0, 3, 6, 3, 6,
2069 2, 5, 7, 5, 4, 4, 7
Dan Gohmanf4423b12008-04-19 00:24:39 +00002070};
2071
2072/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2073 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2074 means the default is an error. */
2075static const yytype_uint16 yydefact[] =
2076{
Chris Lattner15bd0952008-08-29 17:20:18 +00002077 74, 61, 71, 62, 72, 63, 220, 218, 0, 0,
2078 0, 0, 0, 0, 85, 73, 0, 74, 216, 89,
2079 92, 0, 0, 232, 0, 0, 68, 0, 75, 76,
2080 78, 77, 79, 82, 80, 83, 81, 84, 86, 87,
2081 88, 85, 85, 211, 1, 217, 90, 91, 85, 221,
2082 93, 94, 95, 96, 85, 291, 219, 291, 0, 0,
2083 240, 233, 234, 222, 277, 278, 224, 141, 142, 143,
2084 146, 145, 144, 147, 148, 0, 0, 0, 0, 279,
2085 280, 149, 223, 151, 211, 211, 97, 210, 0, 100,
2086 100, 292, 287, 69, 251, 252, 253, 286, 235, 236,
2087 239, 0, 169, 152, 0, 0, 0, 0, 158, 170,
2088 0, 0, 169, 0, 0, 0, 99, 98, 0, 208,
2089 209, 0, 0, 101, 102, 103, 104, 105, 106, 0,
2090 254, 0, 0, 335, 335, 290, 0, 237, 168, 118,
2091 164, 166, 0, 0, 0, 0, 0, 0, 157, 0,
2092 0, 150, 0, 0, 163, 0, 162, 0, 231, 141,
2093 142, 143, 146, 145, 144, 0, 0, 67, 67, 107,
2094 0, 248, 249, 250, 70, 334, 318, 0, 0, 0,
2095 0, 100, 300, 301, 2, 3, 4, 5, 6, 7,
2096 8, 9, 10, 14, 15, 16, 11, 12, 13, 0,
2097 0, 0, 0, 0, 0, 0, 0, 17, 18, 19,
2098 20, 21, 22, 23, 24, 25, 26, 27, 28, 0,
Nate Begemanac80ade2008-05-12 19:01:56 +00002099 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002100 0, 288, 100, 304, 0, 333, 289, 305, 238, 161,
2101 0, 126, 67, 67, 160, 0, 171, 0, 126, 67,
2102 67, 0, 212, 189, 190, 185, 187, 186, 188, 191,
2103 184, 180, 181, 0, 0, 0, 0, 0, 0, 0,
Dan Gohmane4977cf2008-05-23 01:55:30 +00002104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002105 0, 183, 182, 225, 0, 317, 294, 67, 284, 293,
2106 0, 0, 55, 0, 0, 29, 30, 31, 32, 33,
2107 34, 35, 36, 37, 38, 0, 53, 54, 49, 50,
2108 51, 52, 39, 40, 41, 42, 43, 44, 45, 46,
2109 47, 48, 0, 0, 0, 132, 132, 340, 67, 67,
2110 331, 0, 0, 0, 0, 0, 67, 67, 67, 67,
2111 67, 0, 0, 0, 0, 0, 109, 111, 110, 108,
2112 112, 113, 114, 115, 116, 119, 167, 165, 154, 155,
2113 156, 159, 66, 153, 227, 229, 0, 0, 0, 0,
2114 0, 0, 0, 0, 0, 0, 0, 0, 173, 207,
2115 0, 0, 0, 177, 0, 174, 0, 0, 0, 137,
2116 246, 257, 258, 259, 260, 261, 266, 262, 263, 264,
2117 265, 255, 0, 0, 0, 0, 275, 282, 281, 283,
2118 0, 0, 295, 0, 0, 67, 67, 67, 67, 0,
2119 336, 0, 338, 313, 0, 0, 0, 0, 0, 0,
2120 0, 0, 0, 0, 0, 0, 0, 0, 67, 0,
2121 117, 123, 122, 120, 121, 124, 125, 127, 137, 137,
2122 0, 0, 0, 0, 0, 313, 0, 0, 0, 0,
2123 0, 0, 0, 172, 158, 170, 0, 175, 176, 0,
2124 0, 0, 0, 226, 245, 118, 243, 0, 256, 0,
2125 269, 0, 0, 0, 272, 0, 270, 285, 0, 0,
2126 0, 0, 0, 0, 0, 0, 0, 0, 344, 0,
2127 0, 0, 327, 328, 0, 0, 0, 0, 345, 0,
2128 0, 0, 325, 0, 132, 0, 228, 230, 67, 0,
2129 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2130 206, 179, 0, 0, 0, 0, 0, 0, 139, 137,
2131 65, 0, 126, 0, 268, 158, 0, 267, 271, 0,
2132 0, 312, 0, 0, 0, 0, 132, 133, 132, 0,
2133 0, 0, 0, 0, 0, 343, 315, 0, 67, 319,
2134 320, 312, 0, 341, 67, 213, 0, 0, 0, 0,
2135 193, 0, 0, 0, 0, 204, 0, 178, 0, 0,
2136 67, 134, 140, 138, 64, 242, 244, 118, 135, 0,
2137 274, 0, 0, 0, 118, 118, 0, 321, 322, 323,
2138 324, 337, 339, 314, 0, 0, 326, 329, 330, 316,
2139 0, 0, 132, 0, 0, 0, 0, 0, 201, 0,
2140 0, 0, 195, 196, 192, 65, 136, 130, 276, 273,
2141 0, 0, 0, 0, 126, 0, 306, 0, 346, 126,
2142 342, 197, 198, 199, 200, 0, 0, 0, 205, 241,
2143 0, 128, 0, 298, 0, 0, 109, 111, 118, 118,
2144 0, 118, 118, 307, 332, 194, 202, 203, 131, 0,
2145 247, 296, 0, 297, 0, 309, 308, 0, 0, 0,
2146 129, 0, 0, 0, 118, 118, 0, 0, 0, 311,
2147 310, 303, 0, 0, 302, 0, 299
Dan Gohmanf4423b12008-04-19 00:24:39 +00002148};
2149
2150/* YYDEFGOTO[NTERM-NUM]. */
2151static const yytype_int16 yydefgoto[] =
2152{
Chris Lattner15bd0952008-08-29 17:20:18 +00002153 -1, 278, 279, 280, 305, 322, 165, 166, 79, 595,
2154 113, 12, 134, 80, 14, 15, 41, 42, 43, 48,
2155 54, 118, 129, 355, 239, 447, 358, 680, 661, 420,
2156 538, 637, 473, 539, 81, 167, 140, 157, 141, 142,
2157 110, 379, 406, 380, 121, 88, 158, 16, 17, 18,
2158 20, 19, 389, 448, 449, 63, 23, 61, 101, 476,
2159 477, 130, 173, 55, 96, 56, 49, 479, 407, 83,
2160 409, 288, 289, 57, 92, 93, 231, 665, 135, 330,
2161 606, 498, 508, 232, 233, 234, 235
Dan Gohmanf4423b12008-04-19 00:24:39 +00002162};
2163
2164/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2165 STATE-NUM. */
Chris Lattner15bd0952008-08-29 17:20:18 +00002166#define YYPACT_NINF -615
Dan Gohmanf4423b12008-04-19 00:24:39 +00002167static const yytype_int16 yypact[] =
2168{
Chris Lattner15bd0952008-08-29 17:20:18 +00002169 498, -615, -615, -615, -615, -615, -615, -615, 2, -101,
2170 46, -19, 101, -9, 227, -615, 168, 547, -615, 49,
2171 266, 22, 25, -615, 24, 170, -615, 1932, -615, -615,
2172 -615, -615, -615, -615, -615, -615, -615, -615, -615, -615,
2173 -615, -81, -81, 181, -615, -615, -615, -615, -81, -615,
2174 -615, -615, -615, -615, -81, 205, -615, -10, 197, 212,
2175 219, -615, -615, -615, -615, -615, 97, -615, -615, -615,
2176 -615, -615, -615, -615, -615, 259, 263, 3, 629, -615,
2177 -615, -615, -12, -615, 240, 240, 211, -615, 142, 387,
2178 387, -615, -615, 77, -615, -615, -615, -615, -615, -615,
2179 -615, -53, 1650, -615, 120, 143, 811, 97, -615, -12,
2180 -112, 173, 1650, 166, 142, 142, -615, -615, 1691, -615,
2181 -615, 1950, 335, -615, -615, -615, -615, -615, -615, 1979,
2182 -615, -8, 184, 2213, 2213, -615, 325, -615, -615, -12,
2183 -615, 193, 196, 1997, 1997, 189, -104, 1997, -615, 355,
2184 202, -615, 1950, 1997, 97, 204, -12, 242, -615, 41,
2185 353, 354, 361, 362, 366, 277, 368, 1514, 323, -615,
2186 141, -615, -615, -615, -615, -615, -615, 322, 2038, 72,
2187 369, 387, -615, -615, -615, -615, -615, -615, -615, -615,
2188 -615, -615, -615, -615, -615, -615, -615, -615, -615, 559,
2189 285, 559, 285, 1997, 1997, 1997, 1997, -615, -615, -615,
2190 -615, -615, -615, -615, -615, -615, -615, -615, -615, 1997,
2191 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997, 1997,
2192 1997, -615, 387, -615, 104, -615, -615, -615, -615, 183,
2193 1709, -615, -34, -41, -615, 238, -12, 249, -615, 323,
2194 -29, 1691, -615, -615, -615, -615, -615, -615, -615, -615,
2195 -615, -615, -615, 559, 285, 559, 285, 251, 252, 255,
2196 256, 257, 261, 262, 1750, 2056, 1131, 394, 264, 265,
2197 268, -615, -615, -615, 269, -615, 97, 913, -615, 272,
2198 1081, 1081, -615, 1081, 1979, -615, -615, -615, -615, -615,
2199 -615, -615, -615, -615, -615, 1997, -615, -615, -615, -615,
2200 -615, -615, -615, -615, -615, -615, -615, -615, -615, -615,
2201 -615, -615, 1997, 1997, 1997, -28, 67, -615, 913, -33,
2202 273, 274, 275, 276, 282, 284, 913, 913, 913, 913,
2203 913, 385, 1979, 1997, 1997, 423, -615, -615, -615, -615,
2204 -615, -615, -615, -615, -615, -615, -615, -615, 198, -615,
2205 -615, -615, -615, 198, -615, 166, 390, 280, 288, 289,
2206 300, 1950, 1950, 1950, 1950, 1950, 1950, 1950, -615, -615,
2207 -52, 1175, -107, -615, -79, -615, 1950, 1950, 1950, 298,
2208 1769, -615, -615, -615, -615, -615, -615, -615, -615, -615,
2209 -615, 398, 1813, 2112, 1408, 407, -615, -615, -615, -615,
2210 1997, 301, -615, 302, 1081, 913, 913, 913, 913, 18,
2211 -615, 28, -615, -615, 1081, 297, 1997, 1997, 1997, 1997,
2212 1997, 306, 308, 311, 316, 317, 1997, 1081, 913, 318,
2213 -615, -615, -615, -615, -615, -615, -615, -615, 298, 298,
2214 1997, 1950, 1950, 1950, 1950, -615, 319, 321, 324, 326,
2215 308, 336, 1950, -615, 315, 1362, -58, -615, -615, 337,
2216 339, 447, 15, -615, -615, -12, 340, 343, -615, 473,
2217 -615, -40, 1454, -106, -615, -2, -615, -615, 486, 487,
2218 348, 346, 347, 359, 363, 1081, 504, 1081, 364, 367,
2219 1081, 370, -12, -615, 371, 372, 522, 530, 379, 1997,
2220 1081, 1081, -12, 389, 382, 1997, -615, -615, -14, 388,
2221 391, 392, 393, 134, 1950, 1950, 1950, 1950, 135, 1950,
2222 -615, -615, 397, 1950, 1950, 1997, 527, 551, -615, 298,
2223 40, 1871, -615, 396, -615, 401, 52, -615, -615, 1081,
2224 1081, 2159, 1081, 1081, 1081, 1081, 382, -615, 382, 1997,
2225 1081, 399, 1997, 1997, 1997, -615, -615, 553, 913, -615,
2226 -615, 2159, 506, -615, 913, -615, 1950, 1950, 1950, 1950,
2227 -615, 412, 403, 413, 414, -615, 308, -615, 417, 418,
2228 8, -615, -615, -615, -615, -615, -615, -12, 4, 557,
2229 -615, 416, 420, 421, -4, -12, 161, -615, -615, -615,
2230 -615, -615, -615, -615, 422, 1081, -615, -615, -615, -615,
2231 308, 162, 382, 427, 428, 435, 436, 1950, -615, 1950,
2232 1950, 188, -615, -615, -615, 40, -615, 541, -615, -615,
2233 564, 5, 761, 761, -615, 2218, -615, 431, 379, -615,
2234 -615, -615, -615, -615, -615, 439, 442, 443, -615, -615,
2235 598, 451, 1081, -615, 1227, 7, 448, 449, -615, -615,
2236 100, -4, -12, -615, 198, -615, -615, -615, -615, 588,
2237 -615, -615, 454, -615, 1227, 183, 183, 600, 761, 761,
2238 -615, 601, 455, 1081, -615, -615, 1081, 603, 549, 183,
2239 183, -615, 1081, 604, -615, 1081, -615
Dan Gohmanf4423b12008-04-19 00:24:39 +00002240};
2241
2242/* YYPGOTO[NTERM-NUM]. */
2243static const yytype_int16 yypgoto[] =
2244{
Chris Lattner15bd0952008-08-29 17:20:18 +00002245 -615, 96, 112, 190, -165, -160, -178, -615, 0, -11,
2246 -140, 533, -615, 6, -615, -615, -615, -615, 37, -615,
2247 -615, -615, -144, -615, -463, -615, -238, -615, -615, -323,
2248 29, -615, -424, -615, -615, -26, 410, -125, -615, 516,
2249 523, -86, -162, -267, 200, 267, 380, -615, -615, 613,
2250 -615, -615, -615, -615, -615, -615, -615, -615, -615, -615,
2251 -615, 542, -615, -615, -615, -615, -615, -615, -614, -80,
2252 174, -190, -615, -615, 576, -615, 500, -615, -615, -615,
2253 76, 209, -447, -615, 531, -615, -615
Dan Gohmanf4423b12008-04-19 00:24:39 +00002254};
2255
2256/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2257 positive, shift that token. If negative, reduce the rule which
2258 number is the opposite. If zero, do what YYDEFACT says.
2259 If YYTABLE_NINF, syntax error. */
Chris Lattner15bd0952008-08-29 17:20:18 +00002260#define YYTABLE_NINF -216
Dan Gohmanf4423b12008-04-19 00:24:39 +00002261static const yytype_int16 yytable[] =
2262{
Chris Lattner15bd0952008-08-29 17:20:18 +00002263 11, 82, 293, 422, 170, 281, 13, 105, 382, 384,
2264 363, 91, 540, 528, 111, 327, 292, 11, 292, 94,
2265 171, 111, 111, 13, 516, 517, 111, 111, 283, 495,
2266 331, 332, 333, 334, 335, 168, 323, 294, 536, 497,
2267 341, 111, 324, 111, -55, -55, -55, -55, 147, 536,
2268 682, -147, 109, 462, 462, 21, 147, 148, 24, 1,
2269 467, 547, 3, 111, 5, 245, 249, 253, 254, 537,
2270 692, 22, 496, 38, 39, 40, 139, 252, 84, 85,
2271 109, 462, 496, 290, 132, 89, 139, 282, 342, 291,
2272 468, 90, 156, 11, 345, 46, 1, 47, 367, 3,
2273 369, 5, 462, 156, 368, 25, 370, 136, 462, 364,
2274 365, 532, 137, 463, 466, 593, 112, 242, 243, 27,
2275 462, 246, 111, 112, 112, 544, 360, 250, 112, 112,
2276 424, 359, 419, -67, 635, 481, 483, 485, 687, 631,
2277 26, 642, 643, 112, 575, 112, 441, 442, 443, -67,
2278 28, 444, 287, -147, 439, 445, 446, -147, 462, 95,
2279 172, 2, 346, 347, 4, 112, 634, 548, 44, 414,
2280 663, 106, 683, 648, 119, 120, 284, 325, 326, 287,
2281 328, 58, 348, 349, 59, 350, 351, 60, 352, 353,
2282 354, 573, 62, 329, 287, 287, 287, 287, 287, 336,
2283 337, 338, 339, 340, 287, 685, 686, 408, 688, 689,
2284 408, 408, 462, 408, 139, 546, 86, 437, 87, 98,
2285 487, 601, 343, 344, 112, 156, 91, 421, -67, 228,
2286 228, 699, 700, 611, 99, 612, 501, 345, 503, 504,
2287 505, 100, 441, 442, 443, 229, 229, 444, 408, 64,
2288 65, 445, 446, 116, 102, 117, 408, 408, 408, 408,
2289 408, 1, 2, 103, 3, 4, 5, 104, 156, 29,
2290 30, 31, 32, 33, 34, 35, 36, 87, 37, 415,
2291 255, 256, 257, 258, 143, 455, 456, 457, 458, 459,
2292 460, 461, 580, 585, 559, 567, 416, 417, 418, 650,
2293 469, 470, 471, 281, 598, 346, 347, 144, 50, 51,
2294 52, 306, 307, 53, 152, 153, 156, 438, 287, 644,
2295 649, 645, 645, 230, 230, 348, 349, 151, 350, 351,
2296 149, 352, 353, 354, 408, 408, 408, 408, 408, 169,
2297 441, 442, 443, 174, 408, 444, 658, 238, 567, 445,
2298 446, 114, 115, 240, 241, 465, 244, 408, 408, 247,
2299 248, 251, -56, -57, 475, 519, 520, 521, 522, 613,
2300 -60, -59, 616, 617, 618, -58, 530, 259, 111, 285,
2301 292, 38, 39, 40, 287, 282, 308, 309, 310, 311,
2302 312, 313, 314, 315, 316, 317, 318, 319, 320, 321,
2303 287, 502, 287, 287, 287, 361, 670, 362, 371, 372,
2304 512, 674, 373, 374, 375, 408, 385, 408, 376, 377,
2305 408, 386, 387, 436, 518, 388, 390, 440, 450, 486,
2306 408, 408, 410, 425, 426, 427, 428, 451, 581, 582,
2307 583, 584, 429, 586, 430, 452, 453, 588, 589, 122,
2308 123, 124, 125, 126, 127, 128, 465, 454, 472, 478,
2309 500, 488, 489, 664, 411, 412, 506, 413, 507, 408,
2310 408, 509, 408, 408, 408, 408, 510, 511, 515, 524,
2311 408, 525, 531, 568, 526, 535, 527, 684, 408, 574,
2312 623, 624, 625, 626, 408, 543, 529, 533, -215, 534,
2313 541, 542, 423, 549, 550, 551, 552, 553, 557, 590,
2314 431, 432, 433, 434, 435, 597, -69, 1, 2, 554,
2315 3, 4, 5, 555, 559, 605, 565, 560, 6, 7,
2316 562, 563, 564, 287, 566, 408, 287, 287, 287, 567,
2317 594, 655, 572, 656, 657, 605, 571, -214, 576, 591,
2318 8, 577, 578, 579, 9, 592, 599, 619, 10, 615,
2319 496, 628, 408, 408, 587, -69, 1, 2, 600, 3,
2320 4, 5, 627, 629, 630, 632, 633, 6, 7, 638,
2321 640, 662, 408, 639, 641, 651, 652, 646, 490, 491,
2322 492, 493, 494, 653, 654, 660, 673, 675, 499, 8,
2323 676, 677, 678, 9, 679, -18, -19, 10, 408, 408,
2324 690, 513, 514, 408, 691, 697, 408, 693, 696, 672,
2325 702, 705, 408, 703, 659, 408, 133, 636, 150, 146,
2326 45, 366, 131, 97, 236, 594, 64, 65, 0, 107,
2327 67, 68, 69, 70, 71, 72, 73, 621, 1, 2,
2328 357, 3, 4, 5, 295, 296, 297, 298, 299, 300,
2329 301, 302, 303, 304, 523, 237, 0, 0, 0, 556,
2330 0, 558, 0, 0, 561, 0, 0, 0, 0, 74,
2331 0, 0, 0, 0, 569, 570, 0, 0, 0, 0,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002332 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2333 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002334 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002335 0, 0, 0, 602, 603, 0, 607, 608, 609, 610,
2336 0, 0, 0, 0, 614, 0, 0, 0, 0, 0,
2337 0, 0, 620, 0, 0, 0, 0, 0, 622, 0,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002338 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002339 0, 0, 0, 0, 391, 392, 393, 394, 64, 65,
2340 395, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2341 1, 2, 0, 3, 4, 5, 396, 397, 398, 647,
2342 0, 75, 76, 0, 0, 77, 0, 78, 108, 0,
2343 0, 399, 400, 0, 0, 0, 0, 0, 0, 0,
2344 0, 0, 0, 0, 0, 345, 668, 669, 64, 65,
2345 401, 107, 67, 68, 69, 70, 71, 72, 73, 0,
2346 1, 2, 0, 3, 4, 5, 681, 184, 185, 186,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002347 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
Chris Lattner15bd0952008-08-29 17:20:18 +00002348 197, 198, 263, 264, 265, 266, 0, 0, 0, 0,
2349 0, 74, 694, 695, 0, 0, 0, 698, 0, 0,
2350 701, 0, 0, 0, 0, 0, 704, 0, 0, 706,
2351 0, 267, 207, 666, 667, 210, 211, 212, 213, 214,
2352 215, 216, 217, 218, 0, 268, 0, 269, 270, 271,
2353 0, 272, 273, 348, 349, 0, 350, 351, 0, 352,
2354 353, 354, 0, 0, 0, 0, 391, 392, 393, 394,
2355 64, 65, 395, 0, 402, 0, 0, 403, 0, 404,
2356 0, 405, 1, 2, 0, 3, 4, 5, 396, 397,
2357 398, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2358 0, 0, 0, 399, 400, 0, 0, 0, 0, 0,
2359 0, 0, 0, 0, 0, 0, 0, 0, 111, 0,
2360 0, 0, 401, 75, 76, 0, 0, 77, 0, 78,
2361 145, 0, 0, 0, 0, 0, 0, 0, 0, 184,
2362 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
2363 195, 196, 197, 198, 263, 264, 265, 266, 0, 0,
2364 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2365 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2366 0, 0, 0, 267, 207, 208, 209, 210, 211, 212,
2367 213, 214, 215, 216, 217, 218, 0, 268, 0, 269,
2368 270, 271, 0, 272, 273, 0, 0, 0, 0, 0,
2369 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2370 112, 0, 0, 0, 0, 0, 402, 0, 0, 403,
2371 0, 404, 0, 405, 391, 392, 393, 394, 64, 65,
2372 395, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2373 1, 2, 0, 3, 4, 5, 396, 397, 398, 0,
2374 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2375 0, 399, 400, 0, 0, 0, 0, 0, 0, 0,
2376 0, 0, 0, 0, 0, 0, 0, 0, 64, 65,
2377 401, 107, 159, 160, 161, 162, 163, 164, 73, 0,
2378 1, 2, 0, 3, 4, 5, 0, 184, 185, 186,
2379 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
2380 197, 198, 263, 264, 265, 266, 0, 0, 0, 0,
2381 0, 74, 64, 65, 0, 107, 159, 160, 161, 162,
2382 163, 164, 73, 0, 1, 2, 0, 3, 4, 5,
2383 0, 267, 207, 208, 209, 210, 211, 212, 213, 214,
2384 215, 216, 217, 218, 0, 268, 0, 269, 270, 271,
2385 0, 272, 273, 0, 0, 74, 0, 0, 0, 0,
2386 391, 392, 393, 394, 0, 0, 395, 0, 0, 0,
2387 0, 0, 0, 0, 402, 0, 0, 403, 0, 404,
2388 0, 405, 396, 397, 398, 0, 0, 0, 0, 0,
2389 0, 0, 0, 0, 0, 0, 0, 399, 400, 0,
2390 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2391 0, 0, 0, 0, 0, 0, 401, 0, 0, 0,
2392 0, 0, 0, 75, 76, 0, 0, 77, 0, 78,
2393 383, 0, 0, 184, 185, 186, 187, 188, 189, 190,
2394 191, 192, 193, 194, 195, 196, 197, 198, 263, 264,
2395 265, 266, 0, 0, 0, 0, 0, 0, 0, 0,
2396 0, 0, 0, 0, 0, 0, 0, 75, 76, 0,
2397 0, 77, 0, 78, 464, 0, 0, 267, 207, 208,
2398 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2399 0, 268, 0, 269, 270, 271, 0, 272, 273, 64,
2400 65, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2401 0, 1, 2, 0, 3, 4, 5, 260, 0, 0,
2402 402, 0, 0, 403, 0, 404, 0, 405, 0, 0,
2403 0, 0, 261, 262, 0, 0, 0, 0, 0, 0,
2404 0, 0, 0, 0, 0, 64, 65, 111, 107, 159,
2405 160, 161, 162, 163, 164, 73, 0, 1, 2, 0,
2406 3, 4, 5, 0, 0, 0, 0, 0, 184, 185,
2407 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
2408 196, 197, 198, 263, 264, 265, 266, 0, 74, 0,
2409 0, 64, 65, 0, 107, 159, 160, 161, 162, 163,
2410 164, 73, 0, 1, 2, 0, 3, 4, 5, 0,
2411 0, 0, 267, 207, 208, 209, 210, 211, 212, 213,
2412 214, 215, 216, 217, 218, 0, 268, 0, 269, 270,
2413 271, 0, 272, 273, 74, 0, 0, 0, 0, 0,
2414 0, 0, 0, 0, 0, 0, 0, 0, 0, 112,
2415 0, 64, 65, -67, 0, 274, 0, 0, 275, 0,
2416 276, 0, 277, 1, 2, 0, 3, 4, 5, 260,
2417 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2418 0, 0, 0, 0, 261, 262, 0, 0, 0, 0,
2419 0, 0, 0, 0, 0, 0, 0, 0, 0, 111,
2420 75, 76, 0, 0, 77, 0, 78, 484, 0, 0,
2421 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2422 184, 185, 186, 187, 188, 189, 190, 191, 192, 193,
2423 194, 195, 196, 197, 198, 263, 264, 265, 266, 0,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002424 0, 0, 0, 0, 0, 0, 75, 76, 0, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002425 77, 0, 78, 545, 0, 0, 0, 0, 0, 0,
2426 0, 0, 0, 0, 267, 207, 208, 209, 210, 211,
2427 212, 213, 214, 215, 216, 217, 218, 0, 268, 0,
2428 269, 270, 271, 0, 272, 273, 0, 64, 65, 0,
2429 107, 67, 68, 69, 70, 71, 72, 73, 0, 1,
2430 2, 112, 3, 4, 5, 0, 0, 274, 0, 0,
2431 275, 0, 276, 0, 277, 0, 0, 0, 0, 138,
2432 0, 0, 0, 0, 0, 0, 0, 0, 64, 65,
2433 74, 154, 67, 68, 69, 70, 71, 72, 73, 0,
2434 1, 2, 0, 3, 4, 5, 64, 65, 0, 107,
2435 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2436 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2437 0, 74, 0, 0, 0, 0, 0, 0, 356, 0,
2438 0, 0, 0, 0, 0, 0, 0, 64, 65, 74,
2439 107, 159, 160, 161, 162, 163, 164, 73, 0, 1,
2440 2, 0, 3, 4, 5, 0, 64, 65, 0, 107,
2441 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2442 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2443 74, 0, 0, 0, 0, 0, 0, 0, 474, 0,
2444 0, 0, 75, 76, 0, 0, 77, 155, 78, 74,
2445 64, 65, 0, 107, 159, 160, 161, 162, 163, 164,
2446 73, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2448 0, 0, 0, 75, 76, 0, 0, 77, 0, 78,
2449 0, 0, 0, 74, 0, 0, 0, 0, 0, 0,
2450 0, 75, 76, 0, 0, 77, 0, 78, 64, 65,
2451 0, 107, 67, 68, 69, 70, 71, 72, 73, 0,
2452 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2453 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2454 596, 0, 75, 76, 0, 378, 77, 0, 78, 0,
2455 0, 74, 0, 0, 0, 0, 0, 0, 0, 0,
2456 0, 75, 76, 0, 0, 77, 0, 78, 0, 64,
2457 65, 0, 66, 67, 68, 69, 70, 71, 72, 73,
2458 0, 1, 2, 0, 3, 4, 5, 64, 65, 0,
2459 107, 159, 160, 161, 162, 163, 164, 73, 0, 1,
2460 2, 0, 3, 4, 5, 75, 76, 0, 480, 77,
2461 0, 78, 74, 0, 0, 0, 64, 65, 0, 154,
2462 67, 68, 69, 70, 71, 72, 73, 0, 1, 2,
2463 74, 3, 4, 5, 64, 65, 0, 107, 67, 68,
2464 69, 70, 71, 72, 73, 0, 1, 2, 0, 3,
2465 4, 5, 0, 0, 0, 0, 0, 0, 0, 74,
2466 0, 0, 0, 75, 76, 0, 0, 77, 0, 78,
2467 0, 0, 0, 0, 0, 64, 65, 74, 286, 67,
2468 68, 69, 70, 71, 72, 73, 0, 1, 2, 0,
2469 3, 4, 5, 64, 65, 0, 107, 159, 160, 161,
2470 162, 163, 164, 73, 0, 1, 2, 0, 3, 4,
2471 5, 0, 0, 0, 0, 0, 0, 0, 74, 0,
2472 0, 0, 0, 0, 75, 76, 0, 0, 77, 0,
2473 78, 0, 0, 0, 0, 0, 74, 0, 0, 0,
2474 0, 0, 75, 76, 0, 0, 77, 0, 78, 64,
2475 65, 0, 107, 159, 160, 161, 162, 163, 164, 73,
2476 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2477 0, 75, 76, 0, 0, 77, 0, 78, 0, 0,
2478 0, 0, 0, 0, 0, 0, 0, 0, 0, 75,
2479 76, 0, 74, 77, 0, 78, 64, 65, 0, 107,
2480 67, 68, 69, 70, 71, 72, 604, 0, 1, 2,
2481 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2482 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2483 75, 76, 0, 0, 77, 0, 78, 0, 0, 74,
2484 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
2485 0, 0, 77, 0, 381, 64, 65, 0, 107, 67,
2486 68, 69, 70, 71, 72, 671, 0, 1, 2, 0,
2487 3, 4, 5, 0, 0, 0, 0, 0, 0, 175,
2488 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2489 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
2490 176, 177, 0, 0, 75, 76, 0, 0, 77, 0,
2491 482, 0, 0, 178, 179, 180, 181, 182, 183, 184,
2492 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
2493 195, 196, 197, 198, 199, 200, 201, 202, 0, 0,
2494 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2495 0, 75, 76, 0, 0, 77, 0, 78, 203, 204,
2496 205, 0, 0, 206, 207, 208, 209, 210, 211, 212,
2497 213, 214, 215, 216, 217, 218, 219, 220, 221, 222,
2498 223, 224, 225, 226, 227, 0, 0, 0, 0, 0,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002499 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2500 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner15bd0952008-08-29 17:20:18 +00002501 75, 76, 0, 0, 77, 0, 78
Dan Gohmanf4423b12008-04-19 00:24:39 +00002502};
2503
2504static const yytype_int16 yycheck[] =
2505{
Chris Lattner15bd0952008-08-29 17:20:18 +00002506 0, 27, 180, 326, 129, 167, 0, 4, 275, 276,
2507 248, 21, 475, 460, 55, 205, 11, 17, 11, 29,
2508 28, 55, 55, 17, 448, 449, 55, 55, 168, 11,
2509 220, 221, 222, 223, 224, 121, 201, 181, 34, 11,
2510 230, 55, 202, 55, 3, 4, 5, 6, 160, 34,
2511 664, 55, 78, 160, 160, 53, 160, 169, 159, 19,
2512 167, 167, 22, 55, 24, 169, 152, 26, 27, 54,
2513 684, 69, 54, 154, 155, 156, 102, 157, 41, 42,
2514 106, 160, 54, 11, 7, 48, 112, 167, 232, 17,
2515 169, 54, 118, 93, 54, 46, 19, 48, 263, 22,
2516 265, 24, 160, 129, 264, 59, 266, 160, 160, 249,
2517 250, 169, 165, 165, 381, 539, 157, 143, 144, 18,
2518 160, 147, 55, 157, 157, 165, 167, 153, 157, 157,
2519 163, 165, 160, 161, 597, 402, 403, 404, 38, 586,
2520 159, 604, 605, 157, 158, 157, 142, 143, 144, 161,
2521 159, 147, 178, 157, 344, 151, 152, 161, 160, 169,
2522 168, 20, 122, 123, 23, 157, 158, 169, 0, 294,
2523 165, 168, 165, 620, 32, 33, 170, 203, 204, 205,
2524 206, 159, 142, 143, 159, 145, 146, 163, 148, 149,
2525 150, 514, 22, 219, 220, 221, 222, 223, 224, 225,
2526 226, 227, 228, 229, 230, 668, 669, 287, 671, 672,
2527 290, 291, 160, 293, 240, 482, 35, 342, 37, 22,
2528 410, 169, 118, 119, 157, 251, 21, 160, 161, 133,
2529 134, 694, 695, 556, 22, 558, 426, 54, 428, 429,
2530 430, 22, 142, 143, 144, 133, 134, 147, 328, 7,
2531 8, 151, 152, 42, 157, 44, 336, 337, 338, 339,
2532 340, 19, 20, 4, 22, 23, 24, 4, 294, 42,
2533 43, 44, 45, 46, 47, 48, 49, 37, 51, 305,
2534 3, 4, 5, 6, 164, 371, 372, 373, 374, 375,
2535 376, 377, 158, 158, 160, 160, 322, 323, 324, 622,
2536 386, 387, 388, 465, 542, 122, 123, 164, 42, 43,
2537 44, 26, 27, 47, 114, 115, 342, 343, 344, 158,
2538 158, 160, 160, 133, 134, 142, 143, 161, 145, 146,
2539 157, 148, 149, 150, 414, 415, 416, 417, 418, 4,
2540 142, 143, 144, 159, 424, 147, 158, 22, 160, 151,
2541 152, 84, 85, 160, 158, 381, 167, 437, 438, 4,
2542 158, 157, 9, 9, 390, 451, 452, 453, 454, 559,
2543 9, 9, 562, 563, 564, 9, 462, 9, 55, 57,
2544 11, 154, 155, 156, 410, 465, 101, 102, 103, 104,
2545 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2546 426, 427, 428, 429, 430, 167, 644, 158, 157, 157,
2547 436, 649, 157, 157, 157, 495, 22, 497, 157, 157,
2548 500, 157, 157, 38, 450, 157, 157, 4, 38, 22,
2549 510, 511, 160, 160, 160, 160, 160, 157, 524, 525,
2550 526, 527, 160, 529, 160, 157, 157, 533, 534, 62,
2551 63, 64, 65, 66, 67, 68, 482, 157, 160, 61,
2552 163, 160, 160, 641, 290, 291, 160, 293, 160, 549,
2553 550, 160, 552, 553, 554, 555, 160, 160, 160, 160,
2554 560, 160, 167, 509, 160, 38, 160, 665, 568, 515,
2555 576, 577, 578, 579, 574, 22, 160, 160, 0, 160,
2556 160, 158, 328, 17, 17, 157, 160, 160, 4, 535,
2557 336, 337, 338, 339, 340, 541, 18, 19, 20, 160,
2558 22, 23, 24, 160, 160, 551, 4, 160, 30, 31,
2559 160, 160, 160, 559, 4, 615, 562, 563, 564, 160,
2560 540, 627, 160, 629, 630, 571, 157, 0, 160, 22,
2561 52, 160, 160, 160, 56, 4, 160, 4, 60, 160,
2562 54, 158, 642, 643, 167, 18, 19, 20, 167, 22,
2563 23, 24, 160, 160, 160, 158, 158, 30, 31, 22,
2564 160, 17, 662, 167, 163, 158, 158, 165, 414, 415,
2565 416, 417, 418, 158, 158, 54, 165, 158, 424, 52,
2566 158, 158, 4, 56, 153, 157, 157, 60, 688, 689,
2567 22, 437, 438, 693, 160, 160, 696, 17, 17, 645,
2568 17, 17, 702, 74, 635, 705, 93, 598, 112, 106,
2569 17, 251, 90, 57, 134, 635, 7, 8, -1, 10,
2570 11, 12, 13, 14, 15, 16, 17, 571, 19, 20,
2571 240, 22, 23, 24, 95, 96, 97, 98, 99, 100,
2572 101, 102, 103, 104, 455, 134, -1, -1, -1, 495,
2573 -1, 497, -1, -1, 500, -1, -1, -1, -1, 50,
2574 -1, -1, -1, -1, 510, 511, -1, -1, -1, -1,
Chris Lattner1913b942008-07-11 00:30:39 +00002575 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002576 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002577 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002578 -1, -1, -1, 549, 550, -1, 552, 553, 554, 555,
2579 -1, -1, -1, -1, 560, -1, -1, -1, -1, -1,
2580 -1, -1, 568, -1, -1, -1, -1, -1, 574, -1,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002581 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002582 -1, -1, -1, -1, 3, 4, 5, 6, 7, 8,
2583 9, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2584 19, 20, -1, 22, 23, 24, 25, 26, 27, 615,
2585 -1, 162, 163, -1, -1, 166, -1, 168, 169, -1,
2586 -1, 40, 41, -1, -1, -1, -1, -1, -1, -1,
2587 -1, -1, -1, -1, -1, 54, 642, 643, 7, 8,
2588 59, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2589 19, 20, -1, 22, 23, 24, 662, 76, 77, 78,
2590 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2591 89, 90, 91, 92, 93, 94, -1, -1, -1, -1,
2592 -1, 50, 688, 689, -1, -1, -1, 693, -1, -1,
2593 696, -1, -1, -1, -1, -1, 702, -1, -1, 705,
2594 -1, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2595 129, 130, 131, 132, -1, 134, -1, 136, 137, 138,
2596 -1, 140, 141, 142, 143, -1, 145, 146, -1, 148,
2597 149, 150, -1, -1, -1, -1, 3, 4, 5, 6,
2598 7, 8, 9, -1, 163, -1, -1, 166, -1, 168,
2599 -1, 170, 19, 20, -1, 22, 23, 24, 25, 26,
2600 27, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2601 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
2602 -1, -1, -1, -1, -1, -1, -1, -1, 55, -1,
2603 -1, -1, 59, 162, 163, -1, -1, 166, -1, 168,
2604 169, -1, -1, -1, -1, -1, -1, -1, -1, 76,
2605 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2606 87, 88, 89, 90, 91, 92, 93, 94, -1, -1,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002607 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002608 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002609 -1, -1, -1, 120, 121, 122, 123, 124, 125, 126,
2610 127, 128, 129, 130, 131, 132, -1, 134, -1, 136,
2611 137, 138, -1, 140, 141, -1, -1, -1, -1, -1,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002612 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002613 157, -1, -1, -1, -1, -1, 163, -1, -1, 166,
2614 -1, 168, -1, 170, 3, 4, 5, 6, 7, 8,
2615 9, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2616 19, 20, -1, 22, 23, 24, 25, 26, 27, -1,
Chris Lattner1913b942008-07-11 00:30:39 +00002617 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002618 -1, 40, 41, -1, -1, -1, -1, -1, -1, -1,
2619 -1, -1, -1, -1, -1, -1, -1, -1, 7, 8,
2620 59, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2621 19, 20, -1, 22, 23, 24, -1, 76, 77, 78,
2622 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2623 89, 90, 91, 92, 93, 94, -1, -1, -1, -1,
2624 -1, 50, 7, 8, -1, 10, 11, 12, 13, 14,
2625 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2626 -1, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2627 129, 130, 131, 132, -1, 134, -1, 136, 137, 138,
2628 -1, 140, 141, -1, -1, 50, -1, -1, -1, -1,
2629 3, 4, 5, 6, -1, -1, 9, -1, -1, -1,
2630 -1, -1, -1, -1, 163, -1, -1, 166, -1, 168,
2631 -1, 170, 25, 26, 27, -1, -1, -1, -1, -1,
2632 -1, -1, -1, -1, -1, -1, -1, 40, 41, -1,
2633 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2634 -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
2635 -1, -1, -1, 162, 163, -1, -1, 166, -1, 168,
2636 169, -1, -1, 76, 77, 78, 79, 80, 81, 82,
2637 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2638 93, 94, -1, -1, -1, -1, -1, -1, -1, -1,
2639 -1, -1, -1, -1, -1, -1, -1, 162, 163, -1,
2640 -1, 166, -1, 168, 169, -1, -1, 120, 121, 122,
2641 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
2642 -1, 134, -1, 136, 137, 138, -1, 140, 141, 7,
2643 8, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2644 -1, 19, 20, -1, 22, 23, 24, 25, -1, -1,
2645 163, -1, -1, 166, -1, 168, -1, 170, -1, -1,
Chris Lattner1913b942008-07-11 00:30:39 +00002646 -1, -1, 40, 41, -1, -1, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002647 -1, -1, -1, -1, -1, 7, 8, 55, 10, 11,
2648 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2649 22, 23, 24, -1, -1, -1, -1, -1, 76, 77,
Dan Gohmanf910eaa2008-06-09 14:45:02 +00002650 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
Chris Lattner15bd0952008-08-29 17:20:18 +00002651 88, 89, 90, 91, 92, 93, 94, -1, 50, -1,
2652 -1, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2653 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002654 -1, -1, 120, 121, 122, 123, 124, 125, 126, 127,
2655 128, 129, 130, 131, 132, -1, 134, -1, 136, 137,
Chris Lattner15bd0952008-08-29 17:20:18 +00002656 138, -1, 140, 141, 50, -1, -1, -1, -1, -1,
2657 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2658 -1, 7, 8, 161, -1, 163, -1, -1, 166, -1,
2659 168, -1, 170, 19, 20, -1, 22, 23, 24, 25,
Dan Gohman81a0c0b2008-05-31 00:58:22 +00002660 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002661 -1, -1, -1, -1, 40, 41, -1, -1, -1, -1,
2662 -1, -1, -1, -1, -1, -1, -1, -1, -1, 55,
2663 162, 163, -1, -1, 166, -1, 168, 169, -1, -1,
2664 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2665 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2666 86, 87, 88, 89, 90, 91, 92, 93, 94, -1,
2667 -1, -1, -1, -1, -1, -1, 162, 163, -1, -1,
2668 166, -1, 168, 169, -1, -1, -1, -1, -1, -1,
2669 -1, -1, -1, -1, 120, 121, 122, 123, 124, 125,
2670 126, 127, 128, 129, 130, 131, 132, -1, 134, -1,
2671 136, 137, 138, -1, 140, 141, -1, 7, 8, -1,
2672 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2673 20, 157, 22, 23, 24, -1, -1, 163, -1, -1,
2674 166, -1, 168, -1, 170, -1, -1, -1, -1, 39,
2675 -1, -1, -1, -1, -1, -1, -1, -1, 7, 8,
2676 50, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2677 19, 20, -1, 22, 23, 24, 7, 8, -1, 10,
Chris Lattner1913b942008-07-11 00:30:39 +00002678 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
Chris Lattner15bd0952008-08-29 17:20:18 +00002679 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2680 -1, 50, -1, -1, -1, -1, -1, -1, 39, -1,
2681 -1, -1, -1, -1, -1, -1, -1, 7, 8, 50,
2682 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2683 20, -1, 22, 23, 24, -1, 7, 8, -1, 10,
2684 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2685 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2686 50, -1, -1, -1, -1, -1, -1, -1, 39, -1,
2687 -1, -1, 162, 163, -1, -1, 166, 126, 168, 50,
Chris Lattner1913b942008-07-11 00:30:39 +00002688 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002689 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
Dan Gohmanf910eaa2008-06-09 14:45:02 +00002690 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002691 -1, -1, -1, 162, 163, -1, -1, 166, -1, 168,
2692 -1, -1, -1, 50, -1, -1, -1, -1, -1, -1,
2693 -1, 162, 163, -1, -1, 166, -1, 168, 7, 8,
2694 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2695 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2696 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2697 39, -1, 162, 163, -1, 165, 166, -1, 168, -1,
2698 -1, 50, -1, -1, -1, -1, -1, -1, -1, -1,
2699 -1, 162, 163, -1, -1, 166, -1, 168, -1, 7,
2700 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2701 -1, 19, 20, -1, 22, 23, 24, 7, 8, -1,
2702 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2703 20, -1, 22, 23, 24, 162, 163, -1, 165, 166,
2704 -1, 168, 50, -1, -1, -1, 7, 8, -1, 10,
2705 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2706 50, 22, 23, 24, 7, 8, -1, 10, 11, 12,
2707 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2708 23, 24, -1, -1, -1, -1, -1, -1, -1, 50,
2709 -1, -1, -1, 162, 163, -1, -1, 166, -1, 168,
2710 -1, -1, -1, -1, -1, 7, 8, 50, 10, 11,
2711 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2712 22, 23, 24, 7, 8, -1, 10, 11, 12, 13,
2713 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2714 24, -1, -1, -1, -1, -1, -1, -1, 50, -1,
2715 -1, -1, -1, -1, 162, 163, -1, -1, 166, -1,
2716 168, -1, -1, -1, -1, -1, 50, -1, -1, -1,
2717 -1, -1, 162, 163, -1, -1, 166, -1, 168, 7,
2718 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2719 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2720 -1, 162, 163, -1, -1, 166, -1, 168, -1, -1,
2721 -1, -1, -1, -1, -1, -1, -1, -1, -1, 162,
2722 163, -1, 50, 166, -1, 168, 7, 8, -1, 10,
2723 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2724 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2725 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2726 162, 163, -1, -1, 166, -1, 168, -1, -1, 50,
2727 -1, -1, -1, -1, -1, -1, -1, -1, 162, 163,
2728 -1, -1, 166, -1, 168, 7, 8, -1, 10, 11,
2729 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2730 22, 23, 24, -1, -1, -1, -1, -1, -1, 36,
2731 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2732 -1, -1, -1, -1, -1, -1, -1, -1, 50, -1,
2733 57, 58, -1, -1, 162, 163, -1, -1, 166, -1,
2734 168, -1, -1, 70, 71, 72, 73, 74, 75, 76,
2735 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2736 87, 88, 89, 90, 91, 92, 93, 94, -1, -1,
2737 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2738 -1, 162, 163, -1, -1, 166, -1, 168, 115, 116,
2739 117, -1, -1, 120, 121, 122, 123, 124, 125, 126,
2740 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
2741 137, 138, 139, 140, 141, -1, -1, -1, -1, -1,
Dan Gohman81a0c0b2008-05-31 00:58:22 +00002742 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2743 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner15bd0952008-08-29 17:20:18 +00002744 162, 163, -1, -1, 166, -1, 168
Dan Gohmanf4423b12008-04-19 00:24:39 +00002745};
2746
2747/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2748 symbol of state STATE-NUM. */
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002749static const yytype_uint16 yystos[] =
Dan Gohmanf4423b12008-04-19 00:24:39 +00002750{
Dale Johannesenc7071cc2008-05-14 20:13:36 +00002751 0, 19, 20, 22, 23, 24, 30, 31, 52, 56,
Chris Lattner15bd0952008-08-29 17:20:18 +00002752 60, 179, 182, 184, 185, 186, 218, 219, 220, 222,
2753 221, 53, 69, 227, 159, 59, 159, 18, 159, 42,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002754 43, 44, 45, 46, 47, 48, 49, 51, 154, 155,
Chris Lattner15bd0952008-08-29 17:20:18 +00002755 156, 187, 188, 189, 0, 220, 46, 48, 190, 237,
2756 42, 43, 44, 47, 191, 234, 236, 244, 159, 159,
2757 163, 228, 22, 226, 7, 8, 10, 11, 12, 13,
Dale Johannesen20ab78b2008-08-13 18:41:46 +00002758 14, 15, 16, 17, 50, 162, 163, 166, 168, 179,
Chris Lattner15bd0952008-08-29 17:20:18 +00002759 184, 205, 206, 240, 189, 189, 35, 37, 216, 189,
2760 189, 21, 245, 246, 29, 169, 235, 245, 22, 22,
2761 22, 229, 157, 4, 4, 4, 168, 10, 169, 206,
2762 211, 55, 157, 181, 216, 216, 42, 44, 192, 32,
2763 33, 215, 62, 63, 64, 65, 66, 67, 68, 193,
2764 232, 232, 7, 182, 183, 249, 160, 165, 39, 206,
2765 207, 209, 210, 164, 164, 169, 211, 160, 169, 157,
2766 210, 161, 215, 215, 10, 126, 206, 208, 217, 11,
2767 12, 13, 14, 15, 16, 177, 178, 206, 212, 4,
2768 208, 28, 168, 233, 159, 36, 57, 58, 70, 71,
2769 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2770 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2771 92, 93, 94, 115, 116, 117, 120, 121, 122, 123,
2772 124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
2773 134, 135, 136, 137, 138, 139, 140, 141, 172, 173,
2774 174, 247, 254, 255, 256, 257, 247, 255, 22, 195,
2775 160, 158, 206, 206, 167, 169, 206, 4, 158, 212,
2776 206, 157, 240, 26, 27, 3, 4, 5, 6, 9,
2777 25, 40, 41, 91, 92, 93, 94, 120, 134, 136,
2778 137, 138, 140, 141, 163, 166, 168, 170, 172, 173,
2779 174, 213, 240, 181, 184, 57, 10, 206, 242, 243,
2780 11, 17, 11, 177, 193, 95, 96, 97, 98, 99,
2781 100, 101, 102, 103, 104, 175, 26, 27, 101, 102,
2782 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
2783 113, 114, 176, 175, 176, 206, 206, 242, 206, 206,
2784 250, 242, 242, 242, 242, 242, 206, 206, 206, 206,
2785 206, 242, 193, 118, 119, 54, 122, 123, 142, 143,
2786 145, 146, 148, 149, 150, 194, 39, 207, 197, 165,
2787 167, 167, 158, 197, 181, 181, 217, 175, 176, 175,
2788 176, 157, 157, 157, 157, 157, 157, 157, 165, 212,
2789 214, 168, 214, 169, 214, 22, 157, 157, 157, 223,
2790 157, 3, 4, 5, 6, 9, 25, 26, 27, 40,
2791 41, 59, 163, 166, 168, 170, 213, 239, 240, 241,
2792 160, 241, 241, 241, 208, 206, 206, 206, 206, 160,
2793 200, 160, 200, 241, 163, 160, 160, 160, 160, 160,
2794 160, 241, 241, 241, 241, 241, 38, 208, 206, 242,
2795 4, 142, 143, 144, 147, 151, 152, 196, 224, 225,
2796 38, 157, 157, 157, 157, 212, 212, 212, 212, 212,
2797 212, 212, 160, 165, 169, 206, 214, 167, 169, 212,
2798 212, 212, 160, 203, 39, 206, 230, 231, 61, 238,
2799 165, 214, 168, 214, 169, 214, 22, 242, 160, 160,
2800 241, 241, 241, 241, 241, 11, 54, 11, 252, 241,
2801 163, 242, 206, 242, 242, 242, 160, 160, 253, 160,
2802 160, 160, 206, 241, 241, 160, 203, 203, 206, 212,
2803 212, 212, 212, 252, 160, 160, 160, 160, 253, 160,
2804 212, 167, 169, 160, 160, 38, 34, 54, 201, 204,
2805 195, 160, 158, 22, 165, 169, 214, 167, 169, 17,
2806 17, 157, 160, 160, 160, 160, 241, 4, 241, 160,
2807 160, 241, 160, 160, 160, 4, 4, 160, 206, 241,
2808 241, 157, 160, 200, 206, 158, 160, 160, 160, 160,
2809 158, 212, 212, 212, 212, 158, 212, 167, 212, 212,
2810 206, 22, 4, 203, 179, 180, 39, 206, 197, 160,
2811 167, 169, 241, 241, 17, 206, 251, 241, 241, 241,
2812 241, 200, 200, 242, 241, 160, 242, 242, 242, 4,
2813 241, 251, 241, 212, 212, 212, 212, 160, 158, 160,
2814 160, 253, 158, 158, 158, 195, 201, 202, 22, 167,
2815 160, 163, 195, 195, 158, 160, 165, 241, 253, 158,
2816 200, 158, 158, 158, 158, 212, 212, 212, 158, 180,
2817 54, 199, 17, 165, 177, 248, 122, 123, 241, 241,
2818 197, 17, 206, 165, 197, 158, 158, 158, 4, 153,
2819 198, 241, 239, 165, 177, 195, 195, 38, 195, 195,
2820 22, 160, 239, 17, 241, 241, 17, 160, 241, 195,
2821 195, 241, 17, 74, 241, 17, 241
Dan Gohmanf4423b12008-04-19 00:24:39 +00002822};
David Greene718fda32007-08-01 03:59:32 +00002823
Reid Spencer68a24bd2005-08-27 18:50:39 +00002824#define yyerrok (yyerrstatus = 0)
2825#define yyclearin (yychar = YYEMPTY)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002826#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002827#define YYEOF 0
Dan Gohmanf4423b12008-04-19 00:24:39 +00002828
Reid Spencer68a24bd2005-08-27 18:50:39 +00002829#define YYACCEPT goto yyacceptlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002830#define YYABORT goto yyabortlab
2831#define YYERROR goto yyerrorlab
2832
2833
2834/* Like YYERROR except do call yyerror. This remains here temporarily
2835 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002836 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00002837
Reid Spencer68a24bd2005-08-27 18:50:39 +00002838#define YYFAIL goto yyerrlab
Dan Gohmanf4423b12008-04-19 00:24:39 +00002839
Reid Spencer68a24bd2005-08-27 18:50:39 +00002840#define YYRECOVERING() (!!yyerrstatus)
Dan Gohmanf4423b12008-04-19 00:24:39 +00002841
2842#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002843do \
2844 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002845 { \
2846 yychar = (Token); \
2847 yylval = (Value); \
2848 yytoken = YYTRANSLATE (yychar); \
2849 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002850 goto yybackup; \
2851 } \
2852 else \
Dan Gohmanf4423b12008-04-19 00:24:39 +00002853 { \
2854 yyerror (YY_("syntax error: cannot back up")); \
2855 YYERROR; \
2856 } \
2857while (YYID (0))
2858
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002859
Reid Spencer68a24bd2005-08-27 18:50:39 +00002860#define YYTERROR 1
2861#define YYERRCODE 256
2862
Dan Gohmanf4423b12008-04-19 00:24:39 +00002863
2864/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2865 If N is 0, then set CURRENT to the empty location which ends
2866 the previous symbol: RHS[0] (always defined). */
2867
2868#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2869#ifndef YYLLOC_DEFAULT
2870# define YYLLOC_DEFAULT(Current, Rhs, N) \
2871 do \
2872 if (YYID (N)) \
2873 { \
2874 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2875 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2876 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2877 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2878 } \
2879 else \
2880 { \
2881 (Current).first_line = (Current).last_line = \
2882 YYRHSLOC (Rhs, 0).last_line; \
2883 (Current).first_column = (Current).last_column = \
2884 YYRHSLOC (Rhs, 0).last_column; \
2885 } \
2886 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002887#endif
2888
Dan Gohmanf4423b12008-04-19 00:24:39 +00002889
2890/* YY_LOCATION_PRINT -- Print the location on the stream.
2891 This macro was not mandated originally: define only if we know
2892 we won't break user code: when these are the locations we know. */
2893
2894#ifndef YY_LOCATION_PRINT
Dan Gohman180c1692008-06-23 18:43:26 +00002895# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
Dan Gohmanf4423b12008-04-19 00:24:39 +00002896# define YY_LOCATION_PRINT(File, Loc) \
2897 fprintf (File, "%d.%d-%d.%d", \
2898 (Loc).first_line, (Loc).first_column, \
2899 (Loc).last_line, (Loc).last_column)
2900# else
2901# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2902# endif
2903#endif
2904
2905
2906/* YYLEX -- calling `yylex' with the right arguments. */
2907
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002908#ifdef YYLEX_PARAM
Dan Gohmanf4423b12008-04-19 00:24:39 +00002909# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002910#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002911# define YYLEX yylex ()
Gabor Greife64d2482008-04-06 23:07:54 +00002912#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002913
2914/* Enable debugging if requested. */
2915#if YYDEBUG
2916
2917# ifndef YYFPRINTF
2918# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2919# define YYFPRINTF fprintf
2920# endif
2921
2922# define YYDPRINTF(Args) \
2923do { \
2924 if (yydebug) \
2925 YYFPRINTF Args; \
2926} while (YYID (0))
2927
2928# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2929do { \
2930 if (yydebug) \
2931 { \
2932 YYFPRINTF (stderr, "%s ", Title); \
2933 yy_symbol_print (stderr, \
2934 Type, Value); \
2935 YYFPRINTF (stderr, "\n"); \
2936 } \
2937} while (YYID (0))
2938
2939
2940/*--------------------------------.
2941| Print this symbol on YYOUTPUT. |
2942`--------------------------------*/
2943
2944/*ARGSUSED*/
2945#if (defined __STDC__ || defined __C99__FUNC__ \
2946 || defined __cplusplus || defined _MSC_VER)
2947static void
2948yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greife64d2482008-04-06 23:07:54 +00002949#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00002950static void
2951yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2952 FILE *yyoutput;
2953 int yytype;
2954 YYSTYPE const * const yyvaluep;
Gabor Greife64d2482008-04-06 23:07:54 +00002955#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002956{
2957 if (!yyvaluep)
2958 return;
2959# ifdef YYPRINT
2960 if (yytype < YYNTOKENS)
2961 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2962# else
2963 YYUSE (yyoutput);
2964# endif
2965 switch (yytype)
2966 {
2967 default:
2968 break;
2969 }
2970}
2971
2972
2973/*--------------------------------.
2974| Print this symbol on YYOUTPUT. |
2975`--------------------------------*/
2976
2977#if (defined __STDC__ || defined __C99__FUNC__ \
2978 || defined __cplusplus || defined _MSC_VER)
2979static void
2980yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2981#else
2982static void
2983yy_symbol_print (yyoutput, yytype, yyvaluep)
2984 FILE *yyoutput;
2985 int yytype;
2986 YYSTYPE const * const yyvaluep;
Scott Michel15dcd8e2008-01-30 03:10:00 +00002987#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00002988{
2989 if (yytype < YYNTOKENS)
2990 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2991 else
2992 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner38905612008-02-19 04:36:25 +00002993
Dan Gohmanf4423b12008-04-19 00:24:39 +00002994 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2995 YYFPRINTF (yyoutput, ")");
2996}
Chris Lattner38905612008-02-19 04:36:25 +00002997
Dan Gohmanf4423b12008-04-19 00:24:39 +00002998/*------------------------------------------------------------------.
2999| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3000| TOP (included). |
3001`------------------------------------------------------------------*/
Chris Lattner38905612008-02-19 04:36:25 +00003002
Dan Gohmanf4423b12008-04-19 00:24:39 +00003003#if (defined __STDC__ || defined __C99__FUNC__ \
3004 || defined __cplusplus || defined _MSC_VER)
3005static void
3006yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3007#else
3008static void
3009yy_stack_print (bottom, top)
3010 yytype_int16 *bottom;
3011 yytype_int16 *top;
Scott Michel15dcd8e2008-01-30 03:10:00 +00003012#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003013{
3014 YYFPRINTF (stderr, "Stack now");
3015 for (; bottom <= top; ++bottom)
3016 YYFPRINTF (stderr, " %d", *bottom);
3017 YYFPRINTF (stderr, "\n");
3018}
Chris Lattner38905612008-02-19 04:36:25 +00003019
Dan Gohmanf4423b12008-04-19 00:24:39 +00003020# define YY_STACK_PRINT(Bottom, Top) \
3021do { \
3022 if (yydebug) \
3023 yy_stack_print ((Bottom), (Top)); \
3024} while (YYID (0))
Chris Lattner38905612008-02-19 04:36:25 +00003025
Dan Gohmanf4423b12008-04-19 00:24:39 +00003026
3027/*------------------------------------------------.
3028| Report that the YYRULE is going to be reduced. |
3029`------------------------------------------------*/
3030
3031#if (defined __STDC__ || defined __C99__FUNC__ \
3032 || defined __cplusplus || defined _MSC_VER)
3033static void
3034yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3035#else
3036static void
3037yy_reduce_print (yyvsp, yyrule)
3038 YYSTYPE *yyvsp;
3039 int yyrule;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003040#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003041{
3042 int yynrhs = yyr2[yyrule];
3043 int yyi;
3044 unsigned long int yylno = yyrline[yyrule];
3045 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3046 yyrule - 1, yylno);
3047 /* The symbols being reduced. */
3048 for (yyi = 0; yyi < yynrhs; yyi++)
3049 {
3050 fprintf (stderr, " $%d = ", yyi + 1);
3051 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3052 &(yyvsp[(yyi + 1) - (yynrhs)])
3053 );
3054 fprintf (stderr, "\n");
3055 }
3056}
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003057
Dan Gohmanf4423b12008-04-19 00:24:39 +00003058# define YY_REDUCE_PRINT(Rule) \
3059do { \
3060 if (yydebug) \
3061 yy_reduce_print (yyvsp, Rule); \
3062} while (YYID (0))
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003063
Dan Gohmanf4423b12008-04-19 00:24:39 +00003064/* Nonzero means print parse trace. It is left uninitialized so that
3065 multiple parsers can coexist. */
3066int yydebug;
3067#else /* !YYDEBUG */
3068# define YYDPRINTF(Args)
3069# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3070# define YY_STACK_PRINT(Bottom, Top)
3071# define YY_REDUCE_PRINT(Rule)
3072#endif /* !YYDEBUG */
3073
3074
3075/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003076#ifndef YYINITDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003077# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00003078#endif
3079
Dan Gohmanf4423b12008-04-19 00:24:39 +00003080/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3081 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00003082
Dan Gohmanf4423b12008-04-19 00:24:39 +00003083 Do not make this value too large; the results are undefined if
3084 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3085 evaluated with infinite-precision integer arithmetic. */
David Greene718fda32007-08-01 03:59:32 +00003086
Reid Spencer68a24bd2005-08-27 18:50:39 +00003087#ifndef YYMAXDEPTH
Dan Gohmanf4423b12008-04-19 00:24:39 +00003088# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00003089#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003090
Reid Spencer68a24bd2005-08-27 18:50:39 +00003091
3092
Dan Gohmanf4423b12008-04-19 00:24:39 +00003093#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00003094
Dan Gohmanf4423b12008-04-19 00:24:39 +00003095# ifndef yystrlen
3096# if defined __GLIBC__ && defined _STRING_H
3097# define yystrlen strlen
3098# else
3099/* Return the length of YYSTR. */
3100#if (defined __STDC__ || defined __C99__FUNC__ \
3101 || defined __cplusplus || defined _MSC_VER)
3102static YYSIZE_T
3103yystrlen (const char *yystr)
Chris Lattner38905612008-02-19 04:36:25 +00003104#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003105static YYSIZE_T
3106yystrlen (yystr)
3107 const char *yystr;
3108#endif
3109{
3110 YYSIZE_T yylen;
3111 for (yylen = 0; yystr[yylen]; yylen++)
3112 continue;
3113 return yylen;
3114}
3115# endif
3116# endif
3117
3118# ifndef yystpcpy
3119# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3120# define yystpcpy stpcpy
3121# else
3122/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3123 YYDEST. */
3124#if (defined __STDC__ || defined __C99__FUNC__ \
3125 || defined __cplusplus || defined _MSC_VER)
3126static char *
3127yystpcpy (char *yydest, const char *yysrc)
3128#else
3129static char *
3130yystpcpy (yydest, yysrc)
3131 char *yydest;
3132 const char *yysrc;
3133#endif
3134{
3135 char *yyd = yydest;
3136 const char *yys = yysrc;
3137
3138 while ((*yyd++ = *yys++) != '\0')
3139 continue;
3140
3141 return yyd - 1;
3142}
3143# endif
3144# endif
3145
3146# ifndef yytnamerr
3147/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3148 quotes and backslashes, so that it's suitable for yyerror. The
3149 heuristic is that double-quoting is unnecessary unless the string
3150 contains an apostrophe, a comma, or backslash (other than
3151 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3152 null, do not copy; instead, return the length of what the result
3153 would have been. */
3154static YYSIZE_T
3155yytnamerr (char *yyres, const char *yystr)
3156{
3157 if (*yystr == '"')
3158 {
3159 YYSIZE_T yyn = 0;
3160 char const *yyp = yystr;
3161
3162 for (;;)
3163 switch (*++yyp)
3164 {
3165 case '\'':
3166 case ',':
3167 goto do_not_strip_quotes;
3168
3169 case '\\':
3170 if (*++yyp != '\\')
3171 goto do_not_strip_quotes;
3172 /* Fall through. */
3173 default:
3174 if (yyres)
3175 yyres[yyn] = *yyp;
3176 yyn++;
3177 break;
3178
3179 case '"':
3180 if (yyres)
3181 yyres[yyn] = '\0';
3182 return yyn;
3183 }
3184 do_not_strip_quotes: ;
3185 }
3186
3187 if (! yyres)
3188 return yystrlen (yystr);
3189
3190 return yystpcpy (yyres, yystr) - yyres;
3191}
3192# endif
3193
3194/* Copy into YYRESULT an error message about the unexpected token
3195 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3196 including the terminating null byte. If YYRESULT is null, do not
3197 copy anything; just return the number of bytes that would be
3198 copied. As a special case, return 0 if an ordinary "syntax error"
3199 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3200 size calculation. */
3201static YYSIZE_T
3202yysyntax_error (char *yyresult, int yystate, int yychar)
3203{
3204 int yyn = yypact[yystate];
3205
3206 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3207 return 0;
3208 else
3209 {
3210 int yytype = YYTRANSLATE (yychar);
3211 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3212 YYSIZE_T yysize = yysize0;
3213 YYSIZE_T yysize1;
3214 int yysize_overflow = 0;
3215 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3216 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3217 int yyx;
3218
3219# if 0
3220 /* This is so xgettext sees the translatable formats that are
3221 constructed on the fly. */
3222 YY_("syntax error, unexpected %s");
3223 YY_("syntax error, unexpected %s, expecting %s");
3224 YY_("syntax error, unexpected %s, expecting %s or %s");
3225 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3226 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3227# endif
3228 char *yyfmt;
3229 char const *yyf;
3230 static char const yyunexpected[] = "syntax error, unexpected %s";
3231 static char const yyexpecting[] = ", expecting %s";
3232 static char const yyor[] = " or %s";
3233 char yyformat[sizeof yyunexpected
3234 + sizeof yyexpecting - 1
3235 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3236 * (sizeof yyor - 1))];
3237 char const *yyprefix = yyexpecting;
3238
3239 /* Start YYX at -YYN if negative to avoid negative indexes in
3240 YYCHECK. */
3241 int yyxbegin = yyn < 0 ? -yyn : 0;
3242
3243 /* Stay within bounds of both yycheck and yytname. */
3244 int yychecklim = YYLAST - yyn + 1;
3245 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3246 int yycount = 1;
3247
3248 yyarg[0] = yytname[yytype];
3249 yyfmt = yystpcpy (yyformat, yyunexpected);
3250
3251 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3252 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3253 {
3254 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3255 {
3256 yycount = 1;
3257 yysize = yysize0;
3258 yyformat[sizeof yyunexpected - 1] = '\0';
3259 break;
3260 }
3261 yyarg[yycount++] = yytname[yyx];
3262 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3263 yysize_overflow |= (yysize1 < yysize);
3264 yysize = yysize1;
3265 yyfmt = yystpcpy (yyfmt, yyprefix);
3266 yyprefix = yyor;
3267 }
3268
3269 yyf = YY_(yyformat);
3270 yysize1 = yysize + yystrlen (yyf);
3271 yysize_overflow |= (yysize1 < yysize);
3272 yysize = yysize1;
3273
3274 if (yysize_overflow)
3275 return YYSIZE_MAXIMUM;
3276
3277 if (yyresult)
3278 {
3279 /* Avoid sprintf, as that infringes on the user's name space.
3280 Don't have undefined behavior even if the translation
3281 produced a string with the wrong number of "%s"s. */
3282 char *yyp = yyresult;
3283 int yyi = 0;
3284 while ((*yyp = *yyf) != '\0')
3285 {
3286 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3287 {
3288 yyp += yytnamerr (yyp, yyarg[yyi++]);
3289 yyf += 2;
3290 }
3291 else
3292 {
3293 yyp++;
3294 yyf++;
3295 }
3296 }
3297 }
3298 return yysize;
3299 }
3300}
3301#endif /* YYERROR_VERBOSE */
3302
3303
3304/*-----------------------------------------------.
3305| Release the memory associated to this symbol. |
3306`-----------------------------------------------*/
3307
3308/*ARGSUSED*/
3309#if (defined __STDC__ || defined __C99__FUNC__ \
3310 || defined __cplusplus || defined _MSC_VER)
3311static void
3312yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3313#else
3314static void
3315yydestruct (yymsg, yytype, yyvaluep)
3316 const char *yymsg;
3317 int yytype;
3318 YYSTYPE *yyvaluep;
3319#endif
3320{
3321 YYUSE (yyvaluep);
3322
3323 if (!yymsg)
3324 yymsg = "Deleting";
3325 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3326
3327 switch (yytype)
3328 {
3329
3330 default:
3331 break;
3332 }
3333}
3334
3335
3336/* Prevent warnings from -Wmissing-prototypes. */
3337
3338#ifdef YYPARSE_PARAM
3339#if defined __STDC__ || defined __cplusplus
3340int yyparse (void *YYPARSE_PARAM);
3341#else
3342int yyparse ();
3343#endif
3344#else /* ! YYPARSE_PARAM */
3345#if defined __STDC__ || defined __cplusplus
David Greene5fd22a82007-09-04 18:46:50 +00003346int yyparse (void);
Gabor Greife64d2482008-04-06 23:07:54 +00003347#else
Dan Gohmanf4423b12008-04-19 00:24:39 +00003348int yyparse ();
Scott Michel15dcd8e2008-01-30 03:10:00 +00003349#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003350#endif /* ! YYPARSE_PARAM */
Scott Michel7f9ba9b2008-01-30 02:55:46 +00003351
Chris Lattner38905612008-02-19 04:36:25 +00003352
Dan Gohmanf4423b12008-04-19 00:24:39 +00003353
3354/* The look-ahead symbol. */
3355int yychar;
3356
3357/* The semantic value of the look-ahead symbol. */
3358YYSTYPE yylval;
3359
3360/* Number of syntax errors so far. */
3361int yynerrs;
3362
3363
3364
3365/*----------.
3366| yyparse. |
3367`----------*/
3368
3369#ifdef YYPARSE_PARAM
3370#if (defined __STDC__ || defined __C99__FUNC__ \
3371 || defined __cplusplus || defined _MSC_VER)
3372int
3373yyparse (void *YYPARSE_PARAM)
3374#else
3375int
3376yyparse (YYPARSE_PARAM)
3377 void *YYPARSE_PARAM;
3378#endif
3379#else /* ! YYPARSE_PARAM */
3380#if (defined __STDC__ || defined __C99__FUNC__ \
3381 || defined __cplusplus || defined _MSC_VER)
3382int
3383yyparse (void)
3384#else
3385int
3386yyparse ()
3387
Gabor Greife64d2482008-04-06 23:07:54 +00003388#endif
3389#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00003390{
3391
3392 int yystate;
3393 int yyn;
3394 int yyresult;
3395 /* Number of tokens to shift before error messages enabled. */
3396 int yyerrstatus;
3397 /* Look-ahead token as an internal (translated) token number. */
3398 int yytoken = 0;
3399#if YYERROR_VERBOSE
3400 /* Buffer for error messages, and its allocated size. */
3401 char yymsgbuf[128];
3402 char *yymsg = yymsgbuf;
3403 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greife64d2482008-04-06 23:07:54 +00003404#endif
Chris Lattner38905612008-02-19 04:36:25 +00003405
Dan Gohmanf4423b12008-04-19 00:24:39 +00003406 /* Three stacks and their tools:
3407 `yyss': related to states,
3408 `yyvs': related to semantic values,
3409 `yyls': related to locations.
3410
3411 Refer to the stacks thru separate pointers, to allow yyoverflow
3412 to reallocate them elsewhere. */
3413
3414 /* The state stack. */
3415 yytype_int16 yyssa[YYINITDEPTH];
3416 yytype_int16 *yyss = yyssa;
3417 yytype_int16 *yyssp;
3418
3419 /* The semantic value stack. */
3420 YYSTYPE yyvsa[YYINITDEPTH];
3421 YYSTYPE *yyvs = yyvsa;
3422 YYSTYPE *yyvsp;
3423
3424
3425
3426#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3427
3428 YYSIZE_T yystacksize = YYINITDEPTH;
3429
3430 /* The variables used to return semantic value and location from the
3431 action routines. */
3432 YYSTYPE yyval;
3433
3434
3435 /* The number of symbols on the RHS of the reduced rule.
3436 Keep to zero when no symbol should be popped. */
3437 int yylen = 0;
3438
3439 YYDPRINTF ((stderr, "Starting parse\n"));
3440
Reid Spencer68a24bd2005-08-27 18:50:39 +00003441 yystate = 0;
3442 yyerrstatus = 0;
3443 yynerrs = 0;
3444 yychar = YYEMPTY; /* Cause a token to be read. */
3445
3446 /* Initialize stack pointers.
3447 Waste one element of value and location stack
3448 so that they stay on the same level as the state stack.
3449 The wasted elements are never initialized. */
3450
Dan Gohmanf4423b12008-04-19 00:24:39 +00003451 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003452 yyvsp = yyvs;
3453
Dan Gohmanf4423b12008-04-19 00:24:39 +00003454 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003455
Dan Gohmanf4423b12008-04-19 00:24:39 +00003456/*------------------------------------------------------------.
3457| yynewstate -- Push a new state, which is found in yystate. |
3458`------------------------------------------------------------*/
3459 yynewstate:
3460 /* In all cases, when you get here, the value and location stacks
3461 have just been pushed. So pushing a state here evens the stacks. */
3462 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003463
Dan Gohmanf4423b12008-04-19 00:24:39 +00003464 yysetstate:
3465 *yyssp = yystate;
3466
3467 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003468 {
3469 /* Get the current used size of the three stacks, in elements. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003470 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003471
3472#ifdef yyoverflow
Dan Gohmanf4423b12008-04-19 00:24:39 +00003473 {
3474 /* Give user a chance to reallocate the stack. Use copies of
3475 these so that the &'s don't force the real ones into
3476 memory. */
3477 YYSTYPE *yyvs1 = yyvs;
3478 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003479
Dan Gohmanf4423b12008-04-19 00:24:39 +00003480
3481 /* Each stack pointer address is followed by the size of the
3482 data in use in that stack, in bytes. This used to be a
3483 conditional around just the two extra args, but that might
3484 be undefined if yyoverflow is a macro. */
3485 yyoverflow (YY_("memory exhausted"),
3486 &yyss1, yysize * sizeof (*yyssp),
3487 &yyvs1, yysize * sizeof (*yyvsp),
3488
3489 &yystacksize);
3490
3491 yyss = yyss1;
3492 yyvs = yyvs1;
3493 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003494#else /* no yyoverflow */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003495# ifndef YYSTACK_RELOCATE
3496 goto yyexhaustedlab;
3497# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003498 /* Extend the stack our own way. */
Dan Gohmanf4423b12008-04-19 00:24:39 +00003499 if (YYMAXDEPTH <= yystacksize)
3500 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003501 yystacksize *= 2;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003502 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003503 yystacksize = YYMAXDEPTH;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003504
3505 {
3506 yytype_int16 *yyss1 = yyss;
3507 union yyalloc *yyptr =
3508 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3509 if (! yyptr)
3510 goto yyexhaustedlab;
3511 YYSTACK_RELOCATE (yyss);
3512 YYSTACK_RELOCATE (yyvs);
3513
3514# undef YYSTACK_RELOCATE
3515 if (yyss1 != yyssa)
3516 YYSTACK_FREE (yyss1);
3517 }
3518# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003519#endif /* no yyoverflow */
3520
Dan Gohmanf4423b12008-04-19 00:24:39 +00003521 yyssp = yyss + yysize - 1;
3522 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003523
3524
Dan Gohmanf4423b12008-04-19 00:24:39 +00003525 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3526 (unsigned long int) yystacksize));
3527
3528 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003529 YYABORT;
3530 }
3531
Dan Gohmanf4423b12008-04-19 00:24:39 +00003532 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003533
3534 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003535
Dan Gohmanf4423b12008-04-19 00:24:39 +00003536/*-----------.
3537| yybackup. |
3538`-----------*/
3539yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003540
Dan Gohmanf4423b12008-04-19 00:24:39 +00003541 /* Do appropriate processing given the current state. Read a
3542 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003543
Dan Gohmanf4423b12008-04-19 00:24:39 +00003544 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003545 yyn = yypact[yystate];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003546 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003547 goto yydefault;
3548
Dan Gohmanf4423b12008-04-19 00:24:39 +00003549 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003550
Dan Gohmanf4423b12008-04-19 00:24:39 +00003551 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003552 if (yychar == YYEMPTY)
3553 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003554 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003555 yychar = YYLEX;
3556 }
3557
Dan Gohmanf4423b12008-04-19 00:24:39 +00003558 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003559 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003560 yychar = yytoken = YYEOF;
3561 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003562 }
3563 else
3564 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003565 yytoken = YYTRANSLATE (yychar);
3566 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003567 }
3568
Dan Gohmanf4423b12008-04-19 00:24:39 +00003569 /* If the proper action on seeing token YYTOKEN is to reduce or to
3570 detect an error, take that action. */
3571 yyn += yytoken;
3572 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003573 goto yydefault;
3574 yyn = yytable[yyn];
Dan Gohmanf4423b12008-04-19 00:24:39 +00003575 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003576 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003577 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003578 goto yyerrlab;
3579 yyn = -yyn;
3580 goto yyreduce;
3581 }
3582
3583 if (yyn == YYFINAL)
3584 YYACCEPT;
3585
Dan Gohmanf4423b12008-04-19 00:24:39 +00003586 /* Count tokens shifted since error; after three, turn off error
3587 status. */
3588 if (yyerrstatus)
3589 yyerrstatus--;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003590
Dan Gohmanf4423b12008-04-19 00:24:39 +00003591 /* Shift the look-ahead token. */
3592 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003593
Dan Gohmanf4423b12008-04-19 00:24:39 +00003594 /* Discard the shifted token unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003595 if (yychar != YYEOF)
3596 yychar = YYEMPTY;
3597
Gabor Greife64d2482008-04-06 23:07:54 +00003598 yystate = yyn;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003599 *++yyvsp = yylval;
3600
Reid Spencer68a24bd2005-08-27 18:50:39 +00003601 goto yynewstate;
3602
Gabor Greife64d2482008-04-06 23:07:54 +00003603
Dan Gohmanf4423b12008-04-19 00:24:39 +00003604/*-----------------------------------------------------------.
3605| yydefault -- do the default action for the current state. |
3606`-----------------------------------------------------------*/
3607yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003608 yyn = yydefact[yystate];
3609 if (yyn == 0)
3610 goto yyerrlab;
Dan Gohmanf4423b12008-04-19 00:24:39 +00003611 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003612
Dan Gohmanf4423b12008-04-19 00:24:39 +00003613
3614/*-----------------------------.
3615| yyreduce -- Do a reduction. |
3616`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003617yyreduce:
Dan Gohmanf4423b12008-04-19 00:24:39 +00003618 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003619 yylen = yyr2[yyn];
3620
Dan Gohmanf4423b12008-04-19 00:24:39 +00003621 /* If YYLEN is nonzero, implement the default value of the action:
3622 `$$ = $1'.
3623
3624 Otherwise, the following line sets YYVAL to garbage.
3625 This behavior is undocumented and Bison
3626 users should not rely upon it. Assigning to YYVAL
3627 unconditionally makes the parser a bit smaller, and it avoids a
3628 GCC warning that YYVAL may be used uninitialized. */
3629 yyval = yyvsp[1-yylen];
3630
3631
3632 YY_REDUCE_PRINT (yyn);
3633 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003634 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00003635 case 29:
Chris Lattner15bd0952008-08-29 17:20:18 +00003636#line 1142 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003637 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3638 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003639
Dan Gohmanf4423b12008-04-19 00:24:39 +00003640 case 30:
Chris Lattner15bd0952008-08-29 17:20:18 +00003641#line 1142 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003642 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3643 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003644
Dan Gohmanf4423b12008-04-19 00:24:39 +00003645 case 31:
Chris Lattner15bd0952008-08-29 17:20:18 +00003646#line 1143 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003647 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3648 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003649
Dan Gohmanf4423b12008-04-19 00:24:39 +00003650 case 32:
Chris Lattner15bd0952008-08-29 17:20:18 +00003651#line 1143 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003652 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3653 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003654
Dan Gohmanf4423b12008-04-19 00:24:39 +00003655 case 33:
Chris Lattner15bd0952008-08-29 17:20:18 +00003656#line 1144 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003657 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3658 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003659
Dan Gohmanf4423b12008-04-19 00:24:39 +00003660 case 34:
Chris Lattner15bd0952008-08-29 17:20:18 +00003661#line 1144 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003662 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3663 break;
3664
3665 case 35:
Chris Lattner15bd0952008-08-29 17:20:18 +00003666#line 1145 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003667 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3668 break;
3669
3670 case 36:
Chris Lattner15bd0952008-08-29 17:20:18 +00003671#line 1145 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003672 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3673 break;
3674
3675 case 37:
Chris Lattner15bd0952008-08-29 17:20:18 +00003676#line 1146 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003677 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3678 break;
3679
3680 case 38:
Chris Lattner15bd0952008-08-29 17:20:18 +00003681#line 1146 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003682 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3683 break;
3684
3685 case 39:
Chris Lattner15bd0952008-08-29 17:20:18 +00003686#line 1150 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003687 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3688 break;
3689
3690 case 40:
Chris Lattner15bd0952008-08-29 17:20:18 +00003691#line 1150 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003692 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3693 break;
3694
3695 case 41:
Chris Lattner15bd0952008-08-29 17:20:18 +00003696#line 1151 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003697 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3698 break;
3699
3700 case 42:
Chris Lattner15bd0952008-08-29 17:20:18 +00003701#line 1151 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003702 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3703 break;
3704
3705 case 43:
Chris Lattner15bd0952008-08-29 17:20:18 +00003706#line 1152 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003707 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3708 break;
3709
3710 case 44:
Chris Lattner15bd0952008-08-29 17:20:18 +00003711#line 1152 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003712 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3713 break;
3714
3715 case 45:
Chris Lattner15bd0952008-08-29 17:20:18 +00003716#line 1153 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003717 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3718 break;
3719
3720 case 46:
Chris Lattner15bd0952008-08-29 17:20:18 +00003721#line 1153 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003722 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3723 break;
3724
3725 case 47:
Chris Lattner15bd0952008-08-29 17:20:18 +00003726#line 1154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003727 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3728 break;
3729
3730 case 48:
Chris Lattner15bd0952008-08-29 17:20:18 +00003731#line 1154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003732 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3733 break;
3734
3735 case 49:
Chris Lattner15bd0952008-08-29 17:20:18 +00003736#line 1155 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003737 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3738 break;
3739
3740 case 50:
Chris Lattner15bd0952008-08-29 17:20:18 +00003741#line 1155 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003742 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3743 break;
3744
3745 case 51:
Chris Lattner15bd0952008-08-29 17:20:18 +00003746#line 1156 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003747 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3748 break;
3749
3750 case 52:
Chris Lattner15bd0952008-08-29 17:20:18 +00003751#line 1156 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003752 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3753 break;
3754
3755 case 53:
Chris Lattner15bd0952008-08-29 17:20:18 +00003756#line 1157 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003757 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3758 break;
3759
3760 case 54:
Chris Lattner15bd0952008-08-29 17:20:18 +00003761#line 1158 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003762 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3763 break;
3764
3765 case 65:
Chris Lattner15bd0952008-08-29 17:20:18 +00003766#line 1167 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003767 { (yyval.StrVal) = 0; ;}
3768 break;
3769
3770 case 66:
Chris Lattner15bd0952008-08-29 17:20:18 +00003771#line 1169 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003772 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3773 break;
3774
3775 case 67:
Chris Lattner15bd0952008-08-29 17:20:18 +00003776#line 1170 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003777 { (yyval.UIntVal)=0; ;}
3778 break;
3779
3780 case 68:
Chris Lattner15bd0952008-08-29 17:20:18 +00003781#line 1174 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003782 {
3783 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003784 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003785 ;}
3786 break;
3787
3788 case 69:
Chris Lattner15bd0952008-08-29 17:20:18 +00003789#line 1178 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003790 {
3791 (yyval.StrVal) = 0;
Christopher Lambbf3348d2007-12-12 08:45:45 +00003792 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003793 ;}
3794 break;
3795
Chris Lattner15bd0952008-08-29 17:20:18 +00003796 case 70:
3797#line 1183 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003798 {
Chris Lattner15bd0952008-08-29 17:20:18 +00003799 (yyval.UIntVal) = (yyvsp[(1) - (2)].UIntVal);
3800 CHECK_FOR_ERROR
3801;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003802 break;
3803
3804 case 74:
Chris Lattner15bd0952008-08-29 17:20:18 +00003805#line 1192 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3806 {
3807 (yyval.StrVal) = 0;
3808 CHECK_FOR_ERROR
3809 ;}
3810 break;
3811
3812 case 75:
3813#line 1197 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003814 {
3815 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00003816 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003817 ;}
3818 break;
3819
Chris Lattner15bd0952008-08-29 17:20:18 +00003820 case 76:
3821#line 1203 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003822 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3823 break;
3824
Chris Lattner15bd0952008-08-29 17:20:18 +00003825 case 77:
3826#line 1204 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003827 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3828 break;
3829
Chris Lattner15bd0952008-08-29 17:20:18 +00003830 case 78:
3831#line 1205 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003832 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3833 break;
3834
Chris Lattner15bd0952008-08-29 17:20:18 +00003835 case 79:
3836#line 1206 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003837 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3838 break;
3839
Chris Lattner15bd0952008-08-29 17:20:18 +00003840 case 80:
3841#line 1207 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003842 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3843 break;
3844
Chris Lattner15bd0952008-08-29 17:20:18 +00003845 case 81:
3846#line 1208 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003847 { (yyval.Linkage) = GlobalValue::CommonLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003848 break;
3849
Chris Lattner15bd0952008-08-29 17:20:18 +00003850 case 82:
3851#line 1212 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003852 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003853 break;
3854
Chris Lattner15bd0952008-08-29 17:20:18 +00003855 case 83:
3856#line 1213 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003857 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003858 break;
3859
Chris Lattner15bd0952008-08-29 17:20:18 +00003860 case 84:
3861#line 1214 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003862 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003863 break;
3864
Dan Gohmanf4423b12008-04-19 00:24:39 +00003865 case 85:
Chris Lattner15bd0952008-08-29 17:20:18 +00003866#line 1218 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003867 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003868 break;
3869
3870 case 86:
Chris Lattner15bd0952008-08-29 17:20:18 +00003871#line 1219 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3872 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003873 break;
3874
3875 case 87:
Chris Lattner15bd0952008-08-29 17:20:18 +00003876#line 1220 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3877 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003878 break;
3879
3880 case 88:
Chris Lattner15bd0952008-08-29 17:20:18 +00003881#line 1221 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3882 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003883 break;
3884
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003885 case 89:
Chris Lattner15bd0952008-08-29 17:20:18 +00003886#line 1225 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3887 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003888 break;
3889
3890 case 90:
Chris Lattner15bd0952008-08-29 17:20:18 +00003891#line 1226 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3892 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003893 break;
3894
3895 case 91:
Chris Lattner15bd0952008-08-29 17:20:18 +00003896#line 1227 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3897 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003898 break;
3899
3900 case 92:
Chris Lattner15bd0952008-08-29 17:20:18 +00003901#line 1231 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00003902 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3903 break;
3904
Chris Lattner15bd0952008-08-29 17:20:18 +00003905 case 93:
3906#line 1232 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003907 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003908 break;
3909
Chris Lattner15bd0952008-08-29 17:20:18 +00003910 case 94:
3911#line 1233 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3912 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3913 break;
3914
3915 case 95:
3916#line 1234 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3917 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3918 break;
3919
3920 case 96:
3921#line 1235 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3922 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3923 break;
3924
3925 case 97:
3926#line 1239 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3927 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3928 break;
3929
3930 case 98:
3931#line 1240 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3932 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3933 break;
3934
Dan Gohmanf4423b12008-04-19 00:24:39 +00003935 case 99:
Chris Lattner15bd0952008-08-29 17:20:18 +00003936#line 1241 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3937 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003938 break;
3939
3940 case 100:
Chris Lattner15bd0952008-08-29 17:20:18 +00003941#line 1244 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003942 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003943 break;
3944
3945 case 101:
Chris Lattner15bd0952008-08-29 17:20:18 +00003946#line 1245 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3947 { (yyval.UIntVal) = CallingConv::C; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003948 break;
3949
3950 case 102:
Chris Lattner15bd0952008-08-29 17:20:18 +00003951#line 1246 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3952 { (yyval.UIntVal) = CallingConv::Fast; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003953 break;
3954
3955 case 103:
Chris Lattner15bd0952008-08-29 17:20:18 +00003956#line 1247 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3957 { (yyval.UIntVal) = CallingConv::Cold; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003958 break;
3959
3960 case 104:
Chris Lattner15bd0952008-08-29 17:20:18 +00003961#line 1248 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3962 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00003963 break;
3964
3965 case 105:
Chris Lattner15bd0952008-08-29 17:20:18 +00003966#line 1249 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3967 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00003968 break;
3969
3970 case 106:
Chris Lattner15bd0952008-08-29 17:20:18 +00003971#line 1250 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3972 { (yyval.UIntVal) = CallingConv::X86_SSECall; ;}
3973 break;
3974
3975 case 107:
3976#line 1251 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00003977 {
3978 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003979 GEN_ERROR("Calling conv too large");
Dan Gohmanf4423b12008-04-19 00:24:39 +00003980 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003981 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00003982 ;}
3983 break;
3984
Dan Gohmanf4423b12008-04-19 00:24:39 +00003985 case 108:
Chris Lattner15bd0952008-08-29 17:20:18 +00003986#line 1258 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen20ab78b2008-08-13 18:41:46 +00003987 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003988 break;
3989
3990 case 109:
Chris Lattner15bd0952008-08-29 17:20:18 +00003991#line 1259 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3992 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003993 break;
3994
3995 case 110:
Chris Lattner15bd0952008-08-29 17:20:18 +00003996#line 1260 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen20ab78b2008-08-13 18:41:46 +00003997 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00003998 break;
3999
4000 case 111:
Chris Lattner15bd0952008-08-29 17:20:18 +00004001#line 1261 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4002 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004003 break;
4004
4005 case 112:
Chris Lattner15bd0952008-08-29 17:20:18 +00004006#line 1262 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4007 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004008 break;
4009
4010 case 113:
Chris Lattner15bd0952008-08-29 17:20:18 +00004011#line 1263 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4012 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004013 break;
4014
4015 case 114:
Chris Lattner15bd0952008-08-29 17:20:18 +00004016#line 1264 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4017 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004018 break;
4019
4020 case 115:
Chris Lattner15bd0952008-08-29 17:20:18 +00004021#line 1265 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4022 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004023 break;
4024
4025 case 116:
Chris Lattner15bd0952008-08-29 17:20:18 +00004026#line 1266 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4027 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
4028 break;
4029
4030 case 117:
4031#line 1267 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004032 { (yyval.ParamAttrs) =
4033 ParamAttr::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
4034 break;
4035
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004036 case 118:
Chris Lattner15bd0952008-08-29 17:20:18 +00004037#line 1271 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4038 { (yyval.ParamAttrs) = ParamAttr::None; ;}
Dan Gohmanf4423b12008-04-19 00:24:39 +00004039 break;
4040
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004041 case 119:
Chris Lattner15bd0952008-08-29 17:20:18 +00004042#line 1272 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004043 {
4044 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
4045 ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004046 break;
4047
Chris Lattner15bd0952008-08-29 17:20:18 +00004048 case 120:
4049#line 1277 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4050 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
4051 break;
4052
4053 case 121:
4054#line 1278 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4055 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
4056 break;
4057
4058 case 122:
4059#line 1279 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4060 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
4061 break;
4062
4063 case 123:
4064#line 1280 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4065 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
4066 break;
4067
4068 case 124:
4069#line 1281 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4070 { (yyval.ParamAttrs) = ParamAttr::ReadNone; ;}
4071 break;
4072
4073 case 125:
4074#line 1282 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4075 { (yyval.ParamAttrs) = ParamAttr::ReadOnly; ;}
4076 break;
4077
4078 case 126:
4079#line 1285 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4080 { (yyval.ParamAttrs) = ParamAttr::None; ;}
4081 break;
4082
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004083 case 127:
Chris Lattner15bd0952008-08-29 17:20:18 +00004084#line 1286 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4085 {
4086 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
4087 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004088 break;
4089
4090 case 128:
Chris Lattner15bd0952008-08-29 17:20:18 +00004091#line 1291 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4092 { (yyval.StrVal) = 0; ;}
4093 break;
4094
4095 case 129:
4096#line 1292 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004097 {
4098 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4099 ;}
4100 break;
4101
Chris Lattner15bd0952008-08-29 17:20:18 +00004102 case 130:
4103#line 1299 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004104 { (yyval.UIntVal) = 0; ;}
4105 break;
4106
Chris Lattner15bd0952008-08-29 17:20:18 +00004107 case 131:
4108#line 1300 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004109 {
4110 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4111 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004112 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004113 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004114;}
4115 break;
4116
Chris Lattner15bd0952008-08-29 17:20:18 +00004117 case 132:
4118#line 1306 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004119 { (yyval.UIntVal) = 0; ;}
4120 break;
4121
Chris Lattner15bd0952008-08-29 17:20:18 +00004122 case 133:
4123#line 1307 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004124 {
4125 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4126 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lambbf3348d2007-12-12 08:45:45 +00004127 GEN_ERROR("Alignment must be a power of two");
4128 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004129;}
4130 break;
4131
Chris Lattner15bd0952008-08-29 17:20:18 +00004132 case 134:
4133#line 1316 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004134 {
4135 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
4136 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004137 GEN_ERROR("Invalid character in section name");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004138 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004139 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004140;}
4141 break;
4142
Chris Lattner15bd0952008-08-29 17:20:18 +00004143 case 135:
4144#line 1324 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004145 { (yyval.StrVal) = 0; ;}
4146 break;
4147
Chris Lattner15bd0952008-08-29 17:20:18 +00004148 case 136:
4149#line 1325 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004150 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4151 break;
4152
Dale Johannesenc7071cc2008-05-14 20:13:36 +00004153 case 137:
Chris Lattner15bd0952008-08-29 17:20:18 +00004154#line 1330 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen20ab78b2008-08-13 18:41:46 +00004155 {;}
4156 break;
4157
4158 case 138:
Chris Lattner15bd0952008-08-29 17:20:18 +00004159#line 1331 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4160 {;}
4161 break;
4162
4163 case 139:
4164#line 1332 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004165 {
4166 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4167 delete (yyvsp[(1) - (1)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004168 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004169 ;}
4170 break;
4171
Chris Lattner15bd0952008-08-29 17:20:18 +00004172 case 140:
4173#line 1337 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004174 {
4175 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004176 GEN_ERROR("Alignment must be a power of two");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004177 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004178 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004179 ;}
4180 break;
4181
Chris Lattner15bd0952008-08-29 17:20:18 +00004182 case 148:
4183#line 1353 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004184 {
4185 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004186 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004187 ;}
4188 break;
4189
Chris Lattner15bd0952008-08-29 17:20:18 +00004190 case 149:
4191#line 1357 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004192 {
4193 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004194 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004195 ;}
4196 break;
4197
Chris Lattner15bd0952008-08-29 17:20:18 +00004198 case 150:
4199#line 1361 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004200 { // Pointer type?
4201 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lambbf3348d2007-12-12 08:45:45 +00004202 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004203 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4204 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00004205 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004206 ;}
4207 break;
4208
Chris Lattner15bd0952008-08-29 17:20:18 +00004209 case 151:
4210#line 1368 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004211 { // Named types are also simple types...
4212 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004213 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004214 (yyval.TypeVal) = new PATypeHolder(tmp);
4215 ;}
4216 break;
4217
Chris Lattner15bd0952008-08-29 17:20:18 +00004218 case 152:
4219#line 1373 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004220 { // Type UpReference
4221 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004222 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohmanf4423b12008-04-19 00:24:39 +00004223 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4224 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004225 UR_OUT("New Upreference!\n");
4226 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004227 ;}
4228 break;
4229
Chris Lattner15bd0952008-08-29 17:20:18 +00004230 case 153:
4231#line 1381 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004232 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004233 // Allow but ignore attributes on function types; this permits auto-upgrade.
4234 // FIXME: remove in LLVM 3.0.
Chris Lattnera925a142008-04-23 05:37:08 +00004235 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4236 if (!FunctionType::isValidReturnType(RetTy))
4237 GEN_ERROR("Invalid result type for LLVM function");
4238
Reid Spencer41dff5e2007-01-26 08:05:27 +00004239 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004240 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004241 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004242 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004243 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004244 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004245
Reid Spencer41dff5e2007-01-26 08:05:27 +00004246 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4247 if (isVarArg) Params.pop_back();
4248
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004249 for (unsigned i = 0; i != Params.size(); ++i)
4250 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4251 GEN_ERROR("Function arguments must be value types!");
4252
4253 CHECK_FOR_ERROR
4254
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004255 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004256 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4257 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
4258 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004259 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004260 ;}
4261 break;
4262
Chris Lattner15bd0952008-08-29 17:20:18 +00004263 case 154:
4264#line 1410 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004265 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004266 // Allow but ignore attributes on function types; this permits auto-upgrade.
4267 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004268 std::vector<const Type*> Params;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004269 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004270 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004271 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00004272 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004273 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004274
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004275 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4276 if (isVarArg) Params.pop_back();
4277
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00004278 for (unsigned i = 0; i != Params.size(); ++i)
4279 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4280 GEN_ERROR("Function arguments must be value types!");
4281
4282 CHECK_FOR_ERROR
4283
Dan Gohmanf4423b12008-04-19 00:24:39 +00004284 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
4285 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4286 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004287 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004288 ;}
4289 break;
4290
Chris Lattner15bd0952008-08-29 17:20:18 +00004291 case 155:
4292#line 1435 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004293 { // Sized array type?
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004294 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (yyvsp[(2) - (5)].UInt64Val))));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004295 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004296 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004297 ;}
4298 break;
4299
Chris Lattner15bd0952008-08-29 17:20:18 +00004300 case 156:
4301#line 1440 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004302 { // Vector type?
4303 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4304 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004305 GEN_ERROR("Unsigned result not equal to signed result");
4306 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4307 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004308 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4309 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004310 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004311 ;}
4312 break;
4313
Chris Lattner15bd0952008-08-29 17:20:18 +00004314 case 157:
4315#line 1450 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004316 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004317 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004318 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4319 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004320 Elements.push_back(*I);
4321
Dan Gohmanf4423b12008-04-19 00:24:39 +00004322 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4323 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004324 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004325 ;}
4326 break;
4327
Chris Lattner15bd0952008-08-29 17:20:18 +00004328 case 158:
4329#line 1460 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004330 { // Empty structure type?
4331 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004332 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004333 ;}
4334 break;
4335
Chris Lattner15bd0952008-08-29 17:20:18 +00004336 case 159:
4337#line 1464 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004338 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004339 std::vector<const Type*> Elements;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004340 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4341 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004342 Elements.push_back(*I);
4343
Dan Gohmanf4423b12008-04-19 00:24:39 +00004344 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4345 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004346 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004347 ;}
4348 break;
4349
Chris Lattner15bd0952008-08-29 17:20:18 +00004350 case 160:
4351#line 1474 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004352 { // Empty structure type?
4353 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004354 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004355 ;}
4356 break;
4357
Chris Lattner15bd0952008-08-29 17:20:18 +00004358 case 161:
4359#line 1481 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004360 {
Duncan Sandsdc024672007-11-27 13:23:08 +00004361 // Allow but ignore attributes on function types; this permits auto-upgrade.
4362 // FIXME: remove in LLVM 3.0.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004363 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
4364 (yyval.TypeWithAttrs).Attrs = ParamAttr::None;
4365 ;}
4366 break;
4367
Chris Lattner15bd0952008-08-29 17:20:18 +00004368 case 162:
4369#line 1490 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004370 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004371 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004372 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4373 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004374 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004375 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4376 ;}
4377 break;
4378
Chris Lattner15bd0952008-08-29 17:20:18 +00004379 case 163:
4380#line 1497 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004381 {
4382 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4383 ;}
4384 break;
4385
Chris Lattner15bd0952008-08-29 17:20:18 +00004386 case 164:
4387#line 1502 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004388 {
4389 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4390 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004391 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004392 ;}
4393 break;
4394
Chris Lattner15bd0952008-08-29 17:20:18 +00004395 case 165:
4396#line 1507 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004397 {
4398 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004399 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004400 ;}
4401 break;
4402
Chris Lattner15bd0952008-08-29 17:20:18 +00004403 case 167:
4404#line 1515 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004405 {
4406 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00004407 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004408 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004409 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004410 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004411 ;}
4412 break;
4413
Chris Lattner15bd0952008-08-29 17:20:18 +00004414 case 168:
4415#line 1522 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004416 {
4417 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004418 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4419 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00004420 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004421 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004422 ;}
4423 break;
4424
Chris Lattner15bd0952008-08-29 17:20:18 +00004425 case 169:
4426#line 1529 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004427 {
4428 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004429 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004430 ;}
4431 break;
4432
Chris Lattner15bd0952008-08-29 17:20:18 +00004433 case 170:
4434#line 1537 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004435 {
4436 (yyval.TypeList) = new std::list<PATypeHolder>();
4437 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4438 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004439 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004440 ;}
4441 break;
4442
Chris Lattner15bd0952008-08-29 17:20:18 +00004443 case 171:
4444#line 1543 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004445 {
4446 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4447 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004448 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004449 ;}
4450 break;
4451
Chris Lattner15bd0952008-08-29 17:20:18 +00004452 case 172:
4453#line 1555 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004454 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004455 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004456 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4457 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004458 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004459 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004460 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004461 const Type *ETy = ATy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004462 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004463
4464 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004465 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004466 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004467 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004468 utostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004469
4470 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004471 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4472 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004473 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4474 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004475 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004476 }
4477
Dan Gohmanf4423b12008-04-19 00:24:39 +00004478 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4479 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004480 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004481 ;}
4482 break;
4483
Chris Lattner15bd0952008-08-29 17:20:18 +00004484 case 173:
4485#line 1583 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004486 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004487 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004488 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4489 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004490 if (ATy == 0)
4491 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004492 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004493
Dan Gohman180c1692008-06-23 18:43:26 +00004494 uint64_t NumElements = ATy->getNumElements();
Mon P Wang28873102008-06-25 08:15:39 +00004495 if (NumElements != uint64_t(-1) && NumElements != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004496 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Mon P Wang28873102008-06-25 08:15:39 +00004497 " arguments, but has size of " + utostr(NumElements) +"");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004498 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4499 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004500 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004501 ;}
4502 break;
4503
Chris Lattner15bd0952008-08-29 17:20:18 +00004504 case 174:
4505#line 1599 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004506 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004507 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004508 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4509 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004510 if (ATy == 0)
4511 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004512 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004513
Dan Gohman180c1692008-06-23 18:43:26 +00004514 uint64_t NumElements = ATy->getNumElements();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004515 const Type *ETy = ATy->getElementType();
Mon P Wang28873102008-06-25 08:15:39 +00004516 if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (3)].StrVal)->length())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004517 GEN_ERROR("Can't build string constant of size " +
Mon P Wang28873102008-06-25 08:15:39 +00004518 utostr((yyvsp[(3) - (3)].StrVal)->length()) +
4519 " when array has size " + utostr(NumElements) + "");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004520 std::vector<Constant*> Vals;
4521 if (ETy == Type::Int8Ty) {
Mon P Wang28873102008-06-25 08:15:39 +00004522 for (uint64_t i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004523 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004524 } else {
Dan Gohmanf4423b12008-04-19 00:24:39 +00004525 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004526 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4527 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004528 delete (yyvsp[(3) - (3)].StrVal);
4529 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4530 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004531 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004532 ;}
4533 break;
4534
Chris Lattner15bd0952008-08-29 17:20:18 +00004535 case 175:
4536#line 1626 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004537 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004538 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004539 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4540 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004541 if (PTy == 0)
4542 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004543 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004544 const Type *ETy = PTy->getElementType();
Dan Gohman180c1692008-06-23 18:43:26 +00004545 unsigned NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004546
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004547 // Verify that we have the correct size...
Mon P Wang28873102008-06-25 08:15:39 +00004548 if (NumElements != unsigned(-1) && NumElements != (unsigned)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004549 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004550 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Mon P Wang28873102008-06-25 08:15:39 +00004551 utostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004552
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004553 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004554 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4555 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004556 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4557 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohmanf4423b12008-04-19 00:24:39 +00004558 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004559 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004560
Dan Gohmanf4423b12008-04-19 00:24:39 +00004561 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4562 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004563 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004564 ;}
4565 break;
4566
Chris Lattner15bd0952008-08-29 17:20:18 +00004567 case 176:
4568#line 1654 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004569 {
4570 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004571 if (STy == 0)
4572 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004573 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004574
Dan Gohmanf4423b12008-04-19 00:24:39 +00004575 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004576 GEN_ERROR("Illegal number of initializers for structure type");
4577
4578 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004579 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4580 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004581 GEN_ERROR("Expected type '" +
4582 STy->getElementType(i)->getDescription() +
4583 "' for element #" + utostr(i) +
4584 " of structure initializer");
4585
4586 // Check to ensure that Type is not packed
4587 if (STy->isPacked())
4588 GEN_ERROR("Unpacked Initializer to vector type '" +
4589 STy->getDescription() + "'");
4590
Dan Gohmanf4423b12008-04-19 00:24:39 +00004591 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4592 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004593 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004594 ;}
4595 break;
4596
Chris Lattner15bd0952008-08-29 17:20:18 +00004597 case 177:
4598#line 1680 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004599 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004600 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004601 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4602 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004603 if (STy == 0)
4604 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004605 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004606
4607 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004608 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004609
4610 // Check to ensure that Type is not packed
4611 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004612 GEN_ERROR("Unpacked Initializer to vector type '" +
4613 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004614
Dan Gohmanf4423b12008-04-19 00:24:39 +00004615 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4616 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004617 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004618 ;}
4619 break;
4620
Chris Lattner15bd0952008-08-29 17:20:18 +00004621 case 178:
4622#line 1700 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004623 {
4624 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004625 if (STy == 0)
4626 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004627 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004628
Dan Gohmanf4423b12008-04-19 00:24:39 +00004629 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004630 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004631
4632 // Check to ensure that constants are compatible with the type initializer!
Dan Gohmanf4423b12008-04-19 00:24:39 +00004633 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4634 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004635 GEN_ERROR("Expected type '" +
4636 STy->getElementType(i)->getDescription() +
4637 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004638 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004639
4640 // Check to ensure that Type is packed
4641 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004642 GEN_ERROR("Vector initializer to non-vector type '" +
4643 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004644
Dan Gohmanf4423b12008-04-19 00:24:39 +00004645 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4646 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004647 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004648 ;}
4649 break;
4650
Chris Lattner15bd0952008-08-29 17:20:18 +00004651 case 179:
4652#line 1726 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004653 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004654 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004655 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4656 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004657 if (STy == 0)
4658 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004659 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004660
4661 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004662 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004663
4664 // Check to ensure that Type is packed
4665 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004666 GEN_ERROR("Vector initializer to non-vector type '" +
4667 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004668
Dan Gohmanf4423b12008-04-19 00:24:39 +00004669 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4670 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004671 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004672 ;}
4673 break;
4674
Chris Lattner15bd0952008-08-29 17:20:18 +00004675 case 180:
4676#line 1746 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004677 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004678 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004679 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4680 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004681 if (PTy == 0)
4682 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004683 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004684
Dan Gohmanf4423b12008-04-19 00:24:39 +00004685 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4686 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004687 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004688 ;}
4689 break;
4690
Chris Lattner15bd0952008-08-29 17:20:18 +00004691 case 181:
4692#line 1758 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004693 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004694 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004695 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4696 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4697 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004698 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004699 ;}
4700 break;
4701
Chris Lattner15bd0952008-08-29 17:20:18 +00004702 case 182:
4703#line 1765 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004704 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004705 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004706 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4707 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004708 if (Ty == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00004709 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004710
4711 // ConstExprs can exist in the body of a function, thus creating
4712 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004713 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004714 // symbol table instead of the module symbol table for the global symbol,
4715 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004716 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004717 //
4718 Function *SavedCurFn = CurFun.CurrentFunction;
4719 CurFun.CurrentFunction = 0;
4720
Dan Gohmanf4423b12008-04-19 00:24:39 +00004721 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004722 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004723
4724 CurFun.CurrentFunction = SavedCurFn;
4725
4726 // If this is an initializer for a constant pointer, which is referencing a
4727 // (currently) undefined variable, create a stub now that shall be replaced
4728 // in the future with the right type of variable.
4729 //
4730 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004731 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004732 const PointerType *PT = cast<PointerType>(Ty);
4733
4734 // First check to see if the forward references value is already created!
4735 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohmanf4423b12008-04-19 00:24:39 +00004736 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004737
4738 if (I != CurModule.GlobalRefs.end()) {
4739 V = I->second; // Placeholder already exists, use it...
Dan Gohmanf4423b12008-04-19 00:24:39 +00004740 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004741 } else {
4742 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004743 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4744 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4745 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004746 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004747
4748 // Create the forward referenced global.
4749 GlobalValue *GV;
4750 if (const FunctionType *FTy =
4751 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greife64d2482008-04-06 23:07:54 +00004752 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4753 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004754 } else {
4755 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004756 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004757 Name, CurModule.CurrentModule);
4758 }
4759
4760 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohmanf4423b12008-04-19 00:24:39 +00004761 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004762 V = GV;
4763 }
4764 }
4765
Dan Gohmanf4423b12008-04-19 00:24:39 +00004766 (yyval.ConstVal) = cast<GlobalValue>(V);
4767 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004768 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004769 ;}
4770 break;
4771
Chris Lattner15bd0952008-08-29 17:20:18 +00004772 case 183:
4773#line 1831 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004774 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004775 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004776 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4777 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004778 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00004779 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4780 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4781 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004782 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004783 ;}
4784 break;
4785
Chris Lattner15bd0952008-08-29 17:20:18 +00004786 case 184:
4787#line 1841 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004788 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004789 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004790 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4791 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004792 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4793 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004794 (yyval.ConstVal) = Constant::getNullValue(Ty);
4795 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004796 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004797 ;}
4798 break;
4799
Chris Lattner15bd0952008-08-29 17:20:18 +00004800 case 185:
4801#line 1851 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004802 { // integral constants
4803 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004804 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004805 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004806 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004807 ;}
4808 break;
4809
Chris Lattner15bd0952008-08-29 17:20:18 +00004810 case 186:
4811#line 1857 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004812 { // arbitrary precision integer constants
4813 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4814 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004815 GEN_ERROR("Constant value does not fit in type");
4816 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004817 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4818 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4819 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004820 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004821 ;}
4822 break;
4823
Chris Lattner15bd0952008-08-29 17:20:18 +00004824 case 187:
4825#line 1867 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004826 { // integral constants
4827 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004828 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004829 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004830 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004831 ;}
4832 break;
4833
Chris Lattner15bd0952008-08-29 17:20:18 +00004834 case 188:
4835#line 1873 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004836 { // arbitrary precision integer constants
4837 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4838 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004839 GEN_ERROR("Constant value does not fit in type");
4840 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004841 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4842 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4843 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004844 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004845 ;}
4846 break;
4847
Chris Lattner15bd0952008-08-29 17:20:18 +00004848 case 189:
4849#line 1883 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004850 { // Boolean constants
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004851 if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
4852 GEN_ERROR("Constant true must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004853 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004854 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004855 ;}
4856 break;
4857
Chris Lattner15bd0952008-08-29 17:20:18 +00004858 case 190:
4859#line 1889 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004860 { // Boolean constants
Dan Gohman81a0c0b2008-05-31 00:58:22 +00004861 if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
4862 GEN_ERROR("Constant false must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004863 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004864 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004865 ;}
4866 break;
4867
Chris Lattner15bd0952008-08-29 17:20:18 +00004868 case 191:
4869#line 1895 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004870 { // Floating point constants
4871 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004872 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004873 // Lexer has no type info, so builds all float and double FP constants
4874 // as double. Fix this here. Long double is done right.
Dan Gohmanf4423b12008-04-19 00:24:39 +00004875 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4876 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattnerd8eb63f2008-04-20 00:41:19 +00004877 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Dan Gohmanf4423b12008-04-19 00:24:39 +00004878 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004879 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004880 ;}
4881 break;
4882
Chris Lattner15bd0952008-08-29 17:20:18 +00004883 case 192:
4884#line 1908 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004885 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004886 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00004887 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4888 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4889 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4890 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004891 GEN_ERROR("invalid cast opcode for cast from '" +
4892 Val->getType()->getDescription() + "' to '" +
4893 DestTy->getDescription() + "'");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004894 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4895 delete (yyvsp[(5) - (6)].TypeVal);
4896 ;}
4897 break;
4898
Chris Lattner15bd0952008-08-29 17:20:18 +00004899 case 193:
4900#line 1920 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004901 {
4902 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004903 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004904
4905 const Type *IdxTy =
Dan Gohman041e2eb2008-05-15 19:50:34 +00004906 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004907 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004908 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004909
Chris Lattnerf7469af2007-01-31 04:44:08 +00004910 SmallVector<Constant*, 8> IdxVec;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004911 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4912 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004913 IdxVec.push_back(C);
4914 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004915 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004916
Dan Gohmanf4423b12008-04-19 00:24:39 +00004917 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004918
Dan Gohmanf4423b12008-04-19 00:24:39 +00004919 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004920 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004921 ;}
4922 break;
4923
Chris Lattner15bd0952008-08-29 17:20:18 +00004924 case 194:
4925#line 1941 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004926 {
4927 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004928 GEN_ERROR("Select condition must be of boolean type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004929 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004930 GEN_ERROR("Select operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004931 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004932 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004933 ;}
4934 break;
4935
Chris Lattner15bd0952008-08-29 17:20:18 +00004936 case 195:
4937#line 1949 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004938 {
4939 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004940 GEN_ERROR("Binary operator types must match");
4941 CHECK_FOR_ERROR;
Dan Gohmanf4423b12008-04-19 00:24:39 +00004942 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4943 ;}
4944 break;
4945
Chris Lattner15bd0952008-08-29 17:20:18 +00004946 case 196:
4947#line 1955 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004948 {
4949 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004950 GEN_ERROR("Logical operator types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004951 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
Nate Begeman5bc1ea02008-07-29 15:49:41 +00004952 if (!isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00004953 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004954 GEN_ERROR("Logical operator requires integral operands");
4955 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00004956 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004957 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00004958 ;}
4959 break;
4960
Chris Lattner15bd0952008-08-29 17:20:18 +00004961 case 197:
4962#line 1966 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004963 {
4964 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004965 GEN_ERROR("icmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004966 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4967 ;}
4968 break;
4969
Chris Lattner15bd0952008-08-29 17:20:18 +00004970 case 198:
4971#line 1971 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004972 {
4973 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004974 GEN_ERROR("fcmp operand types must match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00004975 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4976 ;}
4977 break;
4978
Chris Lattner15bd0952008-08-29 17:20:18 +00004979 case 199:
4980#line 1976 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00004981 {
4982 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
4983 GEN_ERROR("vicmp operand types must match");
4984 (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4985 ;}
4986 break;
4987
Chris Lattner15bd0952008-08-29 17:20:18 +00004988 case 200:
4989#line 1981 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00004990 {
4991 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
4992 GEN_ERROR("vfcmp operand types must match");
4993 (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4994 ;}
4995 break;
4996
Chris Lattner15bd0952008-08-29 17:20:18 +00004997 case 201:
4998#line 1986 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00004999 {
5000 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005001 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005002 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005003 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005004 ;}
5005 break;
5006
Chris Lattner15bd0952008-08-29 17:20:18 +00005007 case 202:
5008#line 1992 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005009 {
5010 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005011 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005012 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005013 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005014 ;}
5015 break;
5016
Chris Lattner15bd0952008-08-29 17:20:18 +00005017 case 203:
5018#line 1998 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005019 {
5020 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005021 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005022 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00005023 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005024 ;}
5025 break;
5026
Chris Lattner15bd0952008-08-29 17:20:18 +00005027 case 204:
5028#line 2004 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005029 {
5030 if (!isa<StructType>((yyvsp[(3) - (5)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (5)].ConstVal)->getType()))
5031 GEN_ERROR("ExtractValue requires an aggregate operand");
5032
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005033 (yyval.ConstVal) = ConstantExpr::getExtractValue((yyvsp[(3) - (5)].ConstVal), &(*(yyvsp[(4) - (5)].ConstantList))[0], (yyvsp[(4) - (5)].ConstantList)->size());
5034 delete (yyvsp[(4) - (5)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005035 CHECK_FOR_ERROR
5036 ;}
5037 break;
5038
Chris Lattner15bd0952008-08-29 17:20:18 +00005039 case 205:
5040#line 2012 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005041 {
5042 if (!isa<StructType>((yyvsp[(3) - (7)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (7)].ConstVal)->getType()))
5043 GEN_ERROR("InsertValue requires an aggregate operand");
5044
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005045 (yyval.ConstVal) = ConstantExpr::getInsertValue((yyvsp[(3) - (7)].ConstVal), (yyvsp[(5) - (7)].ConstVal), &(*(yyvsp[(6) - (7)].ConstantList))[0], (yyvsp[(6) - (7)].ConstantList)->size());
5046 delete (yyvsp[(6) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00005047 CHECK_FOR_ERROR
5048 ;}
5049 break;
5050
Chris Lattner15bd0952008-08-29 17:20:18 +00005051 case 206:
5052#line 2023 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005053 {
5054 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005055 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005056 ;}
5057 break;
5058
Chris Lattner15bd0952008-08-29 17:20:18 +00005059 case 207:
5060#line 2027 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005061 {
5062 (yyval.ConstVector) = new std::vector<Constant*>();
5063 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005064 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005065 ;}
5066 break;
5067
Chris Lattner15bd0952008-08-29 17:20:18 +00005068 case 208:
5069#line 2035 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00005070 { (yyval.BoolVal) = false; ;}
Nate Begemanac80ade2008-05-12 19:01:56 +00005071 break;
5072
Dan Gohmane4977cf2008-05-23 01:55:30 +00005073 case 209:
Chris Lattner15bd0952008-08-29 17:20:18 +00005074#line 2035 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005075 { (yyval.BoolVal) = true; ;}
Dan Gohmane4977cf2008-05-23 01:55:30 +00005076 break;
5077
5078 case 210:
Chris Lattner15bd0952008-08-29 17:20:18 +00005079#line 2038 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5080 { (yyval.BoolVal) = true; ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005081 break;
5082
5083 case 211:
Chris Lattner15bd0952008-08-29 17:20:18 +00005084#line 2038 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5085 { (yyval.BoolVal) = false; ;}
5086 break;
5087
5088 case 212:
5089#line 2041 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005090 {
5091 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
5092 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00005093 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005094 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
5095 if (!Aliasee)
5096 GEN_ERROR("Aliases can be created only to global values");
5097
Dan Gohmanf4423b12008-04-19 00:24:39 +00005098 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005099 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005100 delete (yyvsp[(1) - (2)].TypeVal);
5101 ;}
5102 break;
5103
Chris Lattner15bd0952008-08-29 17:20:18 +00005104 case 213:
5105#line 2053 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005106 {
5107 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
5108 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
5109 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005110 GEN_ERROR("invalid cast opcode for cast from '" +
5111 Val->getType()->getDescription() + "' to '" +
5112 DestTy->getDescription() + "'");
5113
Dan Gohmanf4423b12008-04-19 00:24:39 +00005114 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005115 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005116 delete (yyvsp[(5) - (6)].TypeVal);
5117 ;}
5118 break;
5119
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005120 case 214:
Chris Lattner15bd0952008-08-29 17:20:18 +00005121#line 2074 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005122 {
5123 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5124 CurModule.ModuleDone();
5125 CHECK_FOR_ERROR;
5126 ;}
Dale Johannesenc7071cc2008-05-14 20:13:36 +00005127 break;
5128
Chris Lattner15bd0952008-08-29 17:20:18 +00005129 case 215:
5130#line 2079 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5131 {
5132 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
5133 CurModule.ModuleDone();
5134 CHECK_FOR_ERROR;
5135 ;}
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005136 break;
5137
5138 case 218:
Chris Lattner15bd0952008-08-29 17:20:18 +00005139#line 2092 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5140 { CurFun.isDeclare = false; ;}
5141 break;
5142
5143 case 219:
5144#line 2092 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005145 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005146 CurFun.FunctionDone();
5147 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005148 ;}
5149 break;
5150
Chris Lattner15bd0952008-08-29 17:20:18 +00005151 case 220:
5152#line 2096 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005153 { CurFun.isDeclare = true; ;}
5154 break;
5155
Dan Gohmane4977cf2008-05-23 01:55:30 +00005156 case 221:
Chris Lattner15bd0952008-08-29 17:20:18 +00005157#line 2096 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesen20ab78b2008-08-13 18:41:46 +00005158 {
5159 CHECK_FOR_ERROR
5160 ;}
5161 break;
5162
5163 case 222:
Chris Lattner15bd0952008-08-29 17:20:18 +00005164#line 2099 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5165 {
5166 CHECK_FOR_ERROR
5167 ;}
5168 break;
5169
5170 case 223:
5171#line 2102 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005172 {
Reid Spencer14310612006-12-31 05:40:51 +00005173 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005174 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005175 // Eagerly resolve types. This is not an optimization, this is a
5176 // requirement that is due to the fact that we could have this:
5177 //
5178 // %list = type { %list * }
5179 // %list = type { %list * } ; repeated type decl
5180 //
5181 // If types are not resolved eagerly, then the two types will not be
5182 // determined to be the same type!
5183 //
Dan Gohmanf4423b12008-04-19 00:24:39 +00005184 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005185
Dan Gohmanf4423b12008-04-19 00:24:39 +00005186 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00005187 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005188 // If this is a named type that is not a redefinition, add it to the slot
5189 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005190 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005191 }
Reid Spencera132e042006-12-03 05:46:11 +00005192
Dan Gohmanf4423b12008-04-19 00:24:39 +00005193 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005194 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005195 ;}
5196 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00005197
Chris Lattner15bd0952008-08-29 17:20:18 +00005198 case 224:
5199#line 2126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005200 {
5201 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
5202
5203 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005204 CHECK_FOR_ERROR
5205 // If this is a named type that is not a redefinition, add it to the slot
5206 // table.
Dan Gohmanf4423b12008-04-19 00:24:39 +00005207 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005208 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005209 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005210 ;}
5211 break;
5212
Chris Lattner15bd0952008-08-29 17:20:18 +00005213 case 225:
5214#line 2138 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005215 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005216 /* "Externally Visible" Linkage */
Dan Gohmanf4423b12008-04-19 00:24:39 +00005217 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005218 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005219 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5220 (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 +00005221 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005222 ;}
5223 break;
5224
Chris Lattner15bd0952008-08-29 17:20:18 +00005225 case 226:
5226#line 2145 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005227 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005228 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005229 ;}
5230 break;
5231
Chris Lattner15bd0952008-08-29 17:20:18 +00005232 case 227:
5233#line 2149 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005234 {
5235 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lambbf3348d2007-12-12 08:45:45 +00005236 GEN_ERROR("Global value initializer is not a constant");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005237 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 +00005238 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005239 ;}
5240 break;
5241
Chris Lattner15bd0952008-08-29 17:20:18 +00005242 case 228:
5243#line 2154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005244 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005245 CurGV = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005246 ;}
5247 break;
5248
Chris Lattner15bd0952008-08-29 17:20:18 +00005249 case 229:
5250#line 2158 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005251 {
Christopher Lambbf3348d2007-12-12 08:45:45 +00005252 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005253 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5254 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 +00005255 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005256 delete (yyvsp[(6) - (7)].TypeVal);
5257 ;}
5258 break;
5259
Chris Lattner15bd0952008-08-29 17:20:18 +00005260 case 230:
5261#line 2164 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005262 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005263 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005264 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005265 ;}
5266 break;
5267
Chris Lattner15bd0952008-08-29 17:20:18 +00005268 case 231:
5269#line 2168 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005270 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005271 std::string Name;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005272 if ((yyvsp[(1) - (5)].StrVal)) {
5273 Name = *(yyvsp[(1) - (5)].StrVal);
5274 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005275 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005276 if (Name.empty())
5277 GEN_ERROR("Alias name cannot be empty");
5278
Dan Gohmanf4423b12008-04-19 00:24:39 +00005279 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005280 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005281 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005282
Dan Gohmanf4423b12008-04-19 00:24:39 +00005283 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005284 CurModule.CurrentModule);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005285 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005286 InsertValue(GA, CurModule.Values);
Chris Lattner569f7372007-09-10 23:24:14 +00005287
5288
5289 // If there was a forward reference of this alias, resolve it now.
5290
5291 ValID ID;
5292 if (!Name.empty())
5293 ID = ValID::createGlobalName(Name);
5294 else
5295 ID = ValID::createGlobalID(CurModule.Values.size()-1);
5296
5297 if (GlobalValue *FWGV =
5298 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5299 // Replace uses of the fwdref with the actual alias.
5300 FWGV->replaceAllUsesWith(GA);
5301 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5302 GV->eraseFromParent();
5303 else
5304 cast<Function>(FWGV)->eraseFromParent();
5305 }
5306 ID.destroy();
5307
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005308 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005309 ;}
5310 break;
5311
Chris Lattner15bd0952008-08-29 17:20:18 +00005312 case 232:
5313#line 2208 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005314 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005315 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005316 ;}
5317 break;
5318
Chris Lattner15bd0952008-08-29 17:20:18 +00005319 case 233:
5320#line 2211 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005321 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005322 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005323 ;}
5324 break;
5325
Chris Lattner15bd0952008-08-29 17:20:18 +00005326 case 234:
5327#line 2217 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005328 {
Chris Lattner66316012006-01-24 04:14:29 +00005329 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005330 if (AsmSoFar.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005331 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005332 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00005333 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5334 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005335 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005336;}
5337 break;
5338
Chris Lattner15bd0952008-08-29 17:20:18 +00005339 case 235:
5340#line 2227 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005341 {
5342 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5343 delete (yyvsp[(3) - (3)].StrVal);
5344 ;}
5345 break;
5346
Chris Lattner15bd0952008-08-29 17:20:18 +00005347 case 236:
5348#line 2231 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005349 {
5350 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5351 delete (yyvsp[(3) - (3)].StrVal);
5352 ;}
5353 break;
5354
Chris Lattner15bd0952008-08-29 17:20:18 +00005355 case 238:
5356#line 2238 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005357 {
5358 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5359 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lambbf3348d2007-12-12 08:45:45 +00005360 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005361 ;}
5362 break;
5363
Chris Lattner15bd0952008-08-29 17:20:18 +00005364 case 239:
5365#line 2243 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005366 {
5367 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5368 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005369 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005370 ;}
5371 break;
5372
Chris Lattner15bd0952008-08-29 17:20:18 +00005373 case 240:
5374#line 2248 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005375 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005376 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005377 ;}
5378 break;
5379
Chris Lattner15bd0952008-08-29 17:20:18 +00005380 case 241:
5381#line 2257 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005382 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005383 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005384 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005385 if (!(*(yyvsp[(3) - (5)].TypeVal))->isFirstClassType())
5386 GEN_ERROR("Argument types must be first-class");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005387 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5388 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5389 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005390 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005391 ;}
5392 break;
5393
Chris Lattner15bd0952008-08-29 17:20:18 +00005394 case 242:
5395#line 2267 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005396 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005397 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005398 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005399 if (!(*(yyvsp[(1) - (3)].TypeVal))->isFirstClassType())
5400 GEN_ERROR("Argument types must be first-class");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005401 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5402 (yyval.ArgList) = new ArgListType;
5403 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005404 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005405 ;}
5406 break;
5407
Chris Lattner15bd0952008-08-29 17:20:18 +00005408 case 243:
5409#line 2278 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005410 {
5411 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005412 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005413 ;}
5414 break;
5415
Chris Lattner15bd0952008-08-29 17:20:18 +00005416 case 244:
5417#line 2282 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005418 {
5419 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005420 struct ArgListEntry E;
5421 E.Ty = new PATypeHolder(Type::VoidTy);
5422 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00005423 E.Attrs = ParamAttr::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005424 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005425 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005426 ;}
5427 break;
5428
Chris Lattner15bd0952008-08-29 17:20:18 +00005429 case 245:
5430#line 2291 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005431 {
5432 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005433 struct ArgListEntry E;
5434 E.Ty = new PATypeHolder(Type::VoidTy);
5435 E.Name = 0;
5436 E.Attrs = ParamAttr::None;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005437 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005438 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005439 ;}
5440 break;
5441
Chris Lattner15bd0952008-08-29 17:20:18 +00005442 case 246:
5443#line 2300 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005444 {
5445 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005446 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005447 ;}
5448 break;
5449
Chris Lattner15bd0952008-08-29 17:20:18 +00005450 case 247:
5451#line 2306 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005452 {
5453 std::string FunctionName(*(yyvsp[(3) - (10)].StrVal));
5454 delete (yyvsp[(3) - (10)].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005455
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005456 // Check the function result for abstractness if this is a define. We should
5457 // have no abstract types at this point
Dan Gohmanf4423b12008-04-19 00:24:39 +00005458 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (10)].TypeVal)))
5459 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (10)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005460
Chris Lattnera925a142008-04-23 05:37:08 +00005461 if (!FunctionType::isValidReturnType(*(yyvsp[(2) - (10)].TypeVal)))
5462 GEN_ERROR("Invalid result type for LLVM function");
5463
Reid Spencer68a24bd2005-08-27 18:50:39 +00005464 std::vector<const Type*> ParamTypeList;
Chris Lattner58d74912008-03-12 17:45:29 +00005465 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005466 if ((yyvsp[(7) - (10)].ParamAttrs) != ParamAttr::None)
5467 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(7) - (10)].ParamAttrs)));
5468 if ((yyvsp[(5) - (10)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005469 unsigned index = 1;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005470 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin(); I != (yyvsp[(5) - (10)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005471 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005472 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5473 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005474 ParamTypeList.push_back(Ty);
Chris Lattner58d74912008-03-12 17:45:29 +00005475 if (Ty != Type::VoidTy && I->Attrs != ParamAttr::None)
5476 Attrs.push_back(ParamAttrsWithIndex::get(index, I->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00005477 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005478 }
5479
5480 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5481 if (isVarArg) ParamTypeList.pop_back();
5482
Chris Lattner58d74912008-03-12 17:45:29 +00005483 PAListPtr PAL;
Christopher Lamb5c104242007-04-22 20:09:11 +00005484 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00005485 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Reid Spencer7b5d4662007-04-09 06:16:21 +00005486
Dan Gohmanf4423b12008-04-19 00:24:39 +00005487 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (10)].TypeVal), ParamTypeList, isVarArg);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00005488 const PointerType *PFT = PointerType::getUnqual(FT);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005489 delete (yyvsp[(2) - (10)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005490
5491 ValID ID;
5492 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005493 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005494 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005495 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005496 }
5497
5498 Function *Fn = 0;
5499 // See if this function was forward referenced. If so, recycle the object.
5500 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5501 // Move the function to the end of the list, from whereever it was
5502 // previously inserted.
5503 Fn = cast<Function>(FWRef);
Chris Lattner58d74912008-03-12 17:45:29 +00005504 assert(Fn->getParamAttrs().isEmpty() &&
5505 "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005506 CurModule.CurrentModule->getFunctionList().remove(Fn);
5507 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5508 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005509 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005510 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005511 // The existing function doesn't have the same type. This is an overload
5512 // error.
5513 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsdc024672007-11-27 13:23:08 +00005514 } else if (Fn->getParamAttrs() != PAL) {
5515 // The existing function doesn't have the same parameter attributes.
5516 // This is an overload error.
5517 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005518 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005519 // Neither the existing or the current function is a declaration and they
5520 // have the same name and same type. Clearly this is a redefinition.
5521 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005522 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005523 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005524 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5525 AI != AE; ++AI)
5526 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005527 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005528 } else { // Not already defined?
Gabor Greife64d2482008-04-06 23:07:54 +00005529 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5530 CurModule.CurrentModule);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005531 InsertValue(Fn, CurModule.Values);
5532 }
5533
5534 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005535
5536 if (CurFun.isDeclare) {
5537 // If we have declaration, always overwrite linkage. This will allow us to
5538 // correctly handle cases, when pointer to function is passed as argument to
5539 // another function.
5540 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005541 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005542 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005543 Fn->setCallingConv((yyvsp[(1) - (10)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00005544 Fn->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005545 Fn->setAlignment((yyvsp[(9) - (10)].UIntVal));
5546 if ((yyvsp[(8) - (10)].StrVal)) {
5547 Fn->setSection(*(yyvsp[(8) - (10)].StrVal));
5548 delete (yyvsp[(8) - (10)].StrVal);
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00005549 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00005550 if ((yyvsp[(10) - (10)].StrVal)) {
Gordon Henriksen5d82cd32008-08-17 18:48:50 +00005551 Fn->setGC((yyvsp[(10) - (10)].StrVal)->c_str());
Dan Gohmanf4423b12008-04-19 00:24:39 +00005552 delete (yyvsp[(10) - (10)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005553 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005554
5555 // Add all of the arguments we parsed to the function...
Dan Gohmanf4423b12008-04-19 00:24:39 +00005556 if ((yyvsp[(5) - (10)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005557 if (isVarArg) { // Nuke the last entry
Dan Gohmanf4423b12008-04-19 00:24:39 +00005558 assert((yyvsp[(5) - (10)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (10)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005559 "Not a varargs marker!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00005560 delete (yyvsp[(5) - (10)].ArgList)->back().Ty;
5561 (yyvsp[(5) - (10)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005562 }
5563 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005564 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005565 unsigned Idx = 1;
Dan Gohmanf4423b12008-04-19 00:24:39 +00005566 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin();
5567 I != (yyvsp[(5) - (10)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005568 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005569 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005570 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005571 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005572 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005573 }
Reid Spencera132e042006-12-03 05:46:11 +00005574
Dan Gohmanf4423b12008-04-19 00:24:39 +00005575 delete (yyvsp[(5) - (10)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005576 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005577 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005578;}
5579 break;
5580
Chris Lattner15bd0952008-08-29 17:20:18 +00005581 case 250:
5582#line 2436 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005583 {
5584 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005585
5586 // Make sure that we keep track of the linkage type even if there was a
5587 // previous "declare".
Dan Gohmanf4423b12008-04-19 00:24:39 +00005588 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5589 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5590;}
5591 break;
5592
Chris Lattner15bd0952008-08-29 17:20:18 +00005593 case 253:
5594#line 2447 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005595 {
5596 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005597 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005598;}
5599 break;
5600
Chris Lattner15bd0952008-08-29 17:20:18 +00005601 case 254:
5602#line 2452 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005603 {
5604 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5605 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5606 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005607 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005608 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005609 ;}
5610 break;
5611
Chris Lattner15bd0952008-08-29 17:20:18 +00005612 case 255:
5613#line 2464 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005614 {
5615 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005616 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005617 ;}
5618 break;
5619
Chris Lattner15bd0952008-08-29 17:20:18 +00005620 case 256:
5621#line 2468 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005622 {
5623 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005624 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005625 ;}
5626 break;
5627
Chris Lattner15bd0952008-08-29 17:20:18 +00005628 case 257:
5629#line 2473 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005630 { // A reference to a direct constant
5631 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005632 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005633 ;}
5634 break;
5635
Chris Lattner15bd0952008-08-29 17:20:18 +00005636 case 258:
5637#line 2477 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005638 {
5639 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005640 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005641 ;}
5642 break;
5643
Chris Lattner15bd0952008-08-29 17:20:18 +00005644 case 259:
5645#line 2481 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005646 { // arbitrary precision integer constants
5647 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), true);
5648 delete (yyvsp[(1) - (1)].APIntVal);
5649 CHECK_FOR_ERROR
5650 ;}
5651 break;
5652
Chris Lattner15bd0952008-08-29 17:20:18 +00005653 case 260:
5654#line 2486 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner1913b942008-07-11 00:30:39 +00005655 { // arbitrary precision integer constants
5656 (yyval.ValIDVal) = ValID::create(*(yyvsp[(1) - (1)].APIntVal), false);
5657 delete (yyvsp[(1) - (1)].APIntVal);
5658 CHECK_FOR_ERROR
5659 ;}
5660 break;
5661
Chris Lattner15bd0952008-08-29 17:20:18 +00005662 case 261:
5663#line 2491 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005664 { // Perhaps it's an FP constant?
5665 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005666 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005667 ;}
5668 break;
5669
Chris Lattner15bd0952008-08-29 17:20:18 +00005670 case 262:
5671#line 2495 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005672 {
5673 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005674 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005675 ;}
5676 break;
5677
Chris Lattner15bd0952008-08-29 17:20:18 +00005678 case 263:
5679#line 2499 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005680 {
5681 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005682 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005683 ;}
5684 break;
5685
Chris Lattner15bd0952008-08-29 17:20:18 +00005686 case 264:
5687#line 2503 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005688 {
5689 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005690 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005691 ;}
5692 break;
5693
Chris Lattner15bd0952008-08-29 17:20:18 +00005694 case 265:
5695#line 2507 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005696 {
5697 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005698 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005699 ;}
5700 break;
5701
Chris Lattner15bd0952008-08-29 17:20:18 +00005702 case 266:
5703#line 2511 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005704 { // A vector zero constant.
5705 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005706 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005707 ;}
5708 break;
5709
Chris Lattner15bd0952008-08-29 17:20:18 +00005710 case 267:
5711#line 2515 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005712 { // Nonempty unsized packed vector
5713 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Dan Gohman180c1692008-06-23 18:43:26 +00005714 unsigned NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohman81a0c0b2008-05-31 00:58:22 +00005715
5716 if (!ETy->isInteger() && !ETy->isFloatingPoint())
5717 GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005718
Reid Spencer9d6565a2007-02-15 02:26:10 +00005719 VectorType* pt = VectorType::get(ETy, NumElements);
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005720 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005721
5722 // Verify all elements are correct type!
Dan Gohmanf4423b12008-04-19 00:24:39 +00005723 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5724 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005725 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005726 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00005727 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005728 }
5729
Dan Gohmanf4423b12008-04-19 00:24:39 +00005730 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5731 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005732 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005733 ;}
5734 break;
5735
Chris Lattner15bd0952008-08-29 17:20:18 +00005736 case 268:
5737#line 2537 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005738 { // Nonempty unsized arr
5739 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
Dan Gohman180c1692008-06-23 18:43:26 +00005740 uint64_t NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005741
5742 if (!ETy->isFirstClassType())
5743 GEN_ERROR("Invalid array element type: " + ETy->getDescription());
5744
5745 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5746 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
5747
5748 // Verify all elements are correct type!
5749 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5750 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
5751 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
5752 ETy->getDescription() +"' as required!\nIt is of type '"+
5753 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
5754 }
5755
5756 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, *(yyvsp[(2) - (3)].ConstVector)));
5757 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5758 CHECK_FOR_ERROR
5759 ;}
5760 break;
5761
Chris Lattner15bd0952008-08-29 17:20:18 +00005762 case 269:
5763#line 2559 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005764 {
Dan Gohman180c1692008-06-23 18:43:26 +00005765 // Use undef instead of an array because it's inconvenient to determine
5766 // the element type at this point, there being no elements to examine.
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005767 (yyval.ValIDVal) = ValID::createUndef();
5768 CHECK_FOR_ERROR
5769 ;}
5770 break;
5771
Chris Lattner15bd0952008-08-29 17:20:18 +00005772 case 270:
5773#line 2565 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005774 {
Dan Gohman180c1692008-06-23 18:43:26 +00005775 uint64_t NumElements = (yyvsp[(2) - (2)].StrVal)->length();
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005776 const Type *ETy = Type::Int8Ty;
5777
5778 ArrayType *ATy = ArrayType::get(ETy, NumElements);
5779
5780 std::vector<Constant*> Vals;
5781 for (unsigned i = 0; i < (yyvsp[(2) - (2)].StrVal)->length(); ++i)
5782 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(2) - (2)].StrVal))[i]));
5783 delete (yyvsp[(2) - (2)].StrVal);
5784 (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, Vals));
5785 CHECK_FOR_ERROR
5786 ;}
5787 break;
5788
Chris Lattner15bd0952008-08-29 17:20:18 +00005789 case 271:
5790#line 2578 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005791 {
5792 std::vector<const Type*> Elements((yyvsp[(2) - (3)].ConstVector)->size());
5793 for (unsigned i = 0, e = (yyvsp[(2) - (3)].ConstVector)->size(); i != e; ++i)
5794 Elements[i] = (*(yyvsp[(2) - (3)].ConstVector))[i]->getType();
5795
5796 const StructType *STy = StructType::get(Elements);
5797 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5798
5799 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(2) - (3)].ConstVector)));
5800 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5801 CHECK_FOR_ERROR
5802 ;}
5803 break;
5804
Chris Lattner15bd0952008-08-29 17:20:18 +00005805 case 272:
5806#line 2590 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005807 {
5808 const StructType *STy = StructType::get(std::vector<const Type*>());
5809 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5810 CHECK_FOR_ERROR
5811 ;}
5812 break;
5813
Chris Lattner15bd0952008-08-29 17:20:18 +00005814 case 273:
5815#line 2595 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005816 {
5817 std::vector<const Type*> Elements((yyvsp[(3) - (5)].ConstVector)->size());
5818 for (unsigned i = 0, e = (yyvsp[(3) - (5)].ConstVector)->size(); i != e; ++i)
5819 Elements[i] = (*(yyvsp[(3) - (5)].ConstVector))[i]->getType();
5820
5821 const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
5822 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
5823
5824 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(3) - (5)].ConstVector)));
5825 delete PTy; delete (yyvsp[(3) - (5)].ConstVector);
5826 CHECK_FOR_ERROR
5827 ;}
5828 break;
5829
Chris Lattner15bd0952008-08-29 17:20:18 +00005830 case 274:
5831#line 2607 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf910eaa2008-06-09 14:45:02 +00005832 {
5833 const StructType *STy = StructType::get(std::vector<const Type*>(),
5834 /*isPacked=*/true);
5835 (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
5836 CHECK_FOR_ERROR
5837 ;}
5838 break;
5839
Chris Lattner15bd0952008-08-29 17:20:18 +00005840 case 275:
5841#line 2613 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005842 {
5843 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005844 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005845 ;}
5846 break;
5847
Chris Lattner15bd0952008-08-29 17:20:18 +00005848 case 276:
5849#line 2617 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005850 {
5851 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5852 delete (yyvsp[(3) - (5)].StrVal);
5853 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005854 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005855 ;}
5856 break;
5857
Chris Lattner15bd0952008-08-29 17:20:18 +00005858 case 277:
5859#line 2627 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005860 { // Is it an integer reference...?
5861 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005862 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005863 ;}
5864 break;
5865
Chris Lattner15bd0952008-08-29 17:20:18 +00005866 case 278:
5867#line 2631 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005868 {
5869 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005870 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005871 ;}
5872 break;
5873
Chris Lattner15bd0952008-08-29 17:20:18 +00005874 case 279:
5875#line 2635 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005876 { // Is it a named reference...?
5877 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5878 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005879 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005880 ;}
5881 break;
5882
Chris Lattner15bd0952008-08-29 17:20:18 +00005883 case 280:
5884#line 2640 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005885 { // Is it a named reference...?
5886 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5887 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005888 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005889 ;}
5890 break;
5891
Chris Lattner15bd0952008-08-29 17:20:18 +00005892 case 283:
5893#line 2653 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005894 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005895 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00005896 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5897 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5898 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005899 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005900 ;}
5901 break;
5902
Chris Lattner15bd0952008-08-29 17:20:18 +00005903 case 284:
5904#line 2662 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005905 {
5906 (yyval.ValueList) = new std::vector<Value *>();
5907 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005908 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005909 ;}
5910 break;
5911
Chris Lattner15bd0952008-08-29 17:20:18 +00005912 case 285:
5913#line 2667 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005914 {
5915 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patel7990dc72008-02-20 22:40:23 +00005916 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005917 ;}
5918 break;
5919
Chris Lattner15bd0952008-08-29 17:20:18 +00005920 case 286:
5921#line 2672 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005922 {
5923 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005924 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005925 ;}
5926 break;
5927
Chris Lattner15bd0952008-08-29 17:20:18 +00005928 case 287:
5929#line 2676 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005930 { // Do not allow functions with 0 basic blocks
5931 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005932 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005933 ;}
5934 break;
5935
Chris Lattner15bd0952008-08-29 17:20:18 +00005936 case 288:
5937#line 2685 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005938 {
5939 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005940 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005941 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5942 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5943 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005944 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005945 ;}
5946 break;
5947
Chris Lattner15bd0952008-08-29 17:20:18 +00005948 case 289:
5949#line 2694 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5950 {
5951 CHECK_FOR_ERROR
5952 int ValNum = InsertValue((yyvsp[(3) - (3)].TermInstVal));
5953 if (ValNum != (int)(yyvsp[(2) - (3)].UIntVal))
5954 GEN_ERROR("Result value number %" + utostr((yyvsp[(2) - (3)].UIntVal)) +
5955 " is incorrect, expected %" + utostr((unsigned)ValNum));
5956
5957 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5958 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
5959 CHECK_FOR_ERROR
5960;}
5961 break;
5962
5963 case 290:
5964#line 2707 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005965 {
5966 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005967 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5968 if (CI2->getParent() == 0)
Dan Gohmanf4423b12008-04-19 00:24:39 +00005969 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5970 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5971 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005972 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00005973 ;}
5974 break;
Chris Lattner38905612008-02-19 04:36:25 +00005975
Chris Lattner15bd0952008-08-29 17:20:18 +00005976 case 291:
5977#line 2716 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005978 { // Empty space between instruction lists
Chris Lattnercc81d152008-05-04 17:18:47 +00005979 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf4423b12008-04-19 00:24:39 +00005980 CHECK_FOR_ERROR
5981 ;}
5982 break;
5983
Chris Lattner15bd0952008-08-29 17:20:18 +00005984 case 292:
5985#line 2720 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnercc81d152008-05-04 17:18:47 +00005986 { // Labelled (named) basic block
5987 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
5988 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00005989 CHECK_FOR_ERROR
Chris Lattnercc81d152008-05-04 17:18:47 +00005990
Dan Gohmanf4423b12008-04-19 00:24:39 +00005991 ;}
5992 break;
5993
Chris Lattner15bd0952008-08-29 17:20:18 +00005994 case 293:
5995#line 2728 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00005996 { // Return with a result...
5997 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
5998 assert(!VL.empty() && "Invalid ret operands!");
Dan Gohman1a570242008-07-23 00:54:54 +00005999 const Type *ReturnType = CurFun.CurrentFunction->getReturnType();
6000 if (VL.size() > 1 ||
6001 (isa<StructType>(ReturnType) &&
6002 (VL.empty() || VL[0]->getType() != ReturnType))) {
6003 Value *RV = UndefValue::get(ReturnType);
6004 for (unsigned i = 0, e = VL.size(); i != e; ++i) {
6005 Instruction *I = InsertValueInst::Create(RV, VL[i], i, "mrv");
6006 ((yyvsp[(-1) - (2)].BasicBlockVal))->getInstList().push_back(I);
6007 RV = I;
6008 }
6009 (yyval.TermInstVal) = ReturnInst::Create(RV);
6010 } else {
6011 (yyval.TermInstVal) = ReturnInst::Create(VL[0]);
6012 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006013 delete (yyvsp[(2) - (2)].ValueList);
6014 CHECK_FOR_ERROR
6015 ;}
6016 break;
6017
Chris Lattner15bd0952008-08-29 17:20:18 +00006018 case 294:
6019#line 2748 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006020 { // Return with no result...
6021 (yyval.TermInstVal) = ReturnInst::Create();
6022 CHECK_FOR_ERROR
6023 ;}
6024 break;
6025
Chris Lattner15bd0952008-08-29 17:20:18 +00006026 case 295:
6027#line 2752 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006028 { // Unconditional Branch...
6029 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6030 CHECK_FOR_ERROR
6031 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
6032 ;}
6033 break;
6034
Chris Lattner15bd0952008-08-29 17:20:18 +00006035 case 296:
6036#line 2757 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006037 {
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006038 if (cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() != 1)
6039 GEN_ERROR("Branch condition must have type i1");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006040 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6041 CHECK_FOR_ERROR
6042 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6043 CHECK_FOR_ERROR
6044 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6045 CHECK_FOR_ERROR
6046 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
6047 ;}
6048 break;
6049
Chris Lattner15bd0952008-08-29 17:20:18 +00006050 case 297:
6051#line 2768 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006052 {
6053 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
6054 CHECK_FOR_ERROR
6055 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6056 CHECK_FOR_ERROR
6057 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6058 (yyval.TermInstVal) = S;
6059
6060 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6061 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00006062 for (; I != E; ++I) {
6063 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6064 S->addCase(CI, I->second);
6065 else
Reid Spencerb5334b02007-02-05 10:18:06 +00006066 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006067 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006068 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00006069 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006070 ;}
6071 break;
6072
Chris Lattner15bd0952008-08-29 17:20:18 +00006073 case 298:
6074#line 2787 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006075 {
6076 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006077 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006078 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006079 CHECK_FOR_ERROR
Gabor Greife64d2482008-04-06 23:07:54 +00006080 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006081 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006082 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006083 ;}
6084 break;
6085
Chris Lattner15bd0952008-08-29 17:20:18 +00006086 case 299:
6087#line 2797 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006088 {
Reid Spencer3822ff52006-11-08 06:47:33 +00006089
Reid Spencer14310612006-12-31 05:40:51 +00006090 // Handle the short syntax
6091 const PointerType *PFTy = 0;
6092 const FunctionType *Ty = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006093 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00006094 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6095 // Pull out the types of all of the arguments...
6096 std::vector<const Type*> ParamTypes;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006097 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006098 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006099 const Type *Ty = I->Val->getType();
6100 if (Ty == Type::VoidTy)
6101 GEN_ERROR("Short call syntax cannot be used with varargs");
6102 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006103 }
Chris Lattnera925a142008-04-23 05:37:08 +00006104
6105 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (14)].TypeVal)))
6106 GEN_ERROR("Invalid result type for LLVM function");
6107
Dan Gohmanf4423b12008-04-19 00:24:39 +00006108 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006109 PFTy = PointerType::getUnqual(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006110 }
6111
Dan Gohmanf4423b12008-04-19 00:24:39 +00006112 delete (yyvsp[(3) - (14)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00006113
Dan Gohmanf4423b12008-04-19 00:24:39 +00006114 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006115 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006116 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006117 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006118 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00006119 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00006120
Chris Lattner58d74912008-03-12 17:45:29 +00006121 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006122 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None)
6123 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(8) - (14)].ParamAttrs)));
Duncan Sandsdc024672007-11-27 13:23:08 +00006124
Reid Spencer14310612006-12-31 05:40:51 +00006125 // Check the arguments
6126 ValueList Args;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006127 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00006128 // Make sure no arguments is a good thing!
6129 if (Ty->getNumParams() != 0)
6130 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006131 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006132 } else { // Has arguments?
6133 // Loop through FunctionType's arguments and ensure they are specified
6134 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00006135 FunctionType::param_iterator I = Ty->param_begin();
6136 FunctionType::param_iterator E = Ty->param_end();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006137 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006138 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006139
Duncan Sandsdc024672007-11-27 13:23:08 +00006140 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006141 if (ArgI->Val->getType() != *I)
6142 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006143 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006144 Args.push_back(ArgI->Val);
Chris Lattner58d74912008-03-12 17:45:29 +00006145 if (ArgI->Attrs != ParamAttr::None)
6146 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006147 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00006148
Reid Spencer14310612006-12-31 05:40:51 +00006149 if (Ty->isVarArg()) {
6150 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006151 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006152 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner58d74912008-03-12 17:45:29 +00006153 if (ArgI->Attrs != ParamAttr::None)
6154 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006155 }
Reid Spencer14310612006-12-31 05:40:51 +00006156 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006157 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006158 }
Reid Spencer14310612006-12-31 05:40:51 +00006159
Chris Lattner58d74912008-03-12 17:45:29 +00006160 PAListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006161 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00006162 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006163
Reid Spencer14310612006-12-31 05:40:51 +00006164 // Create the InvokeInst
Dan Gohman041e2eb2008-05-15 19:50:34 +00006165 InvokeInst *II = InvokeInst::Create(V, Normal, Except,
6166 Args.begin(), Args.end());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006167 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00006168 II->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006169 (yyval.TermInstVal) = II;
6170 delete (yyvsp[(6) - (14)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006171 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006172 ;}
6173 break;
6174
Chris Lattner15bd0952008-08-29 17:20:18 +00006175 case 300:
6176#line 2882 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006177 {
6178 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006179 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006180 ;}
6181 break;
6182
Chris Lattner15bd0952008-08-29 17:20:18 +00006183 case 301:
6184#line 2886 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006185 {
6186 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00006187 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006188 ;}
6189 break;
6190
Chris Lattner15bd0952008-08-29 17:20:18 +00006191 case 302:
6192#line 2893 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006193 {
6194 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6195 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006196 CHECK_FOR_ERROR
6197 if (V == 0)
6198 GEN_ERROR("May only switch on a constant pool value");
6199
Dan Gohmanf4423b12008-04-19 00:24:39 +00006200 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006201 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006202 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6203 ;}
6204 break;
6205
Chris Lattner15bd0952008-08-29 17:20:18 +00006206 case 303:
6207#line 2904 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006208 {
6209 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6210 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006211 CHECK_FOR_ERROR
6212
6213 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00006214 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006215
Dan Gohmanf4423b12008-04-19 00:24:39 +00006216 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006217 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006218 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6219 ;}
6220 break;
6221
Chris Lattner15bd0952008-08-29 17:20:18 +00006222 case 304:
6223#line 2917 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006224 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006225 // Is this definition named?? if so, assign the name...
Dan Gohmanf4423b12008-04-19 00:24:39 +00006226 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006227 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006228 InsertValue((yyvsp[(2) - (2)].InstVal));
6229 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006230 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006231 ;}
6232 break;
6233
Chris Lattner15bd0952008-08-29 17:20:18 +00006234 case 305:
6235#line 2926 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6236 {
6237 CHECK_FOR_ERROR
6238 int ValNum = InsertValue((yyvsp[(2) - (2)].InstVal));
6239
6240 if (ValNum != (int)(yyvsp[(1) - (2)].UIntVal))
6241 GEN_ERROR("Result value number %" + utostr((yyvsp[(1) - (2)].UIntVal)) +
6242 " is incorrect, expected %" + utostr((unsigned)ValNum));
6243
6244 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6245 CHECK_FOR_ERROR
6246 ;}
6247 break;
6248
6249 case 306:
6250#line 2939 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006251 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006252 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006253 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
6254 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
6255 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00006256 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006257 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006258 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006259 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6260 delete (yyvsp[(1) - (6)].TypeVal);
6261 ;}
6262 break;
6263
Chris Lattner15bd0952008-08-29 17:20:18 +00006264 case 307:
6265#line 2950 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006266 {
6267 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6268 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006269 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006270 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006271 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006272 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
6273 ;}
6274 break;
6275
Chris Lattner15bd0952008-08-29 17:20:18 +00006276 case 308:
6277#line 2960 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006278 {
Duncan Sandsdc024672007-11-27 13:23:08 +00006279 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006280 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006281 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006282 // Used for call and invoke instructions
Dan Gohmanf4423b12008-04-19 00:24:39 +00006283 (yyval.ParamList) = new ParamList();
6284 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal));
6285 (yyval.ParamList)->push_back(E);
6286 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00006287 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006288 ;}
6289 break;
6290
Chris Lattner15bd0952008-08-29 17:20:18 +00006291 case 309:
6292#line 2971 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006293 {
Duncan Sandsdc024672007-11-27 13:23:08 +00006294 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006295 // Labels are only valid in ASMs
Dan Gohmanf4423b12008-04-19 00:24:39 +00006296 (yyval.ParamList) = new ParamList();
6297 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal));
6298 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00006299 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006300 ;}
6301 break;
6302
Chris Lattner15bd0952008-08-29 17:20:18 +00006303 case 310:
6304#line 2979 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006305 {
Duncan Sandsdc024672007-11-27 13:23:08 +00006306 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006307 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006308 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6309 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
6310 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
6311 (yyval.ParamList)->push_back(E);
6312 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006313 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006314 ;}
6315 break;
6316
Chris Lattner15bd0952008-08-29 17:20:18 +00006317 case 311:
6318#line 2989 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006319 {
Duncan Sandsdc024672007-11-27 13:23:08 +00006320 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf4423b12008-04-19 00:24:39 +00006321 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
6322 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal));
6323 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00006324 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006325 ;}
6326 break;
6327
Chris Lattner15bd0952008-08-29 17:20:18 +00006328 case 312:
6329#line 2996 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006330 { (yyval.ParamList) = new ParamList(); ;}
6331 break;
6332
Chris Lattner15bd0952008-08-29 17:20:18 +00006333 case 313:
6334#line 2999 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006335 { (yyval.ValueList) = new std::vector<Value*>(); ;}
6336 break;
6337
Chris Lattner15bd0952008-08-29 17:20:18 +00006338 case 314:
6339#line 3000 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006340 {
6341 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6342 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00006343 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006344 ;}
6345 break;
6346
Chris Lattner15bd0952008-08-29 17:20:18 +00006347 case 315:
6348#line 3008 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006349 {
6350 (yyval.ConstantList) = new std::vector<unsigned>();
6351 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
6352 GEN_ERROR("Index " + utostr((yyvsp[(2) - (2)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6353 (yyval.ConstantList)->push_back((yyvsp[(2) - (2)].UInt64Val));
6354 ;}
6355 break;
6356
Chris Lattner15bd0952008-08-29 17:20:18 +00006357 case 316:
6358#line 3014 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006359 {
6360 (yyval.ConstantList) = (yyvsp[(1) - (3)].ConstantList);
6361 if ((unsigned)(yyvsp[(3) - (3)].UInt64Val) != (yyvsp[(3) - (3)].UInt64Val))
6362 GEN_ERROR("Index " + utostr((yyvsp[(3) - (3)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
6363 (yyval.ConstantList)->push_back((yyvsp[(3) - (3)].UInt64Val));
6364 CHECK_FOR_ERROR
6365 ;}
6366 break;
6367
Chris Lattner15bd0952008-08-29 17:20:18 +00006368 case 317:
6369#line 3023 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006370 {
6371 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006372 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006373 ;}
6374 break;
6375
Chris Lattner15bd0952008-08-29 17:20:18 +00006376 case 318:
6377#line 3027 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006378 {
6379 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006380 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006381 ;}
6382 break;
6383
Chris Lattner15bd0952008-08-29 17:20:18 +00006384 case 319:
6385#line 3032 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006386 {
Reid Spencer14310612006-12-31 05:40:51 +00006387 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006388 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6389 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
6390 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006391 GEN_ERROR(
6392 "Arithmetic operator requires integer, FP, or packed operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006393 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006394 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006395 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006396 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006397 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006398 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006399 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006400 delete (yyvsp[(2) - (5)].TypeVal);
6401 ;}
6402 break;
6403
Chris Lattner15bd0952008-08-29 17:20:18 +00006404 case 320:
6405#line 3048 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006406 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006407 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006408 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6409 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
Nate Begeman5bc1ea02008-07-29 15:49:41 +00006410 if (!isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
Dan Gohmanf4423b12008-04-19 00:24:39 +00006411 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006412 GEN_ERROR("Logical operator requires integral operands");
6413 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006414 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006415 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006416 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006417 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006418 (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006419 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006420 GEN_ERROR("binary operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006421 delete (yyvsp[(2) - (5)].TypeVal);
6422 ;}
6423 break;
6424
Chris Lattner15bd0952008-08-29 17:20:18 +00006425 case 321:
6426#line 3065 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006427 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006428 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006429 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6430 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006431 GEN_ERROR("Vector types not supported by icmp instruction");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006432 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006433 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006434 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006435 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006436 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006437 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006438 GEN_ERROR("icmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006439 delete (yyvsp[(3) - (6)].TypeVal);
6440 ;}
6441 break;
6442
Chris Lattner15bd0952008-08-29 17:20:18 +00006443 case 322:
6444#line 3079 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006445 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006446 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006447 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6448 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006449 GEN_ERROR("Vector types not supported by fcmp instruction");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006450 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006451 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006452 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006453 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006454 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006455 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006456 GEN_ERROR("fcmp operator returned null");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006457 delete (yyvsp[(3) - (6)].TypeVal);
6458 ;}
6459 break;
6460
Chris Lattner15bd0952008-08-29 17:20:18 +00006461 case 323:
6462#line 3093 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006463 {
6464 if (!UpRefs.empty())
6465 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6466 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6467 GEN_ERROR("Scalar types not supported by vicmp instruction");
6468 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6469 CHECK_FOR_ERROR
6470 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6471 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006472 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006473 if ((yyval.InstVal) == 0)
6474 GEN_ERROR("icmp operator returned null");
6475 delete (yyvsp[(3) - (6)].TypeVal);
6476 ;}
6477 break;
6478
Chris Lattner15bd0952008-08-29 17:20:18 +00006479 case 324:
6480#line 3107 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begemanac80ade2008-05-12 19:01:56 +00006481 {
6482 if (!UpRefs.empty())
6483 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6484 if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
6485 GEN_ERROR("Scalar types not supported by vfcmp instruction");
6486 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
6487 CHECK_FOR_ERROR
6488 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
6489 CHECK_FOR_ERROR
Dan Gohmane4977cf2008-05-23 01:55:30 +00006490 (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
Nate Begemanac80ade2008-05-12 19:01:56 +00006491 if ((yyval.InstVal) == 0)
6492 GEN_ERROR("fcmp operator returned null");
6493 delete (yyvsp[(3) - (6)].TypeVal);
6494 ;}
6495 break;
6496
Chris Lattner15bd0952008-08-29 17:20:18 +00006497 case 325:
6498#line 3121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006499 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006500 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006501 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6502 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6503 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6504 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006505 GEN_ERROR("invalid cast opcode for cast from '" +
6506 Val->getType()->getDescription() + "' to '" +
6507 DestTy->getDescription() + "'");
Dan Gohmane4977cf2008-05-23 01:55:30 +00006508 (yyval.InstVal) = CastInst::Create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006509 delete (yyvsp[(4) - (4)].TypeVal);
6510 ;}
6511 break;
6512
Chris Lattner15bd0952008-08-29 17:20:18 +00006513 case 326:
6514#line 3133 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006515 {
6516 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006517 GEN_ERROR("select condition must be boolean");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006518 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006519 GEN_ERROR("select value types should match");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006520 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00006521 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006522 ;}
6523 break;
6524
Chris Lattner15bd0952008-08-29 17:20:18 +00006525 case 327:
6526#line 3141 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006527 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006528 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006529 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6530 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6531 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006532 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006533 ;}
6534 break;
6535
Chris Lattner15bd0952008-08-29 17:20:18 +00006536 case 328:
6537#line 3148 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006538 {
6539 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006540 GEN_ERROR("Invalid extractelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006541 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006542 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006543 ;}
6544 break;
6545
Chris Lattner15bd0952008-08-29 17:20:18 +00006546 case 329:
6547#line 3154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006548 {
6549 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006550 GEN_ERROR("Invalid insertelement operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006551 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006552 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006553 ;}
6554 break;
6555
Chris Lattner15bd0952008-08-29 17:20:18 +00006556 case 330:
6557#line 3160 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006558 {
6559 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006560 GEN_ERROR("Invalid shufflevector operands");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006561 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006562 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006563 ;}
6564 break;
6565
Chris Lattner15bd0952008-08-29 17:20:18 +00006566 case 331:
6567#line 3166 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006568 {
6569 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006570 if (!Ty->isFirstClassType())
6571 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006572 (yyval.InstVal) = PHINode::Create(Ty);
6573 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6574 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
6575 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006576 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006577 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6578 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006579 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006580 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006581 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006582 ;}
6583 break;
6584
Chris Lattner15bd0952008-08-29 17:20:18 +00006585 case 332:
6586#line 3182 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006587 {
Reid Spencer14310612006-12-31 05:40:51 +00006588
6589 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006590 const PointerType *PFTy = 0;
6591 const FunctionType *Ty = 0;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006592 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006593 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6594 // Pull out the types of all of the arguments...
6595 std::vector<const Type*> ParamTypes;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006596 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006597 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006598 const Type *Ty = I->Val->getType();
6599 if (Ty == Type::VoidTy)
6600 GEN_ERROR("Short call syntax cannot be used with varargs");
6601 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006602 }
Chris Lattnera925a142008-04-23 05:37:08 +00006603
6604 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (8)].TypeVal)))
6605 GEN_ERROR("Invalid result type for LLVM function");
6606
Dan Gohmanf4423b12008-04-19 00:24:39 +00006607 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false);
Christopher Lamb4374f8e2007-12-17 01:17:35 +00006608 PFTy = PointerType::getUnqual(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006609 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006610
Dan Gohmanf4423b12008-04-19 00:24:39 +00006611 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006612 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006613
Reid Spencer7780acb2007-04-16 06:56:07 +00006614 // Check for call to invalid intrinsic to avoid crashing later.
6615 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006616 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006617 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6618 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006619 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6620 theF->getName() + "'");
6621 }
6622
Duncan Sandsdc024672007-11-27 13:23:08 +00006623 // Set up the ParamAttrs for the function
Chris Lattner58d74912008-03-12 17:45:29 +00006624 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006625 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None)
6626 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(8) - (8)].ParamAttrs)));
Reid Spencer14310612006-12-31 05:40:51 +00006627 // Check the arguments
6628 ValueList Args;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006629 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006630 // Make sure no arguments is a good thing!
6631 if (Ty->getNumParams() != 0)
6632 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006633 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006634 } else { // Has arguments?
6635 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006636 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006637 FunctionType::param_iterator I = Ty->param_begin();
6638 FunctionType::param_iterator E = Ty->param_end();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006639 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006640 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006641
Duncan Sandsdc024672007-11-27 13:23:08 +00006642 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006643 if (ArgI->Val->getType() != *I)
6644 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006645 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006646 Args.push_back(ArgI->Val);
Chris Lattner58d74912008-03-12 17:45:29 +00006647 if (ArgI->Attrs != ParamAttr::None)
6648 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Reid Spencer14310612006-12-31 05:40:51 +00006649 }
6650 if (Ty->isVarArg()) {
6651 if (I == E)
Chris Lattner38905612008-02-19 04:36:25 +00006652 for (; ArgI != ArgE; ++ArgI, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006653 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner58d74912008-03-12 17:45:29 +00006654 if (ArgI->Attrs != ParamAttr::None)
6655 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner38905612008-02-19 04:36:25 +00006656 }
Reid Spencer14310612006-12-31 05:40:51 +00006657 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006658 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006659 }
Duncan Sandsdc024672007-11-27 13:23:08 +00006660
6661 // Finish off the ParamAttrs and check them
Chris Lattner58d74912008-03-12 17:45:29 +00006662 PAListPtr PAL;
Duncan Sandsdc024672007-11-27 13:23:08 +00006663 if (!Attrs.empty())
Chris Lattner58d74912008-03-12 17:45:29 +00006664 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsdc024672007-11-27 13:23:08 +00006665
Reid Spencer14310612006-12-31 05:40:51 +00006666 // Create the call node
Gabor Greife64d2482008-04-06 23:07:54 +00006667 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Dan Gohmanf4423b12008-04-19 00:24:39 +00006668 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6669 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00006670 CI->setParamAttrs(PAL);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006671 (yyval.InstVal) = CI;
6672 delete (yyvsp[(6) - (8)].ParamList);
6673 delete (yyvsp[(3) - (8)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006674 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006675 ;}
6676 break;
6677
Chris Lattner15bd0952008-08-29 17:20:18 +00006678 case 333:
6679#line 3271 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006680 {
6681 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006682 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006683 ;}
6684 break;
6685
Chris Lattner15bd0952008-08-29 17:20:18 +00006686 case 334:
6687#line 3276 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006688 {
6689 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006690 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006691 ;}
6692 break;
6693
Chris Lattner15bd0952008-08-29 17:20:18 +00006694 case 335:
6695#line 3280 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006696 {
6697 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006698 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006699 ;}
6700 break;
6701
Chris Lattner15bd0952008-08-29 17:20:18 +00006702 case 336:
6703#line 3287 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006704 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006705 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006706 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6707 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6708 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006709 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006710 ;}
6711 break;
6712
Chris Lattner15bd0952008-08-29 17:20:18 +00006713 case 337:
6714#line 3294 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006715 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006716 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006717 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006718 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6719 GEN_ERROR("Malloc array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006720 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006721 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006722 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6723 delete (yyvsp[(2) - (6)].TypeVal);
6724 ;}
6725 break;
6726
Chris Lattner15bd0952008-08-29 17:20:18 +00006727 case 338:
6728#line 3304 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006729 {
Reid Spencer14310612006-12-31 05:40:51 +00006730 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006731 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6732 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6733 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006734 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006735 ;}
6736 break;
6737
Chris Lattner15bd0952008-08-29 17:20:18 +00006738 case 339:
6739#line 3311 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006740 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006741 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006742 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006743 if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
6744 GEN_ERROR("Alloca array size is not a 32-bit integer!");
Dan Gohmanf4423b12008-04-19 00:24:39 +00006745 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006746 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006747 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6748 delete (yyvsp[(2) - (6)].TypeVal);
6749 ;}
6750 break;
6751
Chris Lattner15bd0952008-08-29 17:20:18 +00006752 case 340:
6753#line 3321 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006754 {
6755 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006756 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006757 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6758 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006759 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006760 ;}
6761 break;
6762
Chris Lattner15bd0952008-08-29 17:20:18 +00006763 case 341:
6764#line 3329 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006765 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006766 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006767 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6768 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006769 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006770 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6771 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006772 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006773 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6774 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006775 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006776 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6777 delete (yyvsp[(3) - (5)].TypeVal);
6778 ;}
6779 break;
6780
Chris Lattner15bd0952008-08-29 17:20:18 +00006781 case 342:
6782#line 3343 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006783 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006784 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006785 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6786 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006787 if (!PT)
6788 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006789 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006790 const Type *ElTy = PT->getElementType();
Dan Gohmanf4423b12008-04-19 00:24:39 +00006791 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6792 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006793 "' into space of type '" + ElTy->getDescription() + "'");
6794
Dan Gohmanf4423b12008-04-19 00:24:39 +00006795 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006796 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006797 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6798 delete (yyvsp[(5) - (7)].TypeVal);
6799 ;}
6800 break;
6801
Chris Lattner15bd0952008-08-29 17:20:18 +00006802 case 343:
6803#line 3360 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006804 {
Dan Gohman1a570242008-07-23 00:54:54 +00006805 if (!UpRefs.empty())
6806 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6807 if (!isa<StructType>((yyvsp[(2) - (5)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (5)].TypeVal)->get()))
6808 GEN_ERROR("getresult insn requires an aggregate operand");
6809 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].UInt64Val)))
6810 GEN_ERROR("Invalid getresult index for type '" +
6811 (*(yyvsp[(2) - (5)].TypeVal))->getDescription()+ "'");
6812
6813 Value *tmpVal = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Devang Patel5a970972008-02-19 22:27:01 +00006814 CHECK_FOR_ERROR
Dan Gohman1a570242008-07-23 00:54:54 +00006815 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(5) - (5)].UInt64Val));
6816 delete (yyvsp[(2) - (5)].TypeVal);
Dan Gohmanf4423b12008-04-19 00:24:39 +00006817 ;}
6818 break;
6819
Chris Lattner15bd0952008-08-29 17:20:18 +00006820 case 344:
6821#line 3374 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006822 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006823 if (!UpRefs.empty())
Dan Gohmanf4423b12008-04-19 00:24:39 +00006824 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6825 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006826 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006827
Dan Gohman041e2eb2008-05-15 19:50:34 +00006828 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()))
Reid Spencer61c83e02006-08-18 08:43:06 +00006829 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohmanf4423b12008-04-19 00:24:39 +00006830 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6831 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006832 CHECK_FOR_ERROR
Dan Gohmanf4423b12008-04-19 00:24:39 +00006833 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
6834 delete (yyvsp[(2) - (4)].TypeVal);
6835 delete (yyvsp[(4) - (4)].ValueList);
6836 ;}
6837 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006838
Chris Lattner15bd0952008-08-29 17:20:18 +00006839 case 345:
6840#line 3389 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00006841 {
6842 if (!UpRefs.empty())
6843 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6844 if (!isa<StructType>((yyvsp[(2) - (4)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (4)].TypeVal)->get()))
6845 GEN_ERROR("extractvalue insn requires an aggregate operand");
6846
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006847 if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end()))
Dan Gohmane4977cf2008-05-23 01:55:30 +00006848 GEN_ERROR("Invalid extractvalue indices for type '" +
6849 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6850 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
6851 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006852 (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end());
Dan Gohmane4977cf2008-05-23 01:55:30 +00006853 delete (yyvsp[(2) - (4)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006854 delete (yyvsp[(4) - (4)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00006855 ;}
6856 break;
6857
Chris Lattner15bd0952008-08-29 17:20:18 +00006858 case 346:
6859#line 3404 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmane4977cf2008-05-23 01:55:30 +00006860 {
6861 if (!UpRefs.empty())
6862 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (7)].TypeVal))->getDescription());
6863 if (!isa<StructType>((yyvsp[(2) - (7)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (7)].TypeVal)->get()))
6864 GEN_ERROR("extractvalue insn requires an aggregate operand");
6865
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006866 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 +00006867 GEN_ERROR("Invalid insertvalue indices for type '" +
6868 (*(yyvsp[(2) - (7)].TypeVal))->getDescription()+ "'");
6869 Value* aggVal = getVal(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(3) - (7)].ValIDVal));
6870 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
6871 CHECK_FOR_ERROR
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006872 (yyval.InstVal) = InsertValueInst::Create(aggVal, tmpVal, (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end());
Dan Gohmane4977cf2008-05-23 01:55:30 +00006873 delete (yyvsp[(2) - (7)].TypeVal);
6874 delete (yyvsp[(5) - (7)].TypeVal);
Dan Gohman81a0c0b2008-05-31 00:58:22 +00006875 delete (yyvsp[(7) - (7)].ConstantList);
Dan Gohmane4977cf2008-05-23 01:55:30 +00006876 ;}
6877 break;
6878
Dan Gohmanf4423b12008-04-19 00:24:39 +00006879
6880/* Line 1267 of yacc.c. */
Chris Lattner15bd0952008-08-29 17:20:18 +00006881#line 6882 "llvmAsmParser.tab.c"
Dan Gohmanf4423b12008-04-19 00:24:39 +00006882 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00006883 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00006884 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6885
6886 YYPOPSTACK (yylen);
6887 yylen = 0;
6888 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006889
6890 *++yyvsp = yyval;
6891
6892
Dan Gohmanf4423b12008-04-19 00:24:39 +00006893 /* Now `shift' the result of the reduction. Determine what state
6894 that goes to, based on the state we popped back to and the rule
6895 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006896
6897 yyn = yyr1[yyn];
6898
Dan Gohmanf4423b12008-04-19 00:24:39 +00006899 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6900 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006901 yystate = yytable[yystate];
6902 else
Dan Gohmanf4423b12008-04-19 00:24:39 +00006903 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00006904
6905 goto yynewstate;
6906
6907
Dan Gohmanf4423b12008-04-19 00:24:39 +00006908/*------------------------------------.
6909| yyerrlab -- here on detecting error |
6910`------------------------------------*/
6911yyerrlab:
6912 /* If not already recovering from an error, report this error. */
6913 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006914 {
6915 ++yynerrs;
Dan Gohmanf4423b12008-04-19 00:24:39 +00006916#if ! YYERROR_VERBOSE
6917 yyerror (YY_("syntax error"));
6918#else
6919 {
6920 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6921 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6922 {
6923 YYSIZE_T yyalloc = 2 * yysize;
6924 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6925 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6926 if (yymsg != yymsgbuf)
6927 YYSTACK_FREE (yymsg);
6928 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6929 if (yymsg)
6930 yymsg_alloc = yyalloc;
6931 else
6932 {
6933 yymsg = yymsgbuf;
6934 yymsg_alloc = sizeof yymsgbuf;
6935 }
6936 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00006937
Dan Gohmanf4423b12008-04-19 00:24:39 +00006938 if (0 < yysize && yysize <= yymsg_alloc)
6939 {
6940 (void) yysyntax_error (yymsg, yystate, yychar);
6941 yyerror (yymsg);
6942 }
6943 else
6944 {
6945 yyerror (YY_("syntax error"));
6946 if (yysize != 0)
6947 goto yyexhaustedlab;
6948 }
6949 }
6950#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006951 }
6952
Dan Gohmanf4423b12008-04-19 00:24:39 +00006953
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006954
6955 if (yyerrstatus == 3)
6956 {
Dan Gohmanf4423b12008-04-19 00:24:39 +00006957 /* If just tried and failed to reuse look-ahead token after an
6958 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006959
Dan Gohmanf4423b12008-04-19 00:24:39 +00006960 if (yychar <= YYEOF)
6961 {
6962 /* Return failure if at end of input. */
6963 if (yychar == YYEOF)
6964 YYABORT;
6965 }
6966 else
6967 {
6968 yydestruct ("Error: discarding",
6969 yytoken, &yylval);
6970 yychar = YYEMPTY;
6971 }
6972 }
6973
6974 /* Else will try to reuse look-ahead token after shifting the error
6975 token. */
6976 goto yyerrlab1;
6977
6978
6979/*---------------------------------------------------.
6980| yyerrorlab -- error raised explicitly by YYERROR. |
6981`---------------------------------------------------*/
6982yyerrorlab:
6983
6984 /* Pacify compilers like GCC when the user code never invokes
6985 YYERROR and the label yyerrorlab therefore never appears in user
6986 code. */
6987 if (/*CONSTCOND*/ 0)
6988 goto yyerrorlab;
6989
6990 /* Do not reclaim the symbols of the rule which action triggered
6991 this YYERROR. */
6992 YYPOPSTACK (yylen);
6993 yylen = 0;
6994 YY_STACK_PRINT (yyss, yyssp);
6995 yystate = *yyssp;
6996 goto yyerrlab1;
6997
6998
6999/*-------------------------------------------------------------.
7000| yyerrlab1 -- common code for both syntax error and YYERROR. |
7001`-------------------------------------------------------------*/
7002yyerrlab1:
7003 yyerrstatus = 3; /* Each real token shifted decrements this. */
7004
7005 for (;;)
7006 {
7007 yyn = yypact[yystate];
7008 if (yyn != YYPACT_NINF)
7009 {
7010 yyn += YYTERROR;
7011 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7012 {
7013 yyn = yytable[yyn];
7014 if (0 < yyn)
7015 break;
7016 }
7017 }
7018
7019 /* Pop the current state because it cannot handle the error token. */
7020 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00007021 YYABORT;
7022
Dale Johannesencdd509a2007-09-07 21:07:57 +00007023
Dan Gohmanf4423b12008-04-19 00:24:39 +00007024 yydestruct ("Error: popping",
7025 yystos[yystate], yyvsp);
7026 YYPOPSTACK (1);
7027 yystate = *yyssp;
7028 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007029 }
7030
7031 if (yyn == YYFINAL)
7032 YYACCEPT;
7033
Reid Spencer68a24bd2005-08-27 18:50:39 +00007034 *++yyvsp = yylval;
Dan Gohmanf4423b12008-04-19 00:24:39 +00007035
7036
7037 /* Shift the error token. */
7038 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00007039
Reid Spencer68a24bd2005-08-27 18:50:39 +00007040 yystate = yyn;
7041 goto yynewstate;
7042
Gabor Greife64d2482008-04-06 23:07:54 +00007043
Dan Gohmanf4423b12008-04-19 00:24:39 +00007044/*-------------------------------------.
7045| yyacceptlab -- YYACCEPT comes here. |
7046`-------------------------------------*/
7047yyacceptlab:
7048 yyresult = 0;
7049 goto yyreturn;
7050
7051/*-----------------------------------.
7052| yyabortlab -- YYABORT comes here. |
7053`-----------------------------------*/
7054yyabortlab:
7055 yyresult = 1;
7056 goto yyreturn;
7057
7058#ifndef yyoverflow
7059/*-------------------------------------------------.
7060| yyexhaustedlab -- memory exhaustion comes here. |
7061`-------------------------------------------------*/
7062yyexhaustedlab:
7063 yyerror (YY_("memory exhausted"));
7064 yyresult = 2;
7065 /* Fall through. */
Chris Lattner38905612008-02-19 04:36:25 +00007066#endif
Dan Gohmanf4423b12008-04-19 00:24:39 +00007067
7068yyreturn:
7069 if (yychar != YYEOF && yychar != YYEMPTY)
7070 yydestruct ("Cleanup: discarding lookahead",
7071 yytoken, &yylval);
7072 /* Do not reclaim the symbols of the rule which action triggered
7073 this YYABORT or YYACCEPT. */
7074 YYPOPSTACK (yylen);
7075 YY_STACK_PRINT (yyss, yyssp);
7076 while (yyssp != yyss)
7077 {
7078 yydestruct ("Cleanup: popping",
7079 yystos[*yyssp], yyvsp);
7080 YYPOPSTACK (1);
Gabor Greife64d2482008-04-06 23:07:54 +00007081 }
Dan Gohmanf4423b12008-04-19 00:24:39 +00007082#ifndef yyoverflow
7083 if (yyss != yyssa)
7084 YYSTACK_FREE (yyss);
7085#endif
7086#if YYERROR_VERBOSE
7087 if (yymsg != yymsgbuf)
7088 YYSTACK_FREE (yymsg);
7089#endif
7090 /* Make sure YYID is used. */
7091 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007092}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007093
7094
Chris Lattner15bd0952008-08-29 17:20:18 +00007095#line 3423 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00007096
7097
Reid Spencer14310612006-12-31 05:40:51 +00007098// common code from the two 'RunVMAsmParser' functions
7099static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00007100 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00007101 // Check to make sure the parser succeeded
7102 if (yyparse()) {
7103 if (ParserResult)
7104 delete ParserResult;
7105 return 0;
7106 }
7107
Reid Spencer0d60b5a2007-03-30 01:37:39 +00007108 // Emit an error if there are any unresolved types left.
7109 if (!CurModule.LateResolveTypes.empty()) {
7110 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
7111 if (DID.Type == ValID::LocalName) {
7112 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
7113 } else {
7114 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
7115 }
7116 if (ParserResult)
7117 delete ParserResult;
7118 return 0;
7119 }
7120
7121 // Emit an error if there are any unresolved values left.
7122 if (!CurModule.LateResolveValues.empty()) {
7123 Value *V = CurModule.LateResolveValues.back();
7124 std::map<Value*, std::pair<ValID, int> >::iterator I =
7125 CurModule.PlaceHolderInfo.find(V);
7126
7127 if (I != CurModule.PlaceHolderInfo.end()) {
7128 ValID &DID = I->second.first;
7129 if (DID.Type == ValID::LocalName) {
7130 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
7131 } else {
7132 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
7133 }
7134 if (ParserResult)
7135 delete ParserResult;
7136 return 0;
7137 }
7138 }
7139
Reid Spencer14310612006-12-31 05:40:51 +00007140 // Check to make sure that parsing produced a result
7141 if (!ParserResult)
7142 return 0;
7143
7144 // Reset ParserResult variable while saving its value for the result.
7145 Module *Result = ParserResult;
7146 ParserResult = 0;
7147
7148 return Result;
7149}
7150
Reid Spencer61c83e02006-08-18 08:43:06 +00007151void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007152 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00007153 // TODO: column number in exception
7154 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00007155 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00007156 TriggerError = 1;
7157}
Reid Spencer68a24bd2005-08-27 18:50:39 +00007158
7159int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00007160 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00007161 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00007162 if (yychar != YYEMPTY && yychar != 0) {
7163 errMsg += " while reading token: '";
7164 errMsg += std::string(LLLgetTokenStart(),
7165 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
7166 }
Reid Spencer61c83e02006-08-18 08:43:06 +00007167 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00007168 return 0;
7169}
Dan Gohmanf4423b12008-04-19 00:24:39 +00007170