blob: 9f92ce5bf9b571b74eb1e7673ae96cd20493c404 [file] [log] [blame]
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer9c9b63a2007-04-28 16:07:31 +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 Korobeynikov178a3522007-01-12 19:22:51 +00005
Anton Korobeynikov38e09802007-04-28 13:48:45 +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.
10
11 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 Spencer9c9b63a2007-04-28 16:07:31 +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. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +000025
Reid Spencer9c9b63a2007-04-28 16:07:31 +000026/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +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 Spencer9c9b63a2007-04-28 16:07:31 +000040#define YYBISON_VERSION "2.1"
Anton Korobeynikov38e09802007-04-28 13:48:45 +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
Anton Korobeynikov38e09802007-04-28 13:48:45 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Anton Korobeynikov38e09802007-04-28 13:48:45 +000055#define yylval llvmAsmlval
56#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000057#define yydebug llvmAsmdebug
58#define yynerrs llvmAsmnerrs
59
Anton Korobeynikov38e09802007-04-28 13:48:45 +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,
85 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 ALIAS = 286,
96 VOLATILE = 287,
97 THREAD_LOCAL = 288,
98 TO = 289,
99 DOTDOTDOT = 290,
100 NULL_TOK = 291,
101 UNDEF = 292,
102 INTERNAL = 293,
103 LINKONCE = 294,
104 WEAK = 295,
105 APPENDING = 296,
106 DLLIMPORT = 297,
107 DLLEXPORT = 298,
108 EXTERN_WEAK = 299,
109 OPAQUE = 300,
110 EXTERNAL = 301,
111 TARGET = 302,
112 TRIPLE = 303,
113 ALIGN = 304,
114 DEPLIBS = 305,
115 CALL = 306,
116 TAIL = 307,
117 ASM_TOK = 308,
118 MODULE = 309,
119 SIDEEFFECT = 310,
120 CC_TOK = 311,
121 CCC_TOK = 312,
122 FASTCC_TOK = 313,
123 COLDCC_TOK = 314,
124 X86_STDCALLCC_TOK = 315,
125 X86_FASTCALLCC_TOK = 316,
126 DATALAYOUT = 317,
127 RET = 318,
128 BR = 319,
129 SWITCH = 320,
130 INVOKE = 321,
131 UNWIND = 322,
132 UNREACHABLE = 323,
133 ADD = 324,
134 SUB = 325,
135 MUL = 326,
136 UDIV = 327,
137 SDIV = 328,
138 FDIV = 329,
139 UREM = 330,
140 SREM = 331,
141 FREM = 332,
142 AND = 333,
143 OR = 334,
144 XOR = 335,
145 SHL = 336,
146 LSHR = 337,
147 ASHR = 338,
148 ICMP = 339,
149 FCMP = 340,
150 EQ = 341,
151 NE = 342,
152 SLT = 343,
153 SGT = 344,
154 SLE = 345,
155 SGE = 346,
156 ULT = 347,
157 UGT = 348,
158 ULE = 349,
159 UGE = 350,
160 OEQ = 351,
161 ONE = 352,
162 OLT = 353,
163 OGT = 354,
164 OLE = 355,
165 OGE = 356,
166 ORD = 357,
167 UNO = 358,
168 UEQ = 359,
169 UNE = 360,
170 MALLOC = 361,
171 ALLOCA = 362,
172 FREE = 363,
173 LOAD = 364,
174 STORE = 365,
175 GETELEMENTPTR = 366,
176 TRUNC = 367,
177 ZEXT = 368,
178 SEXT = 369,
179 FPTRUNC = 370,
180 FPEXT = 371,
181 BITCAST = 372,
182 UITOFP = 373,
183 SITOFP = 374,
184 FPTOUI = 375,
185 FPTOSI = 376,
186 INTTOPTR = 377,
187 PTRTOINT = 378,
188 PHI_TOK = 379,
189 SELECT = 380,
190 VAARG = 381,
191 EXTRACTELEMENT = 382,
192 INSERTELEMENT = 383,
193 SHUFFLEVECTOR = 384,
194 NORETURN = 385,
195 INREG = 386,
196 SRET = 387,
197 NOUNWIND = 388,
198 DEFAULT = 389,
199 HIDDEN = 390
200 };
201#endif
202/* Tokens. */
203#define ESINT64VAL 258
204#define EUINT64VAL 259
205#define ESAPINTVAL 260
206#define EUAPINTVAL 261
207#define LOCALVAL_ID 262
208#define GLOBALVAL_ID 263
209#define FPVAL 264
210#define VOID 265
211#define INTTYPE 266
212#define FLOAT 267
213#define DOUBLE 268
214#define LABEL 269
215#define TYPE 270
216#define LOCALVAR 271
217#define GLOBALVAR 272
218#define LABELSTR 273
219#define STRINGCONSTANT 274
220#define ATSTRINGCONSTANT 275
221#define ZEROINITIALIZER 276
222#define TRUETOK 277
223#define FALSETOK 278
224#define BEGINTOK 279
225#define ENDTOK 280
226#define DECLARE 281
227#define DEFINE 282
228#define GLOBAL 283
229#define CONSTANT 284
230#define SECTION 285
231#define ALIAS 286
232#define VOLATILE 287
233#define THREAD_LOCAL 288
234#define TO 289
235#define DOTDOTDOT 290
236#define NULL_TOK 291
237#define UNDEF 292
238#define INTERNAL 293
239#define LINKONCE 294
240#define WEAK 295
241#define APPENDING 296
242#define DLLIMPORT 297
243#define DLLEXPORT 298
244#define EXTERN_WEAK 299
245#define OPAQUE 300
246#define EXTERNAL 301
247#define TARGET 302
248#define TRIPLE 303
249#define ALIGN 304
250#define DEPLIBS 305
251#define CALL 306
252#define TAIL 307
253#define ASM_TOK 308
254#define MODULE 309
255#define SIDEEFFECT 310
256#define CC_TOK 311
257#define CCC_TOK 312
258#define FASTCC_TOK 313
259#define COLDCC_TOK 314
260#define X86_STDCALLCC_TOK 315
261#define X86_FASTCALLCC_TOK 316
262#define DATALAYOUT 317
263#define RET 318
264#define BR 319
265#define SWITCH 320
266#define INVOKE 321
267#define UNWIND 322
268#define UNREACHABLE 323
269#define ADD 324
270#define SUB 325
271#define MUL 326
272#define UDIV 327
273#define SDIV 328
274#define FDIV 329
275#define UREM 330
276#define SREM 331
277#define FREM 332
278#define AND 333
279#define OR 334
280#define XOR 335
281#define SHL 336
282#define LSHR 337
283#define ASHR 338
284#define ICMP 339
285#define FCMP 340
286#define EQ 341
287#define NE 342
288#define SLT 343
289#define SGT 344
290#define SLE 345
291#define SGE 346
292#define ULT 347
293#define UGT 348
294#define ULE 349
295#define UGE 350
296#define OEQ 351
297#define ONE 352
298#define OLT 353
299#define OGT 354
300#define OLE 355
301#define OGE 356
302#define ORD 357
303#define UNO 358
304#define UEQ 359
305#define UNE 360
306#define MALLOC 361
307#define ALLOCA 362
308#define FREE 363
309#define LOAD 364
310#define STORE 365
311#define GETELEMENTPTR 366
312#define TRUNC 367
313#define ZEXT 368
314#define SEXT 369
315#define FPTRUNC 370
316#define FPEXT 371
317#define BITCAST 372
318#define UITOFP 373
319#define SITOFP 374
320#define FPTOUI 375
321#define FPTOSI 376
322#define INTTOPTR 377
323#define PTRTOINT 378
324#define PHI_TOK 379
325#define SELECT 380
326#define VAARG 381
327#define EXTRACTELEMENT 382
328#define INSERTELEMENT 383
329#define SHUFFLEVECTOR 384
330#define NORETURN 385
331#define INREG 386
332#define SRET 387
333#define NOUNWIND 388
334#define DEFAULT 389
335#define HIDDEN 390
336
337
338
339
340/* Copy the first part of user declarations. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000341#line 14 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000342
343#include "ParserInternals.h"
344#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000345#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000346#include "llvm/Instructions.h"
347#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000348#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000349#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000350#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000351#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000352#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000353#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000354#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000355#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000356#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000357#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000358#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000359#ifndef NDEBUG
360#define YYDEBUG 1
361#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000362
Reid Spencere4f47592006-08-18 17:32:55 +0000363// The following is a gross hack. In order to rid the libAsmParser library of
364// exceptions, we have to have a way of getting the yyparse function to go into
365// an error situation. So, whenever we want an error to occur, the GenerateError
366// function (see bottom of file) sets TriggerError. Then, at the end of each
367// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
368// (a goto) to put YACC in error state. Furthermore, several calls to
369// GenerateError are made from inside productions and they must simulate the
370// previous exception behavior by exiting the production immediately. We have
371// replaced these with the GEN_ERROR macro which calls GeneratError and then
372// immediately invokes YYERROR. This would be so much cleaner if it was a
373// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000374static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000375#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000376#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
377
Reid Spencer68a24bd2005-08-27 18:50:39 +0000378int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
379int yylex(); // declaration" of xxx warnings.
380int yyparse();
381
382namespace llvm {
383 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000384#if YYDEBUG
385static cl::opt<bool>
386Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
387 cl::Hidden, cl::init(false));
388#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000389}
390using namespace llvm;
391
392static Module *ParserResult;
393
394// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
395// relating to upreferences in the input stream.
396//
397//#define DEBUG_UPREFS 1
398#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000399#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000400#else
401#define UR_OUT(X)
402#endif
403
404#define YYERROR_VERBOSE 1
405
Chris Lattnerb475c422005-11-12 18:22:38 +0000406static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000407
408
409// This contains info used when building the body of a function. It is
410// destroyed when the function is completed.
411//
412typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000413
Reid Spencer68a24bd2005-08-27 18:50:39 +0000414static void
Reid Spencer93c40032007-03-19 18:40:50 +0000415ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000416
417static struct PerModuleInfo {
418 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000419 ValueList Values; // Module level numbered definitions
420 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000421 std::vector<PATypeHolder> Types;
422 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000423
424 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000425 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000426 /// that we can resolve them later and print error messages as appropriate.
427 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
428
429 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
430 // references to global values. Global values may be referenced before they
431 // are defined, and if so, the temporary object that they represent is held
432 // here. This is used for forward references of GlobalValues.
433 //
434 typedef std::map<std::pair<const PointerType *,
435 ValID>, GlobalValue*> GlobalRefsType;
436 GlobalRefsType GlobalRefs;
437
438 void ModuleDone() {
439 // If we could not resolve some functions at function compilation time
440 // (calls to functions before they are defined), resolve them now... Types
441 // are resolved when the constant pool has been completely parsed.
442 //
443 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000444 if (TriggerError)
445 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000446
447 // Check to make sure that all global value forward references have been
448 // resolved!
449 //
450 if (!GlobalRefs.empty()) {
451 std::string UndefinedReferences = "Unresolved global references exist:\n";
452
453 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
454 I != E; ++I) {
455 UndefinedReferences += " " + I->first.first->getDescription() + " " +
456 I->first.second.getName() + "\n";
457 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000458 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000459 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000460 }
461
462 Values.clear(); // Clear out function local definitions
463 Types.clear();
464 CurrentModule = 0;
465 }
466
Reid Spencer68a24bd2005-08-27 18:50:39 +0000467 // GetForwardRefForGlobal - Check to see if there is a forward reference
468 // for this global. If so, remove it from the GlobalRefs map and return it.
469 // If not, just return null.
470 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
471 // Check to see if there is a forward reference to this global variable...
472 // if there is, eliminate it and patch the reference to use the new def'n.
473 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
474 GlobalValue *Ret = 0;
475 if (I != GlobalRefs.end()) {
476 Ret = I->second;
477 GlobalRefs.erase(I);
478 }
479 return Ret;
480 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000481
482 bool TypeIsUnresolved(PATypeHolder* PATy) {
483 // If it isn't abstract, its resolved
484 const Type* Ty = PATy->get();
485 if (!Ty->isAbstract())
486 return false;
487 // Traverse the type looking for abstract types. If it isn't abstract then
488 // we don't need to traverse that leg of the type.
489 std::vector<const Type*> WorkList, SeenList;
490 WorkList.push_back(Ty);
491 while (!WorkList.empty()) {
492 const Type* Ty = WorkList.back();
493 SeenList.push_back(Ty);
494 WorkList.pop_back();
495 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
496 // Check to see if this is an unresolved type
497 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
498 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
499 for ( ; I != E; ++I) {
500 if (I->second.get() == OpTy)
501 return true;
502 }
503 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
504 const Type* TheTy = SeqTy->getElementType();
505 if (TheTy->isAbstract() && TheTy != Ty) {
506 std::vector<const Type*>::iterator I = SeenList.begin(),
507 E = SeenList.end();
508 for ( ; I != E; ++I)
509 if (*I == TheTy)
510 break;
511 if (I == E)
512 WorkList.push_back(TheTy);
513 }
514 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
515 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
516 const Type* TheTy = StrTy->getElementType(i);
517 if (TheTy->isAbstract() && TheTy != Ty) {
518 std::vector<const Type*>::iterator I = SeenList.begin(),
519 E = SeenList.end();
520 for ( ; I != E; ++I)
521 if (*I == TheTy)
522 break;
523 if (I == E)
524 WorkList.push_back(TheTy);
525 }
526 }
527 }
528 }
529 return false;
530 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000531} CurModule;
532
533static struct PerFunctionInfo {
534 Function *CurrentFunction; // Pointer to current function being created
535
Reid Spencer93c40032007-03-19 18:40:50 +0000536 ValueList Values; // Keep track of #'d definitions
537 unsigned NextValNum;
538 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000539 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000540 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000541 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000542
543 /// BBForwardRefs - When we see forward references to basic blocks, keep
544 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000545 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000546
547 inline PerFunctionInfo() {
548 CurrentFunction = 0;
549 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000550 Linkage = GlobalValue::ExternalLinkage;
551 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000552 }
553
554 inline void FunctionStart(Function *M) {
555 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000556 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000557 }
558
559 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000560 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000561 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000562 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000563 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000564 return;
565 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000566
567 // Resolve all forward references now.
568 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
569
570 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000571 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000572 CurrentFunction = 0;
573 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000574 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000575 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000576 }
577} CurFun; // Info for the current function...
578
579static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
580
581
582//===----------------------------------------------------------------------===//
583// Code to handle definitions of all the types
584//===----------------------------------------------------------------------===//
585
Reid Spencer93c40032007-03-19 18:40:50 +0000586static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
587 // Things that have names or are void typed don't get slot numbers
588 if (V->hasName() || (V->getType() == Type::VoidTy))
589 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000590
Reid Spencer93c40032007-03-19 18:40:50 +0000591 // In the case of function values, we have to allow for the forward reference
592 // of basic blocks, which are included in the numbering. Consequently, we keep
593 // track of the next insertion location with NextValNum. When a BB gets
594 // inserted, it could change the size of the CurFun.Values vector.
595 if (&ValueTab == &CurFun.Values) {
596 if (ValueTab.size() <= CurFun.NextValNum)
597 ValueTab.resize(CurFun.NextValNum+1);
598 ValueTab[CurFun.NextValNum++] = V;
599 return;
600 }
601 // For all other lists, its okay to just tack it on the back of the vector.
602 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000603}
604
605static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
606 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000607 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000608 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000609 if (D.Num < CurModule.Types.size())
610 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000612 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000613 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
614 D.destroy(); // Free old strdup'd memory...
615 return N;
616 }
617 break;
618 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000619 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000620 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621 }
622
623 // If we reached here, we referenced either a symbol that we don't know about
624 // or an id number that hasn't been read yet. We may be referencing something
625 // forward, so just create an entry to be resolved later and get to it...
626 //
627 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
628
629
630 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000631 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000632 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000633 return 0;
634 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000635 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000636 return 0;
637 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000638 }
639
Reid Spencer861d9d62006-11-28 07:29:44 +0000640 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000642 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000643
Reid Spencer861d9d62006-11-28 07:29:44 +0000644 Type *Typ = OpaqueType::get();
645 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
646 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000647 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000648
Reid Spencer93c40032007-03-19 18:40:50 +0000649// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000650// the provided ValID. If the value exists and has already been defined, return
651// it. Otherwise return null.
652//
Reid Spencer93c40032007-03-19 18:40:50 +0000653static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000654 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000655 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000656 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000657 return 0;
658 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000659
660 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000661 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000662 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000663 if (D.Num >= CurFun.Values.size())
664 return 0;
665 Value *Result = CurFun.Values[D.Num];
666 if (Ty != Result->getType()) {
667 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
668 Result->getType()->getDescription() + "' does not match "
669 "expected type, '" + Ty->getDescription() + "'");
670 return 0;
671 }
672 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000673 }
674 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000675 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000676 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000677 Value *Result = CurModule.Values[D.Num];
678 if (Ty != Result->getType()) {
679 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
680 Result->getType()->getDescription() + "' does not match "
681 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000682 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000683 }
684 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000685 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000686
687 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000688 if (!inFunctionScope())
689 return 0;
690 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
691 Value *N = SymTab.lookup(D.Name);
692 if (N == 0)
693 return 0;
694 if (N->getType() != Ty)
695 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000696
697 D.destroy(); // Free old strdup'd memory...
698 return N;
699 }
700 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000701 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
702 Value *N = SymTab.lookup(D.Name);
703 if (N == 0)
704 return 0;
705 if (N->getType() != Ty)
706 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000707
708 D.destroy(); // Free old strdup'd memory...
709 return N;
710 }
711
712 // Check to make sure that "Ty" is an integral type, and that our
713 // value will fit into the specified type...
714 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000715 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000716 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000717 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000718 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000719 return 0;
720 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000721 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000722
723 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000724 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
725 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000726 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000727 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000728 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000729 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000730 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000731 }
732 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000733 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000734 }
735
736 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000737 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000738 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000739 return 0;
740 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000741 return ConstantFP::get(Ty, D.ConstPoolFP);
742
743 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000744 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000745 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000746 return 0;
747 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000748 return ConstantPointerNull::get(cast<PointerType>(Ty));
749
750 case ValID::ConstUndefVal: // Is it an undef value?
751 return UndefValue::get(Ty);
752
Chris Lattner7aa61892005-12-21 17:53:23 +0000753 case ValID::ConstZeroVal: // Is it a zero value?
754 return Constant::getNullValue(Ty);
755
Reid Spencer68a24bd2005-08-27 18:50:39 +0000756 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000757 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000758 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000759 return 0;
760 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000761 return D.ConstantValue;
762
Chris Lattner0e9c3762006-01-25 22:27:16 +0000763 case ValID::InlineAsmVal: { // Inline asm expression
764 const PointerType *PTy = dyn_cast<PointerType>(Ty);
765 const FunctionType *FTy =
766 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000768 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000769 return 0;
770 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000771 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
772 D.IAD->HasSideEffects);
773 D.destroy(); // Free InlineAsmDescriptor.
774 return IA;
775 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000777 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000778 return 0;
779 } // End of switch
780
Reid Spencera9720f52007-02-05 17:04:00 +0000781 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000782 return 0;
783}
784
Reid Spencer93c40032007-03-19 18:40:50 +0000785// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000786// value is not already defined, it "improvises" by creating a placeholder var
787// that looks and acts just like the requested variable. When the value is
788// defined later, all uses of the placeholder variable are replaced with the
789// real thing.
790//
791static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000792 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000793 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000794 return 0;
795 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000796
797 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000798 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000799 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000800 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000801
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000803 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000804 return 0;
805 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000806
807 // If we reached here, we referenced either a symbol that we don't know about
808 // or an id number that hasn't been read yet. We may be referencing something
809 // forward, so just create an entry to be resolved later and get to it...
810 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000811 switch (ID.Type) {
812 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000813 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000814 const PointerType *PTy = dyn_cast<PointerType>(Ty);
815 if (!PTy) {
816 GenerateError("Invalid type for reference to global" );
817 return 0;
818 }
819 const Type* ElTy = PTy->getElementType();
820 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
821 V = new Function(FTy, GlobalValue::ExternalLinkage);
822 else
823 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
824 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000825 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000826 default:
827 V = new Argument(Ty);
828 }
829
Reid Spencer68a24bd2005-08-27 18:50:39 +0000830 // Remember where this forward reference came from. FIXME, shouldn't we try
831 // to recycle these things??
832 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
833 llvmAsmlineno)));
834
835 if (inFunctionScope())
836 InsertValue(V, CurFun.LateResolveValues);
837 else
838 InsertValue(V, CurModule.LateResolveValues);
839 return V;
840}
841
Reid Spencer93c40032007-03-19 18:40:50 +0000842/// defineBBVal - This is a definition of a new basic block with the specified
843/// identifier which must be the same as CurFun.NextValNum, if its numeric.
844static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000845 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000846
Reid Spencer68a24bd2005-08-27 18:50:39 +0000847 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000848
Reid Spencer93c40032007-03-19 18:40:50 +0000849 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000850
Reid Spencer93c40032007-03-19 18:40:50 +0000851 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
852 if (BBI != CurFun.BBForwardRefs.end()) {
853 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000854 // The forward declaration could have been inserted anywhere in the
855 // function: insert it into the correct place now.
856 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
857 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000858
Reid Spencer66728ef2007-03-20 01:13:36 +0000859 // We're about to erase the entry, save the key so we can clean it up.
860 ValID Tmp = BBI->first;
861
Reid Spencer93c40032007-03-19 18:40:50 +0000862 // Erase the forward ref from the map as its no longer "forward"
863 CurFun.BBForwardRefs.erase(ID);
864
Reid Spencer66728ef2007-03-20 01:13:36 +0000865 // The key has been removed from the map but so we don't want to leave
866 // strdup'd memory around so destroy it too.
867 Tmp.destroy();
868
Reid Spencer93c40032007-03-19 18:40:50 +0000869 // If its a numbered definition, bump the number and set the BB value.
870 if (ID.Type == ValID::LocalID) {
871 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
872 InsertValue(BB);
873 }
874
875 ID.destroy();
876 return BB;
877 }
878
879 // We haven't seen this BB before and its first mention is a definition.
880 // Just create it and return it.
881 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
882 BB = new BasicBlock(Name, CurFun.CurrentFunction);
883 if (ID.Type == ValID::LocalID) {
884 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
885 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000886 }
Reid Spencer93c40032007-03-19 18:40:50 +0000887
888 ID.destroy(); // Free strdup'd memory
889 return BB;
890}
891
892/// getBBVal - get an existing BB value or create a forward reference for it.
893///
894static BasicBlock *getBBVal(const ValID &ID) {
895 assert(inFunctionScope() && "Can't get basic block at global scope!");
896
897 BasicBlock *BB = 0;
898
899 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
900 if (BBI != CurFun.BBForwardRefs.end()) {
901 BB = BBI->second;
902 } if (ID.Type == ValID::LocalName) {
903 std::string Name = ID.Name;
904 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
905 if (N)
906 if (N->getType()->getTypeID() == Type::LabelTyID)
907 BB = cast<BasicBlock>(N);
908 else
909 GenerateError("Reference to label '" + Name + "' is actually of type '"+
910 N->getType()->getDescription() + "'");
911 } else if (ID.Type == ValID::LocalID) {
912 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
913 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
914 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
915 else
916 GenerateError("Reference to label '%" + utostr(ID.Num) +
917 "' is actually of type '"+
918 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
919 }
920 } else {
921 GenerateError("Illegal label reference " + ID.getName());
922 return 0;
923 }
924
925 // If its already been defined, return it now.
926 if (BB) {
927 ID.destroy(); // Free strdup'd memory.
928 return BB;
929 }
930
931 // Otherwise, this block has not been seen before, create it.
932 std::string Name;
933 if (ID.Type == ValID::LocalName)
934 Name = ID.Name;
935 BB = new BasicBlock(Name, CurFun.CurrentFunction);
936
937 // Insert it in the forward refs map.
938 CurFun.BBForwardRefs[ID] = BB;
939
Reid Spencer68a24bd2005-08-27 18:50:39 +0000940 return BB;
941}
942
943
944//===----------------------------------------------------------------------===//
945// Code to handle forward references in instructions
946//===----------------------------------------------------------------------===//
947//
948// This code handles the late binding needed with statements that reference
949// values not defined yet... for example, a forward branch, or the PHI node for
950// a loop body.
951//
952// This keeps a table (CurFun.LateResolveValues) of all such forward references
953// and back patchs after we are done.
954//
955
956// ResolveDefinitions - If we could not resolve some defs at parsing
957// time (forward branches, phi functions for loops, etc...) resolve the
958// defs now...
959//
960static void
Reid Spencer93c40032007-03-19 18:40:50 +0000961ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000962 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000963 while (!LateResolvers.empty()) {
964 Value *V = LateResolvers.back();
965 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000966
Reid Spencer93c40032007-03-19 18:40:50 +0000967 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
968 CurModule.PlaceHolderInfo.find(V);
969 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000970
Reid Spencer93c40032007-03-19 18:40:50 +0000971 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000972
Reid Spencer93c40032007-03-19 18:40:50 +0000973 Value *TheRealValue = getExistingVal(V->getType(), DID);
974 if (TriggerError)
975 return;
976 if (TheRealValue) {
977 V->replaceAllUsesWith(TheRealValue);
978 delete V;
979 CurModule.PlaceHolderInfo.erase(PHI);
980 } else if (FutureLateResolvers) {
981 // Functions have their unresolved items forwarded to the module late
982 // resolver table
983 InsertValue(V, *FutureLateResolvers);
984 } else {
985 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
986 GenerateError("Reference to an invalid definition: '" +DID.getName()+
987 "' of type '" + V->getType()->getDescription() + "'",
988 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000989 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000990 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000991 GenerateError("Reference to an invalid definition: #" +
992 itostr(DID.Num) + " of type '" +
993 V->getType()->getDescription() + "'",
994 PHI->second.second);
995 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000996 }
997 }
998 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000999 LateResolvers.clear();
1000}
1001
1002// ResolveTypeTo - A brand new type was just declared. This means that (if
1003// name is not null) things referencing Name can be resolved. Otherwise, things
1004// refering to the number can be resolved. Do this now.
1005//
1006static void ResolveTypeTo(char *Name, const Type *ToTy) {
1007 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +00001008 if (Name) D = ValID::createLocalName(Name);
1009 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001010
Reid Spencer861d9d62006-11-28 07:29:44 +00001011 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001012 CurModule.LateResolveTypes.find(D);
1013 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001014 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001015 CurModule.LateResolveTypes.erase(I);
1016 }
1017}
1018
1019// setValueName - Set the specified value to the name given. The name may be
1020// null potentially, in which case this is a noop. The string passed in is
1021// assumed to be a malloc'd string buffer, and is free'd by this function.
1022//
1023static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001024 if (!NameStr) return;
1025 std::string Name(NameStr); // Copy string
1026 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001027
Reid Spencer41dff5e2007-01-26 08:05:27 +00001028 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001029 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001030 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001031 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001032
Reid Spencera9720f52007-02-05 17:04:00 +00001033 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001034 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1035 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001036 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001037 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001038 return;
1039 }
1040
1041 // Set the name.
1042 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001043}
1044
1045/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1046/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001047static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001048ParseGlobalVariable(char *NameStr,
1049 GlobalValue::LinkageTypes Linkage,
1050 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001051 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001052 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001053 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001054 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001055 return 0;
1056 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001057
1058 const PointerType *PTy = PointerType::get(Ty);
1059
1060 std::string Name;
1061 if (NameStr) {
1062 Name = NameStr; // Copy string
1063 free(NameStr); // Free old string
1064 }
1065
1066 // See if this global value was forward referenced. If so, recycle the
1067 // object.
1068 ValID ID;
1069 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001070 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001071 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001072 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001073 }
1074
1075 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1076 // Move the global to the end of the list, from whereever it was
1077 // previously inserted.
1078 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1079 CurModule.CurrentModule->getGlobalList().remove(GV);
1080 CurModule.CurrentModule->getGlobalList().push_back(GV);
1081 GV->setInitializer(Initializer);
1082 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001083 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001084 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001085 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001086 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001087 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001088 }
1089
Reid Spenceref9b9a72007-02-05 20:47:22 +00001090 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001091 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001092 // if the global we're parsing has an initializer (is a definition) and
1093 // has external linkage.
1094 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1095 // If there is already a global with external linkage with this name
1096 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1097 // If we allow this GVar to get created, it will be renamed in the
1098 // symbol table because it conflicts with an existing GVar. We can't
1099 // allow redefinition of GVars whose linking indicates that their name
1100 // must stay the same. Issue the error.
1101 GenerateError("Redefinition of global variable named '" + Name +
1102 "' of type '" + Ty->getDescription() + "'");
1103 return 0;
1104 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001105 }
1106
1107 // Otherwise there is no existing GV to use, create one now.
1108 GlobalVariable *GV =
1109 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001110 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001111 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001112 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001113 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001114}
1115
1116// setTypeName - Set the specified type to the name given. The name may be
1117// null potentially, in which case this is a noop. The string passed in is
1118// assumed to be a malloc'd string buffer, and is freed by this function.
1119//
1120// This function returns true if the type has already been defined, but is
1121// allowed to be redefined in the specified context. If the name is a new name
1122// for the type plane, it is inserted and false is returned.
1123static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001124 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001125 if (NameStr == 0) return false;
1126
1127 std::string Name(NameStr); // Copy string
1128 free(NameStr); // Free old string
1129
1130 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001131 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001132 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001133 return false;
1134 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001135
1136 // Set the type name, checking for conflicts as we do so.
1137 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1138
1139 if (AlreadyExists) { // Inserting a name that is already defined???
1140 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001141 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001142
1143 // There is only one case where this is allowed: when we are refining an
1144 // opaque type. In this case, Existing will be an opaque type.
1145 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1146 // We ARE replacing an opaque type!
1147 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1148 return true;
1149 }
1150
1151 // Otherwise, this is an attempt to redefine a type. That's okay if
1152 // the redefinition is identical to the original. This will be so if
1153 // Existing and T point to the same Type object. In this one case we
1154 // allow the equivalent redefinition.
1155 if (Existing == T) return true; // Yes, it's equal.
1156
1157 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001158 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001159 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001160 }
1161
1162 return false;
1163}
1164
1165//===----------------------------------------------------------------------===//
1166// Code for handling upreferences in type names...
1167//
1168
1169// TypeContains - Returns true if Ty directly contains E in it.
1170//
1171static bool TypeContains(const Type *Ty, const Type *E) {
1172 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1173 E) != Ty->subtype_end();
1174}
1175
1176namespace {
1177 struct UpRefRecord {
1178 // NestingLevel - The number of nesting levels that need to be popped before
1179 // this type is resolved.
1180 unsigned NestingLevel;
1181
1182 // LastContainedTy - This is the type at the current binding level for the
1183 // type. Every time we reduce the nesting level, this gets updated.
1184 const Type *LastContainedTy;
1185
1186 // UpRefTy - This is the actual opaque type that the upreference is
1187 // represented with.
1188 OpaqueType *UpRefTy;
1189
1190 UpRefRecord(unsigned NL, OpaqueType *URTy)
1191 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1192 };
1193}
1194
1195// UpRefs - A list of the outstanding upreferences that need to be resolved.
1196static std::vector<UpRefRecord> UpRefs;
1197
1198/// HandleUpRefs - Every time we finish a new layer of types, this function is
1199/// called. It loops through the UpRefs vector, which is a list of the
1200/// currently active types. For each type, if the up reference is contained in
1201/// the newly completed type, we decrement the level count. When the level
1202/// count reaches zero, the upreferenced type is the type that is passed in:
1203/// thus we can complete the cycle.
1204///
1205static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001206 // If Ty isn't abstract, or if there are no up-references in it, then there is
1207 // nothing to resolve here.
1208 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1209
Reid Spencer68a24bd2005-08-27 18:50:39 +00001210 PATypeHolder Ty(ty);
1211 UR_OUT("Type '" << Ty->getDescription() <<
1212 "' newly formed. Resolving upreferences.\n" <<
1213 UpRefs.size() << " upreferences active!\n");
1214
1215 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1216 // to zero), we resolve them all together before we resolve them to Ty. At
1217 // the end of the loop, if there is anything to resolve to Ty, it will be in
1218 // this variable.
1219 OpaqueType *TypeToResolve = 0;
1220
1221 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1222 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1223 << UpRefs[i].second->getDescription() << ") = "
1224 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1225 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1226 // Decrement level of upreference
1227 unsigned Level = --UpRefs[i].NestingLevel;
1228 UpRefs[i].LastContainedTy = Ty;
1229 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1230 if (Level == 0) { // Upreference should be resolved!
1231 if (!TypeToResolve) {
1232 TypeToResolve = UpRefs[i].UpRefTy;
1233 } else {
1234 UR_OUT(" * Resolving upreference for "
1235 << UpRefs[i].second->getDescription() << "\n";
1236 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1237 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1238 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1239 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1240 }
1241 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1242 --i; // Do not skip the next element...
1243 }
1244 }
1245 }
1246
1247 if (TypeToResolve) {
1248 UR_OUT(" * Resolving upreference for "
1249 << UpRefs[i].second->getDescription() << "\n";
1250 std::string OldName = TypeToResolve->getDescription());
1251 TypeToResolve->refineAbstractTypeTo(Ty);
1252 }
1253
1254 return Ty;
1255}
1256
Reid Spencer68a24bd2005-08-27 18:50:39 +00001257//===----------------------------------------------------------------------===//
1258// RunVMAsmParser - Define an interface to this parser
1259//===----------------------------------------------------------------------===//
1260//
Reid Spencer14310612006-12-31 05:40:51 +00001261static Module* RunParser(Module * M);
1262
Reid Spencer68a24bd2005-08-27 18:50:39 +00001263Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1264 set_scan_file(F);
1265
1266 CurFilename = Filename;
1267 return RunParser(new Module(CurFilename));
1268}
1269
1270Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1271 set_scan_string(AsmString);
1272
1273 CurFilename = "from_memory";
1274 if (M == NULL) {
1275 return RunParser(new Module (CurFilename));
1276 } else {
1277 return RunParser(M);
1278 }
1279}
1280
1281
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001282
1283/* Enabling traces. */
1284#ifndef YYDEBUG
1285# define YYDEBUG 0
1286#endif
1287
1288/* Enabling verbose error messages. */
1289#ifdef YYERROR_VERBOSE
1290# undef YYERROR_VERBOSE
1291# define YYERROR_VERBOSE 1
1292#else
1293# define YYERROR_VERBOSE 0
1294#endif
1295
1296/* Enabling the token table. */
1297#ifndef YYTOKEN_TABLE
1298# define YYTOKEN_TABLE 0
1299#endif
1300
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001301#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1302#line 955 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
1303typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001304 llvm::Module *ModuleVal;
1305 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001306 llvm::BasicBlock *BasicBlockVal;
1307 llvm::TerminatorInst *TermInstVal;
1308 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001309 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001310
Reid Spencera132e042006-12-03 05:46:11 +00001311 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001312 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001313 llvm::PATypeHolder *TypeVal;
1314 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001315 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001316 llvm::ArgListType *ArgList;
1317 llvm::TypeWithAttrs TypeWithAttrs;
1318 llvm::TypeWithAttrsList *TypeWithAttrsList;
1319 llvm::ValueRefList *ValueRefList;
1320
Reid Spencer68a24bd2005-08-27 18:50:39 +00001321 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001322 std::list<std::pair<llvm::Value*,
1323 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001324 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001325 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001326
1327 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001328 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001329 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001330 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001331 int64_t SInt64Val;
1332 uint64_t UInt64Val;
1333 int SIntVal;
1334 unsigned UIntVal;
1335 double FPVal;
1336 bool BoolVal;
1337
1338 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001339 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001340
Reid Spencera132e042006-12-03 05:46:11 +00001341 llvm::Instruction::BinaryOps BinaryOpVal;
1342 llvm::Instruction::TermOps TermOpVal;
1343 llvm::Instruction::MemoryOps MemOpVal;
1344 llvm::Instruction::CastOps CastOpVal;
1345 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001346 llvm::ICmpInst::Predicate IPredicate;
1347 llvm::FCmpInst::Predicate FPredicate;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001348} YYSTYPE;
1349/* Line 196 of yacc.c. */
1350#line 1351 "llvmAsmParser.tab.c"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001351# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1352# define YYSTYPE_IS_DECLARED 1
1353# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001354#endif
1355
Reid Spencer41dff5e2007-01-26 08:05:27 +00001356
Reid Spencer68a24bd2005-08-27 18:50:39 +00001357
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001358/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001359
1360
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001361/* Line 219 of yacc.c. */
1362#line 1363 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001363
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001364#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1365# define YYSIZE_T __SIZE_TYPE__
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001366#endif
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001367#if ! defined (YYSIZE_T) && defined (size_t)
1368# define YYSIZE_T size_t
Reid Spencer7780acb2007-04-16 06:56:07 +00001369#endif
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001370#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1371# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1372# define YYSIZE_T size_t
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001373#endif
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001374#if ! defined (YYSIZE_T)
1375# define YYSIZE_T unsigned int
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001376#endif
1377
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001378#ifndef YY_
1379# if YYENABLE_NLS
1380# if ENABLE_NLS
1381# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1382# define YY_(msgid) dgettext ("bison-runtime", msgid)
1383# endif
1384# endif
1385# ifndef YY_
1386# define YY_(msgid) msgid
1387# endif
1388#endif
1389
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001390#if ! defined (yyoverflow) || YYERROR_VERBOSE
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001391
1392/* The parser invokes alloca or malloc; define the necessary symbols. */
1393
1394# ifdef YYSTACK_USE_ALLOCA
1395# if YYSTACK_USE_ALLOCA
1396# ifdef __GNUC__
1397# define YYSTACK_ALLOC __builtin_alloca
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001398# else
1399# define YYSTACK_ALLOC alloca
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001400# if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001401# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001402# define YYINCLUDED_STDLIB_H
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001403# endif
1404# endif
1405# endif
1406# endif
1407
1408# ifdef YYSTACK_ALLOC
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001409 /* Pacify GCC's `empty if-body' warning. */
1410# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001411# ifndef YYSTACK_ALLOC_MAXIMUM
1412 /* The OS might guarantee only one guard page at the bottom of the stack,
1413 and a page size can be as small as 4096 bytes. So we cannot safely
1414 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1415 to allow for a few compiler-allocated temporary stack slots. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001416# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001417# endif
1418# else
1419# define YYSTACK_ALLOC YYMALLOC
1420# define YYSTACK_FREE YYFREE
1421# ifndef YYSTACK_ALLOC_MAXIMUM
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001422# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001423# endif
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001424# ifdef __cplusplus
1425extern "C" {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001426# endif
1427# ifndef YYMALLOC
1428# define YYMALLOC malloc
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001429# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1430 && (defined (__STDC__) || defined (__cplusplus)))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001431void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1432# endif
1433# endif
1434# ifndef YYFREE
1435# define YYFREE free
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001436# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1437 && (defined (__STDC__) || defined (__cplusplus)))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001438void free (void *); /* INFRINGES ON USER NAME SPACE */
1439# endif
1440# endif
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001441# ifdef __cplusplus
1442}
1443# endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001444# endif
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001445#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001446
1447
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001448#if (! defined (yyoverflow) \
1449 && (! defined (__cplusplus) \
1450 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001451
1452/* A type that is properly aligned for any stack member. */
1453union yyalloc
1454{
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001455 short int yyss;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001456 YYSTYPE yyvs;
1457 };
1458
1459/* The size of the maximum gap between one aligned stack and the next. */
1460# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1461
1462/* The size of an array large to enough to hold all stacks, each with
1463 N elements. */
1464# define YYSTACK_BYTES(N) \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001465 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001466 + YYSTACK_GAP_MAXIMUM)
1467
1468/* Copy COUNT objects from FROM to TO. The source and destination do
1469 not overlap. */
1470# ifndef YYCOPY
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001471# if defined (__GNUC__) && 1 < __GNUC__
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001472# define YYCOPY(To, From, Count) \
1473 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1474# else
1475# define YYCOPY(To, From, Count) \
1476 do \
1477 { \
1478 YYSIZE_T yyi; \
1479 for (yyi = 0; yyi < (Count); yyi++) \
1480 (To)[yyi] = (From)[yyi]; \
1481 } \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001482 while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001483# endif
1484# endif
1485
1486/* Relocate STACK from its old location to the new one. The
1487 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1488 elements in the stack, and YYPTR gives the new location of the
1489 stack. Advance YYPTR to a properly aligned location for the next
1490 stack. */
1491# define YYSTACK_RELOCATE(Stack) \
1492 do \
1493 { \
1494 YYSIZE_T yynewbytes; \
1495 YYCOPY (&yyptr->Stack, Stack, yysize); \
1496 Stack = &yyptr->Stack; \
1497 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1498 yyptr += yynewbytes / sizeof (*yyptr); \
1499 } \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001500 while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001501
1502#endif
1503
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001504#if defined (__STDC__) || defined (__cplusplus)
1505 typedef signed char yysigned_char;
1506#else
1507 typedef short int yysigned_char;
1508#endif
1509
1510/* YYFINAL -- State number of the termination state. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001511#define YYFINAL 41
1512/* YYLAST -- Last index in YYTABLE. */
1513#define YYLAST 1600
1514
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001515/* YYNTOKENS -- Number of terminals. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001516#define YYNTOKENS 150
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001517/* YYNNTS -- Number of nonterminals. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001518#define YYNNTS 82
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001519/* YYNRULES -- Number of rules. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001520#define YYNRULES 296
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001521/* YYNRULES -- Number of states. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001522#define YYNSTATES 580
1523
1524/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1525#define YYUNDEFTOK 2
1526#define YYMAXUTOK 390
1527
1528#define YYTRANSLATE(YYX) \
1529 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1530
1531/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001532static const unsigned char yytranslate[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001533{
1534 0, 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 140, 141, 138, 2, 137, 2, 2, 2, 2, 2,
1539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1540 145, 136, 146, 2, 2, 2, 2, 2, 2, 2,
1541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1543 2, 142, 139, 144, 2, 2, 2, 2, 2, 149,
1544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1546 143, 2, 2, 147, 2, 148, 2, 2, 2, 2,
1547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1559 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1560 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1561 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1562 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1563 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1564 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1565 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1566 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1567 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1568 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1569 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1570 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1571 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1572 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1573 135
1574};
1575
1576#if YYDEBUG
1577/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1578 YYRHS. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001579static const unsigned short int yyprhs[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001580{
1581 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1582 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1583 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1584 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1585 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1586 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1587 119, 121, 122, 125, 126, 128, 130, 132, 133, 136,
1588 138, 140, 142, 144, 146, 148, 150, 152, 153, 155,
1589 157, 158, 160, 162, 163, 165, 167, 169, 171, 172,
1590 174, 176, 177, 179, 181, 183, 185, 187, 190, 192,
1591 194, 196, 198, 199, 202, 204, 206, 208, 209, 212,
1592 213, 216, 217, 221, 224, 225, 227, 228, 232, 234,
1593 237, 239, 241, 243, 245, 247, 249, 252, 254, 257,
1594 263, 269, 275, 281, 285, 288, 294, 299, 302, 304,
1595 306, 308, 312, 314, 318, 320, 321, 323, 327, 332,
1596 336, 340, 345, 350, 354, 361, 367, 370, 373, 376,
1597 379, 382, 385, 388, 391, 394, 397, 400, 403, 410,
1598 416, 425, 432, 439, 447, 455, 462, 471, 480, 484,
1599 486, 488, 490, 492, 493, 496, 503, 505, 506, 508,
1600 511, 512, 516, 517, 521, 525, 529, 533, 534, 542,
1601 543, 552, 553, 562, 568, 571, 575, 577, 581, 585,
1602 589, 593, 595, 596, 602, 606, 608, 612, 614, 615,
1603 625, 627, 629, 634, 636, 638, 641, 645, 646, 648,
1604 650, 652, 654, 656, 658, 660, 662, 664, 668, 670,
1605 676, 678, 680, 682, 684, 686, 688, 691, 694, 697,
1606 701, 704, 705, 707, 710, 713, 717, 727, 737, 746,
1607 761, 763, 765, 772, 778, 781, 788, 796, 800, 806,
1608 807, 808, 812, 815, 817, 823, 829, 836, 843, 848,
1609 855, 860, 865, 872, 879, 882, 891, 893, 895, 896,
1610 900, 907, 911, 918, 921, 927, 935
1611};
1612
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001613/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1614static const short int yyrhs[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001615{
1616 194, 0, -1, 69, -1, 70, -1, 71, -1, 72,
1617 -1, 73, -1, 74, -1, 75, -1, 76, -1, 77,
1618 -1, 81, -1, 82, -1, 83, -1, 78, -1, 79,
1619 -1, 80, -1, 112, -1, 113, -1, 114, -1, 115,
1620 -1, 116, -1, 117, -1, 118, -1, 119, -1, 120,
1621 -1, 121, -1, 122, -1, 123, -1, 86, -1, 87,
1622 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
1623 -1, 93, -1, 94, -1, 95, -1, 96, -1, 97,
1624 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
1625 -1, 103, -1, 104, -1, 105, -1, 92, -1, 93,
1626 -1, 94, -1, 95, -1, 22, -1, 23, -1, 11,
1627 -1, 12, -1, 13, -1, 16, -1, 19, -1, 158,
1628 -1, -1, 158, 136, -1, -1, 17, -1, 20, -1,
1629 163, -1, -1, 161, 136, -1, 38, -1, 40, -1,
1630 39, -1, 41, -1, 43, -1, 42, -1, 44, -1,
1631 46, -1, -1, 134, -1, 135, -1, -1, 42, -1,
1632 44, -1, -1, 38, -1, 39, -1, 40, -1, 43,
1633 -1, -1, 40, -1, 38, -1, -1, 57, -1, 58,
1634 -1, 59, -1, 60, -1, 61, -1, 56, 4, -1,
1635 113, -1, 114, -1, 131, -1, 132, -1, -1, 172,
1636 171, -1, 130, -1, 133, -1, 171, -1, -1, 174,
1637 173, -1, -1, 49, 4, -1, -1, 137, 49, 4,
1638 -1, 30, 19, -1, -1, 177, -1, -1, 137, 180,
1639 179, -1, 177, -1, 49, 4, -1, 11, -1, 12,
1640 -1, 13, -1, 14, -1, 45, -1, 181, -1, 182,
1641 138, -1, 216, -1, 139, 4, -1, 182, 140, 186,
1642 141, 174, -1, 10, 140, 186, 141, 174, -1, 142,
1643 4, 143, 182, 144, -1, 145, 4, 143, 182, 146,
1644 -1, 147, 187, 148, -1, 147, 148, -1, 145, 147,
1645 187, 148, 146, -1, 145, 147, 148, 146, -1, 182,
1646 172, -1, 182, -1, 10, -1, 183, -1, 185, 137,
1647 183, -1, 185, -1, 185, 137, 35, -1, 35, -1,
1648 -1, 182, -1, 187, 137, 182, -1, 182, 142, 190,
1649 144, -1, 182, 142, 144, -1, 182, 149, 19, -1,
1650 182, 145, 190, 146, -1, 182, 147, 190, 148, -1,
1651 182, 147, 148, -1, 182, 145, 147, 190, 148, 146,
1652 -1, 182, 145, 147, 148, 146, -1, 182, 36, -1,
1653 182, 37, -1, 182, 216, -1, 182, 189, -1, 182,
1654 21, -1, 156, 3, -1, 156, 5, -1, 156, 4,
1655 -1, 156, 6, -1, 11, 22, -1, 11, 23, -1,
1656 157, 9, -1, 153, 140, 188, 34, 182, 141, -1,
1657 111, 140, 188, 227, 141, -1, 125, 140, 188, 137,
1658 188, 137, 188, 141, -1, 151, 140, 188, 137, 188,
1659 141, -1, 152, 140, 188, 137, 188, 141, -1, 84,
1660 154, 140, 188, 137, 188, 141, -1, 85, 155, 140,
1661 188, 137, 188, 141, -1, 127, 140, 188, 137, 188,
1662 141, -1, 128, 140, 188, 137, 188, 137, 188, 141,
1663 -1, 129, 140, 188, 137, 188, 137, 188, 141, -1,
1664 190, 137, 188, -1, 188, -1, 28, -1, 29, -1,
1665 33, -1, -1, 184, 216, -1, 117, 140, 193, 34,
1666 182, 141, -1, 195, -1, -1, 196, -1, 195, 196,
1667 -1, -1, 27, 197, 212, -1, -1, 26, 198, 213,
1668 -1, 54, 53, 202, -1, 160, 15, 182, -1, 160,
1669 15, 10, -1, -1, 162, 166, 192, 191, 188, 199,
1670 179, -1, -1, 162, 164, 166, 192, 191, 188, 200,
1671 179, -1, -1, 162, 165, 166, 192, 191, 182, 201,
1672 179, -1, 162, 166, 31, 169, 193, -1, 47, 203,
1673 -1, 50, 136, 204, -1, 19, -1, 48, 136, 19,
1674 -1, 62, 136, 19, -1, 142, 205, 144, -1, 205,
1675 137, 19, -1, 19, -1, -1, 206, 137, 182, 172,
1676 159, -1, 182, 172, 159, -1, 206, -1, 206, 137,
1677 35, -1, 35, -1, -1, 170, 184, 161, 140, 207,
1678 141, 174, 178, 175, -1, 24, -1, 147, -1, 168,
1679 166, 208, 209, -1, 25, -1, 148, -1, 219, 211,
1680 -1, 167, 166, 208, -1, -1, 55, -1, 3, -1,
1681 4, -1, 9, -1, 22, -1, 23, -1, 36, -1,
1682 37, -1, 21, -1, 145, 190, 146, -1, 189, -1,
1683 53, 214, 19, 137, 19, -1, 7, -1, 8, -1,
1684 158, -1, 161, -1, 216, -1, 215, -1, 182, 217,
1685 -1, 219, 220, -1, 210, 220, -1, 221, 160, 222,
1686 -1, 221, 224, -1, -1, 18, -1, 63, 218, -1,
1687 63, 10, -1, 64, 14, 217, -1, 64, 11, 217,
1688 137, 14, 217, 137, 14, 217, -1, 65, 156, 217,
1689 137, 14, 217, 142, 223, 144, -1, 65, 156, 217,
1690 137, 14, 217, 142, 144, -1, 66, 170, 184, 217,
1691 140, 226, 141, 174, 34, 14, 217, 67, 14, 217,
1692 -1, 67, -1, 68, -1, 223, 156, 215, 137, 14,
1693 217, -1, 156, 215, 137, 14, 217, -1, 160, 229,
1694 -1, 182, 142, 217, 137, 217, 144, -1, 225, 137,
1695 142, 217, 137, 217, 144, -1, 182, 217, 172, -1,
1696 226, 137, 182, 217, 172, -1, -1, -1, 227, 137,
1697 218, -1, 52, 51, -1, 51, -1, 151, 182, 217,
1698 137, 217, -1, 152, 182, 217, 137, 217, -1, 84,
1699 154, 182, 217, 137, 217, -1, 85, 155, 182, 217,
1700 137, 217, -1, 153, 218, 34, 182, -1, 125, 218,
1701 137, 218, 137, 218, -1, 126, 218, 137, 182, -1,
1702 127, 218, 137, 218, -1, 128, 218, 137, 218, 137,
1703 218, -1, 129, 218, 137, 218, 137, 218, -1, 124,
1704 225, -1, 228, 170, 184, 217, 140, 226, 141, 174,
1705 -1, 231, -1, 32, -1, -1, 106, 182, 176, -1,
1706 106, 182, 137, 11, 217, 176, -1, 107, 182, 176,
1707 -1, 107, 182, 137, 11, 217, 176, -1, 108, 218,
1708 -1, 230, 109, 182, 217, 176, -1, 230, 110, 218,
1709 137, 182, 217, 176, -1, 111, 182, 217, 227, -1
1710};
1711
1712/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001713static const unsigned short int yyrline[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001714{
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001715 0, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111,
1716 1111, 1112, 1112, 1112, 1112, 1112, 1112, 1113, 1113, 1113,
1717 1113, 1113, 1113, 1114, 1114, 1114, 1114, 1114, 1114, 1117,
1718 1117, 1118, 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1125,
1719 1125, 1126, 1126, 1127, 1127, 1128, 1128, 1129, 1129, 1130,
1720 1130, 1131, 1131, 1132, 1133, 1138, 1139, 1139, 1141, 1141,
1721 1142, 1142, 1146, 1150, 1155, 1155, 1157, 1158, 1163, 1169,
1722 1170, 1171, 1172, 1173, 1177, 1178, 1179, 1183, 1184, 1185,
1723 1189, 1190, 1191, 1195, 1196, 1197, 1198, 1199, 1203, 1204,
1724 1205, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1221, 1222,
1725 1223, 1224, 1227, 1228, 1233, 1234, 1235, 1238, 1239, 1246,
1726 1247, 1253, 1254, 1262, 1270, 1271, 1276, 1277, 1278, 1283,
1727 1296, 1296, 1296, 1296, 1299, 1303, 1307, 1314, 1319, 1327,
1728 1357, 1388, 1393, 1405, 1415, 1419, 1429, 1436, 1443, 1450,
1729 1455, 1460, 1467, 1468, 1475, 1482, 1490, 1496, 1508, 1536,
1730 1552, 1581, 1609, 1635, 1655, 1681, 1701, 1713, 1720, 1786,
1731 1796, 1806, 1812, 1822, 1828, 1838, 1843, 1848, 1856, 1868,
1732 1890, 1898, 1904, 1915, 1920, 1925, 1931, 1937, 1946, 1950,
1733 1958, 1958, 1961, 1961, 1964, 1975, 1996, 2001, 2009, 2010,
1734 2014, 2014, 2018, 2018, 2021, 2024, 2048, 2059, 2059, 2070,
1735 2069, 2079, 2078, 2089, 2104, 2107, 2113, 2126, 2130, 2135,
1736 2137, 2142, 2147, 2156, 2166, 2177, 2181, 2190, 2199, 2204,
1737 2326, 2326, 2328, 2337, 2337, 2339, 2344, 2356, 2360, 2365,
1738 2369, 2373, 2377, 2381, 2385, 2389, 2393, 2397, 2422, 2426,
1739 2440, 2444, 2448, 2452, 2458, 2458, 2464, 2473, 2477, 2486,
1740 2495, 2504, 2508, 2513, 2517, 2521, 2526, 2536, 2555, 2564,
1741 2644, 2648, 2655, 2666, 2679, 2689, 2700, 2710, 2719, 2728,
1742 2731, 2732, 2739, 2743, 2748, 2769, 2786, 2800, 2814, 2826,
1743 2834, 2841, 2847, 2853, 2859, 2874, 2959, 2964, 2968, 2975,
1744 2982, 2990, 2997, 3005, 3013, 3027, 3044
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001745};
1746#endif
1747
1748#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1749/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001750 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001751static const char *const yytname[] =
1752{
1753 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1754 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1755 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
1756 "STRINGCONSTANT", "ATSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1757 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1758 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1759 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1760 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1761 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1762 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1763 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1764 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1765 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1766 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1767 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1768 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1769 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1770 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1771 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1772 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET",
1773 "NOUNWIND", "DEFAULT", "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('",
1774 "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept",
1775 "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", "FPredicates",
1776 "IntType", "FPType", "LocalName", "OptLocalName", "OptLocalAssign",
1777 "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1778 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1779 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1780 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign",
1781 "SectionString", "OptSection", "GlobalVarAttributes",
1782 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1783 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1784 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1785 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1786 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1787 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1788 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1789 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1790 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1791 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1792 "OptVolatile", "MemoryInst", 0
1793};
1794#endif
1795
1796# ifdef YYPRINT
1797/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1798 token YYLEX-NUM. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001799static const unsigned short int yytoknum[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001800{
1801 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1802 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1803 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1804 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1805 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1806 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1807 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1808 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1809 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1810 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1811 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1812 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1813 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1814 385, 386, 387, 388, 389, 390, 61, 44, 42, 92,
1815 40, 41, 91, 120, 93, 60, 62, 123, 125, 99
1816};
1817# endif
1818
1819/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001820static const unsigned char yyr1[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001821{
1822 0, 150, 151, 151, 151, 151, 151, 151, 151, 151,
1823 151, 152, 152, 152, 152, 152, 152, 153, 153, 153,
1824 153, 153, 153, 153, 153, 153, 153, 153, 153, 154,
1825 154, 154, 154, 154, 154, 154, 154, 154, 154, 155,
1826 155, 155, 155, 155, 155, 155, 155, 155, 155, 155,
1827 155, 155, 155, 155, 155, 156, 157, 157, 158, 158,
1828 159, 159, 160, 160, 161, 161, 162, 162, 163, 164,
1829 164, 164, 164, 164, 165, 165, 165, 166, 166, 166,
1830 167, 167, 167, 168, 168, 168, 168, 168, 169, 169,
1831 169, 170, 170, 170, 170, 170, 170, 170, 171, 171,
1832 171, 171, 172, 172, 173, 173, 173, 174, 174, 175,
1833 175, 176, 176, 177, 178, 178, 179, 179, 180, 180,
1834 181, 181, 181, 181, 182, 182, 182, 182, 182, 182,
1835 182, 182, 182, 182, 182, 182, 182, 183, 184, 184,
1836 185, 185, 186, 186, 186, 186, 187, 187, 188, 188,
1837 188, 188, 188, 188, 188, 188, 188, 188, 188, 188,
1838 188, 188, 188, 188, 188, 188, 188, 188, 189, 189,
1839 189, 189, 189, 189, 189, 189, 189, 189, 190, 190,
1840 191, 191, 192, 192, 193, 193, 194, 194, 195, 195,
1841 197, 196, 198, 196, 196, 196, 196, 199, 196, 200,
1842 196, 201, 196, 196, 196, 196, 202, 203, 203, 204,
1843 205, 205, 205, 206, 206, 207, 207, 207, 207, 208,
1844 209, 209, 210, 211, 211, 212, 213, 214, 214, 215,
1845 215, 215, 215, 215, 215, 215, 215, 215, 215, 215,
1846 216, 216, 216, 216, 217, 217, 218, 219, 219, 220,
1847 221, 221, 221, 222, 222, 222, 222, 222, 222, 222,
1848 222, 222, 223, 223, 224, 225, 225, 226, 226, 226,
1849 227, 227, 228, 228, 229, 229, 229, 229, 229, 229,
1850 229, 229, 229, 229, 229, 229, 229, 230, 230, 231,
1851 231, 231, 231, 231, 231, 231, 231
1852};
1853
1854/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001855static const unsigned char yyr2[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001856{
1857 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1858 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1859 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1860 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1861 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1862 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1863 1, 0, 2, 0, 1, 1, 1, 0, 2, 1,
1864 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
1865 0, 1, 1, 0, 1, 1, 1, 1, 0, 1,
1866 1, 0, 1, 1, 1, 1, 1, 2, 1, 1,
1867 1, 1, 0, 2, 1, 1, 1, 0, 2, 0,
1868 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
1869 1, 1, 1, 1, 1, 1, 2, 1, 2, 5,
1870 5, 5, 5, 3, 2, 5, 4, 2, 1, 1,
1871 1, 3, 1, 3, 1, 0, 1, 3, 4, 3,
1872 3, 4, 4, 3, 6, 5, 2, 2, 2, 2,
1873 2, 2, 2, 2, 2, 2, 2, 2, 6, 5,
1874 8, 6, 6, 7, 7, 6, 8, 8, 3, 1,
1875 1, 1, 1, 0, 2, 6, 1, 0, 1, 2,
1876 0, 3, 0, 3, 3, 3, 3, 0, 7, 0,
1877 8, 0, 8, 5, 2, 3, 1, 3, 3, 3,
1878 3, 1, 0, 5, 3, 1, 3, 1, 0, 9,
1879 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
1880 1, 1, 1, 1, 1, 1, 1, 3, 1, 5,
1881 1, 1, 1, 1, 1, 1, 2, 2, 2, 3,
1882 2, 0, 1, 2, 2, 3, 9, 9, 8, 14,
1883 1, 1, 6, 5, 2, 6, 7, 3, 5, 0,
1884 0, 3, 2, 1, 5, 5, 6, 6, 4, 6,
1885 4, 4, 6, 6, 2, 8, 1, 1, 0, 3,
1886 6, 3, 6, 2, 5, 7, 4
1887};
1888
1889/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1890 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1891 means the default is an error. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001892static const unsigned short int yydefact[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001893{
1894 67, 58, 64, 59, 65, 192, 190, 0, 0, 0,
1895 0, 0, 0, 77, 66, 0, 67, 188, 80, 83,
1896 0, 0, 204, 0, 0, 62, 0, 68, 69, 71,
1897 70, 72, 74, 73, 75, 76, 78, 79, 77, 77,
1898 183, 1, 189, 81, 82, 77, 193, 84, 85, 86,
1899 87, 77, 251, 191, 251, 0, 0, 212, 205, 206,
1900 194, 240, 241, 196, 120, 121, 122, 123, 124, 0,
1901 0, 0, 0, 242, 243, 125, 195, 127, 183, 183,
1902 88, 182, 0, 91, 91, 252, 248, 63, 223, 224,
1903 225, 247, 207, 208, 211, 0, 145, 128, 0, 0,
1904 0, 0, 134, 146, 0, 126, 145, 0, 0, 90,
1905 89, 0, 180, 181, 0, 0, 92, 93, 94, 95,
1906 96, 0, 226, 0, 288, 250, 0, 209, 144, 102,
1907 140, 142, 0, 0, 0, 0, 0, 0, 133, 0,
1908 0, 0, 139, 0, 138, 0, 203, 120, 121, 122,
1909 0, 0, 0, 197, 97, 0, 220, 221, 222, 287,
1910 273, 0, 0, 0, 0, 91, 260, 261, 2, 3,
1911 4, 5, 6, 7, 8, 9, 10, 14, 15, 16,
1912 11, 12, 13, 0, 0, 0, 0, 0, 0, 17,
1913 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1914 28, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1915 249, 91, 264, 0, 286, 210, 137, 0, 107, 0,
1916 0, 136, 0, 147, 107, 199, 201, 0, 184, 165,
1917 166, 161, 163, 162, 164, 167, 160, 156, 157, 0,
1918 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1919 0, 0, 0, 159, 158, 116, 0, 272, 254, 0,
1920 253, 0, 0, 55, 0, 0, 29, 30, 31, 32,
1921 33, 34, 35, 36, 37, 38, 0, 53, 54, 49,
1922 50, 51, 52, 39, 40, 41, 42, 43, 44, 45,
1923 46, 47, 48, 0, 111, 111, 293, 0, 0, 284,
1924 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1925 0, 98, 99, 100, 101, 103, 143, 141, 130, 131,
1926 132, 135, 129, 116, 116, 0, 0, 0, 0, 0,
1927 0, 0, 0, 149, 179, 0, 0, 0, 153, 0,
1928 150, 0, 0, 0, 0, 198, 218, 229, 230, 231,
1929 236, 232, 233, 234, 235, 227, 0, 238, 245, 244,
1930 246, 0, 255, 0, 0, 0, 0, 0, 289, 0,
1931 291, 270, 0, 0, 0, 0, 0, 0, 0, 0,
1932 0, 0, 0, 0, 0, 104, 105, 106, 108, 200,
1933 202, 0, 0, 0, 270, 0, 0, 0, 0, 0,
1934 148, 134, 146, 0, 151, 152, 0, 0, 0, 0,
1935 0, 118, 116, 217, 102, 215, 0, 228, 0, 0,
1936 0, 0, 0, 0, 0, 0, 0, 0, 296, 0,
1937 0, 0, 280, 281, 0, 0, 0, 0, 278, 0,
1938 111, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1939 178, 155, 0, 0, 0, 0, 113, 119, 117, 61,
1940 0, 107, 0, 237, 0, 0, 269, 0, 0, 111,
1941 112, 111, 0, 0, 0, 0, 0, 0, 274, 275,
1942 269, 0, 294, 0, 185, 0, 0, 169, 0, 0,
1943 0, 0, 154, 0, 0, 0, 60, 214, 216, 102,
1944 114, 0, 0, 0, 0, 0, 276, 277, 290, 292,
1945 271, 0, 0, 279, 282, 283, 0, 111, 0, 0,
1946 0, 175, 0, 0, 171, 172, 168, 61, 115, 109,
1947 239, 0, 0, 102, 0, 107, 265, 0, 107, 295,
1948 173, 174, 0, 0, 0, 213, 0, 219, 0, 258,
1949 0, 0, 267, 0, 0, 266, 285, 170, 176, 177,
1950 110, 256, 0, 257, 0, 102, 0, 0, 0, 268,
1951 0, 0, 0, 0, 263, 0, 0, 262, 0, 259
1952};
1953
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001954/* YYDEFGOTO[NTERM-NUM]. */
1955static const short int yydefgoto[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001956{
1957 -1, 250, 251, 252, 276, 293, 150, 151, 73, 497,
1958 11, 74, 13, 14, 38, 39, 40, 45, 51, 111,
1959 121, 315, 216, 388, 318, 547, 368, 411, 529, 345,
1960 412, 75, 152, 130, 145, 131, 132, 104, 334, 357,
1961 335, 114, 82, 146, 15, 16, 17, 19, 18, 255,
1962 323, 324, 60, 22, 58, 95, 415, 416, 122, 158,
1963 52, 90, 53, 46, 418, 358, 77, 360, 260, 54,
1964 86, 87, 210, 551, 125, 299, 505, 428, 211, 212,
1965 213, 214
1966};
1967
1968/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1969 STATE-NUM. */
1970#define YYPACT_NINF -472
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001971static const short int yypact[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001972{
1973 50, -472, -472, -472, -472, -472, -472, -20, -110, 93,
1974 -64, 160, 68, 14, -472, 185, 203, -472, 77, 199,
1975 76, 81, -472, 79, 205, -472, 1214, -472, -472, -472,
1976 -472, -472, -472, -472, -472, -472, -472, -472, 56, 56,
1977 137, -472, -472, -472, -472, 56, -472, -472, -472, -472,
1978 -472, 56, 210, -472, 2, 236, 246, 277, -472, -472,
1979 -472, -472, -472, 170, -472, -472, -472, -472, -472, 315,
1980 318, 6, 368, -472, -472, -472, 154, -472, 287, 287,
1981 255, -472, 207, 281, 281, -472, -472, 82, -472, -472,
1982 -472, -472, -472, -472, -472, -1, 1109, -472, 184, 188,
1983 685, 170, -472, 154, -49, -472, 1109, 207, 207, -472,
1984 -472, 777, -472, -472, 1230, 326, -472, -472, -472, -472,
1985 -472, 1269, -472, -7, 1471, -472, 324, -472, -472, 154,
1986 -472, 208, 206, 1312, 1312, 200, -43, 1312, -472, 213,
1987 1230, 1312, 170, 215, 154, 316, -472, 40, 339, 350,
1988 256, 352, 856, -472, -472, 86, -472, -472, -472, -472,
1989 -472, 311, 1372, 187, 356, 281, -472, -472, -472, -472,
1990 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
1991 -472, -472, -472, 394, 177, 1312, 1312, 1312, 1312, -472,
1992 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
1993 -472, 1312, 1312, 1312, 1312, 1312, 1312, 1312, 1312, 1312,
1994 -472, 281, -472, 122, -472, -472, -40, 1126, -472, 67,
1995 49, -472, 222, 154, -472, -472, 154, 777, -472, -472,
1996 -472, -472, -472, -472, -472, -472, -472, -472, -472, 394,
1997 177, 229, 232, 234, 237, 243, 1156, 1386, 898, 367,
1998 249, 251, 252, -472, -472, 257, 258, -472, 170, 606,
1999 -472, 733, 733, -472, 733, 1269, -472, -472, -472, -472,
2000 -472, -472, -472, -472, -472, -472, 1312, -472, -472, -472,
2001 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
2002 -472, -472, -472, 1312, -89, 108, -472, 606, 116, 259,
2003 260, 262, 263, 266, 267, 606, 606, 361, 1269, 1312,
2004 1312, -472, -472, -472, -472, -472, -472, -472, 41, -472,
2005 -472, -472, 41, 257, 257, 371, 268, 270, 1230, 1230,
2006 1230, 1230, 1230, -472, -472, 15, 937, -113, -472, -35,
2007 -472, 1230, 1230, 1230, 29, -472, 1170, -472, -472, -472,
2008 -472, -472, -472, -472, -472, 351, 1230, -472, -472, -472,
2009 -472, 274, -472, 275, 733, 606, 606, 12, -472, 19,
2010 -472, -472, 733, 265, 1312, 1312, 1312, 1312, 1312, 278,
2011 284, 1312, 733, 606, 285, -472, -472, -472, -472, -472,
2012 -472, 1312, 1230, 1230, -472, 286, 289, 290, 291, 1230,
2013 -472, 283, 856, -30, -472, -472, 296, 297, 403, 419,
2014 436, -472, 257, -472, 154, 305, 302, -472, 425, -8,
2015 431, 432, 308, 312, 317, 733, 449, 733, 321, 327,
2016 733, 328, 154, -472, 329, 330, 733, 733, 154, 323,
2017 332, 1312, 126, 333, 334, -57, 1230, 1230, 1230, 1230,
2018 -472, -472, 331, 1230, 1230, 1312, -472, -472, -472, 13,
2019 1200, -472, 335, -472, 733, 733, 1312, 733, 733, 332,
2020 -472, 332, 1312, 733, 336, 1312, 1312, 1312, -472, -472,
2021 1312, 426, -472, 606, -472, 1230, 1230, -472, 337, 349,
2022 355, 358, -472, 357, 359, 149, -472, -472, -472, 154,
2023 1, 457, 360, 354, 606, -2, -472, -472, -472, -472,
2024 -472, 362, 733, -472, -472, -472, 28, 332, 363, 364,
2025 1230, -472, 1230, 1230, -472, -472, -472, 13, -472, 450,
2026 -472, 487, -3, -472, 1312, -472, -472, 370, -472, -472,
2027 -472, -472, 376, 377, 378, -472, 498, -472, 733, -472,
2028 986, 3, -40, 606, 83, -472, 41, -472, -472, -472,
2029 -472, -472, 366, -472, 986, -472, 494, 497, 375, -40,
2030 733, 733, 506, 455, -472, 733, 510, -472, 733, -472
2031};
2032
2033/* YYPGOTO[NTERM-NUM]. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002034static const short int yypgoto[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002035{
2036 -472, 401, 404, 405, 292, 294, -161, -472, 0, 8,
2037 443, 9, -472, -472, -472, -472, 44, -472, -472, -472,
2038 -147, -307, -409, -472, -220, -472, -283, 36, -472, -284,
2039 -472, -472, -25, 320, -114, -472, 433, 438, -29, -150,
2040 -226, 198, 238, 313, -472, -472, 525, -472, -472, -472,
2041 -472, -472, -472, -472, -472, -472, -472, -472, 458, -472,
2042 -472, -472, -472, -472, -472, -471, -139, 96, -168, -472,
2043 489, -472, -472, -472, -472, -472, 64, 151, -472, -472,
2044 -472, -472
2045};
2046
2047/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2048 positive, shift that token. If negative, reduce the rule which
2049 number is the opposite. If zero, do what YYDEFACT says.
2050 If YYTABLE_NINF, syntax error. */
2051#define YYTABLE_NINF -188
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002052static const short int yytable[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002053{
2054 10, 76, 253, 264, 322, 459, 228, 155, 263, 12,
2055 99, 387, 370, 254, 263, 387, 10, 156, 265, 296,
2056 85, 337, 339, 425, 399, 12, 23, 88, 20, 1,
2057 427, 409, 3, 404, 300, 301, 302, 303, 304, 389,
2058 390, 307, 21, -55, -55, -55, -55, 103, 367, 105,
2059 -187, 106, 28, 29, 30, 31, 32, 33, 34, 409,
2060 35, 426, 229, 230, 308, -63, 1, 2, 426, 3,
2061 4, 129, 25, 311, 312, 103, 5, 6, 410, 562,
2062 472, 129, 78, 79, 487, 153, 144, 10, 137, 83,
2063 527, 313, 314, 568, 137, 84, 144, 7, 1, 138,
2064 8, 3, 399, 2, 9, 222, 4, 399, 219, 220,
2065 403, 225, 223, 405, 311, 312, 226, 566, 452, 43,
2066 359, 44, 359, 359, 552, 359, 311, 312, 458, 399,
2067 419, 385, 313, 314, 386, 534, 126, 259, 463, 535,
2068 157, 549, 384, 127, 313, 314, 24, 563, 36, 37,
2069 89, 364, 399, 100, 311, 312, 569, 482, 359, 400,
2070 294, 295, 259, 297, 256, 534, 359, 359, 80, 538,
2071 81, 385, 313, 314, 386, 26, 298, 259, 259, 259,
2072 259, 259, 305, 306, 259, 41, 508, 105, 509, 106,
2073 36, 37, 129, 387, 382, 320, 311, 312, 261, 277,
2074 278, 262, 144, -186, 27, 105, 431, 106, 433, 434,
2075 435, 319, 55, 385, 313, 314, 386, 56, -63, 1,
2076 2, 57, 3, 4, 59, 359, 359, 359, 85, 5,
2077 6, 309, 310, 359, 539, 112, 113, 47, 48, 49,
2078 144, 500, 50, 359, 359, 369, 105, 387, 106, 387,
2079 7, 365, 253, 8, 105, 92, 106, 9, 372, 231,
2080 232, 233, 234, 254, 105, 93, 106, 484, 366, 279,
2081 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
2082 290, 291, 292, 144, 383, 259, 359, 105, 359, 106,
2083 526, 359, 105, 109, 106, 110, 94, 359, 359, 394,
2084 395, 396, 397, 398, 510, 140, 141, 513, 514, 515,
2085 96, 402, 406, 407, 408, 554, 107, 108, 556, 97,
2086 81, 414, 98, 61, 62, 359, 359, 133, 359, 359,
2087 154, 134, 1, 2, 359, 3, 4, 115, 116, 117,
2088 118, 119, 120, 215, 359, 217, 221, 218, -56, 259,
2089 432, 259, 259, 259, 224, 227, 438, 361, 362, -57,
2090 363, 235, 257, 443, 444, 359, 442, 263, 321, 328,
2091 450, 550, 329, 359, 330, 61, 62, 331, 101, 64,
2092 65, 66, 67, 332, 1, 2, 340, 3, 4, 341,
2093 564, 342, 343, 371, 344, 381, 373, 374, 346, 375,
2094 376, 379, 380, 377, 378, 391, 417, 430, 392, 359,
2095 393, 420, 421, 68, 359, 436, 483, 488, 489, 490,
2096 491, 437, 441, 446, 493, 494, 447, 448, 449, 451,
2097 495, 359, 359, 453, 454, 499, 359, 455, 456, 359,
2098 457, 504, 460, 461, 462, 464, 465, 259, 466, 467,
2099 259, 259, 259, 470, 468, 504, 518, 519, 472, 496,
2100 422, 423, 424, 480, 473, 475, 476, 477, 429, 481,
2101 485, 486, 501, 512, 520, 426, 530, 492, 439, 440,
2102 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
2103 521, 542, 522, 543, 544, 523, 532, 531, 524, 546,
2104 525, 548, 560, 567, 540, 541, 536, 69, 570, 553,
2105 70, 571, 572, 71, 555, 72, 102, 557, 558, 559,
2106 575, 469, 576, 471, 578, 207, 474, 496, 208, 209,
2107 124, 326, 478, 479, 327, 545, 528, 317, 136, 139,
2108 325, 42, 123, 91, 516, 445, 0, 0, 0, 0,
2109 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2110 502, 503, 0, 506, 507, 0, 0, 0, 0, 511,
2111 0, 0, 0, 0, 0, 0, 0, 0, 0, 517,
2112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2114 533, 0, 0, 0, 0, 0, 0, 0, 537, 347,
2115 348, 0, 0, 61, 62, 349, 0, 0, 0, 0,
2116 0, 0, 1, 2, 0, 3, 4, 350, 351, 352,
2117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2118 0, 0, 353, 354, 561, 0, 0, 0, 0, 565,
2119 0, 0, 0, 0, 0, 0, 0, 0, 0, 355,
2120 0, 0, 0, 0, 0, 0, 573, 574, 0, 0,
2121 0, 577, 0, 0, 579, 168, 169, 170, 171, 172,
2122 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2123 239, 240, 61, 62, 0, 101, 64, 65, 66, 67,
2124 0, 1, 2, 0, 3, 4, 0, 0, 0, 0,
2125 0, 0, 0, 0, 0, 0, 0, 241, 189, 190,
2126 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2127 68, 242, 0, 243, 244, 245, 347, 348, 0, 0,
2128 61, 62, 349, 0, 105, 0, 106, 0, 0, 1,
2129 2, 356, 3, 4, 350, 351, 352, 0, 0, 0,
2130 0, 0, 0, 0, 0, 0, 0, 0, 0, 353,
2131 354, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2132 0, 0, 0, 0, 61, 62, 355, 142, 64, 65,
2133 66, 67, 0, 1, 2, 0, 3, 4, 0, 0,
2134 0, 0, 168, 169, 170, 171, 172, 173, 174, 175,
2135 176, 177, 178, 179, 180, 181, 182, 239, 240, 0,
2136 0, 0, 68, 0, 69, 0, 0, 70, 0, 0,
2137 71, 0, 72, 135, 0, 0, 0, 0, 0, 0,
2138 0, 0, 0, 0, 241, 189, 190, 191, 192, 193,
2139 194, 195, 196, 197, 198, 199, 200, 0, 242, 0,
2140 243, 244, 245, 61, 62, 0, 0, 0, 0, 0,
2141 0, 0, 1, 2, 0, 3, 4, 236, 356, 0,
2142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2143 0, 0, 237, 238, 143, 0, 0, 0, 0, 0,
2144 0, 0, 0, 0, 0, 61, 62, 0, 101, 147,
2145 148, 149, 67, 0, 1, 2, 69, 3, 4, 70,
2146 0, 0, 71, 0, 72, 168, 169, 170, 171, 172,
2147 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2148 239, 240, 0, 68, 61, 62, 0, 101, 147, 148,
2149 149, 67, 0, 1, 2, 0, 3, 4, 0, 0,
2150 0, 0, 0, 0, 0, 0, 0, 241, 189, 190,
2151 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2152 0, 242, 68, 243, 244, 245, 0, 0, 0, 347,
2153 348, 0, 0, 0, 105, 349, 106, 0, 246, 0,
2154 0, 247, 0, 248, 0, 249, 0, 350, 351, 352,
2155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2156 0, 0, 353, 354, 0, 0, 0, 0, 0, 0,
2157 0, 0, 0, 0, 0, 0, 0, 69, 0, 355,
2158 70, 0, 0, 71, 0, 72, 338, 0, 0, 0,
2159 0, 0, 0, 0, 0, 168, 169, 170, 171, 172,
2160 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2161 239, 240, 0, 0, 0, 0, 69, 0, 0, 70,
2162 0, 0, 71, 0, 72, 401, 0, 0, 0, 0,
2163 0, 0, 0, 0, 0, 0, 0, 241, 189, 190,
2164 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2165 0, 242, 0, 243, 244, 245, 61, 62, 0, 101,
2166 64, 65, 66, 67, 0, 1, 2, 0, 3, 4,
2167 0, 356, 0, 61, 62, 0, 101, 64, 65, 66,
2168 67, 0, 1, 2, 128, 3, 4, 0, 0, 0,
2169 0, 0, 0, 0, 68, 0, 0, 0, 0, 0,
2170 0, 316, 0, 61, 62, 0, 101, 147, 148, 149,
2171 67, 68, 1, 2, 0, 3, 4, 61, 62, 0,
2172 101, 64, 65, 66, 67, 0, 1, 2, 0, 3,
2173 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2174 0, 68, 0, 0, 0, 413, 0, 61, 62, 0,
2175 101, 64, 65, 66, 67, 68, 1, 2, 0, 3,
2176 4, 61, 62, 0, 63, 64, 65, 66, 67, 0,
2177 1, 2, 0, 3, 4, 498, 0, 61, 62, 0,
2178 101, 147, 148, 149, 67, 68, 1, 2, 69, 3,
2179 4, 70, 0, 0, 71, 0, 72, 0, 0, 68,
2180 0, 0, 0, 0, 0, 69, 0, 0, 70, 0,
2181 0, 71, 0, 72, 0, 68, 61, 62, 0, 142,
2182 64, 65, 66, 67, 0, 1, 2, 0, 3, 4,
2183 0, 0, 0, 0, 0, 69, 0, 0, 70, 0,
2184 333, 71, 0, 72, 0, 0, 0, 0, 0, 69,
2185 0, 0, 70, 0, 68, 71, 0, 72, 0, 61,
2186 62, 0, 101, 64, 65, 66, 67, 0, 1, 2,
2187 0, 3, 4, 0, 0, 0, 0, 0, 0, 69,
2188 0, 0, 70, 0, 0, 71, 0, 72, 0, 0,
2189 0, 0, 0, 69, 0, 0, 70, 68, 0, 71,
2190 0, 72, 0, 0, 0, 0, 0, 0, 0, 69,
2191 0, 0, 70, 0, 0, 71, 0, 72, 0, 61,
2192 62, 0, 258, 64, 65, 66, 67, 0, 1, 2,
2193 0, 3, 4, 61, 62, 0, 101, 147, 148, 149,
2194 67, 0, 1, 2, 0, 3, 4, 0, 69, 0,
2195 0, 70, 0, 0, 71, 0, 72, 68, 0, 0,
2196 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2197 0, 68, 0, 0, 0, 0, 0, 0, 0, 0,
2198 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2199 0, 69, 0, 0, 70, 0, 0, 71, 0, 72,
2200 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2201 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2202 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2203 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2204 0, 0, 0, 159, 0, 0, 0, 0, 0, 0,
2205 0, 69, 0, 0, 70, 0, 0, 71, 0, 72,
2206 0, 0, 160, 161, 0, 69, 0, 0, 70, 0,
2207 0, 71, 0, 336, 162, 163, 164, 165, 166, 167,
2208 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
2209 178, 179, 180, 181, 182, 183, 184, 0, 0, 0,
2210 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2211 0, 0, 0, 0, 0, 0, 0, 185, 186, 187,
2212 0, 0, 188, 189, 190, 191, 192, 193, 194, 195,
2213 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
2214 206
2215};
2216
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002217static const short int yycheck[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002218{
2219 0, 26, 152, 164, 224, 414, 145, 121, 11, 0,
2220 4, 318, 295, 152, 11, 322, 16, 24, 165, 187,
2221 18, 247, 248, 11, 137, 16, 136, 25, 48, 16,
2222 11, 30, 19, 146, 202, 203, 204, 205, 206, 323,
2223 324, 209, 62, 3, 4, 5, 6, 72, 137, 138,
2224 0, 140, 38, 39, 40, 41, 42, 43, 44, 30,
2225 46, 49, 22, 23, 211, 15, 16, 17, 49, 19,
2226 20, 96, 136, 113, 114, 100, 26, 27, 49, 550,
2227 137, 106, 38, 39, 141, 114, 111, 87, 137, 45,
2228 499, 131, 132, 564, 137, 51, 121, 47, 16, 148,
2229 50, 19, 137, 17, 54, 148, 20, 137, 133, 134,
2230 336, 140, 137, 148, 113, 114, 141, 34, 148, 42,
2231 259, 44, 261, 262, 533, 264, 113, 114, 412, 137,
2232 356, 130, 131, 132, 133, 137, 137, 162, 146, 141,
2233 147, 144, 310, 144, 131, 132, 53, 144, 134, 135,
2234 148, 265, 137, 147, 113, 114, 565, 440, 297, 144,
2235 185, 186, 187, 188, 155, 137, 305, 306, 31, 141,
2236 33, 130, 131, 132, 133, 15, 201, 202, 203, 204,
2237 205, 206, 207, 208, 209, 0, 469, 138, 471, 140,
2238 134, 135, 217, 500, 308, 146, 113, 114, 11, 22,
2239 23, 14, 227, 0, 136, 138, 374, 140, 376, 377,
2240 378, 144, 136, 130, 131, 132, 133, 136, 15, 16,
2241 17, 142, 19, 20, 19, 364, 365, 366, 18, 26,
2242 27, 109, 110, 372, 517, 28, 29, 38, 39, 40,
2243 265, 461, 43, 382, 383, 137, 138, 554, 140, 556,
2244 47, 276, 402, 50, 138, 19, 140, 54, 142, 3,
2245 4, 5, 6, 402, 138, 19, 140, 141, 293, 92,
2246 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
2247 103, 104, 105, 308, 309, 310, 425, 138, 427, 140,
2248 141, 430, 138, 38, 140, 40, 19, 436, 437, 328,
2249 329, 330, 331, 332, 472, 107, 108, 475, 476, 477,
2250 140, 336, 341, 342, 343, 535, 78, 79, 538, 4,
2251 33, 346, 4, 7, 8, 464, 465, 143, 467, 468,
2252 4, 143, 16, 17, 473, 19, 20, 56, 57, 58,
2253 59, 60, 61, 19, 483, 137, 146, 141, 9, 374,
2254 375, 376, 377, 378, 141, 140, 381, 261, 262, 9,
2255 264, 9, 51, 392, 393, 504, 391, 11, 146, 140,
2256 399, 532, 140, 512, 140, 7, 8, 140, 10, 11,
2257 12, 13, 14, 140, 16, 17, 19, 19, 20, 140,
2258 551, 140, 140, 297, 137, 34, 137, 137, 140, 137,
2259 137, 305, 306, 137, 137, 34, 55, 142, 140, 548,
2260 140, 137, 137, 45, 553, 137, 441, 446, 447, 448,
2261 449, 137, 137, 137, 453, 454, 137, 137, 137, 146,
2262 455, 570, 571, 137, 137, 460, 575, 34, 19, 578,
2263 4, 466, 137, 141, 19, 14, 14, 472, 140, 137,
2264 475, 476, 477, 4, 137, 480, 485, 486, 137, 459,
2265 364, 365, 366, 140, 137, 137, 137, 137, 372, 137,
2266 137, 137, 137, 137, 137, 49, 19, 146, 382, 383,
2267 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
2268 141, 520, 137, 522, 523, 137, 142, 137, 141, 49,
2269 141, 14, 4, 137, 141, 141, 144, 139, 14, 534,
2270 142, 14, 137, 145, 144, 147, 148, 141, 141, 141,
2271 14, 425, 67, 427, 14, 124, 430, 527, 124, 124,
2272 87, 239, 436, 437, 240, 527, 500, 217, 100, 106,
2273 227, 16, 84, 54, 480, 394, -1, -1, -1, -1,
2274 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2275 464, 465, -1, 467, 468, -1, -1, -1, -1, 473,
2276 -1, -1, -1, -1, -1, -1, -1, -1, -1, 483,
2277 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2278 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2279 504, -1, -1, -1, -1, -1, -1, -1, 512, 3,
2280 4, -1, -1, 7, 8, 9, -1, -1, -1, -1,
2281 -1, -1, 16, 17, -1, 19, 20, 21, 22, 23,
2282 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2283 -1, -1, 36, 37, 548, -1, -1, -1, -1, 553,
2284 -1, -1, -1, -1, -1, -1, -1, -1, -1, 53,
2285 -1, -1, -1, -1, -1, -1, 570, 571, -1, -1,
2286 -1, 575, -1, -1, 578, 69, 70, 71, 72, 73,
2287 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2288 84, 85, 7, 8, -1, 10, 11, 12, 13, 14,
2289 -1, 16, 17, -1, 19, 20, -1, -1, -1, -1,
2290 -1, -1, -1, -1, -1, -1, -1, 111, 112, 113,
2291 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2292 45, 125, -1, 127, 128, 129, 3, 4, -1, -1,
2293 7, 8, 9, -1, 138, -1, 140, -1, -1, 16,
2294 17, 145, 19, 20, 21, 22, 23, -1, -1, -1,
2295 -1, -1, -1, -1, -1, -1, -1, -1, -1, 36,
2296 37, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2297 -1, -1, -1, -1, 7, 8, 53, 10, 11, 12,
2298 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
2299 -1, -1, 69, 70, 71, 72, 73, 74, 75, 76,
2300 77, 78, 79, 80, 81, 82, 83, 84, 85, -1,
2301 -1, -1, 45, -1, 139, -1, -1, 142, -1, -1,
2302 145, -1, 147, 148, -1, -1, -1, -1, -1, -1,
2303 -1, -1, -1, -1, 111, 112, 113, 114, 115, 116,
2304 117, 118, 119, 120, 121, 122, 123, -1, 125, -1,
2305 127, 128, 129, 7, 8, -1, -1, -1, -1, -1,
2306 -1, -1, 16, 17, -1, 19, 20, 21, 145, -1,
2307 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2308 -1, -1, 36, 37, 117, -1, -1, -1, -1, -1,
2309 -1, -1, -1, -1, -1, 7, 8, -1, 10, 11,
2310 12, 13, 14, -1, 16, 17, 139, 19, 20, 142,
2311 -1, -1, 145, -1, 147, 69, 70, 71, 72, 73,
2312 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2313 84, 85, -1, 45, 7, 8, -1, 10, 11, 12,
2314 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
2315 -1, -1, -1, -1, -1, -1, -1, 111, 112, 113,
2316 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2317 -1, 125, 45, 127, 128, 129, -1, -1, -1, 3,
2318 4, -1, -1, -1, 138, 9, 140, -1, 142, -1,
2319 -1, 145, -1, 147, -1, 149, -1, 21, 22, 23,
2320 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2321 -1, -1, 36, 37, -1, -1, -1, -1, -1, -1,
2322 -1, -1, -1, -1, -1, -1, -1, 139, -1, 53,
2323 142, -1, -1, 145, -1, 147, 148, -1, -1, -1,
2324 -1, -1, -1, -1, -1, 69, 70, 71, 72, 73,
2325 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2326 84, 85, -1, -1, -1, -1, 139, -1, -1, 142,
2327 -1, -1, 145, -1, 147, 148, -1, -1, -1, -1,
2328 -1, -1, -1, -1, -1, -1, -1, 111, 112, 113,
2329 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2330 -1, 125, -1, 127, 128, 129, 7, 8, -1, 10,
2331 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
2332 -1, 145, -1, 7, 8, -1, 10, 11, 12, 13,
2333 14, -1, 16, 17, 35, 19, 20, -1, -1, -1,
2334 -1, -1, -1, -1, 45, -1, -1, -1, -1, -1,
2335 -1, 35, -1, 7, 8, -1, 10, 11, 12, 13,
2336 14, 45, 16, 17, -1, 19, 20, 7, 8, -1,
2337 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
2338 20, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2339 -1, 45, -1, -1, -1, 35, -1, 7, 8, -1,
2340 10, 11, 12, 13, 14, 45, 16, 17, -1, 19,
2341 20, 7, 8, -1, 10, 11, 12, 13, 14, -1,
2342 16, 17, -1, 19, 20, 35, -1, 7, 8, -1,
2343 10, 11, 12, 13, 14, 45, 16, 17, 139, 19,
2344 20, 142, -1, -1, 145, -1, 147, -1, -1, 45,
2345 -1, -1, -1, -1, -1, 139, -1, -1, 142, -1,
2346 -1, 145, -1, 147, -1, 45, 7, 8, -1, 10,
2347 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
2348 -1, -1, -1, -1, -1, 139, -1, -1, 142, -1,
2349 144, 145, -1, 147, -1, -1, -1, -1, -1, 139,
2350 -1, -1, 142, -1, 45, 145, -1, 147, -1, 7,
2351 8, -1, 10, 11, 12, 13, 14, -1, 16, 17,
2352 -1, 19, 20, -1, -1, -1, -1, -1, -1, 139,
2353 -1, -1, 142, -1, -1, 145, -1, 147, -1, -1,
2354 -1, -1, -1, 139, -1, -1, 142, 45, -1, 145,
2355 -1, 147, -1, -1, -1, -1, -1, -1, -1, 139,
2356 -1, -1, 142, -1, -1, 145, -1, 147, -1, 7,
2357 8, -1, 10, 11, 12, 13, 14, -1, 16, 17,
2358 -1, 19, 20, 7, 8, -1, 10, 11, 12, 13,
2359 14, -1, 16, 17, -1, 19, 20, -1, 139, -1,
2360 -1, 142, -1, -1, 145, -1, 147, 45, -1, -1,
2361 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2362 -1, 45, -1, -1, -1, -1, -1, -1, -1, -1,
2363 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2364 -1, 139, -1, -1, 142, -1, -1, 145, -1, 147,
2365 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2366 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2367 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2368 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2369 -1, -1, -1, 32, -1, -1, -1, -1, -1, -1,
2370 -1, 139, -1, -1, 142, -1, -1, 145, -1, 147,
2371 -1, -1, 51, 52, -1, 139, -1, -1, 142, -1,
2372 -1, 145, -1, 147, 63, 64, 65, 66, 67, 68,
2373 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2374 79, 80, 81, 82, 83, 84, 85, -1, -1, -1,
2375 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2376 -1, -1, -1, -1, -1, -1, -1, 106, 107, 108,
2377 -1, -1, 111, 112, 113, 114, 115, 116, 117, 118,
2378 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2379 129
2380};
2381
2382/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2383 symbol of state STATE-NUM. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002384static const unsigned char yystos[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002385{
2386 0, 16, 17, 19, 20, 26, 27, 47, 50, 54,
2387 158, 160, 161, 162, 163, 194, 195, 196, 198, 197,
2388 48, 62, 203, 136, 53, 136, 15, 136, 38, 39,
2389 40, 41, 42, 43, 44, 46, 134, 135, 164, 165,
2390 166, 0, 196, 42, 44, 167, 213, 38, 39, 40,
2391 43, 168, 210, 212, 219, 136, 136, 142, 204, 19,
2392 202, 7, 8, 10, 11, 12, 13, 14, 45, 139,
2393 142, 145, 147, 158, 161, 181, 182, 216, 166, 166,
2394 31, 33, 192, 166, 166, 18, 220, 221, 25, 148,
2395 211, 220, 19, 19, 19, 205, 140, 4, 4, 4,
2396 147, 10, 148, 182, 187, 138, 140, 192, 192, 38,
2397 40, 169, 28, 29, 191, 56, 57, 58, 59, 60,
2398 61, 170, 208, 208, 160, 224, 137, 144, 35, 182,
2399 183, 185, 186, 143, 143, 148, 187, 137, 148, 186,
2400 191, 191, 10, 117, 182, 184, 193, 11, 12, 13,
2401 156, 157, 182, 188, 4, 184, 24, 147, 209, 32,
2402 51, 52, 63, 64, 65, 66, 67, 68, 69, 70,
2403 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2404 81, 82, 83, 84, 85, 106, 107, 108, 111, 112,
2405 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
2406 123, 124, 125, 126, 127, 128, 129, 151, 152, 153,
2407 222, 228, 229, 230, 231, 19, 172, 137, 141, 182,
2408 182, 146, 148, 182, 141, 188, 182, 140, 216, 22,
2409 23, 3, 4, 5, 6, 9, 21, 36, 37, 84,
2410 85, 111, 125, 127, 128, 129, 142, 145, 147, 149,
2411 151, 152, 153, 189, 216, 199, 161, 51, 10, 182,
2412 218, 11, 14, 11, 156, 170, 86, 87, 88, 89,
2413 90, 91, 92, 93, 94, 95, 154, 22, 23, 92,
2414 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
2415 103, 104, 105, 155, 182, 182, 218, 182, 182, 225,
2416 218, 218, 218, 218, 218, 182, 182, 218, 170, 109,
2417 110, 113, 114, 131, 132, 171, 35, 183, 174, 144,
2418 146, 146, 174, 200, 201, 193, 154, 155, 140, 140,
2419 140, 140, 140, 144, 188, 190, 147, 190, 148, 190,
2420 19, 140, 140, 140, 137, 179, 140, 3, 4, 9,
2421 21, 22, 23, 36, 37, 53, 145, 189, 215, 216,
2422 217, 217, 217, 217, 184, 182, 182, 137, 176, 137,
2423 176, 217, 142, 137, 137, 137, 137, 137, 137, 217,
2424 217, 34, 184, 182, 218, 130, 133, 171, 173, 179,
2425 179, 34, 140, 140, 188, 188, 188, 188, 188, 137,
2426 144, 148, 182, 190, 146, 148, 188, 188, 188, 30,
2427 49, 177, 180, 35, 182, 206, 207, 55, 214, 190,
2428 137, 137, 217, 217, 217, 11, 49, 11, 227, 217,
2429 142, 218, 182, 218, 218, 218, 137, 137, 182, 217,
2430 217, 137, 182, 188, 188, 227, 137, 137, 137, 137,
2431 188, 146, 148, 137, 137, 34, 19, 4, 179, 172,
2432 137, 141, 19, 146, 14, 14, 140, 137, 137, 217,
2433 4, 217, 137, 137, 217, 137, 137, 137, 217, 217,
2434 140, 137, 176, 182, 141, 137, 137, 141, 188, 188,
2435 188, 188, 146, 188, 188, 182, 158, 159, 35, 182,
2436 174, 137, 217, 217, 182, 226, 217, 217, 176, 176,
2437 218, 217, 137, 218, 218, 218, 226, 217, 188, 188,
2438 137, 141, 137, 137, 141, 141, 141, 172, 177, 178,
2439 19, 137, 142, 217, 137, 141, 144, 217, 141, 176,
2440 141, 141, 188, 188, 188, 159, 49, 175, 14, 144,
2441 156, 223, 172, 182, 174, 144, 174, 141, 141, 141,
2442 4, 217, 215, 144, 156, 217, 34, 137, 215, 172,
2443 14, 14, 137, 217, 217, 14, 67, 217, 14, 217
2444};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002445
2446#define yyerrok (yyerrstatus = 0)
2447#define yyclearin (yychar = YYEMPTY)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002448#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002449#define YYEOF 0
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002450
Reid Spencer68a24bd2005-08-27 18:50:39 +00002451#define YYACCEPT goto yyacceptlab
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002452#define YYABORT goto yyabortlab
2453#define YYERROR goto yyerrorlab
2454
2455
2456/* Like YYERROR except do call yyerror. This remains here temporarily
2457 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002458 Once GCC version 2 has supplanted version 1, this can go. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002459
Reid Spencer68a24bd2005-08-27 18:50:39 +00002460#define YYFAIL goto yyerrlab
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002461
Reid Spencer68a24bd2005-08-27 18:50:39 +00002462#define YYRECOVERING() (!!yyerrstatus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002463
2464#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002465do \
2466 if (yychar == YYEMPTY && yylen == 1) \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002467 { \
2468 yychar = (Token); \
2469 yylval = (Value); \
2470 yytoken = YYTRANSLATE (yychar); \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002471 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002472 goto yybackup; \
2473 } \
2474 else \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002475 { \
2476 yyerror (YY_("syntax error: cannot back up")); \
2477 YYERROR; \
2478 } \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002479while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002480
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002481
Reid Spencer68a24bd2005-08-27 18:50:39 +00002482#define YYTERROR 1
2483#define YYERRCODE 256
2484
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002485
2486/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2487 If N is 0, then set CURRENT to the empty location which ends
2488 the previous symbol: RHS[0] (always defined). */
2489
2490#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2491#ifndef YYLLOC_DEFAULT
2492# define YYLLOC_DEFAULT(Current, Rhs, N) \
2493 do \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002494 if (N) \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002495 { \
2496 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2497 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2498 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2499 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2500 } \
2501 else \
2502 { \
2503 (Current).first_line = (Current).last_line = \
2504 YYRHSLOC (Rhs, 0).last_line; \
2505 (Current).first_column = (Current).last_column = \
2506 YYRHSLOC (Rhs, 0).last_column; \
2507 } \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002508 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002509#endif
2510
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002511
2512/* YY_LOCATION_PRINT -- Print the location on the stream.
2513 This macro was not mandated originally: define only if we know
2514 we won't break user code: when these are the locations we know. */
2515
2516#ifndef YY_LOCATION_PRINT
2517# if YYLTYPE_IS_TRIVIAL
2518# define YY_LOCATION_PRINT(File, Loc) \
2519 fprintf (File, "%d.%d-%d.%d", \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002520 (Loc).first_line, (Loc).first_column, \
2521 (Loc).last_line, (Loc).last_column)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002522# else
2523# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2524# endif
2525#endif
2526
2527
2528/* YYLEX -- calling `yylex' with the right arguments. */
2529
Reid Spencer41dff5e2007-01-26 08:05:27 +00002530#ifdef YYLEX_PARAM
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002531# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002532#else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002533# define YYLEX yylex ()
Chris Lattner6cdc6822007-04-26 05:31:05 +00002534#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002535
2536/* Enable debugging if requested. */
2537#if YYDEBUG
2538
2539# ifndef YYFPRINTF
2540# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2541# define YYFPRINTF fprintf
2542# endif
2543
2544# define YYDPRINTF(Args) \
2545do { \
2546 if (yydebug) \
2547 YYFPRINTF Args; \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002548} while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002549
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002550# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2551do { \
2552 if (yydebug) \
2553 { \
2554 YYFPRINTF (stderr, "%s ", Title); \
2555 yysymprint (stderr, \
2556 Type, Value); \
2557 YYFPRINTF (stderr, "\n"); \
2558 } \
2559} while (0)
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002560
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002561/*------------------------------------------------------------------.
2562| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2563| TOP (included). |
2564`------------------------------------------------------------------*/
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002565
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002566#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002567static void
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002568yy_stack_print (short int *bottom, short int *top)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002569#else
2570static void
2571yy_stack_print (bottom, top)
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002572 short int *bottom;
2573 short int *top;
Christopher Lamb5c104242007-04-22 20:09:11 +00002574#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002575{
2576 YYFPRINTF (stderr, "Stack now");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002577 for (/* Nothing. */; bottom <= top; ++bottom)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002578 YYFPRINTF (stderr, " %d", *bottom);
2579 YYFPRINTF (stderr, "\n");
2580}
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002581
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002582# define YY_STACK_PRINT(Bottom, Top) \
2583do { \
2584 if (yydebug) \
2585 yy_stack_print ((Bottom), (Top)); \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002586} while (0)
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002587
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002588
2589/*------------------------------------------------.
2590| Report that the YYRULE is going to be reduced. |
2591`------------------------------------------------*/
2592
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002593#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002594static void
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002595yy_reduce_print (int yyrule)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002596#else
2597static void
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002598yy_reduce_print (yyrule)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002599 int yyrule;
Christopher Lamb2330e4d2007-04-21 08:16:25 +00002600#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002601{
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002602 int yyi;
2603 unsigned long int yylno = yyrline[yyrule];
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002604 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2605 yyrule - 1, yylno);
2606 /* Print the symbols being reduced, and their result. */
2607 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2608 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2609 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002610}
Reid Spencerc67bdc22007-04-21 18:36:27 +00002611
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002612# define YY_REDUCE_PRINT(Rule) \
2613do { \
2614 if (yydebug) \
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002615 yy_reduce_print (Rule); \
2616} while (0)
Reid Spencerc67bdc22007-04-21 18:36:27 +00002617
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002618/* Nonzero means print parse trace. It is left uninitialized so that
2619 multiple parsers can coexist. */
2620int yydebug;
2621#else /* !YYDEBUG */
2622# define YYDPRINTF(Args)
2623# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2624# define YY_STACK_PRINT(Bottom, Top)
2625# define YY_REDUCE_PRINT(Rule)
2626#endif /* !YYDEBUG */
2627
2628
2629/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002630#ifndef YYINITDEPTH
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002631# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002632#endif
2633
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002634/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2635 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002636
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002637 Do not make this value too large; the results are undefined if
2638 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2639 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002640
2641#ifndef YYMAXDEPTH
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002642# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002643#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002644
Reid Spencer68a24bd2005-08-27 18:50:39 +00002645
2646
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002647#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002648
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002649# ifndef yystrlen
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002650# if defined (__GLIBC__) && defined (_STRING_H)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002651# define yystrlen strlen
2652# else
2653/* Return the length of YYSTR. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002654static YYSIZE_T
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002655# if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002656yystrlen (const char *yystr)
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002657# else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002658yystrlen (yystr)
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002659 const char *yystr;
2660# endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002661{
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002662 const char *yys = yystr;
2663
2664 while (*yys++ != '\0')
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002665 continue;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002666
2667 return yys - yystr - 1;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002668}
2669# endif
2670# endif
2671
2672# ifndef yystpcpy
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002673# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002674# define yystpcpy stpcpy
2675# else
2676/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2677 YYDEST. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002678static char *
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002679# if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002680yystpcpy (char *yydest, const char *yysrc)
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002681# else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002682yystpcpy (yydest, yysrc)
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002683 char *yydest;
2684 const char *yysrc;
2685# endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002686{
2687 char *yyd = yydest;
2688 const char *yys = yysrc;
2689
2690 while ((*yyd++ = *yys++) != '\0')
2691 continue;
2692
2693 return yyd - 1;
2694}
2695# endif
2696# endif
2697
2698# ifndef yytnamerr
2699/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2700 quotes and backslashes, so that it's suitable for yyerror. The
2701 heuristic is that double-quoting is unnecessary unless the string
2702 contains an apostrophe, a comma, or backslash (other than
2703 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2704 null, do not copy; instead, return the length of what the result
2705 would have been. */
2706static YYSIZE_T
2707yytnamerr (char *yyres, const char *yystr)
2708{
2709 if (*yystr == '"')
2710 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002711 size_t yyn = 0;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002712 char const *yyp = yystr;
2713
2714 for (;;)
2715 switch (*++yyp)
2716 {
2717 case '\'':
2718 case ',':
2719 goto do_not_strip_quotes;
2720
2721 case '\\':
2722 if (*++yyp != '\\')
2723 goto do_not_strip_quotes;
2724 /* Fall through. */
2725 default:
2726 if (yyres)
2727 yyres[yyn] = *yyp;
2728 yyn++;
2729 break;
2730
2731 case '"':
2732 if (yyres)
2733 yyres[yyn] = '\0';
2734 return yyn;
2735 }
2736 do_not_strip_quotes: ;
2737 }
2738
2739 if (! yyres)
2740 return yystrlen (yystr);
2741
2742 return yystpcpy (yyres, yystr) - yyres;
2743}
2744# endif
2745
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002746#endif /* YYERROR_VERBOSE */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002747
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002748
2749
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002750#if YYDEBUG
2751/*--------------------------------.
2752| Print this symbol on YYOUTPUT. |
2753`--------------------------------*/
2754
2755#if defined (__STDC__) || defined (__cplusplus)
2756static void
2757yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
2758#else
2759static void
2760yysymprint (yyoutput, yytype, yyvaluep)
2761 FILE *yyoutput;
2762 int yytype;
2763 YYSTYPE *yyvaluep;
2764#endif
2765{
2766 /* Pacify ``unused variable'' warnings. */
2767 (void) yyvaluep;
2768
2769 if (yytype < YYNTOKENS)
2770 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2771 else
2772 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2773
2774
2775# ifdef YYPRINT
2776 if (yytype < YYNTOKENS)
2777 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2778# endif
2779 switch (yytype)
2780 {
2781 default:
2782 break;
2783 }
2784 YYFPRINTF (yyoutput, ")");
2785}
2786
2787#endif /* ! YYDEBUG */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002788/*-----------------------------------------------.
2789| Release the memory associated to this symbol. |
2790`-----------------------------------------------*/
2791
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002792#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002793static void
2794yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2795#else
2796static void
2797yydestruct (yymsg, yytype, yyvaluep)
2798 const char *yymsg;
2799 int yytype;
2800 YYSTYPE *yyvaluep;
2801#endif
2802{
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002803 /* Pacify ``unused variable'' warnings. */
2804 (void) yyvaluep;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002805
2806 if (!yymsg)
2807 yymsg = "Deleting";
2808 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2809
2810 switch (yytype)
2811 {
2812
2813 default:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002814 break;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002815 }
2816}
2817
2818
2819/* Prevent warnings from -Wmissing-prototypes. */
2820
2821#ifdef YYPARSE_PARAM
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002822# if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002823int yyparse (void *YYPARSE_PARAM);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002824# else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002825int yyparse ();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002826# endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002827#else /* ! YYPARSE_PARAM */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002828#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002829int yyparse (void);
Chris Lattner6cdc6822007-04-26 05:31:05 +00002830#else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002831int yyparse ();
Christopher Lamb5c104242007-04-22 20:09:11 +00002832#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002833#endif /* ! YYPARSE_PARAM */
Chris Lattner7d9801d2007-02-13 00:58:01 +00002834
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002835
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002836
2837/* The look-ahead symbol. */
2838int yychar;
2839
2840/* The semantic value of the look-ahead symbol. */
2841YYSTYPE yylval;
2842
2843/* Number of syntax errors so far. */
2844int yynerrs;
2845
2846
2847
2848/*----------.
2849| yyparse. |
2850`----------*/
2851
2852#ifdef YYPARSE_PARAM
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002853# if defined (__STDC__) || defined (__cplusplus)
2854int yyparse (void *YYPARSE_PARAM)
2855# else
2856int yyparse (YYPARSE_PARAM)
2857 void *YYPARSE_PARAM;
2858# endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002859#else /* ! YYPARSE_PARAM */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002860#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002861int
2862yyparse (void)
2863#else
2864int
2865yyparse ()
2866
Chris Lattner6cdc6822007-04-26 05:31:05 +00002867#endif
2868#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002869{
2870
2871 int yystate;
2872 int yyn;
2873 int yyresult;
2874 /* Number of tokens to shift before error messages enabled. */
2875 int yyerrstatus;
2876 /* Look-ahead token as an internal (translated) token number. */
2877 int yytoken = 0;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002878
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002879 /* Three stacks and their tools:
2880 `yyss': related to states,
2881 `yyvs': related to semantic values,
2882 `yyls': related to locations.
2883
2884 Refer to the stacks thru separate pointers, to allow yyoverflow
2885 to reallocate them elsewhere. */
2886
2887 /* The state stack. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002888 short int yyssa[YYINITDEPTH];
2889 short int *yyss = yyssa;
2890 short int *yyssp;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002891
2892 /* The semantic value stack. */
2893 YYSTYPE yyvsa[YYINITDEPTH];
2894 YYSTYPE *yyvs = yyvsa;
2895 YYSTYPE *yyvsp;
2896
2897
2898
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002899#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002900
2901 YYSIZE_T yystacksize = YYINITDEPTH;
2902
2903 /* The variables used to return semantic value and location from the
2904 action routines. */
2905 YYSTYPE yyval;
2906
2907
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002908 /* When reducing, the number of symbols on the RHS of the reduced
2909 rule. */
2910 int yylen;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002911
2912 YYDPRINTF ((stderr, "Starting parse\n"));
2913
Reid Spencer68a24bd2005-08-27 18:50:39 +00002914 yystate = 0;
2915 yyerrstatus = 0;
2916 yynerrs = 0;
2917 yychar = YYEMPTY; /* Cause a token to be read. */
2918
2919 /* Initialize stack pointers.
2920 Waste one element of value and location stack
2921 so that they stay on the same level as the state stack.
2922 The wasted elements are never initialized. */
2923
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002924 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002925 yyvsp = yyvs;
2926
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002927 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002928
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002929/*------------------------------------------------------------.
2930| yynewstate -- Push a new state, which is found in yystate. |
2931`------------------------------------------------------------*/
2932 yynewstate:
2933 /* In all cases, when you get here, the value and location stacks
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002934 have just been pushed. so pushing a state here evens the stacks.
2935 */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002936 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002937
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002938 yysetstate:
2939 *yyssp = yystate;
2940
2941 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002942 {
2943 /* Get the current used size of the three stacks, in elements. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002944 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002945
2946#ifdef yyoverflow
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002947 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002948 /* Give user a chance to reallocate the stack. Use copies of
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002949 these so that the &'s don't force the real ones into
2950 memory. */
2951 YYSTYPE *yyvs1 = yyvs;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002952 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002953
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002954
2955 /* Each stack pointer address is followed by the size of the
2956 data in use in that stack, in bytes. This used to be a
2957 conditional around just the two extra args, but that might
2958 be undefined if yyoverflow is a macro. */
2959 yyoverflow (YY_("memory exhausted"),
2960 &yyss1, yysize * sizeof (*yyssp),
2961 &yyvs1, yysize * sizeof (*yyvsp),
2962
2963 &yystacksize);
2964
2965 yyss = yyss1;
2966 yyvs = yyvs1;
2967 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002968#else /* no yyoverflow */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002969# ifndef YYSTACK_RELOCATE
2970 goto yyexhaustedlab;
2971# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002972 /* Extend the stack our own way. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002973 if (YYMAXDEPTH <= yystacksize)
2974 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002975 yystacksize *= 2;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002976 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002977 yystacksize = YYMAXDEPTH;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002978
2979 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002980 short int *yyss1 = yyss;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002981 union yyalloc *yyptr =
2982 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2983 if (! yyptr)
2984 goto yyexhaustedlab;
2985 YYSTACK_RELOCATE (yyss);
2986 YYSTACK_RELOCATE (yyvs);
2987
2988# undef YYSTACK_RELOCATE
2989 if (yyss1 != yyssa)
2990 YYSTACK_FREE (yyss1);
2991 }
2992# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002993#endif /* no yyoverflow */
2994
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002995 yyssp = yyss + yysize - 1;
2996 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002997
2998
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002999 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3000 (unsigned long int) yystacksize));
3001
3002 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003003 YYABORT;
3004 }
3005
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003006 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003007
3008 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003009
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003010/*-----------.
3011| yybackup. |
3012`-----------*/
3013yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003014
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003015/* Do appropriate processing given the current state. */
3016/* Read a look-ahead token if we need one and don't already have one. */
3017/* yyresume: */
Reid Spencer7780acb2007-04-16 06:56:07 +00003018
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003019 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003020
Reid Spencer68a24bd2005-08-27 18:50:39 +00003021 yyn = yypact[yystate];
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003022 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003023 goto yydefault;
3024
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003025 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003026
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003027 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003028 if (yychar == YYEMPTY)
3029 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003030 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003031 yychar = YYLEX;
3032 }
3033
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003034 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003035 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003036 yychar = yytoken = YYEOF;
3037 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003038 }
3039 else
3040 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003041 yytoken = YYTRANSLATE (yychar);
3042 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003043 }
3044
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003045 /* If the proper action on seeing token YYTOKEN is to reduce or to
3046 detect an error, take that action. */
3047 yyn += yytoken;
3048 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003049 goto yydefault;
3050 yyn = yytable[yyn];
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003051 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003052 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003053 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003054 goto yyerrlab;
3055 yyn = -yyn;
3056 goto yyreduce;
3057 }
3058
3059 if (yyn == YYFINAL)
3060 YYACCEPT;
3061
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003062 /* Shift the look-ahead token. */
3063 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3064
3065 /* Discard the token being shifted unless it is eof. */
3066 if (yychar != YYEOF)
3067 yychar = YYEMPTY;
3068
3069 *++yyvsp = yylval;
3070
3071
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003072 /* Count tokens shifted since error; after three, turn off error
3073 status. */
3074 if (yyerrstatus)
3075 yyerrstatus--;
Christopher Lamb5c104242007-04-22 20:09:11 +00003076
Chris Lattner6cdc6822007-04-26 05:31:05 +00003077 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003078 goto yynewstate;
3079
Chris Lattner6cdc6822007-04-26 05:31:05 +00003080
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003081/*-----------------------------------------------------------.
3082| yydefault -- do the default action for the current state. |
3083`-----------------------------------------------------------*/
3084yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003085 yyn = yydefact[yystate];
3086 if (yyn == 0)
3087 goto yyerrlab;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003088 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003089
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003090
3091/*-----------------------------.
3092| yyreduce -- Do a reduction. |
3093`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003094yyreduce:
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003095 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003096 yylen = yyr2[yyn];
3097
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003098 /* If YYLEN is nonzero, implement the default value of the action:
3099 `$$ = $1'.
3100
3101 Otherwise, the following line sets YYVAL to garbage.
3102 This behavior is undocumented and Bison
3103 users should not rely upon it. Assigning to YYVAL
3104 unconditionally makes the parser a bit smaller, and it avoids a
3105 GCC warning that YYVAL may be used uninitialized. */
3106 yyval = yyvsp[1-yylen];
3107
3108
3109 YY_REDUCE_PRINT (yyn);
3110 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003111 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003112 case 29:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003113#line 1117 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003114 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3115 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003116
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003117 case 30:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003118#line 1117 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003119 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3120 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003121
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003122 case 31:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003123#line 1118 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003124 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3125 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003126
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003127 case 32:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003128#line 1118 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003129 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3130 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003131
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003132 case 33:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003133#line 1119 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003134 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3135 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003136
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003137 case 34:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003138#line 1119 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003139 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3140 break;
3141
3142 case 35:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003143#line 1120 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003144 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3145 break;
3146
3147 case 36:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003148#line 1120 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003149 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3150 break;
3151
3152 case 37:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003153#line 1121 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003154 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3155 break;
3156
3157 case 38:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003158#line 1121 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003159 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3160 break;
3161
3162 case 39:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003163#line 1125 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003164 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3165 break;
3166
3167 case 40:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003168#line 1125 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003169 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3170 break;
3171
3172 case 41:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003173#line 1126 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003174 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3175 break;
3176
3177 case 42:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003178#line 1126 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003179 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3180 break;
3181
3182 case 43:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003183#line 1127 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003184 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3185 break;
3186
3187 case 44:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003188#line 1127 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003189 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3190 break;
3191
3192 case 45:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003193#line 1128 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003194 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3195 break;
3196
3197 case 46:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003198#line 1128 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003199 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3200 break;
3201
3202 case 47:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003203#line 1129 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003204 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3205 break;
3206
3207 case 48:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003208#line 1129 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003209 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3210 break;
3211
3212 case 49:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003213#line 1130 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003214 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3215 break;
3216
3217 case 50:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003218#line 1130 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003219 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3220 break;
3221
3222 case 51:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003223#line 1131 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003224 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3225 break;
3226
3227 case 52:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003228#line 1131 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003229 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3230 break;
3231
3232 case 53:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003233#line 1132 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003234 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3235 break;
3236
3237 case 54:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003238#line 1133 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003239 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3240 break;
3241
3242 case 61:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003243#line 1142 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003244 { (yyval.StrVal) = 0; ;}
3245 break;
3246
3247 case 62:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003248#line 1146 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003249 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003250 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003251 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003252 ;}
3253 break;
3254
3255 case 63:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003256#line 1150 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003257 {
3258 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003259 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003260 ;}
3261 break;
3262
3263 case 67:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003264#line 1158 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003265 {
3266 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003267 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003268 ;}
3269 break;
3270
3271 case 68:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003272#line 1163 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003273 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003274 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003275 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003276 ;}
3277 break;
3278
3279 case 69:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003280#line 1169 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003281 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3282 break;
3283
3284 case 70:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003285#line 1170 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003286 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3287 break;
3288
3289 case 71:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003290#line 1171 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003291 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3292 break;
3293
3294 case 72:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003295#line 1172 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003296 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3297 break;
3298
3299 case 73:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003300#line 1173 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003301 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3302 break;
3303
3304 case 74:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003305#line 1177 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003306 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3307 break;
3308
3309 case 75:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003310#line 1178 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003311 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3312 break;
3313
3314 case 76:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003315#line 1179 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003316 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3317 break;
3318
3319 case 77:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003320#line 1183 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003321 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3322 break;
3323
3324 case 78:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003325#line 1184 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003326 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3327 break;
3328
3329 case 79:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003330#line 1185 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003331 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3332 break;
3333
3334 case 80:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003335#line 1189 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003336 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3337 break;
3338
3339 case 81:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003340#line 1190 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003341 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3342 break;
3343
3344 case 82:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003345#line 1191 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003346 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3347 break;
3348
3349 case 83:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003350#line 1195 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003351 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3352 break;
3353
3354 case 84:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003355#line 1196 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003356 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3357 break;
3358
3359 case 85:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003360#line 1197 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003361 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3362 break;
3363
3364 case 86:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003365#line 1198 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003366 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3367 break;
3368
3369 case 87:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003370#line 1199 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003371 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3372 break;
3373
3374 case 88:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003375#line 1203 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003376 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3377 break;
3378
3379 case 89:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003380#line 1204 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003381 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3382 break;
3383
3384 case 90:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003385#line 1205 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003386 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3387 break;
3388
3389 case 91:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003390#line 1208 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003391 { (yyval.UIntVal) = CallingConv::C; ;}
3392 break;
3393
3394 case 92:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003395#line 1209 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003396 { (yyval.UIntVal) = CallingConv::C; ;}
3397 break;
3398
3399 case 93:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003400#line 1210 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003401 { (yyval.UIntVal) = CallingConv::Fast; ;}
3402 break;
3403
3404 case 94:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003405#line 1211 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003406 { (yyval.UIntVal) = CallingConv::Cold; ;}
3407 break;
3408
3409 case 95:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003410#line 1212 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003411 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3412 break;
3413
3414 case 96:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003415#line 1213 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003416 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3417 break;
3418
3419 case 97:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003420#line 1214 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003421 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003422 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003423 GEN_ERROR("Calling conv too large");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003424 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003425 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003426 ;}
3427 break;
3428
3429 case 98:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003430#line 1221 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003431 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3432 break;
3433
3434 case 99:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003435#line 1222 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003436 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3437 break;
3438
3439 case 100:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003440#line 1223 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003441 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3442 break;
3443
3444 case 101:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003445#line 1224 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003446 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3447 break;
3448
3449 case 102:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003450#line 1227 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003451 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3452 break;
3453
3454 case 103:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003455#line 1228 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003456 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003457 (yyval.ParamAttrs) = (yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003458 ;}
3459 break;
3460
3461 case 104:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003462#line 1233 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003463 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3464 break;
3465
3466 case 105:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003467#line 1234 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003468 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3469 break;
3470
3471 case 107:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003472#line 1238 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003473 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3474 break;
3475
3476 case 108:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003477#line 1239 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003478 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003479 (yyval.ParamAttrs) = (yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003480 ;}
3481 break;
3482
3483 case 109:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003484#line 1246 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003485 { (yyval.UIntVal) = 0; ;}
3486 break;
3487
3488 case 110:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003489#line 1247 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003490 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003491 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003492 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003493 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003494 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003495;}
3496 break;
3497
3498 case 111:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003499#line 1253 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003500 { (yyval.UIntVal) = 0; ;}
3501 break;
3502
3503 case 112:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003504#line 1254 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003505 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003506 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003507 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer66728ef2007-03-20 01:13:36 +00003508 GEN_ERROR("Alignment must be a power of two");
3509 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003510;}
3511 break;
3512
3513 case 113:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003514#line 1262 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003515 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003516 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3517 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003518 GEN_ERROR("Invalid character in section name");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003519 (yyval.StrVal) = (yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003520 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003521;}
3522 break;
3523
3524 case 114:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003525#line 1270 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003526 { (yyval.StrVal) = 0; ;}
3527 break;
3528
3529 case 115:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003530#line 1271 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
3531 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003532 break;
3533
3534 case 116:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003535#line 1276 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003536 {;}
3537 break;
3538
3539 case 117:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003540#line 1277 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003541 {;}
3542 break;
3543
3544 case 118:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003545#line 1278 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003546 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003547 CurGV->setSection((yyvsp[0].StrVal));
3548 free((yyvsp[0].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003549 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003550 ;}
3551 break;
3552
3553 case 119:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003554#line 1283 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003555 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003556 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003557 GEN_ERROR("Alignment must be a power of two");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003558 CurGV->setAlignment((yyvsp[0].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003559 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003560 ;}
3561 break;
3562
3563 case 124:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003564#line 1299 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003565 {
3566 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003567 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003568 ;}
3569 break;
3570
3571 case 125:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003572#line 1303 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003573 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003574 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003575 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003576 ;}
3577 break;
3578
3579 case 126:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003580#line 1307 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003581 { // Pointer type?
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003582 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003583 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003584 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3585 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003586 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003587 ;}
3588 break;
3589
3590 case 127:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003591#line 1314 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003592 { // Named types are also simple types...
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003593 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003594 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003595 (yyval.TypeVal) = new PATypeHolder(tmp);
3596 ;}
3597 break;
3598
3599 case 128:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003600#line 1319 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003601 { // Type UpReference
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003602 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003603 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003604 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003605 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003606 UR_OUT("New Upreference!\n");
3607 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003608 ;}
3609 break;
3610
3611 case 129:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003612#line 1327 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003613 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003614 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003615 ParamAttrsVector Attrs;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003616 if ((yyvsp[0].ParamAttrs) != ParamAttr::None) {
3617 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[0].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003618 Attrs.push_back(X);
3619 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00003620 unsigned index = 1;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003621 TypeWithAttrsList::iterator I = (yyvsp[-2].TypeWithAttrsList)->begin(), E = (yyvsp[-2].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003622 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003623 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003624 Params.push_back(Ty);
3625 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003626 if (I->Attrs != ParamAttr::None) {
3627 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3628 Attrs.push_back(X);
3629 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003630 }
3631 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3632 if (isVarArg) Params.pop_back();
3633
Reid Spencer7b5d4662007-04-09 06:16:21 +00003634 ParamAttrsList *ActualAttrs = 0;
3635 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003636 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003637 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, ActualAttrs);
3638 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3639 delete (yyvsp[-4].TypeVal); // Delete the return type handle
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003640 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003641 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003642 ;}
3643 break;
3644
3645 case 130:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003646#line 1357 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003647 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003648 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003649 ParamAttrsVector Attrs;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003650 if ((yyvsp[0].ParamAttrs) != ParamAttr::None) {
3651 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[0].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003652 Attrs.push_back(X);
3653 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003654 TypeWithAttrsList::iterator I = (yyvsp[-2].TypeWithAttrsList)->begin(), E = (yyvsp[-2].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003655 unsigned index = 1;
3656 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003657 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003658 Params.push_back(Ty);
3659 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003660 if (I->Attrs != ParamAttr::None) {
3661 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3662 Attrs.push_back(X);
3663 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003664 }
3665 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3666 if (isVarArg) Params.pop_back();
3667
Reid Spencer7b5d4662007-04-09 06:16:21 +00003668 ParamAttrsList *ActualAttrs = 0;
3669 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003670 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003671
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003672 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, ActualAttrs);
3673 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003674 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003675 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003676 ;}
3677 break;
3678
3679 case 131:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003680#line 1388 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003681 { // Sized array type?
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003682 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3683 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003684 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003685 ;}
3686 break;
3687
3688 case 132:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003689#line 1393 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003690 { // Vector type?
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003691 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3692 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003693 GEN_ERROR("Unsigned result not equal to signed result");
3694 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencer9d6565a2007-02-15 02:26:10 +00003695 GEN_ERROR("Element type of a VectorType must be primitive");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003696 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003697 GEN_ERROR("Vector length should be a power of 2");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003698 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3699 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003700 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003701 ;}
3702 break;
3703
3704 case 133:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003705#line 1405 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003706 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003707 std::vector<const Type*> Elements;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003708 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3709 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003710 Elements.push_back(*I);
3711
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003712 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003713 delete (yyvsp[-1].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003714 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003715 ;}
3716 break;
3717
3718 case 134:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003719#line 1415 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003720 { // Empty structure type?
3721 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003722 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003723 ;}
3724 break;
3725
3726 case 135:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003727#line 1419 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003728 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003729 std::vector<const Type*> Elements;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003730 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3731 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003732 Elements.push_back(*I);
3733
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003734 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003735 delete (yyvsp[-2].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003736 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003737 ;}
3738 break;
3739
3740 case 136:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003741#line 1429 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003742 { // Empty structure type?
3743 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003744 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003745 ;}
3746 break;
3747
3748 case 137:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003749#line 1436 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003750 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003751 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3752 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003753 ;}
3754 break;
3755
3756 case 138:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003757#line 1443 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003758 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003759 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003760 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3761 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003762 GEN_ERROR("LLVM functions cannot return aggregate types");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003763 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003764 ;}
3765 break;
3766
3767 case 139:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003768#line 1450 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003769 {
3770 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3771 ;}
3772 break;
3773
3774 case 140:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003775#line 1455 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003776 {
3777 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003778 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003779 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003780 ;}
3781 break;
3782
3783 case 141:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003784#line 1460 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003785 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003786 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003787 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003788 ;}
3789 break;
3790
3791 case 143:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003792#line 1468 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003793 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003794 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00003795 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003796 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003797 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003798 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003799 ;}
3800 break;
3801
3802 case 144:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003803#line 1475 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003804 {
3805 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003806 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003807 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003808 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003809 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003810 ;}
3811 break;
3812
3813 case 145:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003814#line 1482 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003815 {
3816 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003817 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003818 ;}
3819 break;
3820
3821 case 146:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003822#line 1490 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003823 {
3824 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003825 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal));
3826 delete (yyvsp[0].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003827 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003828 ;}
3829 break;
3830
3831 case 147:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003832#line 1496 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003833 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003834 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal));
3835 delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003836 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003837 ;}
3838 break;
3839
3840 case 148:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003841#line 1508 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003842 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003843 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003844 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3845 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003846 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003847 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003848 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003849 const Type *ETy = ATy->getElementType();
3850 int NumElements = ATy->getNumElements();
3851
3852 // Verify that we have the correct size...
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003853 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003854 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003855 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003856 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003857
3858 // Verify all elements are correct type!
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003859 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3860 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003861 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3862 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003863 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003864 }
3865
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003866 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3867 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003868 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003869 ;}
3870 break;
3871
3872 case 149:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003873#line 1536 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003874 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003875 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003876 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3877 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003878 if (ATy == 0)
3879 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003880 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003881
Andrew Lenharth6353e052006-12-08 18:07:09 +00003882 int NumElements = ATy->getNumElements();
3883 if (NumElements != -1 && NumElements != 0)
3884 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003885 " arguments, but has size of " + itostr(NumElements) +"");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003886 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003887 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003888 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003889 ;}
3890 break;
3891
3892 case 150:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003893#line 1552 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003894 {
Reid Spencer14310612006-12-31 05:40:51 +00003895 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003896 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3897 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003898 if (ATy == 0)
3899 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003900 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00003901
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003902 int NumElements = ATy->getNumElements();
3903 const Type *ETy = ATy->getElementType();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003904 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3905 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003906 GEN_ERROR("Can't build string constant of size " +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003907 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003908 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003909 std::vector<Constant*> Vals;
3910 if (ETy == Type::Int8Ty) {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003911 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003912 C != (unsigned char*)EndStr; ++C)
3913 Vals.push_back(ConstantInt::get(ETy, *C));
3914 } else {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003915 free((yyvsp[0].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00003916 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003917 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003918 free((yyvsp[0].StrVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003919 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003920 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003921 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003922 ;}
3923 break;
3924
3925 case 151:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003926#line 1581 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003927 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003928 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003929 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3930 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003931 if (PTy == 0)
3932 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003933 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003934 const Type *ETy = PTy->getElementType();
3935 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003936
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003937 // Verify that we have the correct size...
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003938 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003939 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003940 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003941 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003942
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003943 // Verify all elements are correct type!
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003944 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3945 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003946 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3947 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003948 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003949 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003950
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003951 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector));
3952 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003953 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003954 ;}
3955 break;
3956
3957 case 152:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003958#line 1609 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003959 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003960 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003961 if (STy == 0)
3962 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003963 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003964
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003965 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003966 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003967
3968 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003969 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3970 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003971 GEN_ERROR("Expected type '" +
3972 STy->getElementType(i)->getDescription() +
3973 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003974 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003975
3976 // Check to ensure that Type is not packed
3977 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00003978 GEN_ERROR("Unpacked Initializer to vector type '" +
3979 STy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003980
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003981 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3982 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003983 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003984 ;}
3985 break;
3986
3987 case 153:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003988#line 1635 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003989 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003990 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003991 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3992 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003993 if (STy == 0)
3994 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00003995 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003996
3997 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003998 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003999
4000 // Check to ensure that Type is not packed
4001 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004002 GEN_ERROR("Unpacked Initializer to vector type '" +
4003 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004004
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004005 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004006 delete (yyvsp[-2].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004007 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004008 ;}
4009 break;
4010
4011 case 154:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004012#line 1655 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004013 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004014 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004015 if (STy == 0)
4016 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004017 (*(yyvsp[-5].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004018
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004019 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004020 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004021
4022 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004023 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
4024 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004025 GEN_ERROR("Expected type '" +
4026 STy->getElementType(i)->getDescription() +
4027 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004028 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004029
4030 // Check to ensure that Type is packed
4031 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004032 GEN_ERROR("Vector initializer to non-vector type '" +
4033 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004034
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004035 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
4036 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004037 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004038 ;}
4039 break;
4040
4041 case 155:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004042#line 1681 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004043 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004044 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004045 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
4046 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004047 if (STy == 0)
4048 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004049 (*(yyvsp[-4].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004050
4051 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004052 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004053
4054 // Check to ensure that Type is packed
4055 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004056 GEN_ERROR("Vector initializer to non-vector type '" +
4057 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004058
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004059 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004060 delete (yyvsp[-4].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004061 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004062 ;}
4063 break;
4064
4065 case 156:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004066#line 1701 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004067 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004068 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004069 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4070 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004071 if (PTy == 0)
4072 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004073 (*(yyvsp[-1].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004074
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004075 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004076 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004077 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004078 ;}
4079 break;
4080
4081 case 157:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004082#line 1713 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004083 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004084 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004085 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4086 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
4087 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004088 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004089 ;}
4090 break;
4091
4092 case 158:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004093#line 1720 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004094 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004095 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004096 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4097 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004098 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004099 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004100
4101 // ConstExprs can exist in the body of a function, thus creating
4102 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004103 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004104 // symbol table instead of the module symbol table for the global symbol,
4105 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004106 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004107 //
4108 Function *SavedCurFn = CurFun.CurrentFunction;
4109 CurFun.CurrentFunction = 0;
4110
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004111 Value *V = getExistingVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004112 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004113
4114 CurFun.CurrentFunction = SavedCurFn;
4115
4116 // If this is an initializer for a constant pointer, which is referencing a
4117 // (currently) undefined variable, create a stub now that shall be replaced
4118 // in the future with the right type of variable.
4119 //
4120 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004121 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004122 const PointerType *PT = cast<PointerType>(Ty);
4123
4124 // First check to see if the forward references value is already created!
4125 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004126 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004127
4128 if (I != CurModule.GlobalRefs.end()) {
4129 V = I->second; // Placeholder already exists, use it...
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004130 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004131 } else {
4132 std::string Name;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004133 if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName)
4134 Name = (yyvsp[0].ValIDVal).Name;
4135 else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004136 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004137
4138 // Create the forward referenced global.
4139 GlobalValue *GV;
4140 if (const FunctionType *FTy =
4141 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004142 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004143 CurModule.CurrentModule);
4144 } else {
4145 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004146 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004147 Name, CurModule.CurrentModule);
4148 }
4149
4150 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004151 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004152 V = GV;
4153 }
4154 }
4155
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004156 (yyval.ConstVal) = cast<GlobalValue>(V);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004157 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004158 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004159 ;}
4160 break;
4161
4162 case 159:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004163#line 1786 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004164 {
Reid Spencer14310612006-12-31 05:40:51 +00004165 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004166 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4167 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004168 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004169 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
4170 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4171 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004172 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004173 ;}
4174 break;
4175
4176 case 160:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004177#line 1796 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004178 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004179 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004180 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4181 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004182 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00004183 GEN_ERROR("Cannot create a null initialized value of this type");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004184 (yyval.ConstVal) = Constant::getNullValue(Ty);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004185 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004186 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004187 ;}
4188 break;
4189
4190 case 161:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004191#line 1806 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004192 { // integral constants
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004193 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004194 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004195 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val), true);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004196 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004197 ;}
4198 break;
4199
4200 case 162:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004201#line 1812 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004202 { // arbitrary precision integer constants
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004203 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4204 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
Reid Spencer38c91a92007-02-28 02:24:54 +00004205 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004206 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004207 (yyvsp[0].APIntVal)->sextOrTrunc(BitWidth);
4208 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
4209 delete (yyvsp[0].APIntVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00004210 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004211 ;}
4212 break;
4213
4214 case 163:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004215#line 1822 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004216 { // integral constants
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004217 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004218 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004219 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004220 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004221 ;}
4222 break;
4223
4224 case 164:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004225#line 1828 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004226 { // arbitrary precision integer constants
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004227 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4228 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
Reid Spencer38c91a92007-02-28 02:24:54 +00004229 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004230 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004231 (yyvsp[0].APIntVal)->zextOrTrunc(BitWidth);
4232 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
4233 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004234 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004235 ;}
4236 break;
4237
4238 case 165:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004239#line 1838 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004240 { // Boolean constants
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004241 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004242 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004243 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004244 ;}
4245 break;
4246
4247 case 166:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004248#line 1843 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004249 { // Boolean constants
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004250 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004251 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer38c91a92007-02-28 02:24:54 +00004252 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004253 ;}
4254 break;
4255
4256 case 167:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004257#line 1848 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004258 { // Float & Double constants
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004259 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004260 GEN_ERROR("Floating point constant invalid for type");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004261 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004262 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004263 ;}
4264 break;
4265
4266 case 168:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004267#line 1856 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004268 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004269 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004270 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4271 Constant *Val = (yyvsp[-3].ConstVal);
4272 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4273 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004274 GEN_ERROR("invalid cast opcode for cast from '" +
4275 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004276 DestTy->getDescription() + "'");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004277 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4278 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004279 ;}
4280 break;
4281
4282 case 169:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004283#line 1868 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004284 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004285 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004286 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004287
4288 const Type *IdxTy =
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004289 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004290 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004291 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004292 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004293
Chris Lattnerf7469af2007-01-31 04:44:08 +00004294 SmallVector<Constant*, 8> IdxVec;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004295 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4296 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004297 IdxVec.push_back(C);
4298 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004299 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004300
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004301 delete (yyvsp[-1].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004302
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004303 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004304 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004305 ;}
4306 break;
4307
4308 case 170:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004309#line 1890 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004310 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004311 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004312 GEN_ERROR("Select condition must be of boolean type");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004313 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004314 GEN_ERROR("Select operand types must match");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004315 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004316 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004317 ;}
4318 break;
4319
4320 case 171:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004321#line 1898 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004322 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004323 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004324 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004325 CHECK_FOR_ERROR;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004326 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004327 ;}
4328 break;
4329
4330 case 172:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004331#line 1904 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004332 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004333 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004334 GEN_ERROR("Logical operator types must match");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004335 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4336 if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].ConstVal)->getType()) ||
4337 !cast<VectorType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004338 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004339 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004340 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004341 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004342 ;}
4343 break;
4344
4345 case 173:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004346#line 1915 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004347 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004348 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004349 GEN_ERROR("icmp operand types must match");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004350 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004351 ;}
4352 break;
4353
4354 case 174:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004355#line 1920 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004356 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004357 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004358 GEN_ERROR("fcmp operand types must match");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004359 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004360 ;}
4361 break;
4362
4363 case 175:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004364#line 1925 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004365 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004366 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004367 GEN_ERROR("Invalid extractelement operands");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004368 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004369 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004370 ;}
4371 break;
4372
4373 case 176:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004374#line 1931 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004375 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004376 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004377 GEN_ERROR("Invalid insertelement operands");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004378 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004379 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004380 ;}
4381 break;
4382
4383 case 177:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004384#line 1937 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004385 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004386 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004387 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004388 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004389 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004390 ;}
4391 break;
4392
4393 case 178:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004394#line 1946 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004395 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004396 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004397 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004398 ;}
4399 break;
4400
4401 case 179:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004402#line 1950 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004403 {
4404 (yyval.ConstVector) = new std::vector<Constant*>();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004405 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004406 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004407 ;}
4408 break;
4409
4410 case 180:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004411#line 1958 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004412 { (yyval.BoolVal) = false; ;}
4413 break;
4414
4415 case 181:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004416#line 1958 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004417 { (yyval.BoolVal) = true; ;}
4418 break;
4419
4420 case 182:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004421#line 1961 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004422 { (yyval.BoolVal) = true; ;}
4423 break;
4424
4425 case 183:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004426#line 1961 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004427 { (yyval.BoolVal) = false; ;}
4428 break;
4429
4430 case 184:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004431#line 1964 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004432 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004433 const Type* VTy = (yyvsp[-1].TypeVal)->get();
4434 Value *V = getVal(VTy, (yyvsp[0].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004435 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4436 if (!Aliasee)
4437 GEN_ERROR("Aliases can be created only to global values");
4438
4439 (yyval.ConstVal) = Aliasee;
4440 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004441 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004442 ;}
4443 break;
4444
4445 case 185:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004446#line 1975 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004447 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004448 Constant *Val = (yyvsp[-3].ConstVal);
4449 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4450 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004451 GEN_ERROR("invalid cast opcode for cast from '" +
4452 Val->getType()->getDescription() + "' to '" +
4453 DestTy->getDescription() + "'");
4454
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004455 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004456 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004457 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004458 ;}
4459 break;
4460
4461 case 186:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004462#line 1996 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004463 {
4464 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer67d8ed92007-03-22 02:14:08 +00004465 CurModule.ModuleDone();
4466 CHECK_FOR_ERROR;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004467 ;}
4468 break;
4469
4470 case 187:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004471#line 2001 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004472 {
4473 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004474 CurModule.ModuleDone();
4475 CHECK_FOR_ERROR;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004476 ;}
4477 break;
4478
4479 case 190:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004480#line 2014 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004481 { CurFun.isDeclare = false; ;}
4482 break;
4483
4484 case 191:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004485#line 2014 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004486 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004487 CurFun.FunctionDone();
4488 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004489 ;}
4490 break;
4491
4492 case 192:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004493#line 2018 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004494 { CurFun.isDeclare = true; ;}
4495 break;
4496
4497 case 193:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004498#line 2018 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004499 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004500 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004501 ;}
4502 break;
4503
4504 case 194:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004505#line 2021 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004506 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004507 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004508 ;}
4509 break;
4510
4511 case 195:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004512#line 2024 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004513 {
Reid Spencer14310612006-12-31 05:40:51 +00004514 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004515 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004516 // Eagerly resolve types. This is not an optimization, this is a
4517 // requirement that is due to the fact that we could have this:
4518 //
4519 // %list = type { %list * }
4520 // %list = type { %list * } ; repeated type decl
4521 //
4522 // If types are not resolved eagerly, then the two types will not be
4523 // determined to be the same type!
4524 //
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004525 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004526
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004527 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004528 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004529 // If this is a named type that is not a redefinition, add it to the slot
4530 // table.
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004531 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004532 }
Reid Spencera132e042006-12-03 05:46:11 +00004533
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004534 delete (yyvsp[0].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004535 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004536 ;}
4537 break;
Reid Spencer38c91a92007-02-28 02:24:54 +00004538
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004539 case 196:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004540#line 2048 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004541 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004542 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004543
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004544 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004545 CHECK_FOR_ERROR
4546 // If this is a named type that is not a redefinition, add it to the slot
4547 // table.
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004548 CurModule.Types.push_back((yyvsp[0].PrimType));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004549 }
4550 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004551 ;}
4552 break;
4553
4554 case 197:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004555#line 2059 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004556 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004557 /* "Externally Visible" Linkage */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004558 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004559 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004560 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), GlobalValue::ExternalLinkage,
4561 (yyvsp[-3].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal), (yyvsp[-2].BoolVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004562 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004563 ;}
4564 break;
4565
4566 case 198:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004567#line 2066 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004568 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004569 CurGV = 0;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004570 ;}
4571 break;
4572
4573 case 199:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004574#line 2070 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004575 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004576 if ((yyvsp[0].ConstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004577 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004578 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 +00004579 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004580 ;}
4581 break;
4582
4583 case 200:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004584#line 2075 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004585 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004586 CurGV = 0;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004587 ;}
4588 break;
4589
4590 case 201:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004591#line 2079 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004592 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004593 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004594 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4595 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 +00004596 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004597 delete (yyvsp[0].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004598 ;}
4599 break;
4600
4601 case 202:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004602#line 2085 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004603 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004604 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004605 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004606 ;}
4607 break;
4608
4609 case 203:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004610#line 2089 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004611 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004612 std::string Name((yyvsp[-4].StrVal));
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004613 if (Name.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004614 GEN_ERROR("Alias name cannot be empty");
4615
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004616 Constant* Aliasee = (yyvsp[0].ConstVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004617 if (Aliasee == 0)
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004618 GEN_ERROR(std::string("Invalid aliasee for alias: ") + (yyvsp[-4].StrVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004619
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004620 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[-1].Linkage), Name, Aliasee,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004621 CurModule.CurrentModule);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004622 GA->setVisibility((yyvsp[-3].Visibility));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004623 InsertValue(GA, CurModule.Values);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004624 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004625 ;}
4626 break;
4627
4628 case 204:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004629#line 2104 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004630 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004631 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004632 ;}
4633 break;
4634
4635 case 205:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004636#line 2107 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004637 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004638 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004639 ;}
4640 break;
4641
4642 case 206:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004643#line 2113 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004644 {
Chris Lattner66316012006-01-24 04:14:29 +00004645 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004646 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4647 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4648 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004649
4650 if (AsmSoFar.empty())
4651 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4652 else
4653 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004654 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004655;}
4656 break;
4657
4658 case 207:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004659#line 2126 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004660 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004661 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4662 free((yyvsp[0].StrVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004663 ;}
4664 break;
4665
4666 case 208:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004667#line 2130 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004668 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004669 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4670 free((yyvsp[0].StrVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004671 ;}
4672 break;
4673
4674 case 210:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004675#line 2137 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004676 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004677 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4678 free((yyvsp[0].StrVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004679 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004680 ;}
4681 break;
4682
4683 case 211:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004684#line 2142 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004685 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004686 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4687 free((yyvsp[0].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004688 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004689 ;}
4690 break;
4691
4692 case 212:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004693#line 2147 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004694 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004695 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004696 ;}
4697 break;
4698
4699 case 213:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004700#line 2156 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004701 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004702 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004703 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4704 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004705 GEN_ERROR("void typed arguments are invalid");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004706 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4707 (yyval.ArgList) = (yyvsp[-4].ArgList);
4708 (yyvsp[-4].ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004709 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004710 ;}
4711 break;
4712
4713 case 214:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004714#line 2166 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004715 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004716 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004717 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4718 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004719 GEN_ERROR("void typed arguments are invalid");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004720 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004721 (yyval.ArgList) = new ArgListType;
4722 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004723 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004724 ;}
4725 break;
4726
4727 case 215:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004728#line 2177 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004729 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004730 (yyval.ArgList) = (yyvsp[0].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004731 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004732 ;}
4733 break;
4734
4735 case 216:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004736#line 2181 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004737 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004738 (yyval.ArgList) = (yyvsp[-2].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004739 struct ArgListEntry E;
4740 E.Ty = new PATypeHolder(Type::VoidTy);
4741 E.Name = 0;
4742 E.Attrs = ParamAttr::None;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004743 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004744 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004745 ;}
4746 break;
4747
4748 case 217:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004749#line 2190 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004750 {
4751 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004752 struct ArgListEntry E;
4753 E.Ty = new PATypeHolder(Type::VoidTy);
4754 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004755 E.Attrs = ParamAttr::None;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004756 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004757 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004758 ;}
4759 break;
4760
4761 case 218:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004762#line 2199 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004763 {
4764 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004765 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004766 ;}
4767 break;
4768
4769 case 219:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004770#line 2205 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004771 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004772 UnEscapeLexed((yyvsp[-6].StrVal));
4773 std::string FunctionName((yyvsp[-6].StrVal));
4774 free((yyvsp[-6].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004775
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004776 // Check the function result for abstractness if this is a define. We should
4777 // have no abstract types at this point
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004778 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4779 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004780
Reid Spencer68a24bd2005-08-27 18:50:39 +00004781 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004782 ParamAttrsVector Attrs;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004783 if ((yyvsp[-2].ParamAttrs) != ParamAttr::None) {
4784 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[-2].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00004785 Attrs.push_back(PAWI);
4786 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004787 if ((yyvsp[-4].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004788 unsigned index = 1;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004789 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004790 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004791 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4792 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004793 ParamTypeList.push_back(Ty);
4794 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004795 if (I->Attrs != ParamAttr::None) {
4796 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4797 Attrs.push_back(PAWI);
4798 }
Reid Spencer14310612006-12-31 05:40:51 +00004799 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004800 }
4801
4802 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4803 if (isVarArg) ParamTypeList.pop_back();
4804
Christopher Lamb5c104242007-04-22 20:09:11 +00004805 ParamAttrsList *PAL = 0;
4806 if (!Attrs.empty())
4807 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004808
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004809 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004810 const PointerType *PFT = PointerType::get(FT);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004811 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004812
4813 ValID ID;
4814 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004815 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004816 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004817 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004818 }
4819
4820 Function *Fn = 0;
4821 // See if this function was forward referenced. If so, recycle the object.
4822 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4823 // Move the function to the end of the list, from whereever it was
4824 // previously inserted.
4825 Fn = cast<Function>(FWRef);
4826 CurModule.CurrentModule->getFunctionList().remove(Fn);
4827 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4828 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004829 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004830 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004831 // The existing function doesn't have the same type. This is an overload
4832 // error.
4833 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4834 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004835 // Neither the existing or the current function is a declaration and they
4836 // have the same name and same type. Clearly this is a redefinition.
4837 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004838 } if (Fn->isDeclaration()) {
4839 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004840 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4841 AI != AE; ++AI)
4842 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004843 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004844 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004845 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004846 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004847
Reid Spencer68a24bd2005-08-27 18:50:39 +00004848 InsertValue(Fn, CurModule.Values);
4849 }
4850
4851 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004852
4853 if (CurFun.isDeclare) {
4854 // If we have declaration, always overwrite linkage. This will allow us to
4855 // correctly handle cases, when pointer to function is passed as argument to
4856 // another function.
4857 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004858 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004859 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004860 Fn->setCallingConv((yyvsp[-8].UIntVal));
4861 Fn->setAlignment((yyvsp[0].UIntVal));
4862 if ((yyvsp[-1].StrVal)) {
4863 Fn->setSection((yyvsp[-1].StrVal));
4864 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004865 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004866
4867 // Add all of the arguments we parsed to the function...
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004868 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004869 if (isVarArg) { // Nuke the last entry
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004870 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004871 "Not a varargs marker!");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004872 delete (yyvsp[-4].ArgList)->back().Ty;
4873 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004874 }
4875 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004876 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004877 unsigned Idx = 1;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004878 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin();
4879 I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004880 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00004881 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004882 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004883 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004884 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004885 }
Reid Spencera132e042006-12-03 05:46:11 +00004886
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004887 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004888 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004889 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004890;}
4891 break;
4892
4893 case 222:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004894#line 2328 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004895 {
4896 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004897
4898 // Make sure that we keep track of the linkage type even if there was a
4899 // previous "declare".
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004900 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4901 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004902;}
4903 break;
4904
4905 case 225:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004906#line 2339 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004907 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004908 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004909 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004910;}
4911 break;
4912
4913 case 226:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004914#line 2344 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004915 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004916 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4917 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004918 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004919 CurFun.FunctionDone();
4920 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004921 ;}
4922 break;
4923
4924 case 227:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004925#line 2356 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004926 {
4927 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004928 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004929 ;}
4930 break;
4931
4932 case 228:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004933#line 2360 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004934 {
4935 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004936 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004937 ;}
4938 break;
4939
4940 case 229:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004941#line 2365 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004942 { // A reference to a direct constant
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004943 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004944 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004945 ;}
4946 break;
4947
4948 case 230:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004949#line 2369 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004950 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004951 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004952 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004953 ;}
4954 break;
4955
4956 case 231:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004957#line 2373 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004958 { // Perhaps it's an FP constant?
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004959 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004960 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004961 ;}
4962 break;
4963
4964 case 232:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004965#line 2377 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004966 {
4967 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004968 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004969 ;}
4970 break;
4971
4972 case 233:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004973#line 2381 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004974 {
4975 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004976 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004977 ;}
4978 break;
4979
4980 case 234:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004981#line 2385 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004982 {
4983 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004984 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004985 ;}
4986 break;
4987
4988 case 235:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004989#line 2389 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004990 {
4991 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004992 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004993 ;}
4994 break;
4995
4996 case 236:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00004997#line 2393 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004998 { // A vector zero constant.
4999 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00005000 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005001 ;}
5002 break;
5003
5004 case 237:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005005#line 2397 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005006 { // Nonempty unsized packed vector
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005007 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
5008 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005009
Reid Spencer9d6565a2007-02-15 02:26:10 +00005010 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005011 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005012 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005013 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005014 ETy,
5015 NumElements)
5016 )
5017 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005018
5019 // Verify all elements are correct type!
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005020 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5021 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005022 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005023 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005024 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005025 }
5026
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005027 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector)));
5028 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005029 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005030 ;}
5031 break;
5032
5033 case 238:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005034#line 2422 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005035 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005036 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005037 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005038 ;}
5039 break;
5040
5041 case 239:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005042#line 2426 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005043 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005044 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5045 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5046 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5047 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5048 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5049 free((yyvsp[-2].StrVal));
5050 free((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005051 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005052 ;}
5053 break;
5054
5055 case 240:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005056#line 2440 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005057 { // Is it an integer reference...?
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005058 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005059 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005060 ;}
5061 break;
5062
5063 case 241:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005064#line 2444 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005065 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005066 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005067 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005068 ;}
5069 break;
5070
5071 case 242:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005072#line 2448 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005073 { // Is it a named reference...?
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005074 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005075 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005076 ;}
5077 break;
5078
5079 case 243:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005080#line 2452 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005081 { // Is it a named reference...?
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005082 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005083 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005084 ;}
5085 break;
5086
5087 case 246:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005088#line 2464 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005089 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005090 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005091 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5092 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
5093 delete (yyvsp[-1].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005094 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005095 ;}
5096 break;
5097
5098 case 247:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005099#line 2473 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005100 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005101 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005102 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005103 ;}
5104 break;
5105
5106 case 248:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005107#line 2477 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005108 { // Do not allow functions with 0 basic blocks
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005109 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005110 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005111 ;}
5112 break;
5113
5114 case 249:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005115#line 2486 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005116 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005117 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005118 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005119 InsertValue((yyvsp[0].TermInstVal));
5120 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5121 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005122 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005123 ;}
5124 break;
5125
5126 case 250:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005127#line 2495 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005128 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005129 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005130 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5131 if (CI2->getParent() == 0)
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005132 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
5133 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
5134 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005135 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005136 ;}
5137 break;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005138
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005139 case 251:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005140#line 2504 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005141 { // Empty space between instruction lists
5142 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
5143 CHECK_FOR_ERROR
5144 ;}
5145 break;
5146
5147 case 252:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005148#line 2508 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005149 { // Labelled (named) basic block
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005150 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[0].StrVal)));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005151 CHECK_FOR_ERROR
5152 ;}
5153 break;
5154
5155 case 253:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005156#line 2513 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005157 { // Return with a result...
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005158 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005159 CHECK_FOR_ERROR
5160 ;}
5161 break;
5162
5163 case 254:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005164#line 2517 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005165 { // Return with no result...
5166 (yyval.TermInstVal) = new ReturnInst();
5167 CHECK_FOR_ERROR
5168 ;}
5169 break;
5170
5171 case 255:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005172#line 2521 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005173 { // Unconditional Branch...
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005174 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005175 CHECK_FOR_ERROR
5176 (yyval.TermInstVal) = new BranchInst(tmpBB);
5177 ;}
5178 break;
5179
5180 case 256:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005181#line 2526 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005182 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005183 assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?");
5184 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005185 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005186 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005187 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005188 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005189 CHECK_FOR_ERROR
5190 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5191 ;}
5192 break;
5193
5194 case 257:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005195#line 2536 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005196 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005197 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005198 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005199 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005200 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005201 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005202 (yyval.TermInstVal) = S;
5203
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005204 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5205 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005206 for (; I != E; ++I) {
5207 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5208 S->addCase(CI, I->second);
5209 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005210 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005211 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005212 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005213 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005214 ;}
5215 break;
5216
5217 case 258:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005218#line 2555 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005219 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005220 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005221 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005222 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005223 CHECK_FOR_ERROR
5224 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005225 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005226 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005227 ;}
5228 break;
5229
5230 case 259:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005231#line 2565 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005232 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005233
Reid Spencer14310612006-12-31 05:40:51 +00005234 // Handle the short syntax
5235 const PointerType *PFTy = 0;
5236 const FunctionType *Ty = 0;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005237 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005238 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5239 // Pull out the types of all of the arguments...
5240 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005241 ParamAttrsVector Attrs;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005242 if ((yyvsp[-6].ParamAttrs) != ParamAttr::None) {
Christopher Lamb5c104242007-04-22 20:09:11 +00005243 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = 8;
5244 Attrs.push_back(PAWI);
5245 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005246 ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005247 unsigned index = 1;
5248 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005249 const Type *Ty = I->Val->getType();
5250 if (Ty == Type::VoidTy)
5251 GEN_ERROR("Short call syntax cannot be used with varargs");
5252 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005253 if (I->Attrs != ParamAttr::None) {
5254 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5255 Attrs.push_back(PAWI);
5256 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005257 }
5258
Christopher Lamb5c104242007-04-22 20:09:11 +00005259 ParamAttrsList *PAL = 0;
5260 if (!Attrs.empty())
5261 PAL = ParamAttrsList::get(Attrs);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005262 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005263 PFTy = PointerType::get(Ty);
5264 }
5265
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005266 delete (yyvsp[-11].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005267
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005268 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005269 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005270 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005271 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005272 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005273 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005274
Reid Spencer14310612006-12-31 05:40:51 +00005275 // Check the arguments
5276 ValueList Args;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005277 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005278 // Make sure no arguments is a good thing!
5279 if (Ty->getNumParams() != 0)
5280 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005281 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005282 } else { // Has arguments?
5283 // Loop through FunctionType's arguments and ensure they are specified
5284 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005285 FunctionType::param_iterator I = Ty->param_begin();
5286 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005287 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005288
Reid Spencer14310612006-12-31 05:40:51 +00005289 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5290 if (ArgI->Val->getType() != *I)
5291 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005292 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005293 Args.push_back(ArgI->Val);
5294 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005295
Reid Spencer14310612006-12-31 05:40:51 +00005296 if (Ty->isVarArg()) {
5297 if (I == E)
5298 for (; ArgI != ArgE; ++ArgI)
5299 Args.push_back(ArgI->Val); // push the remaining varargs
5300 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005301 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005302 }
Reid Spencer14310612006-12-31 05:40:51 +00005303
5304 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005305 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005306 II->setCallingConv((yyvsp[-12].UIntVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005307 (yyval.TermInstVal) = II;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005308 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005309 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005310 ;}
5311 break;
5312
5313 case 260:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005314#line 2644 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005315 {
5316 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005317 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005318 ;}
5319 break;
5320
5321 case 261:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005322#line 2648 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005323 {
5324 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005325 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005326 ;}
5327 break;
5328
5329 case 262:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005330#line 2655 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005331 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005332 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5333 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005334 CHECK_FOR_ERROR
5335 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005336 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005337
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005338 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005339 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005340 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5341 ;}
5342 break;
5343
5344 case 263:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005345#line 2666 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005346 {
5347 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005348 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005349 CHECK_FOR_ERROR
5350
5351 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005352 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005353
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005354 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005355 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005356 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5357 ;}
5358 break;
5359
5360 case 264:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005361#line 2679 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005362 {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005363 // Is this definition named?? if so, assign the name...
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005364 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spenceref9b9a72007-02-05 20:47:22 +00005365 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005366 InsertValue((yyvsp[0].InstVal));
5367 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005368 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005369 ;}
5370 break;
5371
5372 case 265:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005373#line 2689 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005374 { // Used for PHI nodes
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005375 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005376 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005377 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005378 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005379 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005380 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005381 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005382 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005383 delete (yyvsp[-5].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005384 ;}
5385 break;
5386
5387 case 266:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005388#line 2700 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005389 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005390 (yyval.PHIList) = (yyvsp[-6].PHIList);
5391 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005392 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005393 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005394 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005395 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005396 ;}
5397 break;
5398
5399 case 267:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005400#line 2710 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005401 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005402 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005403 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005404 // Used for call and invoke instructions
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005405 (yyval.ValueRefList) = new ValueRefList();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005406 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005407 (yyval.ValueRefList)->push_back(E);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005408 delete (yyvsp[-2].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005409 ;}
5410 break;
5411
5412 case 268:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005413#line 2719 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005414 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005415 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005416 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5417 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5418 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005419 (yyval.ValueRefList)->push_back(E);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005420 delete (yyvsp[-2].TypeVal);
Reid Spencer14310612006-12-31 05:40:51 +00005421 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005422 ;}
5423 break;
5424
5425 case 269:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005426#line 2728 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005427 { (yyval.ValueRefList) = new ValueRefList(); ;}
5428 break;
5429
5430 case 270:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005431#line 2731 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005432 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5433 break;
5434
5435 case 271:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005436#line 2732 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005437 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005438 (yyval.ValueList) = (yyvsp[-2].ValueList);
5439 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005440 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005441 ;}
5442 break;
5443
5444 case 272:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005445#line 2739 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005446 {
5447 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005448 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005449 ;}
5450 break;
5451
5452 case 273:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005453#line 2743 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005454 {
5455 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005456 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005457 ;}
5458 break;
5459
5460 case 274:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005461#line 2748 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005462 {
Reid Spencer14310612006-12-31 05:40:51 +00005463 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005464 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5465 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5466 !isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005467 GEN_ERROR(
Reid Spencerb5334b02007-02-05 10:18:06 +00005468 "Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005469 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()) &&
5470 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5471 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5472 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Chris Lattner32980692007-02-19 07:44:24 +00005473 GEN_ERROR("Remainder not supported on vector types");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005474 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005475 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005476 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005477 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005478 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005479 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005480 GEN_ERROR("binary operator returned null");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005481 delete (yyvsp[-3].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005482 ;}
5483 break;
5484
5485 case 275:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005486#line 2769 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005487 {
Reid Spencer14310612006-12-31 05:40:51 +00005488 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005489 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5490 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5491 if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].TypeVal)->get()) ||
5492 !cast<VectorType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005493 GEN_ERROR("Logical operator requires integral operands");
5494 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005495 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005496 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005497 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005498 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005499 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005500 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005501 GEN_ERROR("binary operator returned null");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005502 delete (yyvsp[-3].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005503 ;}
5504 break;
5505
5506 case 276:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005507#line 2786 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005508 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005509 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005510 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5511 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005512 GEN_ERROR("Vector types not supported by icmp instruction");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005513 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005514 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005515 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005516 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005517 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005518 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005519 GEN_ERROR("icmp operator returned null");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005520 delete (yyvsp[-3].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005521 ;}
5522 break;
5523
5524 case 277:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005525#line 2800 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005526 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005527 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005528 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5529 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005530 GEN_ERROR("Vector types not supported by fcmp instruction");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005531 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005532 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005533 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005534 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005535 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005536 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005537 GEN_ERROR("fcmp operator returned null");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005538 delete (yyvsp[-3].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005539 ;}
5540 break;
5541
5542 case 278:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005543#line 2814 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005544 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005545 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005546 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5547 Value* Val = (yyvsp[-2].ValueVal);
5548 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5549 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005550 GEN_ERROR("invalid cast opcode for cast from '" +
5551 Val->getType()->getDescription() + "' to '" +
5552 DestTy->getDescription() + "'");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005553 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5554 delete (yyvsp[0].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005555 ;}
5556 break;
5557
5558 case 279:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005559#line 2826 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005560 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005561 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005562 GEN_ERROR("select condition must be boolean");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005563 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005564 GEN_ERROR("select value types should match");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005565 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005566 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005567 ;}
5568 break;
5569
5570 case 280:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005571#line 2834 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005572 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005573 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005574 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5575 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5576 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005577 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005578 ;}
5579 break;
5580
5581 case 281:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005582#line 2841 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005583 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005584 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005585 GEN_ERROR("Invalid extractelement operands");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005586 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005587 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005588 ;}
5589 break;
5590
5591 case 282:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005592#line 2847 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005593 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005594 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005595 GEN_ERROR("Invalid insertelement operands");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005596 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005597 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005598 ;}
5599 break;
5600
5601 case 283:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005602#line 2853 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005603 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005604 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005605 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005606 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005607 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005608 ;}
5609 break;
5610
5611 case 284:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005612#line 2859 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005613 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005614 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005615 if (!Ty->isFirstClassType())
5616 GEN_ERROR("PHI node operands must be of first class type");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005617 (yyval.InstVal) = new PHINode(Ty);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005618 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5619 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5620 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005621 GEN_ERROR("All elements of a PHI node must be of the same type");
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005622 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5623 (yyvsp[0].PHIList)->pop_front();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005624 }
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005625 delete (yyvsp[0].PHIList); // Free the list...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005626 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005627 ;}
5628 break;
5629
5630 case 285:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005631#line 2875 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005632 {
Reid Spencer14310612006-12-31 05:40:51 +00005633
5634 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005635 const PointerType *PFTy = 0;
5636 const FunctionType *Ty = 0;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005637 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005638 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5639 // Pull out the types of all of the arguments...
5640 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005641 ParamAttrsVector Attrs;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005642 if ((yyvsp[0].ParamAttrs) != ParamAttr::None) {
5643 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[0].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00005644 Attrs.push_back(PAWI);
5645 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00005646 unsigned index = 1;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005647 ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005648 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005649 const Type *Ty = I->Val->getType();
5650 if (Ty == Type::VoidTy)
5651 GEN_ERROR("Short call syntax cannot be used with varargs");
5652 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005653 if (I->Attrs != ParamAttr::None) {
5654 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5655 Attrs.push_back(PAWI);
5656 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005657 }
5658
Christopher Lamb5c104242007-04-22 20:09:11 +00005659 ParamAttrsList *PAL = 0;
5660 if (!Attrs.empty())
5661 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005662
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005663 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005664 PFTy = PointerType::get(Ty);
5665 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00005666
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005667 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005668 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00005669
Reid Spencer7780acb2007-04-16 06:56:07 +00005670 // Check for call to invalid intrinsic to avoid crashing later.
5671 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00005672 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00005673 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5674 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00005675 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5676 theF->getName() + "'");
5677 }
5678
Reid Spencer14310612006-12-31 05:40:51 +00005679 // Check the arguments
5680 ValueList Args;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005681 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005682 // Make sure no arguments is a good thing!
5683 if (Ty->getNumParams() != 0)
5684 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005685 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005686 } else { // Has arguments?
5687 // Loop through FunctionType's arguments and ensure they are specified
5688 // correctly!
5689 //
5690 FunctionType::param_iterator I = Ty->param_begin();
5691 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005692 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005693
Reid Spencer14310612006-12-31 05:40:51 +00005694 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5695 if (ArgI->Val->getType() != *I)
5696 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005697 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005698 Args.push_back(ArgI->Val);
5699 }
5700 if (Ty->isVarArg()) {
5701 if (I == E)
5702 for (; ArgI != ArgE; ++ArgI)
5703 Args.push_back(ArgI->Val); // push the remaining varargs
5704 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005705 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005706 }
Reid Spencer14310612006-12-31 05:40:51 +00005707 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005708 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005709 CI->setTailCall((yyvsp[-7].BoolVal));
5710 CI->setCallingConv((yyvsp[-6].UIntVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005711 (yyval.InstVal) = CI;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005712 delete (yyvsp[-2].ValueRefList);
5713 delete (yyvsp[-5].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005714 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005715 ;}
5716 break;
5717
5718 case 286:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005719#line 2959 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005720 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005721 (yyval.InstVal) = (yyvsp[0].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005722 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005723 ;}
5724 break;
5725
5726 case 287:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005727#line 2964 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005728 {
5729 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005730 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005731 ;}
5732 break;
5733
5734 case 288:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005735#line 2968 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005736 {
5737 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005738 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005739 ;}
5740 break;
5741
5742 case 289:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005743#line 2975 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005744 {
Reid Spencer14310612006-12-31 05:40:51 +00005745 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005746 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5747 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5748 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005749 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005750 ;}
5751 break;
5752
5753 case 290:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005754#line 2982 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005755 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005756 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005757 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5758 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005759 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005760 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5761 delete (yyvsp[-4].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005762 ;}
5763 break;
5764
5765 case 291:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005766#line 2990 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005767 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005768 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005769 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5770 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5771 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005772 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005773 ;}
5774 break;
5775
5776 case 292:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005777#line 2997 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005778 {
Reid Spencer14310612006-12-31 05:40:51 +00005779 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005780 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5781 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005782 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005783 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5784 delete (yyvsp[-4].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005785 ;}
5786 break;
5787
5788 case 293:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005789#line 3005 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005790 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005791 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005792 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005793 (yyvsp[0].ValueVal)->getType()->getDescription() + "");
5794 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005795 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005796 ;}
5797 break;
5798
5799 case 294:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005800#line 3013 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005801 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005802 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005803 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5804 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005805 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005806 (*(yyvsp[-2].TypeVal))->getDescription());
5807 if (!cast<PointerType>((yyvsp[-2].TypeVal)->get())->getElementType()->isFirstClassType())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005808 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005809 (*(yyvsp[-2].TypeVal))->getDescription());
5810 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005811 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005812 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-4].BoolVal), (yyvsp[0].UIntVal));
5813 delete (yyvsp[-2].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005814 ;}
5815 break;
5816
5817 case 295:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005818#line 3027 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005819 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005820 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005821 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5822 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-2].TypeVal)->get());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005823 if (!PT)
5824 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005825 (*(yyvsp[-2].TypeVal))->getDescription());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005826 const Type *ElTy = PT->getElementType();
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005827 if (ElTy != (yyvsp[-4].ValueVal)->getType())
5828 GEN_ERROR("Can't store '" + (yyvsp[-4].ValueVal)->getType()->getDescription() +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005829 "' into space of type '" + ElTy->getDescription() + "'");
5830
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005831 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005832 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005833 (yyval.InstVal) = new StoreInst((yyvsp[-4].ValueVal), tmpVal, (yyvsp[-6].BoolVal), (yyvsp[0].UIntVal));
5834 delete (yyvsp[-2].TypeVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005835 ;}
5836 break;
5837
5838 case 296:
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005839#line 3044 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005840 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005841 if (!UpRefs.empty())
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005842 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5843 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005844 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005845
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005846 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005847 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005848 (*(yyvsp[-2].TypeVal))->getDescription()+ "'");
5849 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005850 CHECK_FOR_ERROR
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005851 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size());
5852 delete (yyvsp[-2].TypeVal);
5853 delete (yyvsp[0].ValueList);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005854 ;}
5855 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00005856
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005857
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005858 default: break;
Christopher Lamb5c104242007-04-22 20:09:11 +00005859 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005860
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005861/* Line 1126 of yacc.c. */
5862#line 5863 "llvmAsmParser.tab.c"
5863
5864 yyvsp -= yylen;
5865 yyssp -= yylen;
5866
5867
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005868 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005869
5870 *++yyvsp = yyval;
5871
5872
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005873 /* Now `shift' the result of the reduction. Determine what state
5874 that goes to, based on the state we popped back to and the rule
5875 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005876
5877 yyn = yyr1[yyn];
5878
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005879 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5880 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005881 yystate = yytable[yystate];
5882 else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005883 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005884
5885 goto yynewstate;
5886
5887
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005888/*------------------------------------.
5889| yyerrlab -- here on detecting error |
5890`------------------------------------*/
5891yyerrlab:
5892 /* If not already recovering from an error, report this error. */
5893 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005894 {
5895 ++yynerrs;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005896#if YYERROR_VERBOSE
5897 yyn = yypact[yystate];
Christopher Lamb5c104242007-04-22 20:09:11 +00005898
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005899 if (YYPACT_NINF < yyn && yyn < YYLAST)
5900 {
5901 int yytype = YYTRANSLATE (yychar);
5902 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5903 YYSIZE_T yysize = yysize0;
5904 YYSIZE_T yysize1;
5905 int yysize_overflow = 0;
5906 char *yymsg = 0;
5907# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5908 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5909 int yyx;
5910
5911#if 0
5912 /* This is so xgettext sees the translatable formats that are
5913 constructed on the fly. */
5914 YY_("syntax error, unexpected %s");
5915 YY_("syntax error, unexpected %s, expecting %s");
5916 YY_("syntax error, unexpected %s, expecting %s or %s");
5917 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5918 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005919#endif
Reid Spencer9c9b63a2007-04-28 16:07:31 +00005920 char *yyfmt;
5921 char const *yyf;
5922 static char const yyunexpected[] = "syntax error, unexpected %s";
5923 static char const yyexpecting[] = ", expecting %s";
5924 static char const yyor[] = " or %s";
5925 char yyformat[sizeof yyunexpected
5926 + sizeof yyexpecting - 1
5927 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5928 * (sizeof yyor - 1))];
5929 char const *yyprefix = yyexpecting;
5930
5931 /* Start YYX at -YYN if negative to avoid negative indexes in
5932 YYCHECK. */
5933 int yyxbegin = yyn < 0 ? -yyn : 0;
5934
5935 /* Stay within bounds of both yycheck and yytname. */
5936 int yychecklim = YYLAST - yyn;
5937 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5938 int yycount = 1;
5939
5940 yyarg[0] = yytname[yytype];
5941 yyfmt = yystpcpy (yyformat, yyunexpected);
5942
5943 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5944 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5945 {
5946 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5947 {
5948 yycount = 1;
5949 yysize = yysize0;
5950 yyformat[sizeof yyunexpected - 1] = '\0';
5951 break;
5952 }
5953 yyarg[yycount++] = yytname[yyx];
5954 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5955 yysize_overflow |= yysize1 < yysize;
5956 yysize = yysize1;
5957 yyfmt = yystpcpy (yyfmt, yyprefix);
5958 yyprefix = yyor;
5959 }
5960
5961 yyf = YY_(yyformat);
5962 yysize1 = yysize + yystrlen (yyf);
5963 yysize_overflow |= yysize1 < yysize;
5964 yysize = yysize1;
5965
5966 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5967 yymsg = (char *) YYSTACK_ALLOC (yysize);
5968 if (yymsg)
5969 {
5970 /* Avoid sprintf, as that infringes on the user's name space.
5971 Don't have undefined behavior even if the translation
5972 produced a string with the wrong number of "%s"s. */
5973 char *yyp = yymsg;
5974 int yyi = 0;
5975 while ((*yyp = *yyf))
5976 {
5977 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5978 {
5979 yyp += yytnamerr (yyp, yyarg[yyi++]);
5980 yyf += 2;
5981 }
5982 else
5983 {
5984 yyp++;
5985 yyf++;
5986 }
5987 }
5988 yyerror (yymsg);
5989 YYSTACK_FREE (yymsg);
5990 }
5991 else
5992 {
5993 yyerror (YY_("syntax error"));
5994 goto yyexhaustedlab;
5995 }
5996 }
5997 else
5998#endif /* YYERROR_VERBOSE */
5999 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00006000 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00006001
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006002
Reid Spencer41dff5e2007-01-26 08:05:27 +00006003
6004 if (yyerrstatus == 3)
6005 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006006 /* If just tried and failed to reuse look-ahead token after an
6007 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00006008
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006009 if (yychar <= YYEOF)
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006010 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006011 /* Return failure if at end of input. */
6012 if (yychar == YYEOF)
6013 YYABORT;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006014 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006015 else
6016 {
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006017 yydestruct ("Error: discarding", yytoken, &yylval);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006018 yychar = YYEMPTY;
6019 }
6020 }
6021
6022 /* Else will try to reuse look-ahead token after shifting the error
6023 token. */
6024 goto yyerrlab1;
6025
6026
6027/*---------------------------------------------------.
6028| yyerrorlab -- error raised explicitly by YYERROR. |
6029`---------------------------------------------------*/
6030yyerrorlab:
6031
6032 /* Pacify compilers like GCC when the user code never invokes
6033 YYERROR and the label yyerrorlab therefore never appears in user
6034 code. */
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006035 if (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006036 goto yyerrorlab;
6037
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006038yyvsp -= yylen;
6039 yyssp -= yylen;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006040 yystate = *yyssp;
6041 goto yyerrlab1;
6042
6043
6044/*-------------------------------------------------------------.
6045| yyerrlab1 -- common code for both syntax error and YYERROR. |
6046`-------------------------------------------------------------*/
6047yyerrlab1:
6048 yyerrstatus = 3; /* Each real token shifted decrements this. */
6049
6050 for (;;)
6051 {
6052 yyn = yypact[yystate];
6053 if (yyn != YYPACT_NINF)
6054 {
6055 yyn += YYTERROR;
6056 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6057 {
6058 yyn = yytable[yyn];
6059 if (0 < yyn)
6060 break;
6061 }
6062 }
6063
6064 /* Pop the current state because it cannot handle the error token. */
6065 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006066 YYABORT;
6067
Reid Spencere4d87aa2006-12-23 06:05:41 +00006068
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006069 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6070 YYPOPSTACK;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006071 yystate = *yyssp;
6072 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006073 }
6074
6075 if (yyn == YYFINAL)
6076 YYACCEPT;
6077
Reid Spencer68a24bd2005-08-27 18:50:39 +00006078 *++yyvsp = yylval;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006079
6080
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006081 /* Shift the error token. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006082 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00006083
Reid Spencer68a24bd2005-08-27 18:50:39 +00006084 yystate = yyn;
6085 goto yynewstate;
6086
Chris Lattner6cdc6822007-04-26 05:31:05 +00006087
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006088/*-------------------------------------.
6089| yyacceptlab -- YYACCEPT comes here. |
6090`-------------------------------------*/
6091yyacceptlab:
6092 yyresult = 0;
6093 goto yyreturn;
6094
6095/*-----------------------------------.
6096| yyabortlab -- YYABORT comes here. |
6097`-----------------------------------*/
6098yyabortlab:
6099 yyresult = 1;
6100 goto yyreturn;
6101
6102#ifndef yyoverflow
6103/*-------------------------------------------------.
6104| yyexhaustedlab -- memory exhaustion comes here. |
6105`-------------------------------------------------*/
6106yyexhaustedlab:
6107 yyerror (YY_("memory exhausted"));
6108 yyresult = 2;
6109 /* Fall through. */
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006110#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006111
6112yyreturn:
6113 if (yychar != YYEOF && yychar != YYEMPTY)
6114 yydestruct ("Cleanup: discarding lookahead",
6115 yytoken, &yylval);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006116 while (yyssp != yyss)
6117 {
6118 yydestruct ("Cleanup: popping",
6119 yystos[*yyssp], yyvsp);
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006120 YYPOPSTACK;
Chris Lattner6cdc6822007-04-26 05:31:05 +00006121 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006122#ifndef yyoverflow
6123 if (yyss != yyssa)
6124 YYSTACK_FREE (yyss);
6125#endif
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006126 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006127}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006128
6129
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006130#line 3061 "/proj/llvm/llvm-2/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006131
6132
Reid Spencer14310612006-12-31 05:40:51 +00006133// common code from the two 'RunVMAsmParser' functions
6134static Module* RunParser(Module * M) {
6135
6136 llvmAsmlineno = 1; // Reset the current line number...
6137 CurModule.CurrentModule = M;
6138#if YYDEBUG
6139 yydebug = Debug;
6140#endif
6141
6142 // Check to make sure the parser succeeded
6143 if (yyparse()) {
6144 if (ParserResult)
6145 delete ParserResult;
6146 return 0;
6147 }
6148
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006149 // Emit an error if there are any unresolved types left.
6150 if (!CurModule.LateResolveTypes.empty()) {
6151 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6152 if (DID.Type == ValID::LocalName) {
6153 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6154 } else {
6155 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6156 }
6157 if (ParserResult)
6158 delete ParserResult;
6159 return 0;
6160 }
6161
6162 // Emit an error if there are any unresolved values left.
6163 if (!CurModule.LateResolveValues.empty()) {
6164 Value *V = CurModule.LateResolveValues.back();
6165 std::map<Value*, std::pair<ValID, int> >::iterator I =
6166 CurModule.PlaceHolderInfo.find(V);
6167
6168 if (I != CurModule.PlaceHolderInfo.end()) {
6169 ValID &DID = I->second.first;
6170 if (DID.Type == ValID::LocalName) {
6171 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6172 } else {
6173 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6174 }
6175 if (ParserResult)
6176 delete ParserResult;
6177 return 0;
6178 }
6179 }
6180
Reid Spencer14310612006-12-31 05:40:51 +00006181 // Check to make sure that parsing produced a result
6182 if (!ParserResult)
6183 return 0;
6184
6185 // Reset ParserResult variable while saving its value for the result.
6186 Module *Result = ParserResult;
6187 ParserResult = 0;
6188
6189 return Result;
6190}
6191
Reid Spencer61c83e02006-08-18 08:43:06 +00006192void llvm::GenerateError(const std::string &message, int LineNo) {
6193 if (LineNo == -1) LineNo = llvmAsmlineno;
6194 // TODO: column number in exception
6195 if (TheParseError)
6196 TheParseError->setError(CurFilename, message, LineNo);
6197 TriggerError = 1;
6198}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006199
6200int yyerror(const char *ErrorMsg) {
6201 std::string where
6202 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6203 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006204 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6205 if (yychar != YYEMPTY && yychar != 0)
6206 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6207 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006208 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006209 return 0;
6210}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006211