blob: 4108df2c1437f6d0b1a8bce33b46e2e2b779d40c [file] [log] [blame]
Reid Spencer7780acb2007-04-16 06:56:07 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer7780acb2007-04-16 06:56:07 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00005
Reid Spencer38c91a92007-02-28 02:24:54 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Anton Korobeynikov178a3522007-01-12 19:22:51 +000010
Reid Spencer38c91a92007-02-28 02:24:54 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
Reid Spencer7780acb2007-04-16 06:56:07 +000021/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
Reid Spencer38c91a92007-02-28 02:24:54 +000025
Reid Spencer7780acb2007-04-16 06:56:07 +000026/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
Reid Spencer38c91a92007-02-28 02:24:54 +000028
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Bison version. */
Reid Spencer7780acb2007-04-16 06:56:07 +000040#define YYBISON_VERSION "2.1"
Reid Spencer38c91a92007-02-28 02:24:54 +000041
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
44
45/* Pure parsers. */
46#define YYPURE 0
47
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
51/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000052#define yyparse llvmAsmparse
Reid Spencer38c91a92007-02-28 02:24:54 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer38c91a92007-02-28 02:24:54 +000055#define yylval llvmAsmlval
56#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000057#define yydebug llvmAsmdebug
58#define yynerrs llvmAsmnerrs
59
Reid Spencer38c91a92007-02-28 02:24:54 +000060
61/* Tokens. */
62#ifndef YYTOKENTYPE
63# define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
67 ESINT64VAL = 258,
68 EUINT64VAL = 259,
69 ESAPINTVAL = 260,
70 EUAPINTVAL = 261,
71 LOCALVAL_ID = 262,
72 GLOBALVAL_ID = 263,
73 FPVAL = 264,
74 VOID = 265,
75 INTTYPE = 266,
76 FLOAT = 267,
77 DOUBLE = 268,
78 LABEL = 269,
79 TYPE = 270,
80 LOCALVAR = 271,
81 GLOBALVAR = 272,
82 LABELSTR = 273,
83 STRINGCONSTANT = 274,
84 ATSTRINGCONSTANT = 275,
Reid Spencer3d6b71e2007-04-09 01:56:05 +000085 ZEROINITIALIZER = 276,
86 TRUETOK = 277,
87 FALSETOK = 278,
88 BEGINTOK = 279,
89 ENDTOK = 280,
90 DECLARE = 281,
91 DEFINE = 282,
92 GLOBAL = 283,
93 CONSTANT = 284,
94 SECTION = 285,
95 VOLATILE = 286,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +000096 THREAD_LOCAL = 287,
97 TO = 288,
98 DOTDOTDOT = 289,
99 NULL_TOK = 290,
100 UNDEF = 291,
101 INTERNAL = 292,
102 LINKONCE = 293,
103 WEAK = 294,
104 APPENDING = 295,
105 DLLIMPORT = 296,
106 DLLEXPORT = 297,
107 EXTERN_WEAK = 298,
108 OPAQUE = 299,
109 EXTERNAL = 300,
110 TARGET = 301,
111 TRIPLE = 302,
112 ALIGN = 303,
113 DEPLIBS = 304,
114 CALL = 305,
115 TAIL = 306,
116 ASM_TOK = 307,
117 MODULE = 308,
118 SIDEEFFECT = 309,
119 CC_TOK = 310,
120 CCC_TOK = 311,
121 FASTCC_TOK = 312,
122 COLDCC_TOK = 313,
123 X86_STDCALLCC_TOK = 314,
124 X86_FASTCALLCC_TOK = 315,
125 DATALAYOUT = 316,
126 RET = 317,
127 BR = 318,
128 SWITCH = 319,
129 INVOKE = 320,
130 UNWIND = 321,
131 UNREACHABLE = 322,
132 ADD = 323,
133 SUB = 324,
134 MUL = 325,
135 UDIV = 326,
136 SDIV = 327,
137 FDIV = 328,
138 UREM = 329,
139 SREM = 330,
140 FREM = 331,
141 AND = 332,
142 OR = 333,
143 XOR = 334,
144 SHL = 335,
145 LSHR = 336,
146 ASHR = 337,
147 ICMP = 338,
148 FCMP = 339,
149 EQ = 340,
150 NE = 341,
151 SLT = 342,
152 SGT = 343,
153 SLE = 344,
154 SGE = 345,
155 ULT = 346,
156 UGT = 347,
157 ULE = 348,
158 UGE = 349,
159 OEQ = 350,
160 ONE = 351,
161 OLT = 352,
162 OGT = 353,
163 OLE = 354,
164 OGE = 355,
165 ORD = 356,
166 UNO = 357,
167 UEQ = 358,
168 UNE = 359,
169 MALLOC = 360,
170 ALLOCA = 361,
171 FREE = 362,
172 LOAD = 363,
173 STORE = 364,
174 GETELEMENTPTR = 365,
175 TRUNC = 366,
176 ZEXT = 367,
177 SEXT = 368,
178 FPTRUNC = 369,
179 FPEXT = 370,
180 BITCAST = 371,
181 UITOFP = 372,
182 SITOFP = 373,
183 FPTOUI = 374,
184 FPTOSI = 375,
185 INTTOPTR = 376,
186 PTRTOINT = 377,
187 PHI_TOK = 378,
188 SELECT = 379,
189 VAARG = 380,
190 EXTRACTELEMENT = 381,
191 INSERTELEMENT = 382,
192 SHUFFLEVECTOR = 383,
193 NORETURN = 384,
194 INREG = 385,
195 SRET = 386,
196 NOUNWIND = 387,
197 DEFAULT = 388,
198 HIDDEN = 389
Reid Spencer38c91a92007-02-28 02:24:54 +0000199 };
200#endif
201/* Tokens. */
202#define ESINT64VAL 258
203#define EUINT64VAL 259
204#define ESAPINTVAL 260
205#define EUAPINTVAL 261
206#define LOCALVAL_ID 262
207#define GLOBALVAL_ID 263
208#define FPVAL 264
209#define VOID 265
210#define INTTYPE 266
211#define FLOAT 267
212#define DOUBLE 268
213#define LABEL 269
214#define TYPE 270
215#define LOCALVAR 271
216#define GLOBALVAR 272
217#define LABELSTR 273
218#define STRINGCONSTANT 274
219#define ATSTRINGCONSTANT 275
Reid Spencer3d6b71e2007-04-09 01:56:05 +0000220#define ZEROINITIALIZER 276
221#define TRUETOK 277
222#define FALSETOK 278
223#define BEGINTOK 279
224#define ENDTOK 280
225#define DECLARE 281
226#define DEFINE 282
227#define GLOBAL 283
228#define CONSTANT 284
229#define SECTION 285
230#define VOLATILE 286
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000231#define THREAD_LOCAL 287
232#define TO 288
233#define DOTDOTDOT 289
234#define NULL_TOK 290
235#define UNDEF 291
236#define INTERNAL 292
237#define LINKONCE 293
238#define WEAK 294
239#define APPENDING 295
240#define DLLIMPORT 296
241#define DLLEXPORT 297
242#define EXTERN_WEAK 298
243#define OPAQUE 299
244#define EXTERNAL 300
245#define TARGET 301
246#define TRIPLE 302
247#define ALIGN 303
248#define DEPLIBS 304
249#define CALL 305
250#define TAIL 306
251#define ASM_TOK 307
252#define MODULE 308
253#define SIDEEFFECT 309
254#define CC_TOK 310
255#define CCC_TOK 311
256#define FASTCC_TOK 312
257#define COLDCC_TOK 313
258#define X86_STDCALLCC_TOK 314
259#define X86_FASTCALLCC_TOK 315
260#define DATALAYOUT 316
261#define RET 317
262#define BR 318
263#define SWITCH 319
264#define INVOKE 320
265#define UNWIND 321
266#define UNREACHABLE 322
267#define ADD 323
268#define SUB 324
269#define MUL 325
270#define UDIV 326
271#define SDIV 327
272#define FDIV 328
273#define UREM 329
274#define SREM 330
275#define FREM 331
276#define AND 332
277#define OR 333
278#define XOR 334
279#define SHL 335
280#define LSHR 336
281#define ASHR 337
282#define ICMP 338
283#define FCMP 339
284#define EQ 340
285#define NE 341
286#define SLT 342
287#define SGT 343
288#define SLE 344
289#define SGE 345
290#define ULT 346
291#define UGT 347
292#define ULE 348
293#define UGE 349
294#define OEQ 350
295#define ONE 351
296#define OLT 352
297#define OGT 353
298#define OLE 354
299#define OGE 355
300#define ORD 356
301#define UNO 357
302#define UEQ 358
303#define UNE 359
304#define MALLOC 360
305#define ALLOCA 361
306#define FREE 362
307#define LOAD 363
308#define STORE 364
309#define GETELEMENTPTR 365
310#define TRUNC 366
311#define ZEXT 367
312#define SEXT 368
313#define FPTRUNC 369
314#define FPEXT 370
315#define BITCAST 371
316#define UITOFP 372
317#define SITOFP 373
318#define FPTOUI 374
319#define FPTOSI 375
320#define INTTOPTR 376
321#define PTRTOINT 377
322#define PHI_TOK 378
323#define SELECT 379
324#define VAARG 380
325#define EXTRACTELEMENT 381
326#define INSERTELEMENT 382
327#define SHUFFLEVECTOR 383
328#define NORETURN 384
329#define INREG 385
330#define SRET 386
331#define NOUNWIND 387
332#define DEFAULT 388
333#define HIDDEN 389
Reid Spencer38c91a92007-02-28 02:24:54 +0000334
335
336
337
338/* Copy the first part of user declarations. */
Reid Spencer7780acb2007-04-16 06:56:07 +0000339#line 14 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000340
341#include "ParserInternals.h"
342#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000343#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000344#include "llvm/Instructions.h"
345#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000346#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000347#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000348#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000349#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000350#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000351#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000352#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000353#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000355#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000356#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000357#ifndef NDEBUG
358#define YYDEBUG 1
359#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000360
Reid Spencere4f47592006-08-18 17:32:55 +0000361// The following is a gross hack. In order to rid the libAsmParser library of
362// exceptions, we have to have a way of getting the yyparse function to go into
363// an error situation. So, whenever we want an error to occur, the GenerateError
364// function (see bottom of file) sets TriggerError. Then, at the end of each
365// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
366// (a goto) to put YACC in error state. Furthermore, several calls to
367// GenerateError are made from inside productions and they must simulate the
368// previous exception behavior by exiting the production immediately. We have
369// replaced these with the GEN_ERROR macro which calls GeneratError and then
370// immediately invokes YYERROR. This would be so much cleaner if it was a
371// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000372static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000373#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000374#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
375
Reid Spencer68a24bd2005-08-27 18:50:39 +0000376int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
377int yylex(); // declaration" of xxx warnings.
378int yyparse();
379
380namespace llvm {
381 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000382#if YYDEBUG
383static cl::opt<bool>
384Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
385 cl::Hidden, cl::init(false));
386#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000387}
388using namespace llvm;
389
390static Module *ParserResult;
391
392// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
393// relating to upreferences in the input stream.
394//
395//#define DEBUG_UPREFS 1
396#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000397#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000398#else
399#define UR_OUT(X)
400#endif
401
402#define YYERROR_VERBOSE 1
403
Chris Lattnerb475c422005-11-12 18:22:38 +0000404static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000405
406
407// This contains info used when building the body of a function. It is
408// destroyed when the function is completed.
409//
410typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000411
Reid Spencer68a24bd2005-08-27 18:50:39 +0000412static void
Reid Spencer93c40032007-03-19 18:40:50 +0000413ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000414
415static struct PerModuleInfo {
416 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000417 ValueList Values; // Module level numbered definitions
418 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000419 std::vector<PATypeHolder> Types;
420 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000421
422 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000423 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000424 /// that we can resolve them later and print error messages as appropriate.
425 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
426
427 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
428 // references to global values. Global values may be referenced before they
429 // are defined, and if so, the temporary object that they represent is held
430 // here. This is used for forward references of GlobalValues.
431 //
432 typedef std::map<std::pair<const PointerType *,
433 ValID>, GlobalValue*> GlobalRefsType;
434 GlobalRefsType GlobalRefs;
435
436 void ModuleDone() {
437 // If we could not resolve some functions at function compilation time
438 // (calls to functions before they are defined), resolve them now... Types
439 // are resolved when the constant pool has been completely parsed.
440 //
441 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000442 if (TriggerError)
443 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000444
445 // Check to make sure that all global value forward references have been
446 // resolved!
447 //
448 if (!GlobalRefs.empty()) {
449 std::string UndefinedReferences = "Unresolved global references exist:\n";
450
451 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
452 I != E; ++I) {
453 UndefinedReferences += " " + I->first.first->getDescription() + " " +
454 I->first.second.getName() + "\n";
455 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000456 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000457 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000458 }
459
460 Values.clear(); // Clear out function local definitions
461 Types.clear();
462 CurrentModule = 0;
463 }
464
Reid Spencer68a24bd2005-08-27 18:50:39 +0000465 // GetForwardRefForGlobal - Check to see if there is a forward reference
466 // for this global. If so, remove it from the GlobalRefs map and return it.
467 // If not, just return null.
468 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
469 // Check to see if there is a forward reference to this global variable...
470 // if there is, eliminate it and patch the reference to use the new def'n.
471 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
472 GlobalValue *Ret = 0;
473 if (I != GlobalRefs.end()) {
474 Ret = I->second;
475 GlobalRefs.erase(I);
476 }
477 return Ret;
478 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000479
480 bool TypeIsUnresolved(PATypeHolder* PATy) {
481 // If it isn't abstract, its resolved
482 const Type* Ty = PATy->get();
483 if (!Ty->isAbstract())
484 return false;
485 // Traverse the type looking for abstract types. If it isn't abstract then
486 // we don't need to traverse that leg of the type.
487 std::vector<const Type*> WorkList, SeenList;
488 WorkList.push_back(Ty);
489 while (!WorkList.empty()) {
490 const Type* Ty = WorkList.back();
491 SeenList.push_back(Ty);
492 WorkList.pop_back();
493 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
494 // Check to see if this is an unresolved type
495 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
496 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
497 for ( ; I != E; ++I) {
498 if (I->second.get() == OpTy)
499 return true;
500 }
501 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
502 const Type* TheTy = SeqTy->getElementType();
503 if (TheTy->isAbstract() && TheTy != Ty) {
504 std::vector<const Type*>::iterator I = SeenList.begin(),
505 E = SeenList.end();
506 for ( ; I != E; ++I)
507 if (*I == TheTy)
508 break;
509 if (I == E)
510 WorkList.push_back(TheTy);
511 }
512 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
513 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
514 const Type* TheTy = StrTy->getElementType(i);
515 if (TheTy->isAbstract() && TheTy != Ty) {
516 std::vector<const Type*>::iterator I = SeenList.begin(),
517 E = SeenList.end();
518 for ( ; I != E; ++I)
519 if (*I == TheTy)
520 break;
521 if (I == E)
522 WorkList.push_back(TheTy);
523 }
524 }
525 }
526 }
527 return false;
528 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000529} CurModule;
530
531static struct PerFunctionInfo {
532 Function *CurrentFunction; // Pointer to current function being created
533
Reid Spencer93c40032007-03-19 18:40:50 +0000534 ValueList Values; // Keep track of #'d definitions
535 unsigned NextValNum;
536 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000537 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000538 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000539 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000540
541 /// BBForwardRefs - When we see forward references to basic blocks, keep
542 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000543 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000544
545 inline PerFunctionInfo() {
546 CurrentFunction = 0;
547 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000548 Linkage = GlobalValue::ExternalLinkage;
549 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000550 }
551
552 inline void FunctionStart(Function *M) {
553 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000554 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000555 }
556
557 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000559 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000560 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000561 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000562 return;
563 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000564
565 // Resolve all forward references now.
566 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
567
568 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000569 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000570 CurrentFunction = 0;
571 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000572 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000573 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000574 }
575} CurFun; // Info for the current function...
576
577static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
578
579
580//===----------------------------------------------------------------------===//
581// Code to handle definitions of all the types
582//===----------------------------------------------------------------------===//
583
Reid Spencer93c40032007-03-19 18:40:50 +0000584static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
585 // Things that have names or are void typed don't get slot numbers
586 if (V->hasName() || (V->getType() == Type::VoidTy))
587 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000588
Reid Spencer93c40032007-03-19 18:40:50 +0000589 // In the case of function values, we have to allow for the forward reference
590 // of basic blocks, which are included in the numbering. Consequently, we keep
591 // track of the next insertion location with NextValNum. When a BB gets
592 // inserted, it could change the size of the CurFun.Values vector.
593 if (&ValueTab == &CurFun.Values) {
594 if (ValueTab.size() <= CurFun.NextValNum)
595 ValueTab.resize(CurFun.NextValNum+1);
596 ValueTab[CurFun.NextValNum++] = V;
597 return;
598 }
599 // For all other lists, its okay to just tack it on the back of the vector.
600 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000601}
602
603static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
604 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000605 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000607 if (D.Num < CurModule.Types.size())
608 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000609 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000610 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
612 D.destroy(); // Free old strdup'd memory...
613 return N;
614 }
615 break;
616 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000617 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000618 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000619 }
620
621 // If we reached here, we referenced either a symbol that we don't know about
622 // or an id number that hasn't been read yet. We may be referencing something
623 // forward, so just create an entry to be resolved later and get to it...
624 //
625 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
626
627
628 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000629 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000630 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000631 return 0;
632 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000633 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000634 return 0;
635 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000636 }
637
Reid Spencer861d9d62006-11-28 07:29:44 +0000638 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000639 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000640 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641
Reid Spencer861d9d62006-11-28 07:29:44 +0000642 Type *Typ = OpaqueType::get();
643 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
644 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000645 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646
Reid Spencer93c40032007-03-19 18:40:50 +0000647// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000648// the provided ValID. If the value exists and has already been defined, return
649// it. Otherwise return null.
650//
Reid Spencer93c40032007-03-19 18:40:50 +0000651static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000652 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000653 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000654 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000655 return 0;
656 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657
658 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000659 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000660 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000661 if (D.Num >= CurFun.Values.size())
662 return 0;
663 Value *Result = CurFun.Values[D.Num];
664 if (Ty != Result->getType()) {
665 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
666 Result->getType()->getDescription() + "' does not match "
667 "expected type, '" + Ty->getDescription() + "'");
668 return 0;
669 }
670 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000671 }
672 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000673 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000674 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000675 Value *Result = CurModule.Values[D.Num];
676 if (Ty != Result->getType()) {
677 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
678 Result->getType()->getDescription() + "' does not match "
679 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000680 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000681 }
682 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000683 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000684
685 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000686 if (!inFunctionScope())
687 return 0;
688 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
689 Value *N = SymTab.lookup(D.Name);
690 if (N == 0)
691 return 0;
692 if (N->getType() != Ty)
693 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000694
695 D.destroy(); // Free old strdup'd memory...
696 return N;
697 }
698 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000699 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
700 Value *N = SymTab.lookup(D.Name);
701 if (N == 0)
702 return 0;
703 if (N->getType() != Ty)
704 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000705
706 D.destroy(); // Free old strdup'd memory...
707 return N;
708 }
709
710 // Check to make sure that "Ty" is an integral type, and that our
711 // value will fit into the specified type...
712 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000713 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000714 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000715 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000716 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000717 return 0;
718 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000719 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000720
721 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000722 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
723 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000724 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000725 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000726 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000727 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000728 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000729 }
730 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000731 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000732 }
733
734 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000735 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000736 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000737 return 0;
738 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000739 return ConstantFP::get(Ty, D.ConstPoolFP);
740
741 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000743 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000744 return 0;
745 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000746 return ConstantPointerNull::get(cast<PointerType>(Ty));
747
748 case ValID::ConstUndefVal: // Is it an undef value?
749 return UndefValue::get(Ty);
750
Chris Lattner7aa61892005-12-21 17:53:23 +0000751 case ValID::ConstZeroVal: // Is it a zero value?
752 return Constant::getNullValue(Ty);
753
Reid Spencer68a24bd2005-08-27 18:50:39 +0000754 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000755 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000756 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000757 return 0;
758 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000759 return D.ConstantValue;
760
Chris Lattner0e9c3762006-01-25 22:27:16 +0000761 case ValID::InlineAsmVal: { // Inline asm expression
762 const PointerType *PTy = dyn_cast<PointerType>(Ty);
763 const FunctionType *FTy =
764 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000765 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000766 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 return 0;
768 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000769 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
770 D.IAD->HasSideEffects);
771 D.destroy(); // Free InlineAsmDescriptor.
772 return IA;
773 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000774 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000775 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776 return 0;
777 } // End of switch
778
Reid Spencera9720f52007-02-05 17:04:00 +0000779 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000780 return 0;
781}
782
Reid Spencer93c40032007-03-19 18:40:50 +0000783// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000784// value is not already defined, it "improvises" by creating a placeholder var
785// that looks and acts just like the requested variable. When the value is
786// defined later, all uses of the placeholder variable are replaced with the
787// real thing.
788//
789static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000790 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000791 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000792 return 0;
793 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794
795 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000796 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000797 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000798 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000799
Reid Spencer5b7e7532006-09-28 19:28:24 +0000800 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000801 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 return 0;
803 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000804
805 // If we reached here, we referenced either a symbol that we don't know about
806 // or an id number that hasn't been read yet. We may be referencing something
807 // forward, so just create an entry to be resolved later and get to it...
808 //
809 V = new Argument(Ty);
810
811 // Remember where this forward reference came from. FIXME, shouldn't we try
812 // to recycle these things??
813 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
814 llvmAsmlineno)));
815
816 if (inFunctionScope())
817 InsertValue(V, CurFun.LateResolveValues);
818 else
819 InsertValue(V, CurModule.LateResolveValues);
820 return V;
821}
822
Reid Spencer93c40032007-03-19 18:40:50 +0000823/// defineBBVal - This is a definition of a new basic block with the specified
824/// identifier which must be the same as CurFun.NextValNum, if its numeric.
825static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000826 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000827
Reid Spencer68a24bd2005-08-27 18:50:39 +0000828 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829
Reid Spencer93c40032007-03-19 18:40:50 +0000830 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000831
Reid Spencer93c40032007-03-19 18:40:50 +0000832 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
833 if (BBI != CurFun.BBForwardRefs.end()) {
834 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000835 // The forward declaration could have been inserted anywhere in the
836 // function: insert it into the correct place now.
837 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
838 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000839
Reid Spencer66728ef2007-03-20 01:13:36 +0000840 // We're about to erase the entry, save the key so we can clean it up.
841 ValID Tmp = BBI->first;
842
Reid Spencer93c40032007-03-19 18:40:50 +0000843 // Erase the forward ref from the map as its no longer "forward"
844 CurFun.BBForwardRefs.erase(ID);
845
Reid Spencer66728ef2007-03-20 01:13:36 +0000846 // The key has been removed from the map but so we don't want to leave
847 // strdup'd memory around so destroy it too.
848 Tmp.destroy();
849
Reid Spencer93c40032007-03-19 18:40:50 +0000850 // If its a numbered definition, bump the number and set the BB value.
851 if (ID.Type == ValID::LocalID) {
852 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
853 InsertValue(BB);
854 }
855
856 ID.destroy();
857 return BB;
858 }
859
860 // We haven't seen this BB before and its first mention is a definition.
861 // Just create it and return it.
862 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
863 BB = new BasicBlock(Name, CurFun.CurrentFunction);
864 if (ID.Type == ValID::LocalID) {
865 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
866 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000867 }
Reid Spencer93c40032007-03-19 18:40:50 +0000868
869 ID.destroy(); // Free strdup'd memory
870 return BB;
871}
872
873/// getBBVal - get an existing BB value or create a forward reference for it.
874///
875static BasicBlock *getBBVal(const ValID &ID) {
876 assert(inFunctionScope() && "Can't get basic block at global scope!");
877
878 BasicBlock *BB = 0;
879
880 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
881 if (BBI != CurFun.BBForwardRefs.end()) {
882 BB = BBI->second;
883 } if (ID.Type == ValID::LocalName) {
884 std::string Name = ID.Name;
885 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
886 if (N)
887 if (N->getType()->getTypeID() == Type::LabelTyID)
888 BB = cast<BasicBlock>(N);
889 else
890 GenerateError("Reference to label '" + Name + "' is actually of type '"+
891 N->getType()->getDescription() + "'");
892 } else if (ID.Type == ValID::LocalID) {
893 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
894 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
895 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
896 else
897 GenerateError("Reference to label '%" + utostr(ID.Num) +
898 "' is actually of type '"+
899 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
900 }
901 } else {
902 GenerateError("Illegal label reference " + ID.getName());
903 return 0;
904 }
905
906 // If its already been defined, return it now.
907 if (BB) {
908 ID.destroy(); // Free strdup'd memory.
909 return BB;
910 }
911
912 // Otherwise, this block has not been seen before, create it.
913 std::string Name;
914 if (ID.Type == ValID::LocalName)
915 Name = ID.Name;
916 BB = new BasicBlock(Name, CurFun.CurrentFunction);
917
918 // Insert it in the forward refs map.
919 CurFun.BBForwardRefs[ID] = BB;
920
Reid Spencer68a24bd2005-08-27 18:50:39 +0000921 return BB;
922}
923
924
925//===----------------------------------------------------------------------===//
926// Code to handle forward references in instructions
927//===----------------------------------------------------------------------===//
928//
929// This code handles the late binding needed with statements that reference
930// values not defined yet... for example, a forward branch, or the PHI node for
931// a loop body.
932//
933// This keeps a table (CurFun.LateResolveValues) of all such forward references
934// and back patchs after we are done.
935//
936
937// ResolveDefinitions - If we could not resolve some defs at parsing
938// time (forward branches, phi functions for loops, etc...) resolve the
939// defs now...
940//
941static void
Reid Spencer93c40032007-03-19 18:40:50 +0000942ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000943 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000944 while (!LateResolvers.empty()) {
945 Value *V = LateResolvers.back();
946 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000947
Reid Spencer93c40032007-03-19 18:40:50 +0000948 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
949 CurModule.PlaceHolderInfo.find(V);
950 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000951
Reid Spencer93c40032007-03-19 18:40:50 +0000952 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000953
Reid Spencer93c40032007-03-19 18:40:50 +0000954 Value *TheRealValue = getExistingVal(V->getType(), DID);
955 if (TriggerError)
956 return;
957 if (TheRealValue) {
958 V->replaceAllUsesWith(TheRealValue);
959 delete V;
960 CurModule.PlaceHolderInfo.erase(PHI);
961 } else if (FutureLateResolvers) {
962 // Functions have their unresolved items forwarded to the module late
963 // resolver table
964 InsertValue(V, *FutureLateResolvers);
965 } else {
966 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
967 GenerateError("Reference to an invalid definition: '" +DID.getName()+
968 "' of type '" + V->getType()->getDescription() + "'",
969 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000970 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000971 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000972 GenerateError("Reference to an invalid definition: #" +
973 itostr(DID.Num) + " of type '" +
974 V->getType()->getDescription() + "'",
975 PHI->second.second);
976 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000977 }
978 }
979 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000980 LateResolvers.clear();
981}
982
983// ResolveTypeTo - A brand new type was just declared. This means that (if
984// name is not null) things referencing Name can be resolved. Otherwise, things
985// refering to the number can be resolved. Do this now.
986//
987static void ResolveTypeTo(char *Name, const Type *ToTy) {
988 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000989 if (Name) D = ValID::createLocalName(Name);
990 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000991
Reid Spencer861d9d62006-11-28 07:29:44 +0000992 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000993 CurModule.LateResolveTypes.find(D);
994 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000995 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000996 CurModule.LateResolveTypes.erase(I);
997 }
998}
999
1000// setValueName - Set the specified value to the name given. The name may be
1001// null potentially, in which case this is a noop. The string passed in is
1002// assumed to be a malloc'd string buffer, and is free'd by this function.
1003//
1004static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001005 if (!NameStr) return;
1006 std::string Name(NameStr); // Copy string
1007 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001008
Reid Spencer41dff5e2007-01-26 08:05:27 +00001009 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001010 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001011 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001012 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001013
Reid Spencera9720f52007-02-05 17:04:00 +00001014 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001015 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1016 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001017 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001018 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001019 return;
1020 }
1021
1022 // Set the name.
1023 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001024}
1025
1026/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1027/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001028static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001029ParseGlobalVariable(char *NameStr,
1030 GlobalValue::LinkageTypes Linkage,
1031 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001032 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001033 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001034 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001035 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001036 return 0;
1037 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001038
1039 const PointerType *PTy = PointerType::get(Ty);
1040
1041 std::string Name;
1042 if (NameStr) {
1043 Name = NameStr; // Copy string
1044 free(NameStr); // Free old string
1045 }
1046
1047 // See if this global value was forward referenced. If so, recycle the
1048 // object.
1049 ValID ID;
1050 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001051 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001052 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001053 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001054 }
1055
1056 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1057 // Move the global to the end of the list, from whereever it was
1058 // previously inserted.
1059 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1060 CurModule.CurrentModule->getGlobalList().remove(GV);
1061 CurModule.CurrentModule->getGlobalList().push_back(GV);
1062 GV->setInitializer(Initializer);
1063 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001064 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001065 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001066 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001067 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001068 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001069 }
1070
Reid Spenceref9b9a72007-02-05 20:47:22 +00001071 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001072 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001073 // if the global we're parsing has an initializer (is a definition) and
1074 // has external linkage.
1075 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1076 // If there is already a global with external linkage with this name
1077 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1078 // If we allow this GVar to get created, it will be renamed in the
1079 // symbol table because it conflicts with an existing GVar. We can't
1080 // allow redefinition of GVars whose linking indicates that their name
1081 // must stay the same. Issue the error.
1082 GenerateError("Redefinition of global variable named '" + Name +
1083 "' of type '" + Ty->getDescription() + "'");
1084 return 0;
1085 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001086 }
1087
1088 // Otherwise there is no existing GV to use, create one now.
1089 GlobalVariable *GV =
1090 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001091 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001092 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001093 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001094 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001095}
1096
1097// setTypeName - Set the specified type to the name given. The name may be
1098// null potentially, in which case this is a noop. The string passed in is
1099// assumed to be a malloc'd string buffer, and is freed by this function.
1100//
1101// This function returns true if the type has already been defined, but is
1102// allowed to be redefined in the specified context. If the name is a new name
1103// for the type plane, it is inserted and false is returned.
1104static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001105 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001106 if (NameStr == 0) return false;
1107
1108 std::string Name(NameStr); // Copy string
1109 free(NameStr); // Free old string
1110
1111 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001112 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001113 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001114 return false;
1115 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001116
1117 // Set the type name, checking for conflicts as we do so.
1118 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1119
1120 if (AlreadyExists) { // Inserting a name that is already defined???
1121 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001122 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001123
1124 // There is only one case where this is allowed: when we are refining an
1125 // opaque type. In this case, Existing will be an opaque type.
1126 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1127 // We ARE replacing an opaque type!
1128 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1129 return true;
1130 }
1131
1132 // Otherwise, this is an attempt to redefine a type. That's okay if
1133 // the redefinition is identical to the original. This will be so if
1134 // Existing and T point to the same Type object. In this one case we
1135 // allow the equivalent redefinition.
1136 if (Existing == T) return true; // Yes, it's equal.
1137
1138 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001139 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001140 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001141 }
1142
1143 return false;
1144}
1145
1146//===----------------------------------------------------------------------===//
1147// Code for handling upreferences in type names...
1148//
1149
1150// TypeContains - Returns true if Ty directly contains E in it.
1151//
1152static bool TypeContains(const Type *Ty, const Type *E) {
1153 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1154 E) != Ty->subtype_end();
1155}
1156
1157namespace {
1158 struct UpRefRecord {
1159 // NestingLevel - The number of nesting levels that need to be popped before
1160 // this type is resolved.
1161 unsigned NestingLevel;
1162
1163 // LastContainedTy - This is the type at the current binding level for the
1164 // type. Every time we reduce the nesting level, this gets updated.
1165 const Type *LastContainedTy;
1166
1167 // UpRefTy - This is the actual opaque type that the upreference is
1168 // represented with.
1169 OpaqueType *UpRefTy;
1170
1171 UpRefRecord(unsigned NL, OpaqueType *URTy)
1172 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1173 };
1174}
1175
1176// UpRefs - A list of the outstanding upreferences that need to be resolved.
1177static std::vector<UpRefRecord> UpRefs;
1178
1179/// HandleUpRefs - Every time we finish a new layer of types, this function is
1180/// called. It loops through the UpRefs vector, which is a list of the
1181/// currently active types. For each type, if the up reference is contained in
1182/// the newly completed type, we decrement the level count. When the level
1183/// count reaches zero, the upreferenced type is the type that is passed in:
1184/// thus we can complete the cycle.
1185///
1186static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001187 // If Ty isn't abstract, or if there are no up-references in it, then there is
1188 // nothing to resolve here.
1189 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1190
Reid Spencer68a24bd2005-08-27 18:50:39 +00001191 PATypeHolder Ty(ty);
1192 UR_OUT("Type '" << Ty->getDescription() <<
1193 "' newly formed. Resolving upreferences.\n" <<
1194 UpRefs.size() << " upreferences active!\n");
1195
1196 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1197 // to zero), we resolve them all together before we resolve them to Ty. At
1198 // the end of the loop, if there is anything to resolve to Ty, it will be in
1199 // this variable.
1200 OpaqueType *TypeToResolve = 0;
1201
1202 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1203 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1204 << UpRefs[i].second->getDescription() << ") = "
1205 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1206 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1207 // Decrement level of upreference
1208 unsigned Level = --UpRefs[i].NestingLevel;
1209 UpRefs[i].LastContainedTy = Ty;
1210 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1211 if (Level == 0) { // Upreference should be resolved!
1212 if (!TypeToResolve) {
1213 TypeToResolve = UpRefs[i].UpRefTy;
1214 } else {
1215 UR_OUT(" * Resolving upreference for "
1216 << UpRefs[i].second->getDescription() << "\n";
1217 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1218 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1219 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1220 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1221 }
1222 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1223 --i; // Do not skip the next element...
1224 }
1225 }
1226 }
1227
1228 if (TypeToResolve) {
1229 UR_OUT(" * Resolving upreference for "
1230 << UpRefs[i].second->getDescription() << "\n";
1231 std::string OldName = TypeToResolve->getDescription());
1232 TypeToResolve->refineAbstractTypeTo(Ty);
1233 }
1234
1235 return Ty;
1236}
1237
Reid Spencer68a24bd2005-08-27 18:50:39 +00001238//===----------------------------------------------------------------------===//
1239// RunVMAsmParser - Define an interface to this parser
1240//===----------------------------------------------------------------------===//
1241//
Reid Spencer14310612006-12-31 05:40:51 +00001242static Module* RunParser(Module * M);
1243
Reid Spencer68a24bd2005-08-27 18:50:39 +00001244Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1245 set_scan_file(F);
1246
1247 CurFilename = Filename;
1248 return RunParser(new Module(CurFilename));
1249}
1250
1251Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1252 set_scan_string(AsmString);
1253
1254 CurFilename = "from_memory";
1255 if (M == NULL) {
1256 return RunParser(new Module (CurFilename));
1257 } else {
1258 return RunParser(M);
1259 }
1260}
1261
1262
Reid Spencer38c91a92007-02-28 02:24:54 +00001263
1264/* Enabling traces. */
1265#ifndef YYDEBUG
1266# define YYDEBUG 0
1267#endif
1268
1269/* Enabling verbose error messages. */
1270#ifdef YYERROR_VERBOSE
1271# undef YYERROR_VERBOSE
1272# define YYERROR_VERBOSE 1
1273#else
1274# define YYERROR_VERBOSE 0
1275#endif
1276
1277/* Enabling the token table. */
1278#ifndef YYTOKEN_TABLE
1279# define YYTOKEN_TABLE 0
1280#endif
1281
Reid Spencer7780acb2007-04-16 06:56:07 +00001282#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1283#line 938 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
1284typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001285 llvm::Module *ModuleVal;
1286 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001287 llvm::BasicBlock *BasicBlockVal;
1288 llvm::TerminatorInst *TermInstVal;
1289 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001290 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001291
Reid Spencera132e042006-12-03 05:46:11 +00001292 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001293 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001294 llvm::PATypeHolder *TypeVal;
1295 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001296 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001297 llvm::ArgListType *ArgList;
1298 llvm::TypeWithAttrs TypeWithAttrs;
1299 llvm::TypeWithAttrsList *TypeWithAttrsList;
1300 llvm::ValueRefList *ValueRefList;
1301
Reid Spencer68a24bd2005-08-27 18:50:39 +00001302 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001303 std::list<std::pair<llvm::Value*,
1304 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001305 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001306 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001307
1308 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001309 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001310 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001311 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001312 int64_t SInt64Val;
1313 uint64_t UInt64Val;
1314 int SIntVal;
1315 unsigned UIntVal;
1316 double FPVal;
1317 bool BoolVal;
1318
1319 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001320 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001321
Reid Spencera132e042006-12-03 05:46:11 +00001322 llvm::Instruction::BinaryOps BinaryOpVal;
1323 llvm::Instruction::TermOps TermOpVal;
1324 llvm::Instruction::MemoryOps MemOpVal;
1325 llvm::Instruction::CastOps CastOpVal;
1326 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001327 llvm::ICmpInst::Predicate IPredicate;
1328 llvm::FCmpInst::Predicate FPredicate;
Reid Spencer7780acb2007-04-16 06:56:07 +00001329} YYSTYPE;
1330/* Line 196 of yacc.c. */
1331#line 1332 "llvmAsmParser.tab.c"
Reid Spencer38c91a92007-02-28 02:24:54 +00001332# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1333# define YYSTYPE_IS_DECLARED 1
1334# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001335#endif
1336
Reid Spencer41dff5e2007-01-26 08:05:27 +00001337
Reid Spencer68a24bd2005-08-27 18:50:39 +00001338
Reid Spencer38c91a92007-02-28 02:24:54 +00001339/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001340
1341
Reid Spencer7780acb2007-04-16 06:56:07 +00001342/* Line 219 of yacc.c. */
1343#line 1344 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001344
Reid Spencer7780acb2007-04-16 06:56:07 +00001345#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1346# define YYSIZE_T __SIZE_TYPE__
Reid Spencer38c91a92007-02-28 02:24:54 +00001347#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00001348#if ! defined (YYSIZE_T) && defined (size_t)
1349# define YYSIZE_T size_t
Reid Spencer38c91a92007-02-28 02:24:54 +00001350#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00001351#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1352# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1353# define YYSIZE_T size_t
Reid Spencer38c91a92007-02-28 02:24:54 +00001354#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00001355#if ! defined (YYSIZE_T)
1356# define YYSIZE_T unsigned int
Reid Spencer38c91a92007-02-28 02:24:54 +00001357#endif
Chris Lattner9d2fda62007-02-13 05:53:56 +00001358
Reid Spencer38c91a92007-02-28 02:24:54 +00001359#ifndef YY_
1360# if YYENABLE_NLS
1361# if ENABLE_NLS
1362# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1363# define YY_(msgid) dgettext ("bison-runtime", msgid)
1364# endif
1365# endif
1366# ifndef YY_
1367# define YY_(msgid) msgid
1368# endif
1369#endif
1370
Reid Spencer7780acb2007-04-16 06:56:07 +00001371#if ! defined (yyoverflow) || YYERROR_VERBOSE
Reid Spencer38c91a92007-02-28 02:24:54 +00001372
1373/* The parser invokes alloca or malloc; define the necessary symbols. */
1374
1375# ifdef YYSTACK_USE_ALLOCA
1376# if YYSTACK_USE_ALLOCA
1377# ifdef __GNUC__
1378# define YYSTACK_ALLOC __builtin_alloca
1379# else
1380# define YYSTACK_ALLOC alloca
Reid Spencer7780acb2007-04-16 06:56:07 +00001381# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer38c91a92007-02-28 02:24:54 +00001382# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Reid Spencer7780acb2007-04-16 06:56:07 +00001383# define YYINCLUDED_STDLIB_H
Reid Spencer38c91a92007-02-28 02:24:54 +00001384# endif
1385# endif
1386# endif
1387# endif
1388
1389# ifdef YYSTACK_ALLOC
Reid Spencer7780acb2007-04-16 06:56:07 +00001390 /* Pacify GCC's `empty if-body' warning. */
1391# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencer38c91a92007-02-28 02:24:54 +00001392# ifndef YYSTACK_ALLOC_MAXIMUM
1393 /* The OS might guarantee only one guard page at the bottom of the stack,
1394 and a page size can be as small as 4096 bytes. So we cannot safely
1395 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1396 to allow for a few compiler-allocated temporary stack slots. */
Reid Spencer7780acb2007-04-16 06:56:07 +00001397# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Reid Spencer38c91a92007-02-28 02:24:54 +00001398# endif
1399# else
1400# define YYSTACK_ALLOC YYMALLOC
1401# define YYSTACK_FREE YYFREE
1402# ifndef YYSTACK_ALLOC_MAXIMUM
Reid Spencer7780acb2007-04-16 06:56:07 +00001403# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
Reid Spencer38c91a92007-02-28 02:24:54 +00001404# endif
Reid Spencer7780acb2007-04-16 06:56:07 +00001405# ifdef __cplusplus
1406extern "C" {
Reid Spencer38c91a92007-02-28 02:24:54 +00001407# endif
1408# ifndef YYMALLOC
1409# define YYMALLOC malloc
Reid Spencer7780acb2007-04-16 06:56:07 +00001410# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1411 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer38c91a92007-02-28 02:24:54 +00001412void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1413# endif
1414# endif
1415# ifndef YYFREE
1416# define YYFREE free
Reid Spencer7780acb2007-04-16 06:56:07 +00001417# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1418 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer38c91a92007-02-28 02:24:54 +00001419void free (void *); /* INFRINGES ON USER NAME SPACE */
1420# endif
1421# endif
Reid Spencer7780acb2007-04-16 06:56:07 +00001422# ifdef __cplusplus
1423}
1424# endif
Reid Spencer38c91a92007-02-28 02:24:54 +00001425# endif
Reid Spencer7780acb2007-04-16 06:56:07 +00001426#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Reid Spencer38c91a92007-02-28 02:24:54 +00001427
1428
Reid Spencer7780acb2007-04-16 06:56:07 +00001429#if (! defined (yyoverflow) \
1430 && (! defined (__cplusplus) \
1431 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer38c91a92007-02-28 02:24:54 +00001432
1433/* A type that is properly aligned for any stack member. */
1434union yyalloc
1435{
Reid Spencer7780acb2007-04-16 06:56:07 +00001436 short int yyss;
Reid Spencer38c91a92007-02-28 02:24:54 +00001437 YYSTYPE yyvs;
1438 };
1439
1440/* The size of the maximum gap between one aligned stack and the next. */
1441# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1442
1443/* The size of an array large to enough to hold all stacks, each with
1444 N elements. */
1445# define YYSTACK_BYTES(N) \
Reid Spencer7780acb2007-04-16 06:56:07 +00001446 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Reid Spencer38c91a92007-02-28 02:24:54 +00001447 + YYSTACK_GAP_MAXIMUM)
1448
1449/* Copy COUNT objects from FROM to TO. The source and destination do
1450 not overlap. */
1451# ifndef YYCOPY
Reid Spencer7780acb2007-04-16 06:56:07 +00001452# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer38c91a92007-02-28 02:24:54 +00001453# define YYCOPY(To, From, Count) \
1454 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1455# else
1456# define YYCOPY(To, From, Count) \
1457 do \
1458 { \
1459 YYSIZE_T yyi; \
1460 for (yyi = 0; yyi < (Count); yyi++) \
1461 (To)[yyi] = (From)[yyi]; \
1462 } \
Reid Spencer7780acb2007-04-16 06:56:07 +00001463 while (0)
Reid Spencer38c91a92007-02-28 02:24:54 +00001464# endif
1465# endif
1466
1467/* Relocate STACK from its old location to the new one. The
1468 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1469 elements in the stack, and YYPTR gives the new location of the
1470 stack. Advance YYPTR to a properly aligned location for the next
1471 stack. */
1472# define YYSTACK_RELOCATE(Stack) \
1473 do \
1474 { \
1475 YYSIZE_T yynewbytes; \
1476 YYCOPY (&yyptr->Stack, Stack, yysize); \
1477 Stack = &yyptr->Stack; \
1478 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1479 yyptr += yynewbytes / sizeof (*yyptr); \
1480 } \
Reid Spencer7780acb2007-04-16 06:56:07 +00001481 while (0)
Chris Lattner9d2fda62007-02-13 05:53:56 +00001482
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001483#endif
1484
Reid Spencer7780acb2007-04-16 06:56:07 +00001485#if defined (__STDC__) || defined (__cplusplus)
1486 typedef signed char yysigned_char;
1487#else
1488 typedef short int yysigned_char;
1489#endif
1490
1491/* YYFINAL -- State number of the termination state. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001492#define YYFINAL 39
Reid Spencer38c91a92007-02-28 02:24:54 +00001493/* YYLAST -- Last index in YYTABLE. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001494#define YYLAST 1317
Reid Spencer38c91a92007-02-28 02:24:54 +00001495
Reid Spencer7780acb2007-04-16 06:56:07 +00001496/* YYNTOKENS -- Number of terminals. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001497#define YYNTOKENS 149
Reid Spencer7780acb2007-04-16 06:56:07 +00001498/* YYNNTS -- Number of nonterminals. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001499#define YYNNTS 79
Reid Spencer7780acb2007-04-16 06:56:07 +00001500/* YYNRULES -- Number of rules. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001501#define YYNRULES 288
Reid Spencer7780acb2007-04-16 06:56:07 +00001502/* YYNRULES -- Number of states. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001503#define YYNSTATES 563
Reid Spencer38c91a92007-02-28 02:24:54 +00001504
1505/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1506#define YYUNDEFTOK 2
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001507#define YYMAXUTOK 389
Reid Spencer38c91a92007-02-28 02:24:54 +00001508
1509#define YYTRANSLATE(YYX) \
1510 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1511
1512/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Reid Spencer7780acb2007-04-16 06:56:07 +00001513static const unsigned char yytranslate[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001514{
1515 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001519 139, 140, 137, 2, 136, 2, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001521 144, 135, 145, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001524 2, 141, 138, 143, 2, 2, 2, 2, 2, 148,
Reid Spencer38c91a92007-02-28 02:24:54 +00001525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001527 142, 2, 2, 146, 2, 147, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1540 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1541 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1542 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1543 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1544 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1545 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1546 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1547 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1548 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1549 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1550 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1551 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1552 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001553 125, 126, 127, 128, 129, 130, 131, 132, 133, 134
Reid Spencer38c91a92007-02-28 02:24:54 +00001554};
1555
1556#if YYDEBUG
1557/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1558 YYRHS. */
Reid Spencer7780acb2007-04-16 06:56:07 +00001559static const unsigned short int yyprhs[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001560{
1561 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1562 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1563 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1564 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1565 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1566 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1567 119, 121, 122, 125, 126, 128, 130, 133, 134, 136,
1568 138, 140, 142, 144, 146, 148, 150, 151, 153, 154,
1569 156, 158, 159, 161, 163, 165, 167, 168, 170, 172,
1570 174, 176, 178, 181, 183, 185, 187, 189, 190, 193,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001571 195, 197, 199, 200, 203, 204, 207, 208, 212, 215,
1572 216, 218, 219, 223, 225, 228, 230, 232, 234, 236,
1573 238, 240, 243, 245, 248, 254, 260, 266, 272, 276,
1574 279, 285, 290, 293, 295, 297, 299, 303, 305, 309,
1575 311, 312, 314, 318, 323, 327, 331, 336, 341, 345,
1576 352, 358, 361, 364, 367, 370, 373, 376, 379, 382,
1577 385, 388, 391, 394, 401, 407, 416, 423, 430, 438,
1578 446, 453, 462, 471, 475, 477, 479, 481, 483, 484,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001579 486, 487, 489, 492, 493, 497, 498, 502, 506, 510,
1580 514, 515, 523, 524, 533, 534, 543, 546, 550, 552,
1581 556, 560, 564, 568, 570, 571, 577, 581, 583, 587,
1582 589, 590, 600, 602, 604, 609, 611, 613, 616, 620,
1583 621, 623, 625, 627, 629, 631, 633, 635, 637, 639,
1584 643, 645, 651, 653, 655, 657, 659, 661, 663, 666,
1585 669, 672, 676, 679, 680, 682, 685, 688, 692, 702,
1586 712, 721, 736, 738, 740, 747, 753, 756, 763, 771,
1587 775, 781, 782, 783, 787, 790, 792, 798, 804, 811,
1588 818, 823, 830, 835, 840, 847, 854, 857, 866, 868,
1589 870, 871, 875, 882, 886, 893, 896, 901, 908
Reid Spencer38c91a92007-02-28 02:24:54 +00001590};
1591
Reid Spencer7780acb2007-04-16 06:56:07 +00001592/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1593static const short int yyrhs[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001594{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001595 190, 0, -1, 68, -1, 69, -1, 70, -1, 71,
1596 -1, 72, -1, 73, -1, 74, -1, 75, -1, 76,
1597 -1, 80, -1, 81, -1, 82, -1, 77, -1, 78,
1598 -1, 79, -1, 111, -1, 112, -1, 113, -1, 114,
1599 -1, 115, -1, 116, -1, 117, -1, 118, -1, 119,
1600 -1, 120, -1, 121, -1, 122, -1, 85, -1, 86,
1601 -1, 87, -1, 88, -1, 89, -1, 90, -1, 91,
1602 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1603 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1604 -1, 102, -1, 103, -1, 104, -1, 91, -1, 92,
1605 -1, 93, -1, 94, -1, 22, -1, 23, -1, 11,
1606 -1, 12, -1, 13, -1, 16, -1, 19, -1, 157,
1607 -1, -1, 157, 135, -1, -1, 17, -1, 20, -1,
1608 160, 135, -1, -1, 37, -1, 39, -1, 38, -1,
1609 40, -1, 42, -1, 41, -1, 43, -1, 45, -1,
1610 -1, 134, -1, -1, 41, -1, 43, -1, -1, 37,
1611 -1, 38, -1, 39, -1, 42, -1, -1, 56, -1,
1612 57, -1, 58, -1, 59, -1, 60, -1, 55, 4,
1613 -1, 112, -1, 113, -1, 130, -1, 131, -1, -1,
1614 169, 168, -1, 129, -1, 132, -1, 168, -1, -1,
1615 171, 170, -1, -1, 48, 4, -1, -1, 136, 48,
1616 4, -1, 30, 19, -1, -1, 174, -1, -1, 136,
1617 177, 176, -1, 174, -1, 48, 4, -1, 11, -1,
1618 12, -1, 13, -1, 14, -1, 44, -1, 178, -1,
1619 179, 137, -1, 212, -1, 138, 4, -1, 179, 139,
1620 183, 140, 171, -1, 10, 139, 183, 140, 171, -1,
1621 141, 4, 142, 179, 143, -1, 144, 4, 142, 179,
1622 145, -1, 146, 184, 147, -1, 146, 147, -1, 144,
1623 146, 184, 147, 145, -1, 144, 146, 147, 145, -1,
1624 179, 169, -1, 179, -1, 10, -1, 180, -1, 182,
1625 136, 180, -1, 182, -1, 182, 136, 34, -1, 34,
1626 -1, -1, 179, -1, 184, 136, 179, -1, 179, 141,
1627 187, 143, -1, 179, 141, 143, -1, 179, 148, 19,
1628 -1, 179, 144, 187, 145, -1, 179, 146, 187, 147,
1629 -1, 179, 146, 147, -1, 179, 144, 146, 187, 147,
1630 145, -1, 179, 144, 146, 147, 145, -1, 179, 35,
1631 -1, 179, 36, -1, 179, 212, -1, 179, 186, -1,
1632 179, 21, -1, 155, 3, -1, 155, 5, -1, 155,
1633 4, -1, 155, 6, -1, 11, 22, -1, 11, 23,
1634 -1, 156, 9, -1, 152, 139, 185, 33, 179, 140,
1635 -1, 110, 139, 185, 223, 140, -1, 124, 139, 185,
1636 136, 185, 136, 185, 140, -1, 150, 139, 185, 136,
1637 185, 140, -1, 151, 139, 185, 136, 185, 140, -1,
1638 83, 153, 139, 185, 136, 185, 140, -1, 84, 154,
1639 139, 185, 136, 185, 140, -1, 126, 139, 185, 136,
1640 185, 140, -1, 127, 139, 185, 136, 185, 136, 185,
1641 140, -1, 128, 139, 185, 136, 185, 136, 185, 140,
1642 -1, 187, 136, 185, -1, 185, -1, 28, -1, 29,
1643 -1, 32, -1, -1, 191, -1, -1, 192, -1, 191,
1644 192, -1, -1, 27, 193, 208, -1, -1, 26, 194,
1645 209, -1, 53, 52, 198, -1, 159, 15, 179, -1,
1646 159, 15, 10, -1, -1, 161, 164, 189, 188, 185,
1647 195, 176, -1, -1, 161, 162, 164, 189, 188, 185,
1648 196, 176, -1, -1, 161, 163, 164, 189, 188, 179,
1649 197, 176, -1, 46, 199, -1, 49, 135, 200, -1,
1650 19, -1, 47, 135, 19, -1, 61, 135, 19, -1,
1651 141, 201, 143, -1, 201, 136, 19, -1, 19, -1,
1652 -1, 202, 136, 179, 169, 158, -1, 179, 169, 158,
1653 -1, 202, -1, 202, 136, 34, -1, 34, -1, -1,
1654 167, 181, 160, 139, 203, 140, 171, 175, 172, -1,
1655 24, -1, 146, -1, 166, 164, 204, 205, -1, 25,
1656 -1, 147, -1, 215, 207, -1, 165, 164, 204, -1,
1657 -1, 54, -1, 3, -1, 4, -1, 9, -1, 22,
1658 -1, 23, -1, 35, -1, 36, -1, 21, -1, 144,
1659 187, 145, -1, 186, -1, 52, 210, 19, 136, 19,
1660 -1, 7, -1, 8, -1, 157, -1, 160, -1, 212,
1661 -1, 211, -1, 179, 213, -1, 215, 216, -1, 206,
1662 216, -1, 217, 159, 218, -1, 217, 220, -1, -1,
1663 18, -1, 62, 214, -1, 62, 10, -1, 63, 14,
1664 213, -1, 63, 11, 213, 136, 14, 213, 136, 14,
1665 213, -1, 64, 155, 213, 136, 14, 213, 141, 219,
1666 143, -1, 64, 155, 213, 136, 14, 213, 141, 143,
1667 -1, 65, 167, 181, 213, 139, 222, 140, 171, 33,
1668 14, 213, 66, 14, 213, -1, 66, -1, 67, -1,
1669 219, 155, 211, 136, 14, 213, -1, 155, 211, 136,
1670 14, 213, -1, 159, 225, -1, 179, 141, 213, 136,
1671 213, 143, -1, 221, 136, 141, 213, 136, 213, 143,
1672 -1, 179, 213, 169, -1, 222, 136, 179, 213, 169,
1673 -1, -1, -1, 223, 136, 214, -1, 51, 50, -1,
1674 50, -1, 150, 179, 213, 136, 213, -1, 151, 179,
1675 213, 136, 213, -1, 83, 153, 179, 213, 136, 213,
1676 -1, 84, 154, 179, 213, 136, 213, -1, 152, 214,
1677 33, 179, -1, 124, 214, 136, 214, 136, 214, -1,
1678 125, 214, 136, 179, -1, 126, 214, 136, 214, -1,
1679 127, 214, 136, 214, 136, 214, -1, 128, 214, 136,
1680 214, 136, 214, -1, 123, 221, -1, 224, 167, 181,
1681 213, 139, 222, 140, 171, -1, 227, -1, 31, -1,
1682 -1, 105, 179, 173, -1, 105, 179, 136, 11, 213,
1683 173, -1, 106, 179, 173, -1, 106, 179, 136, 11,
1684 213, 173, -1, 107, 214, -1, 226, 108, 179, 213,
1685 -1, 226, 109, 214, 136, 179, 213, -1, 110, 179,
1686 213, 223, -1
Reid Spencer38c91a92007-02-28 02:24:54 +00001687};
1688
1689/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencer7780acb2007-04-16 06:56:07 +00001690static const unsigned short int yyrline[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001691{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001692 0, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
1693 1093, 1094, 1094, 1094, 1094, 1094, 1094, 1095, 1095, 1095,
1694 1095, 1095, 1095, 1096, 1096, 1096, 1096, 1096, 1096, 1099,
1695 1099, 1100, 1100, 1101, 1101, 1102, 1102, 1103, 1103, 1107,
1696 1107, 1108, 1108, 1109, 1109, 1110, 1110, 1111, 1111, 1112,
1697 1112, 1113, 1113, 1114, 1115, 1120, 1121, 1121, 1123, 1123,
1698 1124, 1124, 1128, 1132, 1137, 1137, 1139, 1143, 1149, 1150,
1699 1151, 1152, 1153, 1157, 1158, 1159, 1163, 1164, 1168, 1169,
1700 1170, 1174, 1175, 1176, 1177, 1178, 1181, 1182, 1183, 1184,
1701 1185, 1186, 1187, 1194, 1195, 1196, 1197, 1200, 1201, 1206,
1702 1207, 1208, 1211, 1212, 1219, 1220, 1226, 1227, 1235, 1243,
1703 1244, 1249, 1250, 1251, 1256, 1269, 1269, 1269, 1269, 1272,
1704 1276, 1280, 1287, 1292, 1300, 1326, 1353, 1358, 1370, 1380,
1705 1384, 1394, 1401, 1408, 1415, 1420, 1425, 1432, 1433, 1440,
1706 1447, 1455, 1461, 1473, 1501, 1517, 1546, 1574, 1599, 1618,
1707 1644, 1664, 1676, 1683, 1749, 1759, 1769, 1775, 1785, 1791,
1708 1801, 1806, 1811, 1819, 1831, 1853, 1861, 1867, 1878, 1883,
1709 1888, 1894, 1900, 1909, 1913, 1921, 1921, 1924, 1924, 1935,
1710 1940, 1948, 1949, 1953, 1953, 1957, 1957, 1960, 1963, 1987,
1711 1998, 1998, 2008, 2008, 2016, 2016, 2026, 2029, 2035, 2048,
1712 2052, 2057, 2059, 2064, 2069, 2078, 2088, 2099, 2103, 2112,
1713 2121, 2126, 2245, 2245, 2247, 2256, 2256, 2258, 2263, 2275,
1714 2279, 2284, 2288, 2292, 2296, 2300, 2304, 2308, 2312, 2316,
1715 2341, 2345, 2359, 2363, 2367, 2371, 2377, 2377, 2383, 2392,
1716 2396, 2405, 2414, 2423, 2427, 2432, 2436, 2440, 2445, 2455,
1717 2474, 2483, 2559, 2563, 2570, 2581, 2594, 2604, 2615, 2625,
1718 2634, 2643, 2646, 2647, 2654, 2658, 2663, 2684, 2701, 2715,
Reid Spencer2eb203a2007-04-16 17:47:06 +00001719 2729, 2741, 2749, 2756, 2762, 2768, 2774, 2789, 2870, 2875,
1720 2879, 2886, 2893, 2901, 2908, 2916, 2924, 2938, 2955
Reid Spencer38c91a92007-02-28 02:24:54 +00001721};
1722#endif
1723
1724#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1725/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencer7780acb2007-04-16 06:56:07 +00001726 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer38c91a92007-02-28 02:24:54 +00001727static const char *const yytname[] =
1728{
1729 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1730 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1731 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001732 "STRINGCONSTANT", "ATSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1733 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001734 "CONSTANT", "SECTION", "VOLATILE", "THREAD_LOCAL", "TO", "DOTDOTDOT",
1735 "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK", "APPENDING",
1736 "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", "EXTERNAL", "TARGET",
1737 "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1738 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK",
1739 "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", "RET", "BR",
1740 "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV",
1741 "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", "XOR", "SHL",
1742 "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE",
1743 "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE",
1744 "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE",
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001745 "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST",
1746 "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT",
1747 "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT",
1748 "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", "NOUNWIND", "DEFAULT",
1749 "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'",
1750 "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps",
1751 "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType",
1752 "FPType", "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName",
1753 "OptGlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1754 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1755 "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr",
1756 "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1757 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1758 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001759 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "ThreadLocal",
1760 "Module", "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5",
1761 "AsmBlock", "TargetDefinition", "LibrariesDefinition", "LibList",
1762 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
1763 "END", "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
Reid Spencer38c91a92007-02-28 02:24:54 +00001764 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1765 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1766 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1767 "OptVolatile", "MemoryInst", 0
1768};
1769#endif
1770
1771# ifdef YYPRINT
1772/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1773 token YYLEX-NUM. */
Reid Spencer7780acb2007-04-16 06:56:07 +00001774static const unsigned short int yytoknum[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001775{
1776 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1777 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1778 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1779 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1780 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1781 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1782 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1783 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1784 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1785 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1786 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1787 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1788 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001789 385, 386, 387, 388, 389, 61, 44, 42, 92, 40,
1790 41, 91, 120, 93, 60, 62, 123, 125, 99
Reid Spencer38c91a92007-02-28 02:24:54 +00001791};
1792# endif
1793
1794/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Reid Spencer7780acb2007-04-16 06:56:07 +00001795static const unsigned char yyr1[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001796{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001797 0, 149, 150, 150, 150, 150, 150, 150, 150, 150,
1798 150, 151, 151, 151, 151, 151, 151, 152, 152, 152,
Reid Spencer38c91a92007-02-28 02:24:54 +00001799 152, 152, 152, 152, 152, 152, 152, 152, 152, 153,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001800 153, 153, 153, 153, 153, 153, 153, 153, 153, 154,
1801 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
1802 154, 154, 154, 154, 154, 155, 156, 156, 157, 157,
1803 158, 158, 159, 159, 160, 160, 161, 161, 162, 162,
1804 162, 162, 162, 163, 163, 163, 164, 164, 165, 165,
1805 165, 166, 166, 166, 166, 166, 167, 167, 167, 167,
1806 167, 167, 167, 168, 168, 168, 168, 169, 169, 170,
1807 170, 170, 171, 171, 172, 172, 173, 173, 174, 175,
1808 175, 176, 176, 177, 177, 178, 178, 178, 178, 179,
1809 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
1810 179, 179, 180, 181, 181, 182, 182, 183, 183, 183,
1811 183, 184, 184, 185, 185, 185, 185, 185, 185, 185,
1812 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
1813 185, 185, 185, 186, 186, 186, 186, 186, 186, 186,
1814 186, 186, 186, 187, 187, 188, 188, 189, 189, 190,
1815 190, 191, 191, 193, 192, 194, 192, 192, 192, 192,
1816 195, 192, 196, 192, 197, 192, 192, 192, 198, 199,
1817 199, 200, 201, 201, 201, 202, 202, 203, 203, 203,
1818 203, 204, 205, 205, 206, 207, 207, 208, 209, 210,
1819 210, 211, 211, 211, 211, 211, 211, 211, 211, 211,
1820 211, 211, 212, 212, 212, 212, 213, 213, 214, 215,
1821 215, 216, 217, 217, 217, 218, 218, 218, 218, 218,
1822 218, 218, 218, 218, 219, 219, 220, 221, 221, 222,
1823 222, 222, 223, 223, 224, 224, 225, 225, 225, 225,
1824 225, 225, 225, 225, 225, 225, 225, 225, 225, 226,
1825 226, 227, 227, 227, 227, 227, 227, 227, 227
Reid Spencer38c91a92007-02-28 02:24:54 +00001826};
1827
1828/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Reid Spencer7780acb2007-04-16 06:56:07 +00001829static const unsigned char yyr2[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001830{
1831 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1832 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1833 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1834 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1835 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1836 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1837 1, 0, 2, 0, 1, 1, 2, 0, 1, 1,
1838 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
1839 1, 0, 1, 1, 1, 1, 0, 1, 1, 1,
1840 1, 1, 2, 1, 1, 1, 1, 0, 2, 1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001841 1, 1, 0, 2, 0, 2, 0, 3, 2, 0,
1842 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1843 1, 2, 1, 2, 5, 5, 5, 5, 3, 2,
1844 5, 4, 2, 1, 1, 1, 3, 1, 3, 1,
1845 0, 1, 3, 4, 3, 3, 4, 4, 3, 6,
1846 5, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1847 2, 2, 2, 6, 5, 8, 6, 6, 7, 7,
1848 6, 8, 8, 3, 1, 1, 1, 1, 0, 1,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001849 0, 1, 2, 0, 3, 0, 3, 3, 3, 3,
1850 0, 7, 0, 8, 0, 8, 2, 3, 1, 3,
1851 3, 3, 3, 1, 0, 5, 3, 1, 3, 1,
1852 0, 9, 1, 1, 4, 1, 1, 2, 3, 0,
1853 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1854 1, 5, 1, 1, 1, 1, 1, 1, 2, 2,
1855 2, 3, 2, 0, 1, 2, 2, 3, 9, 9,
1856 8, 14, 1, 1, 6, 5, 2, 6, 7, 3,
1857 5, 0, 0, 3, 2, 1, 5, 5, 6, 6,
1858 4, 6, 4, 4, 6, 6, 2, 8, 1, 1,
1859 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer38c91a92007-02-28 02:24:54 +00001860};
1861
1862/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1863 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1864 means the default is an error. */
Reid Spencer7780acb2007-04-16 06:56:07 +00001865static const unsigned short int yydefact[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001866{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001867 67, 58, 64, 59, 65, 185, 183, 0, 0, 0,
1868 0, 0, 0, 76, 0, 67, 181, 78, 81, 0,
1869 0, 196, 0, 0, 62, 0, 66, 68, 70, 69,
1870 71, 73, 72, 74, 75, 77, 76, 76, 178, 1,
1871 182, 79, 80, 76, 186, 82, 83, 84, 85, 76,
1872 243, 184, 243, 0, 0, 204, 197, 198, 187, 232,
1873 233, 189, 115, 116, 117, 118, 119, 0, 0, 0,
1874 0, 234, 235, 120, 188, 122, 178, 178, 177, 0,
1875 86, 86, 244, 240, 63, 215, 216, 217, 239, 199,
1876 200, 203, 0, 140, 123, 0, 0, 0, 0, 129,
1877 141, 0, 121, 140, 0, 0, 175, 176, 0, 0,
1878 87, 88, 89, 90, 91, 0, 218, 0, 280, 242,
1879 0, 201, 139, 97, 135, 137, 0, 0, 0, 0,
1880 0, 0, 128, 0, 0, 0, 115, 116, 117, 0,
1881 0, 0, 190, 92, 134, 133, 0, 212, 213, 214,
1882 279, 265, 0, 0, 0, 0, 86, 252, 253, 2,
1883 3, 4, 5, 6, 7, 8, 9, 10, 14, 15,
1884 16, 11, 12, 13, 0, 0, 0, 0, 0, 0,
1885 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1886 27, 28, 0, 0, 0, 0, 0, 0, 0, 0,
1887 0, 241, 86, 256, 0, 278, 202, 132, 0, 102,
1888 0, 0, 131, 0, 142, 102, 192, 194, 160, 161,
1889 156, 158, 157, 159, 162, 155, 151, 152, 0, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00001890 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001891 0, 0, 154, 153, 111, 0, 264, 246, 0, 245,
1892 0, 0, 55, 0, 0, 29, 30, 31, 32, 33,
1893 34, 35, 36, 37, 38, 0, 53, 54, 49, 50,
1894 51, 52, 39, 40, 41, 42, 43, 44, 45, 46,
1895 47, 48, 0, 106, 106, 285, 0, 0, 276, 0,
1896 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1897 93, 94, 95, 96, 98, 138, 136, 125, 126, 127,
1898 130, 124, 111, 111, 0, 0, 0, 0, 0, 0,
1899 0, 144, 174, 0, 0, 0, 148, 0, 145, 0,
1900 0, 0, 0, 191, 210, 221, 222, 223, 228, 224,
1901 225, 226, 227, 219, 0, 230, 237, 236, 238, 0,
1902 247, 0, 0, 0, 0, 0, 281, 0, 283, 262,
1903 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1904 0, 0, 0, 99, 100, 101, 103, 193, 195, 0,
1905 0, 262, 0, 0, 0, 0, 0, 143, 129, 141,
1906 0, 146, 147, 0, 0, 0, 0, 0, 113, 111,
1907 209, 97, 207, 0, 220, 0, 0, 0, 0, 0,
1908 0, 0, 0, 0, 0, 288, 0, 0, 0, 272,
1909 273, 0, 0, 0, 0, 270, 0, 286, 0, 0,
1910 0, 0, 0, 0, 0, 0, 173, 150, 0, 0,
1911 0, 0, 108, 114, 112, 61, 0, 102, 0, 229,
1912 0, 0, 261, 0, 0, 106, 107, 106, 0, 0,
1913 0, 0, 0, 0, 266, 267, 261, 0, 0, 0,
1914 164, 0, 0, 0, 0, 149, 0, 0, 0, 60,
1915 206, 208, 97, 109, 0, 0, 0, 0, 0, 268,
1916 269, 0, 282, 284, 263, 0, 0, 271, 274, 275,
1917 0, 287, 0, 0, 0, 170, 0, 0, 166, 167,
1918 163, 61, 110, 104, 231, 0, 0, 97, 0, 102,
1919 257, 0, 102, 168, 169, 0, 0, 0, 205, 0,
1920 211, 0, 250, 0, 0, 259, 0, 0, 258, 277,
1921 165, 171, 172, 105, 248, 0, 249, 0, 97, 0,
1922 0, 0, 260, 0, 0, 0, 0, 255, 0, 0,
1923 254, 0, 251
Reid Spencer38c91a92007-02-28 02:24:54 +00001924};
1925
Reid Spencer7780acb2007-04-16 06:56:07 +00001926/* YYDEFGOTO[NTERM-NUM]. */
1927static const short int yydefgoto[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001928{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001929 -1, 239, 240, 241, 265, 282, 139, 140, 71, 480,
1930 11, 72, 13, 36, 37, 38, 43, 49, 115, 304,
1931 207, 376, 307, 530, 356, 398, 513, 333, 399, 73,
1932 141, 124, 146, 125, 126, 101, 322, 345, 323, 108,
1933 79, 14, 15, 16, 18, 17, 244, 312, 313, 58,
1934 21, 56, 92, 402, 403, 116, 149, 50, 87, 51,
1935 44, 405, 346, 75, 348, 249, 52, 83, 84, 201,
1936 534, 119, 288, 488, 415, 202, 203, 204, 205
Reid Spencer38c91a92007-02-28 02:24:54 +00001937};
1938
1939/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1940 STATE-NUM. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001941#define YYPACT_NINF -476
Reid Spencer7780acb2007-04-16 06:56:07 +00001942static const short int yypact[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001943{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001944 28, -476, -476, -476, -476, -476, -476, -10, -55, 8,
1945 -33, 97, 3, 55, 167, 394, -476, 172, 210, 86,
1946 98, -476, 102, 219, -476, 1017, -476, -476, -476, -476,
1947 -476, -476, -476, -476, -476, -476, 123, 123, 218, -476,
1948 -476, -476, -476, 123, -476, -476, -476, -476, -476, 123,
1949 241, -476, 2, 242, 251, 253, -476, -476, -476, -476,
1950 -476, 137, -476, -476, -476, -476, -476, 274, 283, 1,
1951 456, -476, -476, -476, 83, -476, 218, 218, -476, 103,
1952 291, 291, -476, -476, 121, -476, -476, -476, -476, -476,
1953 -476, -476, -26, 874, -476, 148, 149, 470, 137, -476,
1954 83, -97, -476, 874, 103, 103, -476, -476, 1031, 288,
1955 -476, -476, -476, -476, -476, 1073, -476, -7, 1172, -476,
1956 282, -476, -476, 83, -476, 157, 162, 1087, 1087, 158,
1957 -61, 1087, -476, 165, 1031, 1087, 60, 297, 298, 201,
1958 299, 656, -476, -476, 137, 83, 217, -476, -476, -476,
1959 -476, -476, 262, 1129, 257, 302, 291, -476, -476, -476,
1960 -476, -476, -476, -476, -476, -476, -476, -476, -476, -476,
1961 -476, -476, -476, -476, 461, 273, 1087, 1087, 1087, 1087,
1962 -476, -476, -476, -476, -476, -476, -476, -476, -476, -476,
1963 -476, -476, 1087, 1087, 1087, 1087, 1087, 1087, 1087, 1087,
1964 1087, -476, 291, -476, 74, -476, -476, -25, 914, -476,
1965 19, 41, -476, 175, 83, -476, -476, 83, -476, -476,
1966 -476, -476, -476, -476, -476, -476, -476, -476, 461, 273,
1967 178, 182, 183, 184, 186, 933, 1171, 552, 309, 190,
1968 191, 194, -476, -476, 199, 197, -476, 137, 509, -476,
1969 635, 635, -476, 635, 1073, -476, -476, -476, -476, -476,
1970 -476, -476, -476, -476, -476, 1087, -476, -476, -476, -476,
1971 -476, -476, -476, -476, -476, -476, -476, -476, -476, -476,
1972 -476, -476, 1087, -17, 92, -476, 509, 75, 207, 208,
1973 220, 221, 222, 223, 509, 509, 304, 1073, 1087, 1087,
1974 -476, -476, -476, -476, -476, -476, -476, 154, -476, -476,
1975 -476, 154, 199, 199, 214, 215, 1031, 1031, 1031, 1031,
1976 1031, -476, -476, -22, 828, -75, -476, -58, -476, 1031,
1977 1031, 1031, 5, -476, 972, -476, -476, -476, -476, -476,
1978 -476, -476, -476, 301, 1031, -476, -476, -476, -476, 224,
1979 -476, 226, 635, 509, 509, 14, -476, 23, -476, -476,
1980 635, 237, 1087, 1087, 1087, 1087, 1087, 243, 244, 1087,
1981 635, 509, 246, -476, -476, -476, -476, -476, -476, 1031,
1982 1031, -476, 247, 248, 254, 255, 1031, -476, 250, 656,
1983 -46, -476, -476, 256, 261, 360, 383, 399, -476, 199,
1984 -476, 83, 269, 266, -476, 388, -60, 398, 401, 277,
1985 272, 289, 635, 420, 635, 293, 294, 635, 295, 83,
1986 -476, 296, 300, 635, 635, 83, 305, -476, 1087, 310,
1987 314, -98, 1031, 1031, 1031, 1031, -476, -476, 290, 1031,
1988 1031, 1087, -476, -476, -476, 33, 988, -476, 315, -476,
1989 635, 635, 1087, 635, 635, 316, -476, 316, 1087, 635,
1990 317, 1087, 1087, 1087, -476, -476, 1087, 509, 1031, 1031,
1991 -476, 318, 287, 320, 321, -476, 319, 322, 116, -476,
1992 -476, -476, 83, 79, 414, 324, 330, 509, 21, -476,
1993 -476, 393, -476, -476, -476, 331, 635, -476, -476, -476,
1994 59, -476, 325, 339, 1031, -476, 1031, 1031, -476, -476,
1995 -476, 33, -476, 410, -476, 447, -2, -476, 1087, -476,
1996 -476, 342, -476, -476, -476, 348, 351, 352, -476, 489,
1997 -476, 635, -476, 785, -1, -25, 509, 133, -476, 154,
1998 -476, -476, -476, -476, -476, 359, -476, 785, -476, 482,
1999 483, 362, -25, 635, 635, 485, 439, -476, 635, 492,
2000 -476, 635, -476
Reid Spencer38c91a92007-02-28 02:24:54 +00002001};
2002
2003/* YYPGOTO[NTERM-NUM]. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002004static const short int yypgoto[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00002005{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002006 -476, 389, 392, 397, 292, 306, -153, -476, 0, 10,
2007 435, 4, -476, -476, -476, 87, -476, -476, -145, -295,
2008 -383, -476, -208, -476, -276, 39, -476, -291, -476, -476,
2009 -24, 326, -241, -476, 421, 426, 69, -138, -196, 89,
2010 204, -476, -476, 512, -476, -476, -476, -476, -476, -476,
2011 -476, -476, -476, -476, -476, 452, -476, -476, -476, -476,
2012 -476, -476, -475, -135, -227, -164, -476, 484, -476, -476,
2013 -476, -476, -476, 73, 159, -476, -476, -476, -476
Reid Spencer38c91a92007-02-28 02:24:54 +00002014};
2015
2016/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2017 positive, shift that token. If negative, reduce the rule which
2018 number is the opposite. If zero, do what YYDEFACT says.
2019 If YYTABLE_NINF, syntax error. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002020#define YYTABLE_NINF -181
Reid Spencer7780acb2007-04-16 06:56:07 +00002021static const short int yytable[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00002022{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002023 10, 74, 253, 242, 12, 96, 243, 311, 358, 252,
2024 252, 254, 375, 352, 285, 10, 375, 147, 445, 12,
2025 82, 377, 378, 349, 350, 412, 351, 85, -180, 289,
2026 290, 291, 292, 293, 414, 396, 296, 19, 458, 131,
2027 325, 327, 470, -63, 1, 2, 100, 3, 4, 1,
2028 132, 20, 3, 397, 5, 6, 370, 297, 545, 359,
2029 23, 386, 413, -55, -55, -55, -55, 367, 368, 123,
2030 391, 413, 551, 100, 7, 131, 386, 8, 386, 123,
2031 22, 9, 218, 219, 10, 449, 213, 300, 301, 392,
2032 386, 145, 27, 28, 29, 30, 31, 32, 33, 511,
2033 34, 438, 24, 210, 211, 302, 303, 214, 444, 396,
2034 120, 217, 25, 347, 386, 347, 347, 121, 347, 355,
2035 102, 387, 103, 76, 77, 409, 410, 411, 390, 248,
2036 80, 106, 107, 416, 535, 372, 81, 1, 26, 148,
2037 3, 532, 546, 426, 427, 300, 301, 97, 406, 86,
2038 245, 347, 283, 284, 248, 286, 102, 518, 103, 347,
2039 347, 519, 308, 302, 303, 552, 549, 39, 287, 248,
2040 248, 248, 248, 248, 294, 295, 248, 142, 102, 492,
2041 103, 493, 298, 299, 123, 455, 309, 457, 375, 35,
2042 460, 300, 301, 134, 135, 518, 464, 465, 418, 522,
2043 420, 421, 422, 216, 220, 221, 222, 223, 373, 302,
2044 303, 374, 102, 41, 103, 42, 360, 347, 347, 347,
2045 102, 53, 103, 485, 486, 347, 489, 490, 357, 102,
2046 145, 103, 495, 54, 2, 347, 347, 4, 57, 483,
2047 501, 353, 375, 55, 375, 300, 301, 45, 46, 47,
2048 78, 242, 48, 102, 243, 103, 510, 35, 354, 82,
2049 517, 89, 373, 302, 303, 374, 300, 301, 250, 521,
2050 90, 251, 91, 145, 371, 248, 93, 347, 94, 347,
2051 104, 105, 347, 373, 302, 303, 374, 95, 347, 347,
2052 127, 128, 143, 208, 494, 266, 267, 497, 498, 499,
2053 389, 206, 209, 212, 544, 215, -56, -57, 224, 548,
2054 401, 537, 246, 252, 539, 347, 347, 316, 347, 347,
2055 310, 317, 318, 319, 347, 320, 556, 557, 328, 329,
2056 330, 560, 347, 331, 562, 332, 334, 369, 248, 419,
2057 248, 248, 248, 361, 362, 425, 109, 110, 111, 112,
2058 113, 114, 347, 379, 380, 404, 363, 364, 365, 366,
2059 407, 347, 408, 533, 268, 269, 270, 271, 272, 273,
2060 274, 275, 276, 277, 278, 279, 280, 281, 417, 423,
2061 424, 547, 428, 432, 433, 381, 382, 383, 384, 385,
2062 434, 435, 439, 441, -179, 437, 347, 440, 393, 394,
2063 395, 347, 442, 443, 467, 446, 447, 448, 453, -63,
2064 1, 2, 450, 3, 4, 451, 452, 478, 347, 347,
2065 5, 6, 482, 347, 456, 454, 347, 505, 487, 458,
2066 459, 461, 462, 514, 248, 475, 463, 248, 248, 248,
2067 7, 413, 487, 8, 466, 479, 468, 9, 429, 430,
2068 469, 484, 491, 496, 504, 436, 506, 507, 529, 508,
2069 515, 531, 509, 59, 60, 523, 98, 62, 63, 64,
2070 65, 516, 1, 2, 520, 3, 4, 59, 60, 524,
2071 98, 62, 63, 64, 65, 538, 1, 2, 540, 3,
2072 4, 541, 542, 543, 536, 550, 553, 554, 555, 558,
2073 66, 471, 472, 473, 474, 559, 561, 198, 476, 477,
2074 199, 479, 335, 336, 66, 200, 59, 60, 337, 118,
2075 314, 528, 512, 130, 133, 1, 2, 40, 3, 4,
2076 338, 339, 340, 117, 306, 315, 88, 502, 503, 500,
2077 431, 0, 0, 0, 341, 342, 255, 256, 257, 258,
2078 259, 260, 261, 262, 263, 264, 0, 0, 0, 59,
2079 60, 343, 98, 136, 137, 138, 65, 0, 1, 2,
2080 0, 3, 4, 525, 0, 526, 527, 159, 160, 161,
2081 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
2082 172, 173, 228, 229, 67, 0, 66, 68, 0, 0,
2083 69, 0, 70, 99, 0, 0, 0, 0, 67, 0,
2084 0, 68, 0, 0, 69, 0, 70, 129, 0, 230,
2085 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
2086 190, 191, 0, 231, 0, 232, 233, 234, 335, 336,
2087 0, 0, 59, 60, 337, 0, 102, 0, 103, 0,
2088 0, 1, 2, 344, 3, 4, 338, 339, 340, 0,
2089 0, 0, 0, 59, 60, 0, 0, 0, 0, 0,
2090 341, 342, 1, 2, 0, 3, 4, 225, 0, 0,
2091 0, 0, 0, 0, 0, 0, 0, 343, 0, 0,
2092 67, 226, 227, 68, 0, 0, 69, 0, 70, 326,
2093 0, 0, 0, 159, 160, 161, 162, 163, 164, 165,
2094 166, 167, 168, 169, 170, 171, 172, 173, 228, 229,
2095 0, 0, 0, 0, 159, 160, 161, 162, 163, 164,
2096 165, 166, 167, 168, 169, 170, 171, 172, 173, 228,
2097 229, 0, 0, 0, 0, 230, 180, 181, 182, 183,
2098 184, 185, 186, 187, 188, 189, 190, 191, 0, 231,
2099 0, 232, 233, 234, 0, 0, 230, 180, 181, 182,
2100 183, 184, 185, 186, 187, 188, 189, 190, 191, 344,
2101 231, 0, 232, 233, 234, 0, 0, 0, 335, 336,
2102 0, 0, 0, 102, 337, 103, 0, 235, 0, 0,
2103 236, 0, 237, 0, 238, 0, 338, 339, 340, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00002104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002105 341, 342, 0, 0, 0, 0, 0, 0, 0, 0,
2106 0, 0, 0, 0, 0, 59, 60, 343, 98, 136,
2107 137, 138, 65, 0, 1, 2, 0, 3, 4, 0,
2108 0, 0, 0, 159, 160, 161, 162, 163, 164, 165,
2109 166, 167, 168, 169, 170, 171, 172, 173, 228, 229,
2110 0, 0, 66, 0, 0, 0, 0, 0, 0, 0,
2111 0, 59, 60, 0, 98, 62, 63, 64, 65, 0,
2112 1, 2, 0, 3, 4, 230, 180, 181, 182, 183,
2113 184, 185, 186, 187, 188, 189, 190, 191, 122, 231,
2114 0, 232, 233, 234, 0, 0, 0, 0, 66, 0,
2115 0, 59, 60, 0, 98, 62, 63, 64, 65, 344,
2116 1, 2, 0, 3, 4, 0, 0, 0, 0, 0,
2117 59, 60, 0, 98, 136, 137, 138, 65, 305, 1,
2118 2, 0, 3, 4, 0, 0, 0, 0, 66, 0,
2119 0, 0, 0, 0, 0, 0, 67, 0, 0, 68,
2120 0, 0, 69, 0, 70, 388, 0, 66, 0, 59,
2121 60, 0, 98, 62, 63, 64, 65, 0, 1, 2,
2122 0, 3, 4, 0, 0, 59, 60, 0, 98, 62,
2123 63, 64, 65, 0, 1, 2, 400, 3, 4, 0,
2124 0, 0, 67, 0, 0, 68, 66, 0, 69, 0,
2125 70, 0, 481, 0, 59, 60, 0, 61, 62, 63,
2126 64, 65, 66, 1, 2, 0, 3, 4, 59, 60,
2127 0, 98, 136, 137, 138, 65, 0, 1, 2, 0,
2128 3, 4, 67, 0, 0, 68, 0, 0, 69, 0,
2129 70, 66, 0, 0, 0, 0, 0, 0, 0, 0,
2130 0, 67, 0, 0, 68, 66, 321, 69, 0, 70,
2131 59, 60, 0, 144, 62, 63, 64, 65, 0, 1,
2132 2, 0, 3, 4, 59, 60, 0, 98, 62, 63,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002133 64, 65, 0, 1, 2, 0, 3, 4, 0, 0,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002134 67, 0, 0, 68, 0, 0, 69, 66, 70, 0,
2135 0, 0, 0, 0, 0, 0, 67, 0, 0, 68,
2136 0, 66, 69, 0, 70, 0, 59, 60, 0, 247,
2137 62, 63, 64, 65, 0, 1, 2, 0, 3, 4,
2138 0, 0, 0, 0, 0, 67, 0, 0, 68, 0,
2139 0, 69, 0, 70, 0, 0, 0, 0, 0, 67,
2140 0, 0, 68, 66, 0, 69, 0, 70, 59, 60,
2141 0, 98, 136, 137, 138, 65, 0, 1, 2, 0,
2142 3, 4, 0, 0, 0, 0, 0, 0, 0, 0,
2143 0, 0, 0, 150, 0, 0, 0, 0, 0, 0,
2144 0, 67, 0, 0, 68, 66, 0, 69, 0, 70,
2145 0, 0, 151, 152, 0, 67, 0, 0, 68, 0,
2146 0, 69, 0, 70, 153, 154, 155, 156, 157, 158,
2147 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
2148 169, 170, 171, 172, 173, 174, 175, 0, 0, 0,
2149 0, 0, 0, 0, 0, 0, 0, 67, 0, 0,
2150 68, 0, 0, 69, 0, 70, 0, 176, 177, 178,
2151 0, 0, 179, 180, 181, 182, 183, 184, 185, 186,
2152 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
2153 197, 0, 0, 0, 0, 0, 0, 0, 0, 67,
2154 0, 0, 68, 0, 0, 69, 0, 324
Reid Spencer38c91a92007-02-28 02:24:54 +00002155};
2156
Reid Spencer7780acb2007-04-16 06:56:07 +00002157static const short int yycheck[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00002158{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002159 0, 25, 155, 141, 0, 4, 141, 215, 284, 11,
2160 11, 156, 307, 254, 178, 15, 311, 24, 401, 15,
2161 18, 312, 313, 250, 251, 11, 253, 25, 0, 193,
2162 194, 195, 196, 197, 11, 30, 200, 47, 136, 136,
2163 236, 237, 140, 15, 16, 17, 70, 19, 20, 16,
2164 147, 61, 19, 48, 26, 27, 297, 202, 533, 286,
2165 52, 136, 48, 3, 4, 5, 6, 294, 295, 93,
2166 145, 48, 547, 97, 46, 136, 136, 49, 136, 103,
2167 135, 53, 22, 23, 84, 145, 147, 112, 113, 147,
2168 136, 115, 37, 38, 39, 40, 41, 42, 43, 482,
2169 45, 147, 135, 127, 128, 130, 131, 131, 399, 30,
2170 136, 135, 15, 248, 136, 250, 251, 143, 253, 136,
2171 137, 143, 139, 36, 37, 352, 353, 354, 324, 153,
2172 43, 28, 29, 360, 517, 299, 49, 16, 135, 146,
2173 19, 143, 143, 370, 371, 112, 113, 146, 344, 147,
2174 146, 286, 176, 177, 178, 179, 137, 136, 139, 294,
2175 295, 140, 143, 130, 131, 548, 33, 0, 192, 193,
2176 194, 195, 196, 197, 198, 199, 200, 108, 137, 455,
2177 139, 457, 108, 109, 208, 412, 145, 414, 483, 134,
2178 417, 112, 113, 104, 105, 136, 423, 424, 362, 140,
2179 364, 365, 366, 134, 3, 4, 5, 6, 129, 130,
2180 131, 132, 137, 41, 139, 43, 141, 352, 353, 354,
2181 137, 135, 139, 450, 451, 360, 453, 454, 136, 137,
2182 254, 139, 459, 135, 17, 370, 371, 20, 19, 447,
2183 467, 265, 537, 141, 539, 112, 113, 37, 38, 39,
2184 32, 389, 42, 137, 389, 139, 140, 134, 282, 18,
2185 487, 19, 129, 130, 131, 132, 112, 113, 11, 496,
2186 19, 14, 19, 297, 298, 299, 139, 412, 4, 414,
2187 76, 77, 417, 129, 130, 131, 132, 4, 423, 424,
2188 142, 142, 4, 136, 458, 22, 23, 461, 462, 463,
2189 324, 19, 140, 145, 531, 140, 9, 9, 9, 536,
2190 334, 519, 50, 11, 522, 450, 451, 139, 453, 454,
2191 145, 139, 139, 139, 459, 139, 553, 554, 19, 139,
2192 139, 558, 467, 139, 561, 136, 139, 33, 362, 363,
2193 364, 365, 366, 136, 136, 369, 55, 56, 57, 58,
2194 59, 60, 487, 139, 139, 54, 136, 136, 136, 136,
2195 136, 496, 136, 516, 91, 92, 93, 94, 95, 96,
2196 97, 98, 99, 100, 101, 102, 103, 104, 141, 136,
2197 136, 534, 136, 136, 136, 316, 317, 318, 319, 320,
2198 136, 136, 136, 33, 0, 145, 531, 136, 329, 330,
2199 331, 536, 19, 4, 428, 136, 140, 19, 136, 15,
2200 16, 17, 14, 19, 20, 14, 139, 441, 553, 554,
2201 26, 27, 446, 558, 4, 136, 561, 140, 452, 136,
2202 136, 136, 136, 19, 458, 145, 136, 461, 462, 463,
2203 46, 48, 466, 49, 139, 445, 136, 53, 379, 380,
2204 136, 136, 136, 136, 136, 386, 136, 136, 48, 140,
2205 136, 14, 140, 7, 8, 140, 10, 11, 12, 13,
2206 14, 141, 16, 17, 143, 19, 20, 7, 8, 140,
2207 10, 11, 12, 13, 14, 143, 16, 17, 140, 19,
2208 20, 140, 140, 4, 518, 136, 14, 14, 136, 14,
2209 44, 432, 433, 434, 435, 66, 14, 118, 439, 440,
2210 118, 511, 3, 4, 44, 118, 7, 8, 9, 84,
2211 228, 511, 483, 97, 103, 16, 17, 15, 19, 20,
2212 21, 22, 23, 81, 208, 229, 52, 468, 469, 466,
2213 381, -1, -1, -1, 35, 36, 85, 86, 87, 88,
2214 89, 90, 91, 92, 93, 94, -1, -1, -1, 7,
2215 8, 52, 10, 11, 12, 13, 14, -1, 16, 17,
2216 -1, 19, 20, 504, -1, 506, 507, 68, 69, 70,
2217 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2218 81, 82, 83, 84, 138, -1, 44, 141, -1, -1,
2219 144, -1, 146, 147, -1, -1, -1, -1, 138, -1,
2220 -1, 141, -1, -1, 144, -1, 146, 147, -1, 110,
2221 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
2222 121, 122, -1, 124, -1, 126, 127, 128, 3, 4,
2223 -1, -1, 7, 8, 9, -1, 137, -1, 139, -1,
2224 -1, 16, 17, 144, 19, 20, 21, 22, 23, -1,
2225 -1, -1, -1, 7, 8, -1, -1, -1, -1, -1,
2226 35, 36, 16, 17, -1, 19, 20, 21, -1, -1,
2227 -1, -1, -1, -1, -1, -1, -1, 52, -1, -1,
2228 138, 35, 36, 141, -1, -1, 144, -1, 146, 147,
2229 -1, -1, -1, 68, 69, 70, 71, 72, 73, 74,
2230 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2231 -1, -1, -1, -1, 68, 69, 70, 71, 72, 73,
Reid Spencer38c91a92007-02-28 02:24:54 +00002232 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002233 84, -1, -1, -1, -1, 110, 111, 112, 113, 114,
2234 115, 116, 117, 118, 119, 120, 121, 122, -1, 124,
2235 -1, 126, 127, 128, -1, -1, 110, 111, 112, 113,
2236 114, 115, 116, 117, 118, 119, 120, 121, 122, 144,
2237 124, -1, 126, 127, 128, -1, -1, -1, 3, 4,
2238 -1, -1, -1, 137, 9, 139, -1, 141, -1, -1,
2239 144, -1, 146, -1, 148, -1, 21, 22, 23, -1,
2240 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2241 35, 36, -1, -1, -1, -1, -1, -1, -1, -1,
2242 -1, -1, -1, -1, -1, 7, 8, 52, 10, 11,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002243 12, 13, 14, -1, 16, 17, -1, 19, 20, -1,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002244 -1, -1, -1, 68, 69, 70, 71, 72, 73, 74,
2245 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2246 -1, -1, 44, -1, -1, -1, -1, -1, -1, -1,
2247 -1, 7, 8, -1, 10, 11, 12, 13, 14, -1,
2248 16, 17, -1, 19, 20, 110, 111, 112, 113, 114,
2249 115, 116, 117, 118, 119, 120, 121, 122, 34, 124,
2250 -1, 126, 127, 128, -1, -1, -1, -1, 44, -1,
2251 -1, 7, 8, -1, 10, 11, 12, 13, 14, 144,
2252 16, 17, -1, 19, 20, -1, -1, -1, -1, -1,
2253 7, 8, -1, 10, 11, 12, 13, 14, 34, 16,
2254 17, -1, 19, 20, -1, -1, -1, -1, 44, -1,
2255 -1, -1, -1, -1, -1, -1, 138, -1, -1, 141,
2256 -1, -1, 144, -1, 146, 147, -1, 44, -1, 7,
2257 8, -1, 10, 11, 12, 13, 14, -1, 16, 17,
2258 -1, 19, 20, -1, -1, 7, 8, -1, 10, 11,
2259 12, 13, 14, -1, 16, 17, 34, 19, 20, -1,
2260 -1, -1, 138, -1, -1, 141, 44, -1, 144, -1,
2261 146, -1, 34, -1, 7, 8, -1, 10, 11, 12,
2262 13, 14, 44, 16, 17, -1, 19, 20, 7, 8,
2263 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2264 19, 20, 138, -1, -1, 141, -1, -1, 144, -1,
2265 146, 44, -1, -1, -1, -1, -1, -1, -1, -1,
2266 -1, 138, -1, -1, 141, 44, 143, 144, -1, 146,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002267 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
Reid Spencer38c91a92007-02-28 02:24:54 +00002268 17, -1, 19, 20, 7, 8, -1, 10, 11, 12,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002269 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002270 138, -1, -1, 141, -1, -1, 144, 44, 146, -1,
2271 -1, -1, -1, -1, -1, -1, 138, -1, -1, 141,
2272 -1, 44, 144, -1, 146, -1, 7, 8, -1, 10,
2273 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
2274 -1, -1, -1, -1, -1, 138, -1, -1, 141, -1,
2275 -1, 144, -1, 146, -1, -1, -1, -1, -1, 138,
2276 -1, -1, 141, 44, -1, 144, -1, 146, 7, 8,
2277 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2278 19, 20, -1, -1, -1, -1, -1, -1, -1, -1,
2279 -1, -1, -1, 31, -1, -1, -1, -1, -1, -1,
2280 -1, 138, -1, -1, 141, 44, -1, 144, -1, 146,
2281 -1, -1, 50, 51, -1, 138, -1, -1, 141, -1,
2282 -1, 144, -1, 146, 62, 63, 64, 65, 66, 67,
2283 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2284 78, 79, 80, 81, 82, 83, 84, -1, -1, -1,
2285 -1, -1, -1, -1, -1, -1, -1, 138, -1, -1,
2286 141, -1, -1, 144, -1, 146, -1, 105, 106, 107,
2287 -1, -1, 110, 111, 112, 113, 114, 115, 116, 117,
2288 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2289 128, -1, -1, -1, -1, -1, -1, -1, -1, 138,
2290 -1, -1, 141, -1, -1, 144, -1, 146
Reid Spencer38c91a92007-02-28 02:24:54 +00002291};
2292
2293/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2294 symbol of state STATE-NUM. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002295static const unsigned char yystos[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00002296{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002297 0, 16, 17, 19, 20, 26, 27, 46, 49, 53,
2298 157, 159, 160, 161, 190, 191, 192, 194, 193, 47,
2299 61, 199, 135, 52, 135, 15, 135, 37, 38, 39,
2300 40, 41, 42, 43, 45, 134, 162, 163, 164, 0,
2301 192, 41, 43, 165, 209, 37, 38, 39, 42, 166,
2302 206, 208, 215, 135, 135, 141, 200, 19, 198, 7,
2303 8, 10, 11, 12, 13, 14, 44, 138, 141, 144,
2304 146, 157, 160, 178, 179, 212, 164, 164, 32, 189,
2305 164, 164, 18, 216, 217, 25, 147, 207, 216, 19,
2306 19, 19, 201, 139, 4, 4, 4, 146, 10, 147,
2307 179, 184, 137, 139, 189, 189, 28, 29, 188, 55,
2308 56, 57, 58, 59, 60, 167, 204, 204, 159, 220,
2309 136, 143, 34, 179, 180, 182, 183, 142, 142, 147,
2310 184, 136, 147, 183, 188, 188, 11, 12, 13, 155,
2311 156, 179, 185, 4, 10, 179, 181, 24, 146, 205,
2312 31, 50, 51, 62, 63, 64, 65, 66, 67, 68,
2313 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2314 79, 80, 81, 82, 83, 84, 105, 106, 107, 110,
Reid Spencer38c91a92007-02-28 02:24:54 +00002315 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002316 121, 122, 123, 124, 125, 126, 127, 128, 150, 151,
2317 152, 218, 224, 225, 226, 227, 19, 169, 136, 140,
2318 179, 179, 145, 147, 179, 140, 185, 179, 22, 23,
2319 3, 4, 5, 6, 9, 21, 35, 36, 83, 84,
2320 110, 124, 126, 127, 128, 141, 144, 146, 148, 150,
2321 151, 152, 186, 212, 195, 160, 50, 10, 179, 214,
2322 11, 14, 11, 155, 167, 85, 86, 87, 88, 89,
2323 90, 91, 92, 93, 94, 153, 22, 23, 91, 92,
2324 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
2325 103, 104, 154, 179, 179, 214, 179, 179, 221, 214,
2326 214, 214, 214, 214, 179, 179, 214, 167, 108, 109,
2327 112, 113, 130, 131, 168, 34, 180, 171, 143, 145,
2328 145, 171, 196, 197, 153, 154, 139, 139, 139, 139,
2329 139, 143, 185, 187, 146, 187, 147, 187, 19, 139,
2330 139, 139, 136, 176, 139, 3, 4, 9, 21, 22,
2331 23, 35, 36, 52, 144, 186, 211, 212, 213, 213,
2332 213, 213, 181, 179, 179, 136, 173, 136, 173, 213,
2333 141, 136, 136, 136, 136, 136, 136, 213, 213, 33,
2334 181, 179, 214, 129, 132, 168, 170, 176, 176, 139,
2335 139, 185, 185, 185, 185, 185, 136, 143, 147, 179,
2336 187, 145, 147, 185, 185, 185, 30, 48, 174, 177,
2337 34, 179, 202, 203, 54, 210, 187, 136, 136, 213,
2338 213, 213, 11, 48, 11, 223, 213, 141, 214, 179,
2339 214, 214, 214, 136, 136, 179, 213, 213, 136, 185,
2340 185, 223, 136, 136, 136, 136, 185, 145, 147, 136,
2341 136, 33, 19, 4, 176, 169, 136, 140, 19, 145,
2342 14, 14, 139, 136, 136, 213, 4, 213, 136, 136,
2343 213, 136, 136, 136, 213, 213, 139, 179, 136, 136,
2344 140, 185, 185, 185, 185, 145, 185, 185, 179, 157,
2345 158, 34, 179, 171, 136, 213, 213, 179, 222, 213,
2346 213, 136, 173, 173, 214, 213, 136, 214, 214, 214,
2347 222, 213, 185, 185, 136, 140, 136, 136, 140, 140,
2348 140, 169, 174, 175, 19, 136, 141, 213, 136, 140,
2349 143, 213, 140, 140, 140, 185, 185, 185, 158, 48,
2350 172, 14, 143, 155, 219, 169, 179, 171, 143, 171,
2351 140, 140, 140, 4, 213, 211, 143, 155, 213, 33,
2352 136, 211, 169, 14, 14, 136, 213, 213, 14, 66,
2353 213, 14, 213
Reid Spencer38c91a92007-02-28 02:24:54 +00002354};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002355
2356#define yyerrok (yyerrstatus = 0)
2357#define yyclearin (yychar = YYEMPTY)
Reid Spencer38c91a92007-02-28 02:24:54 +00002358#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002359#define YYEOF 0
Reid Spencer38c91a92007-02-28 02:24:54 +00002360
Reid Spencer68a24bd2005-08-27 18:50:39 +00002361#define YYACCEPT goto yyacceptlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002362#define YYABORT goto yyabortlab
2363#define YYERROR goto yyerrorlab
2364
2365
2366/* Like YYERROR except do call yyerror. This remains here temporarily
2367 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002368 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002369
Reid Spencer68a24bd2005-08-27 18:50:39 +00002370#define YYFAIL goto yyerrlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002371
Reid Spencer68a24bd2005-08-27 18:50:39 +00002372#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002373
2374#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002375do \
2376 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer38c91a92007-02-28 02:24:54 +00002377 { \
2378 yychar = (Token); \
2379 yylval = (Value); \
2380 yytoken = YYTRANSLATE (yychar); \
Reid Spencer7780acb2007-04-16 06:56:07 +00002381 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002382 goto yybackup; \
2383 } \
2384 else \
Reid Spencer38c91a92007-02-28 02:24:54 +00002385 { \
2386 yyerror (YY_("syntax error: cannot back up")); \
2387 YYERROR; \
2388 } \
Reid Spencer7780acb2007-04-16 06:56:07 +00002389while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002390
Reid Spencer38c91a92007-02-28 02:24:54 +00002391
Reid Spencer68a24bd2005-08-27 18:50:39 +00002392#define YYTERROR 1
2393#define YYERRCODE 256
2394
Reid Spencer38c91a92007-02-28 02:24:54 +00002395
2396/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2397 If N is 0, then set CURRENT to the empty location which ends
2398 the previous symbol: RHS[0] (always defined). */
2399
2400#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2401#ifndef YYLLOC_DEFAULT
2402# define YYLLOC_DEFAULT(Current, Rhs, N) \
2403 do \
Reid Spencer7780acb2007-04-16 06:56:07 +00002404 if (N) \
Reid Spencer38c91a92007-02-28 02:24:54 +00002405 { \
2406 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2407 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2408 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2409 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2410 } \
2411 else \
2412 { \
2413 (Current).first_line = (Current).last_line = \
2414 YYRHSLOC (Rhs, 0).last_line; \
2415 (Current).first_column = (Current).last_column = \
2416 YYRHSLOC (Rhs, 0).last_column; \
2417 } \
Reid Spencer7780acb2007-04-16 06:56:07 +00002418 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002419#endif
2420
Reid Spencer38c91a92007-02-28 02:24:54 +00002421
2422/* YY_LOCATION_PRINT -- Print the location on the stream.
2423 This macro was not mandated originally: define only if we know
2424 we won't break user code: when these are the locations we know. */
2425
2426#ifndef YY_LOCATION_PRINT
2427# if YYLTYPE_IS_TRIVIAL
2428# define YY_LOCATION_PRINT(File, Loc) \
2429 fprintf (File, "%d.%d-%d.%d", \
Reid Spencer7780acb2007-04-16 06:56:07 +00002430 (Loc).first_line, (Loc).first_column, \
2431 (Loc).last_line, (Loc).last_column)
Reid Spencer38c91a92007-02-28 02:24:54 +00002432# else
2433# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2434# endif
2435#endif
2436
2437
2438/* YYLEX -- calling `yylex' with the right arguments. */
2439
Reid Spencer41dff5e2007-01-26 08:05:27 +00002440#ifdef YYLEX_PARAM
Reid Spencer38c91a92007-02-28 02:24:54 +00002441# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002442#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002443# define YYLEX yylex ()
Chris Lattner32980692007-02-19 07:44:24 +00002444#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002445
2446/* Enable debugging if requested. */
2447#if YYDEBUG
2448
2449# ifndef YYFPRINTF
2450# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2451# define YYFPRINTF fprintf
2452# endif
2453
2454# define YYDPRINTF(Args) \
2455do { \
2456 if (yydebug) \
2457 YYFPRINTF Args; \
Reid Spencer7780acb2007-04-16 06:56:07 +00002458} while (0)
Reid Spencer38c91a92007-02-28 02:24:54 +00002459
Reid Spencer7780acb2007-04-16 06:56:07 +00002460# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2461do { \
2462 if (yydebug) \
2463 { \
2464 YYFPRINTF (stderr, "%s ", Title); \
2465 yysymprint (stderr, \
2466 Type, Value); \
2467 YYFPRINTF (stderr, "\n"); \
2468 } \
2469} while (0)
Reid Spencer38c91a92007-02-28 02:24:54 +00002470
2471/*------------------------------------------------------------------.
2472| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2473| TOP (included). |
2474`------------------------------------------------------------------*/
2475
Reid Spencer7780acb2007-04-16 06:56:07 +00002476#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002477static void
Reid Spencer7780acb2007-04-16 06:56:07 +00002478yy_stack_print (short int *bottom, short int *top)
Chris Lattner32980692007-02-19 07:44:24 +00002479#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002480static void
2481yy_stack_print (bottom, top)
Reid Spencer7780acb2007-04-16 06:56:07 +00002482 short int *bottom;
2483 short int *top;
Chris Lattner32980692007-02-19 07:44:24 +00002484#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002485{
2486 YYFPRINTF (stderr, "Stack now");
Reid Spencer7780acb2007-04-16 06:56:07 +00002487 for (/* Nothing. */; bottom <= top; ++bottom)
Reid Spencer38c91a92007-02-28 02:24:54 +00002488 YYFPRINTF (stderr, " %d", *bottom);
2489 YYFPRINTF (stderr, "\n");
2490}
2491
2492# define YY_STACK_PRINT(Bottom, Top) \
2493do { \
2494 if (yydebug) \
2495 yy_stack_print ((Bottom), (Top)); \
Reid Spencer7780acb2007-04-16 06:56:07 +00002496} while (0)
Reid Spencer38c91a92007-02-28 02:24:54 +00002497
2498
2499/*------------------------------------------------.
2500| Report that the YYRULE is going to be reduced. |
2501`------------------------------------------------*/
2502
Reid Spencer7780acb2007-04-16 06:56:07 +00002503#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002504static void
Reid Spencer7780acb2007-04-16 06:56:07 +00002505yy_reduce_print (int yyrule)
Reid Spencer38c91a92007-02-28 02:24:54 +00002506#else
2507static void
Reid Spencer7780acb2007-04-16 06:56:07 +00002508yy_reduce_print (yyrule)
Reid Spencer38c91a92007-02-28 02:24:54 +00002509 int yyrule;
Chris Lattner9d2fda62007-02-13 05:53:56 +00002510#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002511{
2512 int yyi;
2513 unsigned long int yylno = yyrline[yyrule];
Reid Spencer7780acb2007-04-16 06:56:07 +00002514 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2515 yyrule - 1, yylno);
2516 /* Print the symbols being reduced, and their result. */
2517 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2518 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2519 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Reid Spencer38c91a92007-02-28 02:24:54 +00002520}
Reid Spencer9d6565a2007-02-15 02:26:10 +00002521
Reid Spencer38c91a92007-02-28 02:24:54 +00002522# define YY_REDUCE_PRINT(Rule) \
2523do { \
2524 if (yydebug) \
Reid Spencer7780acb2007-04-16 06:56:07 +00002525 yy_reduce_print (Rule); \
2526} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00002527
Reid Spencer38c91a92007-02-28 02:24:54 +00002528/* Nonzero means print parse trace. It is left uninitialized so that
2529 multiple parsers can coexist. */
2530int yydebug;
2531#else /* !YYDEBUG */
2532# define YYDPRINTF(Args)
2533# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2534# define YY_STACK_PRINT(Bottom, Top)
2535# define YY_REDUCE_PRINT(Rule)
2536#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00002537
Reid Spencer9d6565a2007-02-15 02:26:10 +00002538
Reid Spencer38c91a92007-02-28 02:24:54 +00002539/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002540#ifndef YYINITDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002541# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002542#endif
2543
Reid Spencer38c91a92007-02-28 02:24:54 +00002544/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2545 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002546
Reid Spencer38c91a92007-02-28 02:24:54 +00002547 Do not make this value too large; the results are undefined if
2548 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2549 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002550
2551#ifndef YYMAXDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002552# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002553#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002554
Reid Spencer68a24bd2005-08-27 18:50:39 +00002555
2556
Reid Spencer38c91a92007-02-28 02:24:54 +00002557#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002558
Reid Spencer38c91a92007-02-28 02:24:54 +00002559# ifndef yystrlen
Reid Spencer7780acb2007-04-16 06:56:07 +00002560# if defined (__GLIBC__) && defined (_STRING_H)
Reid Spencer38c91a92007-02-28 02:24:54 +00002561# define yystrlen strlen
2562# else
2563/* Return the length of YYSTR. */
2564static YYSIZE_T
Reid Spencer7780acb2007-04-16 06:56:07 +00002565# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002566yystrlen (const char *yystr)
Reid Spencer7780acb2007-04-16 06:56:07 +00002567# else
Reid Spencer38c91a92007-02-28 02:24:54 +00002568yystrlen (yystr)
Reid Spencer7780acb2007-04-16 06:56:07 +00002569 const char *yystr;
2570# endif
Chris Lattner32980692007-02-19 07:44:24 +00002571{
Reid Spencer7780acb2007-04-16 06:56:07 +00002572 const char *yys = yystr;
2573
2574 while (*yys++ != '\0')
Reid Spencer38c91a92007-02-28 02:24:54 +00002575 continue;
Reid Spencer7780acb2007-04-16 06:56:07 +00002576
2577 return yys - yystr - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002578}
Reid Spencer38c91a92007-02-28 02:24:54 +00002579# endif
2580# endif
Chris Lattner32980692007-02-19 07:44:24 +00002581
Reid Spencer38c91a92007-02-28 02:24:54 +00002582# ifndef yystpcpy
Reid Spencer7780acb2007-04-16 06:56:07 +00002583# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Reid Spencer38c91a92007-02-28 02:24:54 +00002584# define yystpcpy stpcpy
2585# else
2586/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2587 YYDEST. */
2588static char *
Reid Spencer7780acb2007-04-16 06:56:07 +00002589# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002590yystpcpy (char *yydest, const char *yysrc)
Reid Spencer7780acb2007-04-16 06:56:07 +00002591# else
Reid Spencer38c91a92007-02-28 02:24:54 +00002592yystpcpy (yydest, yysrc)
Reid Spencer7780acb2007-04-16 06:56:07 +00002593 char *yydest;
2594 const char *yysrc;
2595# endif
Chris Lattner32980692007-02-19 07:44:24 +00002596{
Reid Spencer38c91a92007-02-28 02:24:54 +00002597 char *yyd = yydest;
2598 const char *yys = yysrc;
Chris Lattner32980692007-02-19 07:44:24 +00002599
Reid Spencer38c91a92007-02-28 02:24:54 +00002600 while ((*yyd++ = *yys++) != '\0')
2601 continue;
2602
2603 return yyd - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002604}
Reid Spencer38c91a92007-02-28 02:24:54 +00002605# endif
2606# endif
Chris Lattner32980692007-02-19 07:44:24 +00002607
Reid Spencer38c91a92007-02-28 02:24:54 +00002608# ifndef yytnamerr
2609/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2610 quotes and backslashes, so that it's suitable for yyerror. The
2611 heuristic is that double-quoting is unnecessary unless the string
2612 contains an apostrophe, a comma, or backslash (other than
2613 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2614 null, do not copy; instead, return the length of what the result
2615 would have been. */
2616static YYSIZE_T
2617yytnamerr (char *yyres, const char *yystr)
2618{
2619 if (*yystr == '"')
2620 {
Reid Spencer7780acb2007-04-16 06:56:07 +00002621 size_t yyn = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00002622 char const *yyp = yystr;
2623
2624 for (;;)
2625 switch (*++yyp)
2626 {
2627 case '\'':
2628 case ',':
2629 goto do_not_strip_quotes;
2630
2631 case '\\':
2632 if (*++yyp != '\\')
2633 goto do_not_strip_quotes;
2634 /* Fall through. */
2635 default:
2636 if (yyres)
2637 yyres[yyn] = *yyp;
2638 yyn++;
2639 break;
2640
2641 case '"':
2642 if (yyres)
2643 yyres[yyn] = '\0';
2644 return yyn;
2645 }
2646 do_not_strip_quotes: ;
2647 }
2648
2649 if (! yyres)
2650 return yystrlen (yystr);
2651
2652 return yystpcpy (yyres, yystr) - yyres;
2653}
2654# endif
2655
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002656#endif /* YYERROR_VERBOSE */
Reid Spencer7780acb2007-04-16 06:56:07 +00002657
Reid Spencer9d6565a2007-02-15 02:26:10 +00002658
2659
Reid Spencer7780acb2007-04-16 06:56:07 +00002660#if YYDEBUG
2661/*--------------------------------.
2662| Print this symbol on YYOUTPUT. |
2663`--------------------------------*/
2664
2665#if defined (__STDC__) || defined (__cplusplus)
2666static void
2667yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
2668#else
2669static void
2670yysymprint (yyoutput, yytype, yyvaluep)
2671 FILE *yyoutput;
2672 int yytype;
2673 YYSTYPE *yyvaluep;
2674#endif
2675{
2676 /* Pacify ``unused variable'' warnings. */
2677 (void) yyvaluep;
2678
2679 if (yytype < YYNTOKENS)
2680 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2681 else
2682 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2683
2684
2685# ifdef YYPRINT
2686 if (yytype < YYNTOKENS)
2687 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2688# endif
2689 switch (yytype)
2690 {
2691 default:
2692 break;
2693 }
2694 YYFPRINTF (yyoutput, ")");
2695}
2696
2697#endif /* ! YYDEBUG */
Reid Spencer38c91a92007-02-28 02:24:54 +00002698/*-----------------------------------------------.
2699| Release the memory associated to this symbol. |
2700`-----------------------------------------------*/
2701
Reid Spencer7780acb2007-04-16 06:56:07 +00002702#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002703static void
2704yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2705#else
2706static void
2707yydestruct (yymsg, yytype, yyvaluep)
2708 const char *yymsg;
2709 int yytype;
2710 YYSTYPE *yyvaluep;
2711#endif
2712{
Reid Spencer7780acb2007-04-16 06:56:07 +00002713 /* Pacify ``unused variable'' warnings. */
2714 (void) yyvaluep;
Reid Spencer38c91a92007-02-28 02:24:54 +00002715
2716 if (!yymsg)
2717 yymsg = "Deleting";
2718 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2719
2720 switch (yytype)
2721 {
2722
2723 default:
Reid Spencer7780acb2007-04-16 06:56:07 +00002724 break;
Reid Spencer38c91a92007-02-28 02:24:54 +00002725 }
2726}
2727
2728
2729/* Prevent warnings from -Wmissing-prototypes. */
2730
2731#ifdef YYPARSE_PARAM
Reid Spencer7780acb2007-04-16 06:56:07 +00002732# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002733int yyparse (void *YYPARSE_PARAM);
Reid Spencer7780acb2007-04-16 06:56:07 +00002734# else
Reid Spencer38c91a92007-02-28 02:24:54 +00002735int yyparse ();
Reid Spencer7780acb2007-04-16 06:56:07 +00002736# endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002737#else /* ! YYPARSE_PARAM */
Reid Spencer7780acb2007-04-16 06:56:07 +00002738#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002739int yyparse (void);
Chris Lattner32980692007-02-19 07:44:24 +00002740#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002741int yyparse ();
2742#endif
2743#endif /* ! YYPARSE_PARAM */
2744
2745
2746
2747/* The look-ahead symbol. */
2748int yychar;
2749
2750/* The semantic value of the look-ahead symbol. */
2751YYSTYPE yylval;
2752
2753/* Number of syntax errors so far. */
2754int yynerrs;
2755
2756
2757
2758/*----------.
2759| yyparse. |
2760`----------*/
2761
2762#ifdef YYPARSE_PARAM
Reid Spencer7780acb2007-04-16 06:56:07 +00002763# if defined (__STDC__) || defined (__cplusplus)
2764int yyparse (void *YYPARSE_PARAM)
2765# else
2766int yyparse (YYPARSE_PARAM)
2767 void *YYPARSE_PARAM;
2768# endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002769#else /* ! YYPARSE_PARAM */
Reid Spencer7780acb2007-04-16 06:56:07 +00002770#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002771int
2772yyparse (void)
2773#else
2774int
2775yyparse ()
2776
2777#endif
2778#endif
2779{
2780
2781 int yystate;
2782 int yyn;
2783 int yyresult;
2784 /* Number of tokens to shift before error messages enabled. */
2785 int yyerrstatus;
2786 /* Look-ahead token as an internal (translated) token number. */
2787 int yytoken = 0;
2788
2789 /* Three stacks and their tools:
2790 `yyss': related to states,
2791 `yyvs': related to semantic values,
2792 `yyls': related to locations.
2793
2794 Refer to the stacks thru separate pointers, to allow yyoverflow
2795 to reallocate them elsewhere. */
2796
2797 /* The state stack. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002798 short int yyssa[YYINITDEPTH];
2799 short int *yyss = yyssa;
2800 short int *yyssp;
Reid Spencer38c91a92007-02-28 02:24:54 +00002801
2802 /* The semantic value stack. */
2803 YYSTYPE yyvsa[YYINITDEPTH];
2804 YYSTYPE *yyvs = yyvsa;
2805 YYSTYPE *yyvsp;
2806
2807
2808
Reid Spencer7780acb2007-04-16 06:56:07 +00002809#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002810
Reid Spencer38c91a92007-02-28 02:24:54 +00002811 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002812
Reid Spencer38c91a92007-02-28 02:24:54 +00002813 /* The variables used to return semantic value and location from the
2814 action routines. */
2815 YYSTYPE yyval;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002816
Chris Lattner7d9801d2007-02-13 00:58:01 +00002817
Reid Spencer7780acb2007-04-16 06:56:07 +00002818 /* When reducing, the number of symbols on the RHS of the reduced
2819 rule. */
2820 int yylen;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002821
Reid Spencer38c91a92007-02-28 02:24:54 +00002822 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner7d9801d2007-02-13 00:58:01 +00002823
Reid Spencer68a24bd2005-08-27 18:50:39 +00002824 yystate = 0;
2825 yyerrstatus = 0;
2826 yynerrs = 0;
2827 yychar = YYEMPTY; /* Cause a token to be read. */
2828
2829 /* Initialize stack pointers.
2830 Waste one element of value and location stack
2831 so that they stay on the same level as the state stack.
2832 The wasted elements are never initialized. */
2833
Reid Spencer38c91a92007-02-28 02:24:54 +00002834 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002835 yyvsp = yyvs;
2836
Reid Spencer38c91a92007-02-28 02:24:54 +00002837 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002838
Reid Spencer38c91a92007-02-28 02:24:54 +00002839/*------------------------------------------------------------.
2840| yynewstate -- Push a new state, which is found in yystate. |
2841`------------------------------------------------------------*/
2842 yynewstate:
2843 /* In all cases, when you get here, the value and location stacks
Reid Spencer7780acb2007-04-16 06:56:07 +00002844 have just been pushed. so pushing a state here evens the stacks.
2845 */
Reid Spencer38c91a92007-02-28 02:24:54 +00002846 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002847
Reid Spencer38c91a92007-02-28 02:24:54 +00002848 yysetstate:
2849 *yyssp = yystate;
2850
2851 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002852 {
2853 /* Get the current used size of the three stacks, in elements. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002854 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002855
2856#ifdef yyoverflow
Reid Spencer38c91a92007-02-28 02:24:54 +00002857 {
Reid Spencer7780acb2007-04-16 06:56:07 +00002858 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer38c91a92007-02-28 02:24:54 +00002859 these so that the &'s don't force the real ones into
2860 memory. */
2861 YYSTYPE *yyvs1 = yyvs;
Reid Spencer7780acb2007-04-16 06:56:07 +00002862 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002863
Reid Spencer38c91a92007-02-28 02:24:54 +00002864
2865 /* Each stack pointer address is followed by the size of the
2866 data in use in that stack, in bytes. This used to be a
2867 conditional around just the two extra args, but that might
2868 be undefined if yyoverflow is a macro. */
2869 yyoverflow (YY_("memory exhausted"),
2870 &yyss1, yysize * sizeof (*yyssp),
2871 &yyvs1, yysize * sizeof (*yyvsp),
2872
2873 &yystacksize);
2874
2875 yyss = yyss1;
2876 yyvs = yyvs1;
2877 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002878#else /* no yyoverflow */
Reid Spencer38c91a92007-02-28 02:24:54 +00002879# ifndef YYSTACK_RELOCATE
2880 goto yyexhaustedlab;
2881# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002882 /* Extend the stack our own way. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002883 if (YYMAXDEPTH <= yystacksize)
2884 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002885 yystacksize *= 2;
Reid Spencer38c91a92007-02-28 02:24:54 +00002886 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002887 yystacksize = YYMAXDEPTH;
Reid Spencer38c91a92007-02-28 02:24:54 +00002888
2889 {
Reid Spencer7780acb2007-04-16 06:56:07 +00002890 short int *yyss1 = yyss;
Reid Spencer38c91a92007-02-28 02:24:54 +00002891 union yyalloc *yyptr =
2892 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2893 if (! yyptr)
2894 goto yyexhaustedlab;
2895 YYSTACK_RELOCATE (yyss);
2896 YYSTACK_RELOCATE (yyvs);
2897
2898# undef YYSTACK_RELOCATE
2899 if (yyss1 != yyssa)
2900 YYSTACK_FREE (yyss1);
2901 }
2902# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002903#endif /* no yyoverflow */
2904
Reid Spencer38c91a92007-02-28 02:24:54 +00002905 yyssp = yyss + yysize - 1;
2906 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002907
2908
Reid Spencer38c91a92007-02-28 02:24:54 +00002909 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2910 (unsigned long int) yystacksize));
2911
2912 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002913 YYABORT;
2914 }
2915
Reid Spencer38c91a92007-02-28 02:24:54 +00002916 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002917
2918 goto yybackup;
Reid Spencer38c91a92007-02-28 02:24:54 +00002919
2920/*-----------.
2921| yybackup. |
2922`-----------*/
2923yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002924
Reid Spencer7780acb2007-04-16 06:56:07 +00002925/* Do appropriate processing given the current state. */
2926/* Read a look-ahead token if we need one and don't already have one. */
2927/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002928
Reid Spencer38c91a92007-02-28 02:24:54 +00002929 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002930
Reid Spencer68a24bd2005-08-27 18:50:39 +00002931 yyn = yypact[yystate];
Reid Spencer38c91a92007-02-28 02:24:54 +00002932 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002933 goto yydefault;
2934
Reid Spencer38c91a92007-02-28 02:24:54 +00002935 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002936
Reid Spencer38c91a92007-02-28 02:24:54 +00002937 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002938 if (yychar == YYEMPTY)
2939 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002940 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002941 yychar = YYLEX;
2942 }
2943
Reid Spencer38c91a92007-02-28 02:24:54 +00002944 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002945 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002946 yychar = yytoken = YYEOF;
2947 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002948 }
2949 else
2950 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002951 yytoken = YYTRANSLATE (yychar);
2952 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002953 }
2954
Reid Spencer38c91a92007-02-28 02:24:54 +00002955 /* If the proper action on seeing token YYTOKEN is to reduce or to
2956 detect an error, take that action. */
2957 yyn += yytoken;
2958 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002959 goto yydefault;
2960 yyn = yytable[yyn];
Reid Spencer38c91a92007-02-28 02:24:54 +00002961 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002962 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002963 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002964 goto yyerrlab;
2965 yyn = -yyn;
2966 goto yyreduce;
2967 }
2968
2969 if (yyn == YYFINAL)
2970 YYACCEPT;
2971
Reid Spencer7780acb2007-04-16 06:56:07 +00002972 /* Shift the look-ahead token. */
2973 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2974
2975 /* Discard the token being shifted unless it is eof. */
2976 if (yychar != YYEOF)
2977 yychar = YYEMPTY;
2978
2979 *++yyvsp = yylval;
2980
2981
Reid Spencer38c91a92007-02-28 02:24:54 +00002982 /* Count tokens shifted since error; after three, turn off error
2983 status. */
2984 if (yyerrstatus)
2985 yyerrstatus--;
Chris Lattner9d2fda62007-02-13 05:53:56 +00002986
2987 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002988 goto yynewstate;
2989
Chris Lattner32980692007-02-19 07:44:24 +00002990
Reid Spencer38c91a92007-02-28 02:24:54 +00002991/*-----------------------------------------------------------.
2992| yydefault -- do the default action for the current state. |
2993`-----------------------------------------------------------*/
2994yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002995 yyn = yydefact[yystate];
2996 if (yyn == 0)
2997 goto yyerrlab;
Reid Spencer38c91a92007-02-28 02:24:54 +00002998 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002999
Reid Spencer38c91a92007-02-28 02:24:54 +00003000
3001/*-----------------------------.
3002| yyreduce -- Do a reduction. |
3003`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003004yyreduce:
Reid Spencer38c91a92007-02-28 02:24:54 +00003005 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003006 yylen = yyr2[yyn];
3007
Reid Spencer38c91a92007-02-28 02:24:54 +00003008 /* If YYLEN is nonzero, implement the default value of the action:
3009 `$$ = $1'.
3010
3011 Otherwise, the following line sets YYVAL to garbage.
3012 This behavior is undocumented and Bison
3013 users should not rely upon it. Assigning to YYVAL
3014 unconditionally makes the parser a bit smaller, and it avoids a
3015 GCC warning that YYVAL may be used uninitialized. */
3016 yyval = yyvsp[1-yylen];
3017
3018
3019 YY_REDUCE_PRINT (yyn);
3020 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003021 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003022 case 29:
Reid Spencer7780acb2007-04-16 06:56:07 +00003023#line 1099 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003024 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3025 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003026
Reid Spencer38c91a92007-02-28 02:24:54 +00003027 case 30:
Reid Spencer7780acb2007-04-16 06:56:07 +00003028#line 1099 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003029 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3030 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003031
Reid Spencer38c91a92007-02-28 02:24:54 +00003032 case 31:
Reid Spencer7780acb2007-04-16 06:56:07 +00003033#line 1100 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003034 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3035 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003036
Reid Spencer38c91a92007-02-28 02:24:54 +00003037 case 32:
Reid Spencer7780acb2007-04-16 06:56:07 +00003038#line 1100 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003039 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3040 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003041
Reid Spencer38c91a92007-02-28 02:24:54 +00003042 case 33:
Reid Spencer7780acb2007-04-16 06:56:07 +00003043#line 1101 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003044 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3045 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003046
Reid Spencer38c91a92007-02-28 02:24:54 +00003047 case 34:
Reid Spencer7780acb2007-04-16 06:56:07 +00003048#line 1101 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003049 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3050 break;
3051
3052 case 35:
Reid Spencer7780acb2007-04-16 06:56:07 +00003053#line 1102 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003054 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3055 break;
3056
3057 case 36:
Reid Spencer7780acb2007-04-16 06:56:07 +00003058#line 1102 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003059 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3060 break;
3061
3062 case 37:
Reid Spencer7780acb2007-04-16 06:56:07 +00003063#line 1103 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003064 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3065 break;
3066
3067 case 38:
Reid Spencer7780acb2007-04-16 06:56:07 +00003068#line 1103 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003069 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3070 break;
3071
3072 case 39:
Reid Spencer7780acb2007-04-16 06:56:07 +00003073#line 1107 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003074 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3075 break;
3076
3077 case 40:
Reid Spencer7780acb2007-04-16 06:56:07 +00003078#line 1107 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003079 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3080 break;
3081
3082 case 41:
Reid Spencer7780acb2007-04-16 06:56:07 +00003083#line 1108 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003084 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3085 break;
3086
3087 case 42:
Reid Spencer7780acb2007-04-16 06:56:07 +00003088#line 1108 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003089 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3090 break;
3091
3092 case 43:
Reid Spencer7780acb2007-04-16 06:56:07 +00003093#line 1109 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003094 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3095 break;
3096
3097 case 44:
Reid Spencer7780acb2007-04-16 06:56:07 +00003098#line 1109 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003099 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3100 break;
3101
3102 case 45:
Reid Spencer7780acb2007-04-16 06:56:07 +00003103#line 1110 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003104 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3105 break;
3106
3107 case 46:
Reid Spencer7780acb2007-04-16 06:56:07 +00003108#line 1110 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003109 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3110 break;
3111
3112 case 47:
Reid Spencer7780acb2007-04-16 06:56:07 +00003113#line 1111 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003114 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3115 break;
3116
3117 case 48:
Reid Spencer7780acb2007-04-16 06:56:07 +00003118#line 1111 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003119 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3120 break;
3121
3122 case 49:
Reid Spencer7780acb2007-04-16 06:56:07 +00003123#line 1112 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003124 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3125 break;
3126
3127 case 50:
Reid Spencer7780acb2007-04-16 06:56:07 +00003128#line 1112 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003129 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3130 break;
3131
3132 case 51:
Reid Spencer7780acb2007-04-16 06:56:07 +00003133#line 1113 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003134 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3135 break;
3136
3137 case 52:
Reid Spencer7780acb2007-04-16 06:56:07 +00003138#line 1113 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003139 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3140 break;
3141
3142 case 53:
Reid Spencer7780acb2007-04-16 06:56:07 +00003143#line 1114 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003144 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3145 break;
3146
3147 case 54:
Reid Spencer7780acb2007-04-16 06:56:07 +00003148#line 1115 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003149 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3150 break;
3151
3152 case 61:
Reid Spencer7780acb2007-04-16 06:56:07 +00003153#line 1124 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003154 { (yyval.StrVal) = 0; ;}
3155 break;
3156
3157 case 62:
Reid Spencer7780acb2007-04-16 06:56:07 +00003158#line 1128 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003159 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003160 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003161 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003162 ;}
3163 break;
3164
3165 case 63:
Reid Spencer7780acb2007-04-16 06:56:07 +00003166#line 1132 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003167 {
3168 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003169 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003170 ;}
3171 break;
3172
3173 case 66:
Reid Spencer7780acb2007-04-16 06:56:07 +00003174#line 1139 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003175 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003176 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003177 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003178 ;}
3179 break;
3180
3181 case 67:
Reid Spencer7780acb2007-04-16 06:56:07 +00003182#line 1143 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003183 {
3184 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003185 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003186 ;}
3187 break;
3188
3189 case 68:
Reid Spencer7780acb2007-04-16 06:56:07 +00003190#line 1149 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003191 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3192 break;
3193
3194 case 69:
Reid Spencer7780acb2007-04-16 06:56:07 +00003195#line 1150 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003196 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3197 break;
3198
3199 case 70:
Reid Spencer7780acb2007-04-16 06:56:07 +00003200#line 1151 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003201 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3202 break;
3203
3204 case 71:
Reid Spencer7780acb2007-04-16 06:56:07 +00003205#line 1152 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003206 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3207 break;
3208
3209 case 72:
Reid Spencer7780acb2007-04-16 06:56:07 +00003210#line 1153 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003211 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3212 break;
3213
3214 case 73:
Reid Spencer7780acb2007-04-16 06:56:07 +00003215#line 1157 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003216 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3217 break;
3218
3219 case 74:
Reid Spencer7780acb2007-04-16 06:56:07 +00003220#line 1158 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003221 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3222 break;
3223
3224 case 75:
Reid Spencer7780acb2007-04-16 06:56:07 +00003225#line 1159 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003226 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3227 break;
3228
3229 case 76:
Reid Spencer7780acb2007-04-16 06:56:07 +00003230#line 1163 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003231 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3232 break;
3233
3234 case 77:
Reid Spencer7780acb2007-04-16 06:56:07 +00003235#line 1164 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003236 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3237 break;
3238
3239 case 78:
Reid Spencer7780acb2007-04-16 06:56:07 +00003240#line 1168 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003241 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3242 break;
3243
3244 case 79:
Reid Spencer7780acb2007-04-16 06:56:07 +00003245#line 1169 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003246 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3247 break;
3248
3249 case 80:
Reid Spencer7780acb2007-04-16 06:56:07 +00003250#line 1170 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003251 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3252 break;
3253
3254 case 81:
Reid Spencer7780acb2007-04-16 06:56:07 +00003255#line 1174 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003256 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3257 break;
3258
3259 case 82:
Reid Spencer7780acb2007-04-16 06:56:07 +00003260#line 1175 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003261 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3262 break;
3263
3264 case 83:
Reid Spencer7780acb2007-04-16 06:56:07 +00003265#line 1176 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003266 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3267 break;
3268
3269 case 84:
Reid Spencer7780acb2007-04-16 06:56:07 +00003270#line 1177 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003271 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3272 break;
3273
3274 case 85:
Reid Spencer7780acb2007-04-16 06:56:07 +00003275#line 1178 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003276 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3277 break;
3278
3279 case 86:
Reid Spencer7780acb2007-04-16 06:56:07 +00003280#line 1181 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003281 { (yyval.UIntVal) = CallingConv::C; ;}
3282 break;
3283
3284 case 87:
Reid Spencer7780acb2007-04-16 06:56:07 +00003285#line 1182 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003286 { (yyval.UIntVal) = CallingConv::C; ;}
3287 break;
3288
3289 case 88:
Reid Spencer7780acb2007-04-16 06:56:07 +00003290#line 1183 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003291 { (yyval.UIntVal) = CallingConv::Fast; ;}
3292 break;
3293
3294 case 89:
Reid Spencer7780acb2007-04-16 06:56:07 +00003295#line 1184 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003296 { (yyval.UIntVal) = CallingConv::Cold; ;}
3297 break;
3298
3299 case 90:
Reid Spencer7780acb2007-04-16 06:56:07 +00003300#line 1185 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003301 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3302 break;
3303
3304 case 91:
Reid Spencer7780acb2007-04-16 06:56:07 +00003305#line 1186 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003306 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3307 break;
3308
3309 case 92:
Reid Spencer7780acb2007-04-16 06:56:07 +00003310#line 1187 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003311 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003312 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003313 GEN_ERROR("Calling conv too large");
Reid Spencer7780acb2007-04-16 06:56:07 +00003314 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003315 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003316 ;}
3317 break;
3318
3319 case 93:
Reid Spencer7780acb2007-04-16 06:56:07 +00003320#line 1194 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003321 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003322 break;
3323
3324 case 94:
Reid Spencer7780acb2007-04-16 06:56:07 +00003325#line 1195 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003326 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003327 break;
3328
3329 case 95:
Reid Spencer7780acb2007-04-16 06:56:07 +00003330#line 1196 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003331 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003332 break;
3333
3334 case 96:
Reid Spencer7780acb2007-04-16 06:56:07 +00003335#line 1197 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003336 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003337 break;
3338
3339 case 97:
Reid Spencer7780acb2007-04-16 06:56:07 +00003340#line 1200 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003341 { (yyval.ParamAttrs) = ParamAttr::None; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003342 break;
3343
3344 case 98:
Reid Spencer7780acb2007-04-16 06:56:07 +00003345#line 1201 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003346 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003347 (yyval.ParamAttrs) = (yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs);
Reid Spencer38c91a92007-02-28 02:24:54 +00003348 ;}
3349 break;
3350
3351 case 99:
Reid Spencer7780acb2007-04-16 06:56:07 +00003352#line 1206 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003353 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003354 break;
3355
Reid Spencer67d8ed92007-03-22 02:14:08 +00003356 case 100:
Reid Spencer7780acb2007-04-16 06:56:07 +00003357#line 1207 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003358 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003359 break;
3360
3361 case 102:
Reid Spencer7780acb2007-04-16 06:56:07 +00003362#line 1211 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003363 { (yyval.ParamAttrs) = ParamAttr::None; ;}
Reid Spencer67d8ed92007-03-22 02:14:08 +00003364 break;
3365
3366 case 103:
Reid Spencer7780acb2007-04-16 06:56:07 +00003367#line 1212 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003368 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003369 (yyval.ParamAttrs) = (yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs);
Reid Spencer38c91a92007-02-28 02:24:54 +00003370 ;}
3371 break;
3372
Reid Spencer67d8ed92007-03-22 02:14:08 +00003373 case 104:
Reid Spencer7780acb2007-04-16 06:56:07 +00003374#line 1219 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003375 { (yyval.UIntVal) = 0; ;}
3376 break;
3377
Reid Spencer67d8ed92007-03-22 02:14:08 +00003378 case 105:
Reid Spencer7780acb2007-04-16 06:56:07 +00003379#line 1220 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003380 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003381 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer38c91a92007-02-28 02:24:54 +00003382 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003383 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003384 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003385;}
3386 break;
3387
Reid Spencer66728ef2007-03-20 01:13:36 +00003388 case 106:
Reid Spencer7780acb2007-04-16 06:56:07 +00003389#line 1226 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003390 { (yyval.UIntVal) = 0; ;}
3391 break;
3392
3393 case 107:
Reid Spencer7780acb2007-04-16 06:56:07 +00003394#line 1227 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer66728ef2007-03-20 01:13:36 +00003395 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003396 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer66728ef2007-03-20 01:13:36 +00003397 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3398 GEN_ERROR("Alignment must be a power of two");
3399 CHECK_FOR_ERROR
3400;}
3401 break;
3402
Reid Spencer67d8ed92007-03-22 02:14:08 +00003403 case 108:
Reid Spencer7780acb2007-04-16 06:56:07 +00003404#line 1235 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003405 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003406 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3407 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003408 GEN_ERROR("Invalid character in section name");
Reid Spencer7780acb2007-04-16 06:56:07 +00003409 (yyval.StrVal) = (yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003410 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003411;}
3412 break;
3413
Reid Spencer67d8ed92007-03-22 02:14:08 +00003414 case 109:
Reid Spencer7780acb2007-04-16 06:56:07 +00003415#line 1243 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003416 { (yyval.StrVal) = 0; ;}
3417 break;
3418
Reid Spencer38c91a92007-02-28 02:24:54 +00003419 case 110:
Reid Spencer7780acb2007-04-16 06:56:07 +00003420#line 1244 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
3421 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003422 break;
3423
3424 case 111:
Reid Spencer7780acb2007-04-16 06:56:07 +00003425#line 1249 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003426 {;}
3427 break;
3428
3429 case 112:
Reid Spencer7780acb2007-04-16 06:56:07 +00003430#line 1250 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003431 {;}
3432 break;
3433
3434 case 113:
Reid Spencer7780acb2007-04-16 06:56:07 +00003435#line 1251 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003436 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003437 CurGV->setSection((yyvsp[0].StrVal));
3438 free((yyvsp[0].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003439 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003440 ;}
3441 break;
3442
Reid Spencer67d8ed92007-03-22 02:14:08 +00003443 case 114:
Reid Spencer7780acb2007-04-16 06:56:07 +00003444#line 1256 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003445 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003446 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003447 GEN_ERROR("Alignment must be a power of two");
Reid Spencer7780acb2007-04-16 06:56:07 +00003448 CurGV->setAlignment((yyvsp[0].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003449 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003450 ;}
3451 break;
3452
Reid Spencer67d8ed92007-03-22 02:14:08 +00003453 case 119:
Reid Spencer7780acb2007-04-16 06:56:07 +00003454#line 1272 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003455 {
3456 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003457 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003458 ;}
3459 break;
3460
Reid Spencer67d8ed92007-03-22 02:14:08 +00003461 case 120:
Reid Spencer7780acb2007-04-16 06:56:07 +00003462#line 1276 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003463 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003464 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003465 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003466 ;}
3467 break;
3468
Reid Spencer67d8ed92007-03-22 02:14:08 +00003469 case 121:
Reid Spencer7780acb2007-04-16 06:56:07 +00003470#line 1280 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003471 { // Pointer type?
Reid Spencer7780acb2007-04-16 06:56:07 +00003472 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003473 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencer7780acb2007-04-16 06:56:07 +00003474 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3475 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003476 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003477 ;}
3478 break;
3479
Reid Spencer67d8ed92007-03-22 02:14:08 +00003480 case 122:
Reid Spencer7780acb2007-04-16 06:56:07 +00003481#line 1287 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003482 { // Named types are also simple types...
Reid Spencer7780acb2007-04-16 06:56:07 +00003483 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003484 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003485 (yyval.TypeVal) = new PATypeHolder(tmp);
3486 ;}
3487 break;
3488
Reid Spencer67d8ed92007-03-22 02:14:08 +00003489 case 123:
Reid Spencer7780acb2007-04-16 06:56:07 +00003490#line 1292 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003491 { // Type UpReference
Reid Spencer7780acb2007-04-16 06:56:07 +00003492 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003493 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer7780acb2007-04-16 06:56:07 +00003494 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
Reid Spencer38c91a92007-02-28 02:24:54 +00003495 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003496 UR_OUT("New Upreference!\n");
3497 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003498 ;}
3499 break;
3500
Reid Spencer67d8ed92007-03-22 02:14:08 +00003501 case 124:
Reid Spencer7780acb2007-04-16 06:56:07 +00003502#line 1300 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003503 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003504 std::vector<const Type*> Params;
Reid Spencer7b5d4662007-04-09 06:16:21 +00003505 ParamAttrsList Attrs;
Reid Spencer7780acb2007-04-16 06:56:07 +00003506 if ((yyvsp[0].ParamAttrs) != ParamAttr::None)
3507 Attrs.addAttributes(0, (yyvsp[0].ParamAttrs));
Reid Spencer7b5d4662007-04-09 06:16:21 +00003508 unsigned index = 1;
Reid Spencer7780acb2007-04-16 06:56:07 +00003509 TypeWithAttrsList::iterator I = (yyvsp[-2].TypeWithAttrsList)->begin(), E = (yyvsp[-2].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003510 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003511 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003512 Params.push_back(Ty);
3513 if (Ty != Type::VoidTy)
Reid Spencer18da0722007-04-11 02:44:20 +00003514 if (I->Attrs != ParamAttr::None)
Reid Spencer7b5d4662007-04-09 06:16:21 +00003515 Attrs.addAttributes(index, I->Attrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003516 }
3517 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3518 if (isVarArg) Params.pop_back();
3519
Reid Spencer7b5d4662007-04-09 06:16:21 +00003520 ParamAttrsList *ActualAttrs = 0;
3521 if (!Attrs.empty())
3522 ActualAttrs = new ParamAttrsList(Attrs);
Reid Spencer7780acb2007-04-16 06:56:07 +00003523 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, ActualAttrs);
3524 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3525 delete (yyvsp[-4].TypeVal); // Delete the return type handle
Reid Spencer38c91a92007-02-28 02:24:54 +00003526 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003527 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003528 ;}
3529 break;
3530
Reid Spencer67d8ed92007-03-22 02:14:08 +00003531 case 125:
Reid Spencer7780acb2007-04-16 06:56:07 +00003532#line 1326 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003533 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003534 std::vector<const Type*> Params;
Reid Spencer7b5d4662007-04-09 06:16:21 +00003535 ParamAttrsList Attrs;
Reid Spencer7780acb2007-04-16 06:56:07 +00003536 if ((yyvsp[0].ParamAttrs) != ParamAttr::None)
3537 Attrs.addAttributes(0, (yyvsp[0].ParamAttrs));
3538 TypeWithAttrsList::iterator I = (yyvsp[-2].TypeWithAttrsList)->begin(), E = (yyvsp[-2].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003539 unsigned index = 1;
3540 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003541 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003542 Params.push_back(Ty);
3543 if (Ty != Type::VoidTy)
Reid Spencer18da0722007-04-11 02:44:20 +00003544 if (I->Attrs != ParamAttr::None)
Reid Spencer7b5d4662007-04-09 06:16:21 +00003545 Attrs.addAttributes(index, I->Attrs);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003546 }
3547 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3548 if (isVarArg) Params.pop_back();
3549
Reid Spencer7b5d4662007-04-09 06:16:21 +00003550 ParamAttrsList *ActualAttrs = 0;
3551 if (!Attrs.empty())
3552 ActualAttrs = new ParamAttrsList(Attrs);
3553
Reid Spencer7780acb2007-04-16 06:56:07 +00003554 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, ActualAttrs);
3555 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
Reid Spencer38c91a92007-02-28 02:24:54 +00003556 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003557 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003558 ;}
3559 break;
3560
Reid Spencer67d8ed92007-03-22 02:14:08 +00003561 case 126:
Reid Spencer7780acb2007-04-16 06:56:07 +00003562#line 1353 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003563 { // Sized array type?
Reid Spencer7780acb2007-04-16 06:56:07 +00003564 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3565 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003566 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003567 ;}
3568 break;
3569
Reid Spencer67d8ed92007-03-22 02:14:08 +00003570 case 127:
Reid Spencer7780acb2007-04-16 06:56:07 +00003571#line 1358 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003572 { // Vector type?
Reid Spencer7780acb2007-04-16 06:56:07 +00003573 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3574 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003575 GEN_ERROR("Unsigned result not equal to signed result");
3576 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencer9d6565a2007-02-15 02:26:10 +00003577 GEN_ERROR("Element type of a VectorType must be primitive");
Reid Spencer7780acb2007-04-16 06:56:07 +00003578 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003579 GEN_ERROR("Vector length should be a power of 2");
Reid Spencer7780acb2007-04-16 06:56:07 +00003580 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3581 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003582 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003583 ;}
3584 break;
3585
Reid Spencer67d8ed92007-03-22 02:14:08 +00003586 case 128:
Reid Spencer7780acb2007-04-16 06:56:07 +00003587#line 1370 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003588 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003589 std::vector<const Type*> Elements;
Reid Spencer7780acb2007-04-16 06:56:07 +00003590 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3591 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003592 Elements.push_back(*I);
3593
Reid Spencer38c91a92007-02-28 02:24:54 +00003594 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
Reid Spencer7780acb2007-04-16 06:56:07 +00003595 delete (yyvsp[-1].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003596 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003597 ;}
3598 break;
3599
Reid Spencer67d8ed92007-03-22 02:14:08 +00003600 case 129:
Reid Spencer7780acb2007-04-16 06:56:07 +00003601#line 1380 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003602 { // Empty structure type?
3603 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003604 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003605 ;}
3606 break;
3607
Reid Spencer67d8ed92007-03-22 02:14:08 +00003608 case 130:
Reid Spencer7780acb2007-04-16 06:56:07 +00003609#line 1384 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003610 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003611 std::vector<const Type*> Elements;
Reid Spencer7780acb2007-04-16 06:56:07 +00003612 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3613 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003614 Elements.push_back(*I);
3615
Reid Spencer38c91a92007-02-28 02:24:54 +00003616 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
Reid Spencer7780acb2007-04-16 06:56:07 +00003617 delete (yyvsp[-2].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003618 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003619 ;}
3620 break;
3621
Reid Spencer67d8ed92007-03-22 02:14:08 +00003622 case 131:
Reid Spencer7780acb2007-04-16 06:56:07 +00003623#line 1394 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003624 { // Empty structure type?
3625 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003626 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003627 ;}
3628 break;
3629
Reid Spencer67d8ed92007-03-22 02:14:08 +00003630 case 132:
Reid Spencer7780acb2007-04-16 06:56:07 +00003631#line 1401 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003632 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003633 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3634 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
Reid Spencer38c91a92007-02-28 02:24:54 +00003635 ;}
3636 break;
3637
Reid Spencer67d8ed92007-03-22 02:14:08 +00003638 case 133:
Reid Spencer7780acb2007-04-16 06:56:07 +00003639#line 1408 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003640 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003641 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00003642 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3643 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003644 GEN_ERROR("LLVM functions cannot return aggregate types");
Reid Spencer7780acb2007-04-16 06:56:07 +00003645 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00003646 ;}
3647 break;
3648
Reid Spencer67d8ed92007-03-22 02:14:08 +00003649 case 134:
Reid Spencer7780acb2007-04-16 06:56:07 +00003650#line 1415 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003651 {
3652 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3653 ;}
3654 break;
3655
Reid Spencer67d8ed92007-03-22 02:14:08 +00003656 case 135:
Reid Spencer7780acb2007-04-16 06:56:07 +00003657#line 1420 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003658 {
3659 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer7780acb2007-04-16 06:56:07 +00003660 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003661 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003662 ;}
3663 break;
3664
Reid Spencer67d8ed92007-03-22 02:14:08 +00003665 case 136:
Reid Spencer7780acb2007-04-16 06:56:07 +00003666#line 1425 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003667 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003668 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003669 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003670 ;}
3671 break;
3672
Reid Spencer67d8ed92007-03-22 02:14:08 +00003673 case 138:
Reid Spencer7780acb2007-04-16 06:56:07 +00003674#line 1433 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003675 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003676 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00003677 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003678 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003679 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003680 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003681 ;}
3682 break;
3683
Reid Spencer67d8ed92007-03-22 02:14:08 +00003684 case 139:
Reid Spencer7780acb2007-04-16 06:56:07 +00003685#line 1440 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003686 {
3687 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003688 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003689 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003690 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003691 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003692 ;}
3693 break;
3694
Reid Spencer67d8ed92007-03-22 02:14:08 +00003695 case 140:
Reid Spencer7780acb2007-04-16 06:56:07 +00003696#line 1447 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003697 {
3698 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003699 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003700 ;}
3701 break;
3702
Reid Spencer67d8ed92007-03-22 02:14:08 +00003703 case 141:
Reid Spencer7780acb2007-04-16 06:56:07 +00003704#line 1455 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003705 {
3706 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer7780acb2007-04-16 06:56:07 +00003707 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal));
3708 delete (yyvsp[0].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003709 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003710 ;}
3711 break;
3712
Reid Spencer67d8ed92007-03-22 02:14:08 +00003713 case 142:
Reid Spencer7780acb2007-04-16 06:56:07 +00003714#line 1461 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003715 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003716 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal));
3717 delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003718 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003719 ;}
3720 break;
3721
Reid Spencer67d8ed92007-03-22 02:14:08 +00003722 case 143:
Reid Spencer7780acb2007-04-16 06:56:07 +00003723#line 1473 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003724 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003725 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00003726 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3727 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003728 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003729 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00003730 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003731 const Type *ETy = ATy->getElementType();
3732 int NumElements = ATy->getNumElements();
3733
3734 // Verify that we have the correct size...
Reid Spencer7780acb2007-04-16 06:56:07 +00003735 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003736 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer7780acb2007-04-16 06:56:07 +00003737 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003738 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003739
3740 // Verify all elements are correct type!
Reid Spencer7780acb2007-04-16 06:56:07 +00003741 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3742 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003743 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3744 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer7780acb2007-04-16 06:56:07 +00003745 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003746 }
3747
Reid Spencer7780acb2007-04-16 06:56:07 +00003748 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3749 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003750 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003751 ;}
3752 break;
3753
Reid Spencer67d8ed92007-03-22 02:14:08 +00003754 case 144:
Reid Spencer7780acb2007-04-16 06:56:07 +00003755#line 1501 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003756 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003757 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00003758 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3759 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003760 if (ATy == 0)
3761 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00003762 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003763
Andrew Lenharth6353e052006-12-08 18:07:09 +00003764 int NumElements = ATy->getNumElements();
3765 if (NumElements != -1 && NumElements != 0)
3766 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003767 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer38c91a92007-02-28 02:24:54 +00003768 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencer7780acb2007-04-16 06:56:07 +00003769 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003770 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003771 ;}
3772 break;
3773
Reid Spencer67d8ed92007-03-22 02:14:08 +00003774 case 145:
Reid Spencer7780acb2007-04-16 06:56:07 +00003775#line 1517 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003776 {
Reid Spencer14310612006-12-31 05:40:51 +00003777 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00003778 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3779 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003780 if (ATy == 0)
3781 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00003782 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00003783
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003784 int NumElements = ATy->getNumElements();
3785 const Type *ETy = ATy->getElementType();
Reid Spencer7780acb2007-04-16 06:56:07 +00003786 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3787 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003788 GEN_ERROR("Can't build string constant of size " +
Reid Spencer7780acb2007-04-16 06:56:07 +00003789 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003790 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003791 std::vector<Constant*> Vals;
3792 if (ETy == Type::Int8Ty) {
Reid Spencer7780acb2007-04-16 06:56:07 +00003793 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003794 C != (unsigned char*)EndStr; ++C)
3795 Vals.push_back(ConstantInt::get(ETy, *C));
3796 } else {
Reid Spencer7780acb2007-04-16 06:56:07 +00003797 free((yyvsp[0].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00003798 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003799 }
Reid Spencer7780acb2007-04-16 06:56:07 +00003800 free((yyvsp[0].StrVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00003801 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
Reid Spencer7780acb2007-04-16 06:56:07 +00003802 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003803 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003804 ;}
3805 break;
3806
Reid Spencer67d8ed92007-03-22 02:14:08 +00003807 case 146:
Reid Spencer7780acb2007-04-16 06:56:07 +00003808#line 1546 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003809 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003810 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00003811 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3812 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003813 if (PTy == 0)
3814 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00003815 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003816 const Type *ETy = PTy->getElementType();
3817 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003818
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003819 // Verify that we have the correct size...
Reid Spencer7780acb2007-04-16 06:56:07 +00003820 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003821 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer7780acb2007-04-16 06:56:07 +00003822 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003823 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003824
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003825 // Verify all elements are correct type!
Reid Spencer7780acb2007-04-16 06:56:07 +00003826 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3827 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003828 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3829 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer7780acb2007-04-16 06:56:07 +00003830 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003831 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003832
Reid Spencer7780acb2007-04-16 06:56:07 +00003833 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector));
3834 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003835 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003836 ;}
3837 break;
3838
Reid Spencer67d8ed92007-03-22 02:14:08 +00003839 case 147:
Reid Spencer7780acb2007-04-16 06:56:07 +00003840#line 1574 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003841 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003842 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003843 if (STy == 0)
3844 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00003845 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003846
Reid Spencer7780acb2007-04-16 06:56:07 +00003847 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003848 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003849
3850 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer7780acb2007-04-16 06:56:07 +00003851 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3852 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003853 GEN_ERROR("Expected type '" +
3854 STy->getElementType(i)->getDescription() +
3855 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003856 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003857
3858 // Check to ensure that Type is not packed
3859 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003860 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003861
Reid Spencer7780acb2007-04-16 06:56:07 +00003862 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3863 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003864 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003865 ;}
3866 break;
3867
Reid Spencer67d8ed92007-03-22 02:14:08 +00003868 case 148:
Reid Spencer7780acb2007-04-16 06:56:07 +00003869#line 1599 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003870 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003871 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00003872 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3873 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003874 if (STy == 0)
3875 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00003876 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003877
3878 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003879 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003880
3881 // Check to ensure that Type is not packed
3882 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003883 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003884
Reid Spencer38c91a92007-02-28 02:24:54 +00003885 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencer7780acb2007-04-16 06:56:07 +00003886 delete (yyvsp[-2].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003887 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003888 ;}
3889 break;
3890
Reid Spencer67d8ed92007-03-22 02:14:08 +00003891 case 149:
Reid Spencer7780acb2007-04-16 06:56:07 +00003892#line 1618 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003893 {
Reid Spencer7780acb2007-04-16 06:56:07 +00003894 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003895 if (STy == 0)
3896 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00003897 (*(yyvsp[-5].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003898
Reid Spencer7780acb2007-04-16 06:56:07 +00003899 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003900 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003901
3902 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer7780acb2007-04-16 06:56:07 +00003903 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
3904 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003905 GEN_ERROR("Expected type '" +
3906 STy->getElementType(i)->getDescription() +
3907 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003908 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003909
3910 // Check to ensure that Type is packed
3911 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003912 GEN_ERROR("Vector initializer to non-vector type '" +
3913 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003914
Reid Spencer7780acb2007-04-16 06:56:07 +00003915 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
3916 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003917 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003918 ;}
3919 break;
3920
Reid Spencer67d8ed92007-03-22 02:14:08 +00003921 case 150:
Reid Spencer7780acb2007-04-16 06:56:07 +00003922#line 1644 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003923 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003924 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00003925 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
3926 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003927 if (STy == 0)
3928 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00003929 (*(yyvsp[-4].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003930
3931 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003932 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003933
3934 // Check to ensure that Type is packed
3935 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003936 GEN_ERROR("Vector initializer to non-vector type '" +
3937 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003938
Reid Spencer38c91a92007-02-28 02:24:54 +00003939 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencer7780acb2007-04-16 06:56:07 +00003940 delete (yyvsp[-4].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003941 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003942 ;}
3943 break;
3944
Reid Spencer67d8ed92007-03-22 02:14:08 +00003945 case 151:
Reid Spencer7780acb2007-04-16 06:56:07 +00003946#line 1664 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003947 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003948 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00003949 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3950 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003951 if (PTy == 0)
3952 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00003953 (*(yyvsp[-1].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003954
Reid Spencer38c91a92007-02-28 02:24:54 +00003955 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
Reid Spencer7780acb2007-04-16 06:56:07 +00003956 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003957 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003958 ;}
3959 break;
3960
Reid Spencer67d8ed92007-03-22 02:14:08 +00003961 case 152:
Reid Spencer7780acb2007-04-16 06:56:07 +00003962#line 1676 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003963 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003964 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00003965 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3966 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3967 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003968 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003969 ;}
3970 break;
3971
Reid Spencer67d8ed92007-03-22 02:14:08 +00003972 case 153:
Reid Spencer7780acb2007-04-16 06:56:07 +00003973#line 1683 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003974 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003975 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00003976 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3977 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003978 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003979 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003980
3981 // ConstExprs can exist in the body of a function, thus creating
3982 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00003983 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00003984 // symbol table instead of the module symbol table for the global symbol,
3985 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00003986 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00003987 //
3988 Function *SavedCurFn = CurFun.CurrentFunction;
3989 CurFun.CurrentFunction = 0;
3990
Reid Spencer7780acb2007-04-16 06:56:07 +00003991 Value *V = getExistingVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003992 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003993
3994 CurFun.CurrentFunction = SavedCurFn;
3995
3996 // If this is an initializer for a constant pointer, which is referencing a
3997 // (currently) undefined variable, create a stub now that shall be replaced
3998 // in the future with the right type of variable.
3999 //
4000 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004001 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004002 const PointerType *PT = cast<PointerType>(Ty);
4003
4004 // First check to see if the forward references value is already created!
4005 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer7780acb2007-04-16 06:56:07 +00004006 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004007
4008 if (I != CurModule.GlobalRefs.end()) {
4009 V = I->second; // Placeholder already exists, use it...
Reid Spencer7780acb2007-04-16 06:56:07 +00004010 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004011 } else {
4012 std::string Name;
Reid Spencer7780acb2007-04-16 06:56:07 +00004013 if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName)
4014 Name = (yyvsp[0].ValIDVal).Name;
4015 else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004016 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004017
4018 // Create the forward referenced global.
4019 GlobalValue *GV;
4020 if (const FunctionType *FTy =
4021 dyn_cast<FunctionType>(PT->getElementType())) {
4022 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4023 CurModule.CurrentModule);
4024 } else {
4025 GV = new GlobalVariable(PT->getElementType(), false,
4026 GlobalValue::ExternalLinkage, 0,
4027 Name, CurModule.CurrentModule);
4028 }
4029
4030 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer7780acb2007-04-16 06:56:07 +00004031 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004032 V = GV;
4033 }
4034 }
4035
Reid Spencer38c91a92007-02-28 02:24:54 +00004036 (yyval.ConstVal) = cast<GlobalValue>(V);
Reid Spencer7780acb2007-04-16 06:56:07 +00004037 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004038 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004039 ;}
4040 break;
4041
Reid Spencer67d8ed92007-03-22 02:14:08 +00004042 case 154:
Reid Spencer7780acb2007-04-16 06:56:07 +00004043#line 1749 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004044 {
Reid Spencer14310612006-12-31 05:40:51 +00004045 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00004046 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4047 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004048 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencer7780acb2007-04-16 06:56:07 +00004049 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
4050 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4051 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004052 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004053 ;}
4054 break;
4055
Reid Spencer67d8ed92007-03-22 02:14:08 +00004056 case 155:
Reid Spencer7780acb2007-04-16 06:56:07 +00004057#line 1759 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004058 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004059 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00004060 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4061 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004062 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00004063 GEN_ERROR("Cannot create a null initialized value of this type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004064 (yyval.ConstVal) = Constant::getNullValue(Ty);
Reid Spencer7780acb2007-04-16 06:56:07 +00004065 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004066 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004067 ;}
4068 break;
4069
Reid Spencer67d8ed92007-03-22 02:14:08 +00004070 case 156:
Reid Spencer7780acb2007-04-16 06:56:07 +00004071#line 1769 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004072 { // integral constants
Reid Spencer7780acb2007-04-16 06:56:07 +00004073 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004074 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer7780acb2007-04-16 06:56:07 +00004075 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val), true);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004076 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004077 ;}
4078 break;
4079
Reid Spencer67d8ed92007-03-22 02:14:08 +00004080 case 157:
Reid Spencer7780acb2007-04-16 06:56:07 +00004081#line 1775 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004082 { // arbitrary precision integer constants
Reid Spencer7780acb2007-04-16 06:56:07 +00004083 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4084 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
Reid Spencer38c91a92007-02-28 02:24:54 +00004085 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004086 }
Reid Spencer7780acb2007-04-16 06:56:07 +00004087 (yyvsp[0].APIntVal)->sextOrTrunc(BitWidth);
4088 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
4089 delete (yyvsp[0].APIntVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00004090 CHECK_FOR_ERROR
4091 ;}
4092 break;
4093
Reid Spencer67d8ed92007-03-22 02:14:08 +00004094 case 158:
Reid Spencer7780acb2007-04-16 06:56:07 +00004095#line 1785 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004096 { // integral constants
Reid Spencer7780acb2007-04-16 06:56:07 +00004097 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004098 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer7780acb2007-04-16 06:56:07 +00004099 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004100 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004101 ;}
4102 break;
4103
Reid Spencer67d8ed92007-03-22 02:14:08 +00004104 case 159:
Reid Spencer7780acb2007-04-16 06:56:07 +00004105#line 1791 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004106 { // arbitrary precision integer constants
Reid Spencer7780acb2007-04-16 06:56:07 +00004107 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4108 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
Reid Spencer38c91a92007-02-28 02:24:54 +00004109 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004110 }
Reid Spencer7780acb2007-04-16 06:56:07 +00004111 (yyvsp[0].APIntVal)->zextOrTrunc(BitWidth);
4112 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
4113 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004114 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004115 ;}
4116 break;
4117
Reid Spencer67d8ed92007-03-22 02:14:08 +00004118 case 160:
Reid Spencer7780acb2007-04-16 06:56:07 +00004119#line 1801 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004120 { // Boolean constants
Reid Spencer7780acb2007-04-16 06:56:07 +00004121 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
Reid Spencer38c91a92007-02-28 02:24:54 +00004122 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004123 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004124 ;}
4125 break;
4126
Reid Spencer67d8ed92007-03-22 02:14:08 +00004127 case 161:
Reid Spencer7780acb2007-04-16 06:56:07 +00004128#line 1806 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004129 { // Boolean constants
Reid Spencer7780acb2007-04-16 06:56:07 +00004130 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
Reid Spencer38c91a92007-02-28 02:24:54 +00004131 (yyval.ConstVal) = ConstantInt::getFalse();
4132 CHECK_FOR_ERROR
4133 ;}
4134 break;
4135
Reid Spencer67d8ed92007-03-22 02:14:08 +00004136 case 162:
Reid Spencer7780acb2007-04-16 06:56:07 +00004137#line 1811 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004138 { // Float & Double constants
Reid Spencer7780acb2007-04-16 06:56:07 +00004139 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004140 GEN_ERROR("Floating point constant invalid for type");
Reid Spencer7780acb2007-04-16 06:56:07 +00004141 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004142 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004143 ;}
4144 break;
4145
Reid Spencer67d8ed92007-03-22 02:14:08 +00004146 case 163:
Reid Spencer7780acb2007-04-16 06:56:07 +00004147#line 1819 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004148 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004149 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00004150 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4151 Constant *Val = (yyvsp[-3].ConstVal);
4152 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4153 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004154 GEN_ERROR("invalid cast opcode for cast from '" +
4155 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004156 DestTy->getDescription() + "'");
Reid Spencer7780acb2007-04-16 06:56:07 +00004157 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4158 delete (yyvsp[-1].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00004159 ;}
4160 break;
4161
Reid Spencer67d8ed92007-03-22 02:14:08 +00004162 case 164:
Reid Spencer7780acb2007-04-16 06:56:07 +00004163#line 1831 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004164 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004165 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004166 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004167
4168 const Type *IdxTy =
Reid Spencer7780acb2007-04-16 06:56:07 +00004169 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004170 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004171 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004172 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004173
Chris Lattnerf7469af2007-01-31 04:44:08 +00004174 SmallVector<Constant*, 8> IdxVec;
Reid Spencer7780acb2007-04-16 06:56:07 +00004175 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4176 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004177 IdxVec.push_back(C);
4178 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004179 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004180
Reid Spencer7780acb2007-04-16 06:56:07 +00004181 delete (yyvsp[-1].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004182
Reid Spencer7780acb2007-04-16 06:56:07 +00004183 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004184 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004185 ;}
4186 break;
4187
Reid Spencer67d8ed92007-03-22 02:14:08 +00004188 case 165:
Reid Spencer7780acb2007-04-16 06:56:07 +00004189#line 1853 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004190 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004191 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004192 GEN_ERROR("Select condition must be of boolean type");
Reid Spencer7780acb2007-04-16 06:56:07 +00004193 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004194 GEN_ERROR("Select operand types must match");
Reid Spencer7780acb2007-04-16 06:56:07 +00004195 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004196 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004197 ;}
4198 break;
4199
Reid Spencer67d8ed92007-03-22 02:14:08 +00004200 case 166:
Reid Spencer7780acb2007-04-16 06:56:07 +00004201#line 1861 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004202 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004203 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004204 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004205 CHECK_FOR_ERROR;
Reid Spencer7780acb2007-04-16 06:56:07 +00004206 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004207 ;}
4208 break;
4209
Reid Spencer67d8ed92007-03-22 02:14:08 +00004210 case 167:
Reid Spencer7780acb2007-04-16 06:56:07 +00004211#line 1867 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004212 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004213 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004214 GEN_ERROR("Logical operator types must match");
Reid Spencer7780acb2007-04-16 06:56:07 +00004215 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4216 if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].ConstVal)->getType()) ||
4217 !cast<VectorType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004218 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004219 }
Reid Spencer7780acb2007-04-16 06:56:07 +00004220 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004221 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004222 ;}
4223 break;
4224
Reid Spencer67d8ed92007-03-22 02:14:08 +00004225 case 168:
Reid Spencer7780acb2007-04-16 06:56:07 +00004226#line 1878 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004227 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004228 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004229 GEN_ERROR("icmp operand types must match");
Reid Spencer7780acb2007-04-16 06:56:07 +00004230 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004231 ;}
4232 break;
4233
Reid Spencer67d8ed92007-03-22 02:14:08 +00004234 case 169:
Reid Spencer7780acb2007-04-16 06:56:07 +00004235#line 1883 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004236 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004237 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004238 GEN_ERROR("fcmp operand types must match");
Reid Spencer7780acb2007-04-16 06:56:07 +00004239 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004240 ;}
4241 break;
4242
Reid Spencer67d8ed92007-03-22 02:14:08 +00004243 case 170:
Reid Spencer7780acb2007-04-16 06:56:07 +00004244#line 1888 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004245 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004246 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004247 GEN_ERROR("Invalid extractelement operands");
Reid Spencer7780acb2007-04-16 06:56:07 +00004248 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004249 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004250 ;}
4251 break;
4252
Reid Spencer67d8ed92007-03-22 02:14:08 +00004253 case 171:
Reid Spencer7780acb2007-04-16 06:56:07 +00004254#line 1894 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004255 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004256 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004257 GEN_ERROR("Invalid insertelement operands");
Reid Spencer7780acb2007-04-16 06:56:07 +00004258 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004259 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004260 ;}
4261 break;
4262
Reid Spencer67d8ed92007-03-22 02:14:08 +00004263 case 172:
Reid Spencer7780acb2007-04-16 06:56:07 +00004264#line 1900 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004265 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004266 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004267 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer7780acb2007-04-16 06:56:07 +00004268 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004269 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004270 ;}
4271 break;
4272
Reid Spencer67d8ed92007-03-22 02:14:08 +00004273 case 173:
Reid Spencer7780acb2007-04-16 06:56:07 +00004274#line 1909 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004275 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004276 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004277 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004278 ;}
4279 break;
4280
Reid Spencer67d8ed92007-03-22 02:14:08 +00004281 case 174:
Reid Spencer7780acb2007-04-16 06:56:07 +00004282#line 1913 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004283 {
4284 (yyval.ConstVector) = new std::vector<Constant*>();
Reid Spencer7780acb2007-04-16 06:56:07 +00004285 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004286 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004287 ;}
4288 break;
4289
Reid Spencer67d8ed92007-03-22 02:14:08 +00004290 case 175:
Reid Spencer7780acb2007-04-16 06:56:07 +00004291#line 1921 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004292 { (yyval.BoolVal) = false; ;}
4293 break;
4294
Reid Spencer67d8ed92007-03-22 02:14:08 +00004295 case 176:
Reid Spencer7780acb2007-04-16 06:56:07 +00004296#line 1921 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004297 { (yyval.BoolVal) = true; ;}
4298 break;
4299
Reid Spencer38c91a92007-02-28 02:24:54 +00004300 case 177:
Reid Spencer7780acb2007-04-16 06:56:07 +00004301#line 1924 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004302 { (yyval.BoolVal) = true; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004303 break;
4304
Reid Spencer67d8ed92007-03-22 02:14:08 +00004305 case 178:
Reid Spencer7780acb2007-04-16 06:56:07 +00004306#line 1924 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004307 { (yyval.BoolVal) = false; ;}
4308 break;
4309
4310 case 179:
Reid Spencer7780acb2007-04-16 06:56:07 +00004311#line 1935 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00004312 {
4313 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4314 CurModule.ModuleDone();
4315 CHECK_FOR_ERROR;
4316 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004317 break;
4318
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004319 case 180:
Reid Spencer7780acb2007-04-16 06:56:07 +00004320#line 1940 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004321 {
4322 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4323 CurModule.ModuleDone();
4324 CHECK_FOR_ERROR;
4325 ;}
4326 break;
4327
4328 case 183:
Reid Spencer7780acb2007-04-16 06:56:07 +00004329#line 1953 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00004330 { CurFun.isDeclare = false; ;}
4331 break;
4332
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004333 case 184:
Reid Spencer7780acb2007-04-16 06:56:07 +00004334#line 1953 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004335 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004336 CurFun.FunctionDone();
4337 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004338 ;}
4339 break;
4340
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004341 case 185:
Reid Spencer7780acb2007-04-16 06:56:07 +00004342#line 1957 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004343 { CurFun.isDeclare = true; ;}
4344 break;
4345
Reid Spencer67d8ed92007-03-22 02:14:08 +00004346 case 186:
Reid Spencer7780acb2007-04-16 06:56:07 +00004347#line 1957 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004348 {
4349 CHECK_FOR_ERROR
4350 ;}
4351 break;
4352
4353 case 187:
Reid Spencer7780acb2007-04-16 06:56:07 +00004354#line 1960 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004355 {
4356 CHECK_FOR_ERROR
4357 ;}
4358 break;
4359
4360 case 188:
Reid Spencer7780acb2007-04-16 06:56:07 +00004361#line 1963 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004362 {
Reid Spencer14310612006-12-31 05:40:51 +00004363 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00004364 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004365 // Eagerly resolve types. This is not an optimization, this is a
4366 // requirement that is due to the fact that we could have this:
4367 //
4368 // %list = type { %list * }
4369 // %list = type { %list * } ; repeated type decl
4370 //
4371 // If types are not resolved eagerly, then the two types will not be
4372 // determined to be the same type!
4373 //
Reid Spencer7780acb2007-04-16 06:56:07 +00004374 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004375
Reid Spencer7780acb2007-04-16 06:56:07 +00004376 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004377 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004378 // If this is a named type that is not a redefinition, add it to the slot
4379 // table.
Reid Spencer7780acb2007-04-16 06:56:07 +00004380 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004381 }
Reid Spencera132e042006-12-03 05:46:11 +00004382
Reid Spencer7780acb2007-04-16 06:56:07 +00004383 delete (yyvsp[0].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004384 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004385 ;}
4386 break;
4387
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004388 case 189:
Reid Spencer7780acb2007-04-16 06:56:07 +00004389#line 1987 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004390 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004391 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004392
Reid Spencer7780acb2007-04-16 06:56:07 +00004393 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004394 CHECK_FOR_ERROR
4395 // If this is a named type that is not a redefinition, add it to the slot
4396 // table.
Reid Spencer7780acb2007-04-16 06:56:07 +00004397 CurModule.Types.push_back((yyvsp[0].PrimType));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004398 }
4399 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004400 ;}
4401 break;
4402
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004403 case 190:
Reid Spencer7780acb2007-04-16 06:56:07 +00004404#line 1998 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004405 {
4406 /* "Externally Visible" Linkage */
Reid Spencer7780acb2007-04-16 06:56:07 +00004407 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004408 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer7780acb2007-04-16 06:56:07 +00004409 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), GlobalValue::ExternalLinkage,
4410 (yyvsp[-3].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal), (yyvsp[-2].BoolVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004411 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004412 ;}
4413 break;
4414
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004415 case 191:
Reid Spencer7780acb2007-04-16 06:56:07 +00004416#line 2005 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004417 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004418 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004419 ;}
4420 break;
4421
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004422 case 192:
Reid Spencer7780acb2007-04-16 06:56:07 +00004423#line 2008 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004424 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004425 if ((yyvsp[0].ConstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004426 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer7780acb2007-04-16 06:56:07 +00004427 CurGV = ParseGlobalVariable((yyvsp[-5].StrVal), (yyvsp[-4].Linkage), (yyvsp[-3].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal), (yyvsp[-2].BoolVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004428 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004429 ;}
4430 break;
4431
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004432 case 193:
Reid Spencer7780acb2007-04-16 06:56:07 +00004433#line 2013 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004434 {
4435 CurGV = 0;
4436 ;}
4437 break;
4438
4439 case 194:
Reid Spencer7780acb2007-04-16 06:56:07 +00004440#line 2016 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004441 {
4442 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00004443 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4444 CurGV = ParseGlobalVariable((yyvsp[-5].StrVal), (yyvsp[-4].Linkage), (yyvsp[-3].Visibility), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0, (yyvsp[-2].BoolVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004445 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00004446 delete (yyvsp[0].TypeVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004447 ;}
4448 break;
4449
4450 case 195:
Reid Spencer7780acb2007-04-16 06:56:07 +00004451#line 2022 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004452 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004453 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004454 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004455 ;}
4456 break;
4457
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004458 case 196:
Reid Spencer7780acb2007-04-16 06:56:07 +00004459#line 2026 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004460 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004461 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004462 ;}
4463 break;
4464
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004465 case 197:
Reid Spencer7780acb2007-04-16 06:56:07 +00004466#line 2029 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004467 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004468 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004469 ;}
4470 break;
4471
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004472 case 198:
Reid Spencer7780acb2007-04-16 06:56:07 +00004473#line 2035 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004474 {
Chris Lattner66316012006-01-24 04:14:29 +00004475 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer7780acb2007-04-16 06:56:07 +00004476 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4477 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4478 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004479
4480 if (AsmSoFar.empty())
4481 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4482 else
4483 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004484 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004485;}
4486 break;
4487
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004488 case 199:
Reid Spencer7780acb2007-04-16 06:56:07 +00004489#line 2048 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004490 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004491 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4492 free((yyvsp[0].StrVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004493 ;}
4494 break;
4495
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004496 case 200:
Reid Spencer7780acb2007-04-16 06:56:07 +00004497#line 2052 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004498 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004499 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4500 free((yyvsp[0].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004501 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004502 break;
4503
4504 case 202:
Reid Spencer7780acb2007-04-16 06:56:07 +00004505#line 2059 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004506 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004507 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4508 free((yyvsp[0].StrVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004509 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004510 ;}
4511 break;
4512
4513 case 203:
Reid Spencer7780acb2007-04-16 06:56:07 +00004514#line 2064 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004515 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004516 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4517 free((yyvsp[0].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004518 CHECK_FOR_ERROR
4519 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004520 break;
4521
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004522 case 204:
Reid Spencer7780acb2007-04-16 06:56:07 +00004523#line 2069 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004524 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004525 CHECK_FOR_ERROR
4526 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004527 break;
4528
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004529 case 205:
Reid Spencer7780acb2007-04-16 06:56:07 +00004530#line 2078 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004531 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004532 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00004533 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4534 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004535 GEN_ERROR("void typed arguments are invalid");
Reid Spencer7780acb2007-04-16 06:56:07 +00004536 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4537 (yyval.ArgList) = (yyvsp[-4].ArgList);
4538 (yyvsp[-4].ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004539 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004540 ;}
4541 break;
4542
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004543 case 206:
Reid Spencer7780acb2007-04-16 06:56:07 +00004544#line 2088 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004545 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004546 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00004547 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4548 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004549 GEN_ERROR("void typed arguments are invalid");
Reid Spencer7780acb2007-04-16 06:56:07 +00004550 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004551 (yyval.ArgList) = new ArgListType;
Reid Spencer38c91a92007-02-28 02:24:54 +00004552 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004553 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004554 ;}
4555 break;
4556
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004557 case 207:
Reid Spencer7780acb2007-04-16 06:56:07 +00004558#line 2099 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004559 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004560 (yyval.ArgList) = (yyvsp[0].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004561 CHECK_FOR_ERROR
4562 ;}
4563 break;
4564
4565 case 208:
Reid Spencer7780acb2007-04-16 06:56:07 +00004566#line 2103 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004567 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004568 (yyval.ArgList) = (yyvsp[-2].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004569 struct ArgListEntry E;
4570 E.Ty = new PATypeHolder(Type::VoidTy);
4571 E.Name = 0;
4572 E.Attrs = ParamAttr::None;
4573 (yyval.ArgList)->push_back(E);
4574 CHECK_FOR_ERROR
4575 ;}
4576 break;
4577
4578 case 209:
Reid Spencer7780acb2007-04-16 06:56:07 +00004579#line 2112 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004580 {
4581 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004582 struct ArgListEntry E;
4583 E.Ty = new PATypeHolder(Type::VoidTy);
4584 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004585 E.Attrs = ParamAttr::None;
Reid Spencer38c91a92007-02-28 02:24:54 +00004586 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004587 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004588 ;}
4589 break;
4590
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004591 case 210:
Reid Spencer7780acb2007-04-16 06:56:07 +00004592#line 2121 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004593 {
4594 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004595 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004596 ;}
4597 break;
4598
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004599 case 211:
Reid Spencer7780acb2007-04-16 06:56:07 +00004600#line 2127 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004601 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004602 UnEscapeLexed((yyvsp[-6].StrVal));
4603 std::string FunctionName((yyvsp[-6].StrVal));
4604 free((yyvsp[-6].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004605
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004606 // Check the function result for abstractness if this is a define. We should
4607 // have no abstract types at this point
Reid Spencer7780acb2007-04-16 06:56:07 +00004608 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4609 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004610
Reid Spencer68a24bd2005-08-27 18:50:39 +00004611 std::vector<const Type*> ParamTypeList;
Reid Spencer7b5d4662007-04-09 06:16:21 +00004612 ParamAttrsList ParamAttrs;
Reid Spencer7780acb2007-04-16 06:56:07 +00004613 if ((yyvsp[-2].ParamAttrs) != ParamAttr::None)
4614 ParamAttrs.addAttributes(0, (yyvsp[-2].ParamAttrs));
4615 if ((yyvsp[-4].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004616 unsigned index = 1;
Reid Spencer7780acb2007-04-16 06:56:07 +00004617 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004618 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004619 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4620 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004621 ParamTypeList.push_back(Ty);
4622 if (Ty != Type::VoidTy)
Reid Spencer18da0722007-04-11 02:44:20 +00004623 if (I->Attrs != ParamAttr::None)
Reid Spencer7b5d4662007-04-09 06:16:21 +00004624 ParamAttrs.addAttributes(index, I->Attrs);
Reid Spencer14310612006-12-31 05:40:51 +00004625 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004626 }
4627
4628 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4629 if (isVarArg) ParamTypeList.pop_back();
4630
Reid Spencer7b5d4662007-04-09 06:16:21 +00004631 ParamAttrsList *ActualAttrs = 0;
4632 if (!ParamAttrs.empty())
4633 ActualAttrs = new ParamAttrsList(ParamAttrs);
4634
Reid Spencer7780acb2007-04-16 06:56:07 +00004635 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg,
Reid Spencer7b5d4662007-04-09 06:16:21 +00004636 ActualAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004637 const PointerType *PFT = PointerType::get(FT);
Reid Spencer7780acb2007-04-16 06:56:07 +00004638 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004639
4640 ValID ID;
4641 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004642 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004643 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004644 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004645 }
4646
4647 Function *Fn = 0;
4648 // See if this function was forward referenced. If so, recycle the object.
4649 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4650 // Move the function to the end of the list, from whereever it was
4651 // previously inserted.
4652 Fn = cast<Function>(FWRef);
4653 CurModule.CurrentModule->getFunctionList().remove(Fn);
4654 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4655 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004656 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
4657 if (Fn->getFunctionType() != FT ) {
4658 // The existing function doesn't have the same type. This is an overload
4659 // error.
4660 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4661 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4662 // Neither the existing or the current function is a declaration and they
4663 // have the same name and same type. Clearly this is a redefinition.
Reid Spencerb5334b02007-02-05 10:18:06 +00004664 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004665 } if (Fn->isDeclaration()) {
4666 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004667 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4668 AI != AE; ++AI)
4669 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004670 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004671 } else { // Not already defined?
4672 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4673 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004674
Reid Spencer68a24bd2005-08-27 18:50:39 +00004675 InsertValue(Fn, CurModule.Values);
4676 }
4677
4678 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004679
4680 if (CurFun.isDeclare) {
4681 // If we have declaration, always overwrite linkage. This will allow us to
4682 // correctly handle cases, when pointer to function is passed as argument to
4683 // another function.
4684 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004685 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004686 }
Reid Spencer7780acb2007-04-16 06:56:07 +00004687 Fn->setCallingConv((yyvsp[-8].UIntVal));
4688 Fn->setAlignment((yyvsp[0].UIntVal));
4689 if ((yyvsp[-1].StrVal)) {
4690 Fn->setSection((yyvsp[-1].StrVal));
4691 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004692 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004693
4694 // Add all of the arguments we parsed to the function...
Reid Spencer7780acb2007-04-16 06:56:07 +00004695 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004696 if (isVarArg) { // Nuke the last entry
Reid Spencer7780acb2007-04-16 06:56:07 +00004697 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004698 "Not a varargs marker!");
Reid Spencer7780acb2007-04-16 06:56:07 +00004699 delete (yyvsp[-4].ArgList)->back().Ty;
4700 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004701 }
4702 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004703 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004704 unsigned Idx = 1;
Reid Spencer7780acb2007-04-16 06:56:07 +00004705 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin();
4706 I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004707 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00004708 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004709 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004710 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004711 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004712 }
Reid Spencera132e042006-12-03 05:46:11 +00004713
Reid Spencer7780acb2007-04-16 06:56:07 +00004714 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004715 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004716 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004717;}
4718 break;
4719
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004720 case 214:
Reid Spencer7780acb2007-04-16 06:56:07 +00004721#line 2247 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004722 {
4723 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004724
4725 // Make sure that we keep track of the linkage type even if there was a
4726 // previous "declare".
Reid Spencer7780acb2007-04-16 06:56:07 +00004727 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4728 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
Reid Spencer38c91a92007-02-28 02:24:54 +00004729;}
4730 break;
4731
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004732 case 217:
Reid Spencer7780acb2007-04-16 06:56:07 +00004733#line 2258 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004734 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004735 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004736 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004737;}
4738 break;
4739
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004740 case 218:
Reid Spencer7780acb2007-04-16 06:56:07 +00004741#line 2263 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004742 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004743 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4744 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
Reid Spencer38c91a92007-02-28 02:24:54 +00004745 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004746 CurFun.FunctionDone();
4747 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004748 ;}
4749 break;
4750
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004751 case 219:
Reid Spencer7780acb2007-04-16 06:56:07 +00004752#line 2275 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004753 {
4754 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004755 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004756 ;}
4757 break;
4758
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004759 case 220:
Reid Spencer7780acb2007-04-16 06:56:07 +00004760#line 2279 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004761 {
4762 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004763 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004764 ;}
4765 break;
4766
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004767 case 221:
Reid Spencer7780acb2007-04-16 06:56:07 +00004768#line 2284 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004769 { // A reference to a direct constant
Reid Spencer7780acb2007-04-16 06:56:07 +00004770 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004771 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004772 ;}
4773 break;
4774
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004775 case 222:
Reid Spencer7780acb2007-04-16 06:56:07 +00004776#line 2288 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004777 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004778 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004779 CHECK_FOR_ERROR
4780 ;}
4781 break;
4782
4783 case 223:
Reid Spencer7780acb2007-04-16 06:56:07 +00004784#line 2292 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004785 { // Perhaps it's an FP constant?
Reid Spencer7780acb2007-04-16 06:56:07 +00004786 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004787 CHECK_FOR_ERROR
4788 ;}
4789 break;
4790
4791 case 224:
Reid Spencer7780acb2007-04-16 06:56:07 +00004792#line 2296 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004793 {
4794 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004795 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004796 ;}
4797 break;
4798
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004799 case 225:
Reid Spencer7780acb2007-04-16 06:56:07 +00004800#line 2300 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004801 {
4802 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004803 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004804 ;}
4805 break;
4806
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004807 case 226:
Reid Spencer7780acb2007-04-16 06:56:07 +00004808#line 2304 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004809 {
4810 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004811 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004812 ;}
4813 break;
4814
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004815 case 227:
Reid Spencer7780acb2007-04-16 06:56:07 +00004816#line 2308 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004817 {
4818 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004819 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004820 ;}
4821 break;
4822
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004823 case 228:
Reid Spencer7780acb2007-04-16 06:56:07 +00004824#line 2312 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004825 { // A vector zero constant.
4826 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004827 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004828 ;}
4829 break;
4830
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004831 case 229:
Reid Spencer7780acb2007-04-16 06:56:07 +00004832#line 2316 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004833 { // Nonempty unsized packed vector
Reid Spencer7780acb2007-04-16 06:56:07 +00004834 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4835 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004836
Reid Spencer9d6565a2007-02-15 02:26:10 +00004837 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004838 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004839 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004840 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004841 ETy,
4842 NumElements)
4843 )
4844 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004845
4846 // Verify all elements are correct type!
Reid Spencer7780acb2007-04-16 06:56:07 +00004847 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4848 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004849 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004850 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00004851 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004852 }
4853
Reid Spencer7780acb2007-04-16 06:56:07 +00004854 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector)));
4855 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00004856 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004857 ;}
4858 break;
4859
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004860 case 230:
Reid Spencer7780acb2007-04-16 06:56:07 +00004861#line 2341 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004862 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004863 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004864 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004865 ;}
4866 break;
4867
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004868 case 231:
Reid Spencer7780acb2007-04-16 06:56:07 +00004869#line 2345 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004870 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004871 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4872 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4873 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4874 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4875 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4876 free((yyvsp[-2].StrVal));
4877 free((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004878 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004879 ;}
4880 break;
4881
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004882 case 232:
Reid Spencer7780acb2007-04-16 06:56:07 +00004883#line 2359 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004884 { // Is it an integer reference...?
Reid Spencer7780acb2007-04-16 06:56:07 +00004885 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004886 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004887 ;}
4888 break;
4889
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004890 case 233:
Reid Spencer7780acb2007-04-16 06:56:07 +00004891#line 2363 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004892 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004893 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004894 CHECK_FOR_ERROR
4895 ;}
4896 break;
4897
4898 case 234:
Reid Spencer7780acb2007-04-16 06:56:07 +00004899#line 2367 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004900 { // Is it a named reference...?
Reid Spencer7780acb2007-04-16 06:56:07 +00004901 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004902 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004903 ;}
4904 break;
4905
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004906 case 235:
Reid Spencer7780acb2007-04-16 06:56:07 +00004907#line 2371 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004908 { // Is it a named reference...?
Reid Spencer7780acb2007-04-16 06:56:07 +00004909 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004910 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004911 ;}
4912 break;
4913
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004914 case 238:
Reid Spencer7780acb2007-04-16 06:56:07 +00004915#line 2383 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004916 {
4917 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00004918 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4919 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
4920 delete (yyvsp[-1].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004921 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004922 ;}
4923 break;
4924
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004925 case 239:
Reid Spencer7780acb2007-04-16 06:56:07 +00004926#line 2392 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004927 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004928 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004929 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004930 ;}
4931 break;
4932
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004933 case 240:
Reid Spencer7780acb2007-04-16 06:56:07 +00004934#line 2396 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004935 { // Do not allow functions with 0 basic blocks
Reid Spencer7780acb2007-04-16 06:56:07 +00004936 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004937 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004938 ;}
4939 break;
4940
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004941 case 241:
Reid Spencer7780acb2007-04-16 06:56:07 +00004942#line 2405 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004943 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004944 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004945 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00004946 InsertValue((yyvsp[0].TermInstVal));
4947 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4948 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004949 CHECK_FOR_ERROR
4950 ;}
4951 break;
4952
4953 case 242:
Reid Spencer7780acb2007-04-16 06:56:07 +00004954#line 2414 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004955 {
Reid Spencer7780acb2007-04-16 06:56:07 +00004956 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004957 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4958 if (CI2->getParent() == 0)
Reid Spencer7780acb2007-04-16 06:56:07 +00004959 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
4960 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4961 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004962 CHECK_FOR_ERROR
4963 ;}
4964 break;
4965
4966 case 243:
Reid Spencer7780acb2007-04-16 06:56:07 +00004967#line 2423 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004968 { // Empty space between instruction lists
4969 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004970 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004971 ;}
4972 break;
4973
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004974 case 244:
Reid Spencer7780acb2007-04-16 06:56:07 +00004975#line 2427 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004976 { // Labelled (named) basic block
Reid Spencer7780acb2007-04-16 06:56:07 +00004977 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[0].StrVal)));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004978 CHECK_FOR_ERROR
4979 ;}
4980 break;
4981
4982 case 245:
Reid Spencer7780acb2007-04-16 06:56:07 +00004983#line 2432 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004984 { // Return with a result...
Reid Spencer7780acb2007-04-16 06:56:07 +00004985 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004986 CHECK_FOR_ERROR
4987 ;}
4988 break;
4989
4990 case 246:
Reid Spencer7780acb2007-04-16 06:56:07 +00004991#line 2436 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004992 { // Return with no result...
Reid Spencer38c91a92007-02-28 02:24:54 +00004993 (yyval.TermInstVal) = new ReturnInst();
4994 CHECK_FOR_ERROR
4995 ;}
4996 break;
4997
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004998 case 247:
Reid Spencer7780acb2007-04-16 06:56:07 +00004999#line 2440 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00005000 { // Unconditional Branch...
Reid Spencer7780acb2007-04-16 06:56:07 +00005001 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005002 CHECK_FOR_ERROR
5003 (yyval.TermInstVal) = new BranchInst(tmpBB);
5004 ;}
5005 break;
5006
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005007 case 248:
Reid Spencer7780acb2007-04-16 06:56:07 +00005008#line 2445 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005009 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005010 assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?");
5011 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005012 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005013 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005014 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005015 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005016 CHECK_FOR_ERROR
5017 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5018 ;}
5019 break;
5020
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005021 case 249:
Reid Spencer7780acb2007-04-16 06:56:07 +00005022#line 2455 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005023 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005024 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005025 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005026 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005027 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005028 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005029 (yyval.TermInstVal) = S;
5030
Reid Spencer7780acb2007-04-16 06:56:07 +00005031 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5032 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005033 for (; I != E; ++I) {
5034 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5035 S->addCase(CI, I->second);
5036 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005037 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005038 }
Reid Spencer7780acb2007-04-16 06:56:07 +00005039 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005040 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005041 ;}
5042 break;
5043
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005044 case 250:
Reid Spencer7780acb2007-04-16 06:56:07 +00005045#line 2474 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005046 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005047 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005048 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005049 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005050 CHECK_FOR_ERROR
5051 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer38c91a92007-02-28 02:24:54 +00005052 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005053 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005054 ;}
5055 break;
5056
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005057 case 251:
Reid Spencer7780acb2007-04-16 06:56:07 +00005058#line 2484 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005059 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005060
Reid Spencer14310612006-12-31 05:40:51 +00005061 // Handle the short syntax
5062 const PointerType *PFTy = 0;
5063 const FunctionType *Ty = 0;
Reid Spencer7780acb2007-04-16 06:56:07 +00005064 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005065 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5066 // Pull out the types of all of the arguments...
5067 std::vector<const Type*> ParamTypes;
Reid Spencer7b5d4662007-04-09 06:16:21 +00005068 ParamAttrsList ParamAttrs;
Reid Spencer7780acb2007-04-16 06:56:07 +00005069 if ((yyvsp[-6].ParamAttrs) != ParamAttr::None)
5070 ParamAttrs.addAttributes(0, (yyvsp[-6].ParamAttrs));
5071 ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005072 unsigned index = 1;
5073 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005074 const Type *Ty = I->Val->getType();
5075 if (Ty == Type::VoidTy)
5076 GEN_ERROR("Short call syntax cannot be used with varargs");
5077 ParamTypes.push_back(Ty);
Reid Spencer18da0722007-04-11 02:44:20 +00005078 if (I->Attrs != ParamAttr::None)
Reid Spencer7b5d4662007-04-09 06:16:21 +00005079 ParamAttrs.addAttributes(index, I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005080 }
5081
Reid Spencer7b5d4662007-04-09 06:16:21 +00005082 ParamAttrsList *Attrs = 0;
5083 if (!ParamAttrs.empty())
5084 Attrs = new ParamAttrsList(ParamAttrs);
Reid Spencer7780acb2007-04-16 06:56:07 +00005085 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005086 PFTy = PointerType::get(Ty);
5087 }
5088
Reid Spencer7780acb2007-04-16 06:56:07 +00005089 delete (yyvsp[-11].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005090
Reid Spencer7780acb2007-04-16 06:56:07 +00005091 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005092 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005093 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005094 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005095 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005096 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005097
Reid Spencer14310612006-12-31 05:40:51 +00005098 // Check the arguments
5099 ValueList Args;
Reid Spencer7780acb2007-04-16 06:56:07 +00005100 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005101 // Make sure no arguments is a good thing!
5102 if (Ty->getNumParams() != 0)
5103 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005104 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005105 } else { // Has arguments?
5106 // Loop through FunctionType's arguments and ensure they are specified
5107 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005108 FunctionType::param_iterator I = Ty->param_begin();
5109 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer7780acb2007-04-16 06:56:07 +00005110 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005111
Reid Spencer14310612006-12-31 05:40:51 +00005112 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5113 if (ArgI->Val->getType() != *I)
5114 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005115 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005116 Args.push_back(ArgI->Val);
5117 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005118
Reid Spencer14310612006-12-31 05:40:51 +00005119 if (Ty->isVarArg()) {
5120 if (I == E)
5121 for (; ArgI != ArgE; ++ArgI)
5122 Args.push_back(ArgI->Val); // push the remaining varargs
5123 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005124 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005125 }
Reid Spencer14310612006-12-31 05:40:51 +00005126
5127 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005128 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer7780acb2007-04-16 06:56:07 +00005129 II->setCallingConv((yyvsp[-12].UIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005130 (yyval.TermInstVal) = II;
Reid Spencer7780acb2007-04-16 06:56:07 +00005131 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005132 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005133 ;}
5134 break;
5135
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005136 case 252:
Reid Spencer7780acb2007-04-16 06:56:07 +00005137#line 2559 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005138 {
5139 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005140 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005141 ;}
5142 break;
5143
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005144 case 253:
Reid Spencer7780acb2007-04-16 06:56:07 +00005145#line 2563 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005146 {
5147 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005148 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005149 ;}
5150 break;
5151
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005152 case 254:
Reid Spencer7780acb2007-04-16 06:56:07 +00005153#line 2570 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005154 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005155 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5156 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005157 CHECK_FOR_ERROR
5158 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005159 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005160
Reid Spencer7780acb2007-04-16 06:56:07 +00005161 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005162 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005163 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5164 ;}
5165 break;
5166
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005167 case 255:
Reid Spencer7780acb2007-04-16 06:56:07 +00005168#line 2581 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005169 {
5170 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencer7780acb2007-04-16 06:56:07 +00005171 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005172 CHECK_FOR_ERROR
5173
5174 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005175 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005176
Reid Spencer7780acb2007-04-16 06:56:07 +00005177 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005178 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005179 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5180 ;}
5181 break;
5182
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005183 case 256:
Reid Spencer7780acb2007-04-16 06:56:07 +00005184#line 2594 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005185 {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005186 // Is this definition named?? if so, assign the name...
Reid Spencer7780acb2007-04-16 06:56:07 +00005187 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spenceref9b9a72007-02-05 20:47:22 +00005188 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005189 InsertValue((yyvsp[0].InstVal));
5190 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005191 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005192 ;}
5193 break;
5194
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005195 case 257:
Reid Spencer7780acb2007-04-16 06:56:07 +00005196#line 2604 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005197 { // Used for PHI nodes
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005198 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005199 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005200 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencer7780acb2007-04-16 06:56:07 +00005201 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005202 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005203 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005204 CHECK_FOR_ERROR
5205 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer7780acb2007-04-16 06:56:07 +00005206 delete (yyvsp[-5].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005207 ;}
5208 break;
5209
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005210 case 258:
Reid Spencer7780acb2007-04-16 06:56:07 +00005211#line 2615 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005212 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005213 (yyval.PHIList) = (yyvsp[-6].PHIList);
5214 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005215 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005216 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005217 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005218 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer38c91a92007-02-28 02:24:54 +00005219 ;}
5220 break;
5221
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005222 case 259:
Reid Spencer7780acb2007-04-16 06:56:07 +00005223#line 2625 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005224 {
5225 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005226 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005227 // Used for call and invoke instructions
5228 (yyval.ValueRefList) = new ValueRefList();
Reid Spencer7780acb2007-04-16 06:56:07 +00005229 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005230 (yyval.ValueRefList)->push_back(E);
Reid Spencer7780acb2007-04-16 06:56:07 +00005231 delete (yyvsp[-2].TypeVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005232 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00005233 break;
5234
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005235 case 260:
Reid Spencer7780acb2007-04-16 06:56:07 +00005236#line 2634 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005237 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005238 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005239 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5240 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5241 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005242 (yyval.ValueRefList)->push_back(E);
Reid Spencer7780acb2007-04-16 06:56:07 +00005243 delete (yyvsp[-2].TypeVal);
Reid Spencer14310612006-12-31 05:40:51 +00005244 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005245 ;}
5246 break;
5247
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005248 case 261:
Reid Spencer7780acb2007-04-16 06:56:07 +00005249#line 2643 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005250 { (yyval.ValueRefList) = new ValueRefList(); ;}
5251 break;
5252
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005253 case 262:
Reid Spencer7780acb2007-04-16 06:56:07 +00005254#line 2646 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005255 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5256 break;
5257
5258 case 263:
Reid Spencer7780acb2007-04-16 06:56:07 +00005259#line 2647 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005260 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005261 (yyval.ValueList) = (yyvsp[-2].ValueList);
5262 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005263 CHECK_FOR_ERROR
5264 ;}
5265 break;
5266
5267 case 264:
Reid Spencer7780acb2007-04-16 06:56:07 +00005268#line 2654 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005269 {
5270 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005271 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005272 ;}
5273 break;
5274
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005275 case 265:
Reid Spencer7780acb2007-04-16 06:56:07 +00005276#line 2658 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005277 {
5278 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005279 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005280 ;}
5281 break;
5282
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005283 case 266:
Reid Spencer7780acb2007-04-16 06:56:07 +00005284#line 2663 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005285 {
Reid Spencer14310612006-12-31 05:40:51 +00005286 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005287 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5288 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5289 !isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005290 GEN_ERROR(
Reid Spencerb5334b02007-02-05 10:18:06 +00005291 "Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer7780acb2007-04-16 06:56:07 +00005292 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()) &&
5293 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5294 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5295 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Chris Lattner32980692007-02-19 07:44:24 +00005296 GEN_ERROR("Remainder not supported on vector types");
Reid Spencer7780acb2007-04-16 06:56:07 +00005297 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005298 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005299 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005300 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005301 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
Reid Spencer38c91a92007-02-28 02:24:54 +00005302 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005303 GEN_ERROR("binary operator returned null");
Reid Spencer7780acb2007-04-16 06:56:07 +00005304 delete (yyvsp[-3].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005305 ;}
5306 break;
5307
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005308 case 267:
Reid Spencer7780acb2007-04-16 06:56:07 +00005309#line 2684 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005310 {
Reid Spencer14310612006-12-31 05:40:51 +00005311 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005312 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5313 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5314 if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].TypeVal)->get()) ||
5315 !cast<VectorType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005316 GEN_ERROR("Logical operator requires integral operands");
5317 }
Reid Spencer7780acb2007-04-16 06:56:07 +00005318 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005319 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005320 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005321 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005322 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
Reid Spencer38c91a92007-02-28 02:24:54 +00005323 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005324 GEN_ERROR("binary operator returned null");
Reid Spencer7780acb2007-04-16 06:56:07 +00005325 delete (yyvsp[-3].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005326 ;}
5327 break;
5328
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005329 case 268:
Reid Spencer7780acb2007-04-16 06:56:07 +00005330#line 2701 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005331 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005332 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005333 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5334 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005335 GEN_ERROR("Vector types not supported by icmp instruction");
Reid Spencer7780acb2007-04-16 06:56:07 +00005336 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005337 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005338 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005339 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005340 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005341 if ((yyval.InstVal) == 0)
5342 GEN_ERROR("icmp operator returned null");
Reid Spencer7780acb2007-04-16 06:56:07 +00005343 delete (yyvsp[-3].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005344 ;}
5345 break;
5346
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005347 case 269:
Reid Spencer7780acb2007-04-16 06:56:07 +00005348#line 2715 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005349 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005350 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005351 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5352 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005353 GEN_ERROR("Vector types not supported by fcmp instruction");
Reid Spencer7780acb2007-04-16 06:56:07 +00005354 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005355 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005356 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005357 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005358 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005359 if ((yyval.InstVal) == 0)
5360 GEN_ERROR("fcmp operator returned null");
Reid Spencer7780acb2007-04-16 06:56:07 +00005361 delete (yyvsp[-3].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005362 ;}
5363 break;
5364
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005365 case 270:
Reid Spencer7780acb2007-04-16 06:56:07 +00005366#line 2729 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005367 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005368 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005369 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5370 Value* Val = (yyvsp[-2].ValueVal);
5371 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5372 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005373 GEN_ERROR("invalid cast opcode for cast from '" +
5374 Val->getType()->getDescription() + "' to '" +
5375 DestTy->getDescription() + "'");
Reid Spencer7780acb2007-04-16 06:56:07 +00005376 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5377 delete (yyvsp[0].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005378 ;}
5379 break;
5380
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005381 case 271:
Reid Spencer7780acb2007-04-16 06:56:07 +00005382#line 2741 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005383 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005384 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005385 GEN_ERROR("select condition must be boolean");
Reid Spencer7780acb2007-04-16 06:56:07 +00005386 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005387 GEN_ERROR("select value types should match");
Reid Spencer7780acb2007-04-16 06:56:07 +00005388 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005389 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005390 ;}
5391 break;
5392
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005393 case 272:
Reid Spencer7780acb2007-04-16 06:56:07 +00005394#line 2749 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005395 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005396 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005397 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5398 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5399 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005400 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005401 ;}
5402 break;
5403
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005404 case 273:
Reid Spencer7780acb2007-04-16 06:56:07 +00005405#line 2756 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005406 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005407 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005408 GEN_ERROR("Invalid extractelement operands");
Reid Spencer7780acb2007-04-16 06:56:07 +00005409 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005410 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005411 ;}
5412 break;
5413
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005414 case 274:
Reid Spencer7780acb2007-04-16 06:56:07 +00005415#line 2762 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005416 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005417 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005418 GEN_ERROR("Invalid insertelement operands");
Reid Spencer7780acb2007-04-16 06:56:07 +00005419 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005420 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005421 ;}
5422 break;
5423
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005424 case 275:
Reid Spencer7780acb2007-04-16 06:56:07 +00005425#line 2768 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005426 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005427 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005428 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer7780acb2007-04-16 06:56:07 +00005429 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005430 CHECK_FOR_ERROR
5431 ;}
5432 break;
5433
5434 case 276:
Reid Spencer7780acb2007-04-16 06:56:07 +00005435#line 2774 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005436 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005437 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005438 if (!Ty->isFirstClassType())
5439 GEN_ERROR("PHI node operands must be of first class type");
5440 (yyval.InstVal) = new PHINode(Ty);
Reid Spencer7780acb2007-04-16 06:56:07 +00005441 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5442 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5443 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005444 GEN_ERROR("All elements of a PHI node must be of the same type");
Reid Spencer7780acb2007-04-16 06:56:07 +00005445 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5446 (yyvsp[0].PHIList)->pop_front();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005447 }
Reid Spencer7780acb2007-04-16 06:56:07 +00005448 delete (yyvsp[0].PHIList); // Free the list...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005449 CHECK_FOR_ERROR
5450 ;}
5451 break;
5452
5453 case 277:
Reid Spencer7780acb2007-04-16 06:56:07 +00005454#line 2790 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005455 {
Reid Spencer14310612006-12-31 05:40:51 +00005456
5457 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005458 const PointerType *PFTy = 0;
5459 const FunctionType *Ty = 0;
Reid Spencer7780acb2007-04-16 06:56:07 +00005460 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005461 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5462 // Pull out the types of all of the arguments...
5463 std::vector<const Type*> ParamTypes;
Reid Spencer7b5d4662007-04-09 06:16:21 +00005464 ParamAttrsList ParamAttrs;
Reid Spencer7780acb2007-04-16 06:56:07 +00005465 if ((yyvsp[0].ParamAttrs) != ParamAttr::None)
5466 ParamAttrs.addAttributes(0, (yyvsp[0].ParamAttrs));
Reid Spencer7b5d4662007-04-09 06:16:21 +00005467 unsigned index = 1;
Reid Spencer7780acb2007-04-16 06:56:07 +00005468 ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005469 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005470 const Type *Ty = I->Val->getType();
5471 if (Ty == Type::VoidTy)
5472 GEN_ERROR("Short call syntax cannot be used with varargs");
5473 ParamTypes.push_back(Ty);
Reid Spencer18da0722007-04-11 02:44:20 +00005474 if (I->Attrs != ParamAttr::None)
Reid Spencer7b5d4662007-04-09 06:16:21 +00005475 ParamAttrs.addAttributes(index, I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005476 }
5477
Reid Spencer7b5d4662007-04-09 06:16:21 +00005478 ParamAttrsList *Attrs = 0;
5479 if (!ParamAttrs.empty())
5480 Attrs = new ParamAttrsList(ParamAttrs);
5481
Reid Spencer7780acb2007-04-16 06:56:07 +00005482 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005483 PFTy = PointerType::get(Ty);
5484 }
5485
Reid Spencer7780acb2007-04-16 06:56:07 +00005486 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005487 CHECK_FOR_ERROR
5488
Reid Spencer7780acb2007-04-16 06:56:07 +00005489 // Check for call to invalid intrinsic to avoid crashing later.
5490 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00005491 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00005492 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5493 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00005494 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5495 theF->getName() + "'");
5496 }
5497
Reid Spencer14310612006-12-31 05:40:51 +00005498 // Check the arguments
5499 ValueList Args;
Reid Spencer7780acb2007-04-16 06:56:07 +00005500 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005501 // Make sure no arguments is a good thing!
5502 if (Ty->getNumParams() != 0)
5503 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005504 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005505 } else { // Has arguments?
5506 // Loop through FunctionType's arguments and ensure they are specified
5507 // correctly!
5508 //
5509 FunctionType::param_iterator I = Ty->param_begin();
5510 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer7780acb2007-04-16 06:56:07 +00005511 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005512
Reid Spencer14310612006-12-31 05:40:51 +00005513 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5514 if (ArgI->Val->getType() != *I)
5515 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005516 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005517 Args.push_back(ArgI->Val);
5518 }
5519 if (Ty->isVarArg()) {
5520 if (I == E)
5521 for (; ArgI != ArgE; ++ArgI)
5522 Args.push_back(ArgI->Val); // push the remaining varargs
5523 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005524 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005525 }
Reid Spencer14310612006-12-31 05:40:51 +00005526 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005527 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer7780acb2007-04-16 06:56:07 +00005528 CI->setTailCall((yyvsp[-7].BoolVal));
5529 CI->setCallingConv((yyvsp[-6].UIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005530 (yyval.InstVal) = CI;
Reid Spencer7780acb2007-04-16 06:56:07 +00005531 delete (yyvsp[-2].ValueRefList);
5532 delete (yyvsp[-5].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005533 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005534 ;}
5535 break;
5536
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005537 case 278:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005538#line 2870 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005539 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005540 (yyval.InstVal) = (yyvsp[0].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005541 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005542 ;}
5543 break;
5544
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005545 case 279:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005546#line 2875 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005547 {
5548 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005549 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005550 ;}
5551 break;
5552
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005553 case 280:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005554#line 2879 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005555 {
5556 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005557 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005558 ;}
5559 break;
5560
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005561 case 281:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005562#line 2886 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005563 {
Reid Spencer14310612006-12-31 05:40:51 +00005564 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005565 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5566 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5567 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005568 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005569 ;}
5570 break;
5571
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005572 case 282:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005573#line 2893 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005574 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005575 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005576 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5577 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005578 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005579 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5580 delete (yyvsp[-4].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005581 ;}
5582 break;
5583
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005584 case 283:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005585#line 2901 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005586 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005587 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005588 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5589 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5590 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005591 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005592 ;}
5593 break;
5594
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005595 case 284:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005596#line 2908 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005597 {
Reid Spencer14310612006-12-31 05:40:51 +00005598 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005599 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5600 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005601 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005602 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5603 delete (yyvsp[-4].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005604 ;}
5605 break;
5606
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005607 case 285:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005608#line 2916 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005609 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005610 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005611 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer7780acb2007-04-16 06:56:07 +00005612 (yyvsp[0].ValueVal)->getType()->getDescription() + "");
5613 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005614 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005615 ;}
5616 break;
5617
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005618 case 286:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005619#line 2924 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005620 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005621 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005622 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5623 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005624 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer7780acb2007-04-16 06:56:07 +00005625 (*(yyvsp[-1].TypeVal))->getDescription());
5626 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005627 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer7780acb2007-04-16 06:56:07 +00005628 (*(yyvsp[-1].TypeVal))->getDescription());
5629 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005630 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005631 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5632 delete (yyvsp[-1].TypeVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005633 ;}
5634 break;
5635
5636 case 287:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005637#line 2938 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005638 {
5639 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005640 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5641 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005642 if (!PT)
5643 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer7780acb2007-04-16 06:56:07 +00005644 (*(yyvsp[-1].TypeVal))->getDescription());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005645 const Type *ElTy = PT->getElementType();
Reid Spencer7780acb2007-04-16 06:56:07 +00005646 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5647 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005648 "' into space of type '" + ElTy->getDescription() + "'");
5649
Reid Spencer7780acb2007-04-16 06:56:07 +00005650 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005651 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005652 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5653 delete (yyvsp[-1].TypeVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005654 ;}
5655 break;
5656
5657 case 288:
Reid Spencer2eb203a2007-04-16 17:47:06 +00005658#line 2955 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005659 {
5660 if (!UpRefs.empty())
Reid Spencer7780acb2007-04-16 06:56:07 +00005661 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5662 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005663 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005664
Reid Spencer7780acb2007-04-16 06:56:07 +00005665 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005666 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer7780acb2007-04-16 06:56:07 +00005667 (*(yyvsp[-2].TypeVal))->getDescription()+ "'");
5668 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005669 CHECK_FOR_ERROR
Reid Spencer7780acb2007-04-16 06:56:07 +00005670 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size());
5671 delete (yyvsp[-2].TypeVal);
5672 delete (yyvsp[0].ValueList);
Reid Spencer38c91a92007-02-28 02:24:54 +00005673 ;}
5674 break;
5675
5676
5677 default: break;
5678 }
5679
Reid Spencer7780acb2007-04-16 06:56:07 +00005680/* Line 1126 of yacc.c. */
Reid Spencer2eb203a2007-04-16 17:47:06 +00005681#line 5682 "llvmAsmParser.tab.c"
Reid Spencer7780acb2007-04-16 06:56:07 +00005682
5683 yyvsp -= yylen;
5684 yyssp -= yylen;
5685
5686
Reid Spencer38c91a92007-02-28 02:24:54 +00005687 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005688
5689 *++yyvsp = yyval;
5690
5691
Reid Spencer38c91a92007-02-28 02:24:54 +00005692 /* Now `shift' the result of the reduction. Determine what state
5693 that goes to, based on the state we popped back to and the rule
5694 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005695
5696 yyn = yyr1[yyn];
5697
Reid Spencer38c91a92007-02-28 02:24:54 +00005698 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5699 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005700 yystate = yytable[yystate];
5701 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005702 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005703
5704 goto yynewstate;
5705
5706
Reid Spencer38c91a92007-02-28 02:24:54 +00005707/*------------------------------------.
5708| yyerrlab -- here on detecting error |
5709`------------------------------------*/
5710yyerrlab:
5711 /* If not already recovering from an error, report this error. */
5712 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005713 {
5714 ++yynerrs;
Reid Spencer7780acb2007-04-16 06:56:07 +00005715#if YYERROR_VERBOSE
5716 yyn = yypact[yystate];
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005717
Reid Spencer7780acb2007-04-16 06:56:07 +00005718 if (YYPACT_NINF < yyn && yyn < YYLAST)
5719 {
5720 int yytype = YYTRANSLATE (yychar);
5721 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5722 YYSIZE_T yysize = yysize0;
5723 YYSIZE_T yysize1;
5724 int yysize_overflow = 0;
5725 char *yymsg = 0;
5726# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5727 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5728 int yyx;
5729
5730#if 0
5731 /* This is so xgettext sees the translatable formats that are
5732 constructed on the fly. */
5733 YY_("syntax error, unexpected %s");
5734 YY_("syntax error, unexpected %s, expecting %s");
5735 YY_("syntax error, unexpected %s, expecting %s or %s");
5736 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5737 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005738#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00005739 char *yyfmt;
5740 char const *yyf;
5741 static char const yyunexpected[] = "syntax error, unexpected %s";
5742 static char const yyexpecting[] = ", expecting %s";
5743 static char const yyor[] = " or %s";
5744 char yyformat[sizeof yyunexpected
5745 + sizeof yyexpecting - 1
5746 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5747 * (sizeof yyor - 1))];
5748 char const *yyprefix = yyexpecting;
5749
5750 /* Start YYX at -YYN if negative to avoid negative indexes in
5751 YYCHECK. */
5752 int yyxbegin = yyn < 0 ? -yyn : 0;
5753
5754 /* Stay within bounds of both yycheck and yytname. */
5755 int yychecklim = YYLAST - yyn;
5756 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5757 int yycount = 1;
5758
5759 yyarg[0] = yytname[yytype];
5760 yyfmt = yystpcpy (yyformat, yyunexpected);
5761
5762 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5763 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5764 {
5765 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5766 {
5767 yycount = 1;
5768 yysize = yysize0;
5769 yyformat[sizeof yyunexpected - 1] = '\0';
5770 break;
5771 }
5772 yyarg[yycount++] = yytname[yyx];
5773 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5774 yysize_overflow |= yysize1 < yysize;
5775 yysize = yysize1;
5776 yyfmt = yystpcpy (yyfmt, yyprefix);
5777 yyprefix = yyor;
5778 }
5779
5780 yyf = YY_(yyformat);
5781 yysize1 = yysize + yystrlen (yyf);
5782 yysize_overflow |= yysize1 < yysize;
5783 yysize = yysize1;
5784
5785 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5786 yymsg = (char *) YYSTACK_ALLOC (yysize);
5787 if (yymsg)
5788 {
5789 /* Avoid sprintf, as that infringes on the user's name space.
5790 Don't have undefined behavior even if the translation
5791 produced a string with the wrong number of "%s"s. */
5792 char *yyp = yymsg;
5793 int yyi = 0;
5794 while ((*yyp = *yyf))
5795 {
5796 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5797 {
5798 yyp += yytnamerr (yyp, yyarg[yyi++]);
5799 yyf += 2;
5800 }
5801 else
5802 {
5803 yyp++;
5804 yyf++;
5805 }
5806 }
5807 yyerror (yymsg);
5808 YYSTACK_FREE (yymsg);
5809 }
5810 else
5811 {
5812 yyerror (YY_("syntax error"));
5813 goto yyexhaustedlab;
5814 }
5815 }
5816 else
5817#endif /* YYERROR_VERBOSE */
5818 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005819 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00005820
Reid Spencer38c91a92007-02-28 02:24:54 +00005821
Reid Spencer41dff5e2007-01-26 08:05:27 +00005822
5823 if (yyerrstatus == 3)
5824 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005825 /* If just tried and failed to reuse look-ahead token after an
5826 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00005827
Reid Spencer38c91a92007-02-28 02:24:54 +00005828 if (yychar <= YYEOF)
Reid Spencer7780acb2007-04-16 06:56:07 +00005829 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005830 /* Return failure if at end of input. */
5831 if (yychar == YYEOF)
5832 YYABORT;
Reid Spencer7780acb2007-04-16 06:56:07 +00005833 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005834 else
5835 {
Reid Spencer7780acb2007-04-16 06:56:07 +00005836 yydestruct ("Error: discarding", yytoken, &yylval);
Reid Spencer38c91a92007-02-28 02:24:54 +00005837 yychar = YYEMPTY;
5838 }
5839 }
5840
5841 /* Else will try to reuse look-ahead token after shifting the error
5842 token. */
5843 goto yyerrlab1;
5844
5845
5846/*---------------------------------------------------.
5847| yyerrorlab -- error raised explicitly by YYERROR. |
5848`---------------------------------------------------*/
5849yyerrorlab:
5850
5851 /* Pacify compilers like GCC when the user code never invokes
5852 YYERROR and the label yyerrorlab therefore never appears in user
5853 code. */
Reid Spencer7780acb2007-04-16 06:56:07 +00005854 if (0)
Reid Spencer38c91a92007-02-28 02:24:54 +00005855 goto yyerrorlab;
5856
Reid Spencer7780acb2007-04-16 06:56:07 +00005857yyvsp -= yylen;
5858 yyssp -= yylen;
Reid Spencer38c91a92007-02-28 02:24:54 +00005859 yystate = *yyssp;
5860 goto yyerrlab1;
5861
5862
5863/*-------------------------------------------------------------.
5864| yyerrlab1 -- common code for both syntax error and YYERROR. |
5865`-------------------------------------------------------------*/
5866yyerrlab1:
5867 yyerrstatus = 3; /* Each real token shifted decrements this. */
5868
5869 for (;;)
5870 {
5871 yyn = yypact[yystate];
5872 if (yyn != YYPACT_NINF)
5873 {
5874 yyn += YYTERROR;
5875 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5876 {
5877 yyn = yytable[yyn];
5878 if (0 < yyn)
5879 break;
5880 }
5881 }
5882
5883 /* Pop the current state because it cannot handle the error token. */
5884 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005885 YYABORT;
5886
Reid Spencere4d87aa2006-12-23 06:05:41 +00005887
Reid Spencer7780acb2007-04-16 06:56:07 +00005888 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5889 YYPOPSTACK;
Reid Spencer38c91a92007-02-28 02:24:54 +00005890 yystate = *yyssp;
5891 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005892 }
5893
5894 if (yyn == YYFINAL)
5895 YYACCEPT;
5896
Reid Spencer68a24bd2005-08-27 18:50:39 +00005897 *++yyvsp = yylval;
Reid Spencer38c91a92007-02-28 02:24:54 +00005898
5899
Reid Spencer7780acb2007-04-16 06:56:07 +00005900 /* Shift the error token. */
Reid Spencer38c91a92007-02-28 02:24:54 +00005901 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00005902
Reid Spencer68a24bd2005-08-27 18:50:39 +00005903 yystate = yyn;
5904 goto yynewstate;
5905
Chris Lattner32980692007-02-19 07:44:24 +00005906
Reid Spencer38c91a92007-02-28 02:24:54 +00005907/*-------------------------------------.
5908| yyacceptlab -- YYACCEPT comes here. |
5909`-------------------------------------*/
5910yyacceptlab:
5911 yyresult = 0;
5912 goto yyreturn;
5913
5914/*-----------------------------------.
5915| yyabortlab -- YYABORT comes here. |
5916`-----------------------------------*/
5917yyabortlab:
5918 yyresult = 1;
5919 goto yyreturn;
5920
5921#ifndef yyoverflow
5922/*-------------------------------------------------.
5923| yyexhaustedlab -- memory exhaustion comes here. |
5924`-------------------------------------------------*/
5925yyexhaustedlab:
5926 yyerror (YY_("memory exhausted"));
5927 yyresult = 2;
5928 /* Fall through. */
Chris Lattner32980692007-02-19 07:44:24 +00005929#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00005930
5931yyreturn:
5932 if (yychar != YYEOF && yychar != YYEMPTY)
5933 yydestruct ("Cleanup: discarding lookahead",
5934 yytoken, &yylval);
5935 while (yyssp != yyss)
5936 {
5937 yydestruct ("Cleanup: popping",
5938 yystos[*yyssp], yyvsp);
Reid Spencer7780acb2007-04-16 06:56:07 +00005939 YYPOPSTACK;
Chris Lattner32980692007-02-19 07:44:24 +00005940 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005941#ifndef yyoverflow
5942 if (yyss != yyssa)
5943 YYSTACK_FREE (yyss);
5944#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00005945 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005946}
Reid Spencer38c91a92007-02-28 02:24:54 +00005947
5948
Reid Spencer2eb203a2007-04-16 17:47:06 +00005949#line 2972 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005950
5951
Reid Spencer14310612006-12-31 05:40:51 +00005952// common code from the two 'RunVMAsmParser' functions
5953static Module* RunParser(Module * M) {
5954
5955 llvmAsmlineno = 1; // Reset the current line number...
5956 CurModule.CurrentModule = M;
5957#if YYDEBUG
5958 yydebug = Debug;
5959#endif
5960
5961 // Check to make sure the parser succeeded
5962 if (yyparse()) {
5963 if (ParserResult)
5964 delete ParserResult;
5965 return 0;
5966 }
5967
Reid Spencer0d60b5a2007-03-30 01:37:39 +00005968 // Emit an error if there are any unresolved types left.
5969 if (!CurModule.LateResolveTypes.empty()) {
5970 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5971 if (DID.Type == ValID::LocalName) {
5972 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5973 } else {
5974 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5975 }
5976 if (ParserResult)
5977 delete ParserResult;
5978 return 0;
5979 }
5980
5981 // Emit an error if there are any unresolved values left.
5982 if (!CurModule.LateResolveValues.empty()) {
5983 Value *V = CurModule.LateResolveValues.back();
5984 std::map<Value*, std::pair<ValID, int> >::iterator I =
5985 CurModule.PlaceHolderInfo.find(V);
5986
5987 if (I != CurModule.PlaceHolderInfo.end()) {
5988 ValID &DID = I->second.first;
5989 if (DID.Type == ValID::LocalName) {
5990 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5991 } else {
5992 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5993 }
5994 if (ParserResult)
5995 delete ParserResult;
5996 return 0;
5997 }
5998 }
5999
Reid Spencer14310612006-12-31 05:40:51 +00006000 // Check to make sure that parsing produced a result
6001 if (!ParserResult)
6002 return 0;
6003
6004 // Reset ParserResult variable while saving its value for the result.
6005 Module *Result = ParserResult;
6006 ParserResult = 0;
6007
6008 return Result;
6009}
6010
Reid Spencer61c83e02006-08-18 08:43:06 +00006011void llvm::GenerateError(const std::string &message, int LineNo) {
6012 if (LineNo == -1) LineNo = llvmAsmlineno;
6013 // TODO: column number in exception
6014 if (TheParseError)
6015 TheParseError->setError(CurFilename, message, LineNo);
6016 TriggerError = 1;
6017}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006018
6019int yyerror(const char *ErrorMsg) {
6020 std::string where
6021 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6022 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006023 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6024 if (yychar != YYEMPTY && yychar != 0)
6025 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6026 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006027 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006028 return 0;
6029}
Reid Spencer38c91a92007-02-28 02:24:54 +00006030