blob: b45143323a69364fd033c1a2247b93e191a16403 [file] [log] [blame]
Reid Spencere4d87aa2006-12-23 06:05:41 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Andrew Lenharth6353e052006-12-08 18:07:09 +00003/* Skeleton parser for Yacc-like parsing with Bison,
Reid Spencere4d87aa2006-12-23 06:05:41 +00004 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005
Reid Spencer3822ff52006-11-08 06:47:33 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +000010
Reid Spencer3822ff52006-11-08 06:47:33 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
Reid Spencere4d87aa2006-12-23 06:05:41 +000018 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
Reid Spencer3822ff52006-11-08 06:47:33 +000020
Andrew Lenharth6353e052006-12-08 18:07:09 +000021/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
Reid Spencer3822ff52006-11-08 06:47:33 +000025
Andrew Lenharth6353e052006-12-08 18:07:09 +000026/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
Reid Spencer3822ff52006-11-08 06:47:33 +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
Reid Spencere4d87aa2006-12-23 06:05:41 +000039/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
Reid Spencer3822ff52006-11-08 06:47:33 +000042/* 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
Reid Spencere4d87aa2006-12-23 06:05:41 +000051/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000052#define yyparse llvmAsmparse
Reid Spencer3822ff52006-11-08 06:47:33 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer3822ff52006-11-08 06:47:33 +000055#define yylval llvmAsmlval
56#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000057#define yydebug llvmAsmdebug
58#define yynerrs llvmAsmnerrs
59
Reid Spencer3822ff52006-11-08 06:47:33 +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 SINTVAL = 260,
70 UINTVAL = 261,
71 FPVAL = 262,
72 VOID = 263,
73 BOOL = 264,
74 SBYTE = 265,
75 UBYTE = 266,
76 SHORT = 267,
77 USHORT = 268,
78 INT = 269,
79 UINT = 270,
80 LONG = 271,
81 ULONG = 272,
82 FLOAT = 273,
83 DOUBLE = 274,
Reid Spencer6fd36ab2006-12-29 20:35:03 +000084 LABEL = 275,
85 TYPE = 276,
Reid Spencer3822ff52006-11-08 06:47:33 +000086 VAR_ID = 277,
87 LABELSTR = 278,
88 STRINGCONSTANT = 279,
89 IMPLEMENTATION = 280,
90 ZEROINITIALIZER = 281,
91 TRUETOK = 282,
92 FALSETOK = 283,
93 BEGINTOK = 284,
94 ENDTOK = 285,
95 DECLARE = 286,
Reid Spencer6fd36ab2006-12-29 20:35:03 +000096 DEFINE = 287,
97 GLOBAL = 288,
98 CONSTANT = 289,
99 SECTION = 290,
100 VOLATILE = 291,
101 TO = 292,
102 DOTDOTDOT = 293,
103 NULL_TOK = 294,
104 UNDEF = 295,
105 CONST = 296,
106 INTERNAL = 297,
107 LINKONCE = 298,
108 WEAK = 299,
109 APPENDING = 300,
110 DLLIMPORT = 301,
111 DLLEXPORT = 302,
112 EXTERN_WEAK = 303,
113 OPAQUE = 304,
114 NOT = 305,
115 EXTERNAL = 306,
116 TARGET = 307,
117 TRIPLE = 308,
118 ENDIAN = 309,
119 POINTERSIZE = 310,
120 LITTLE = 311,
121 BIG = 312,
122 ALIGN = 313,
123 DEPLIBS = 314,
124 CALL = 315,
125 TAIL = 316,
126 ASM_TOK = 317,
127 MODULE = 318,
128 SIDEEFFECT = 319,
129 CC_TOK = 320,
130 CCC_TOK = 321,
131 CSRETCC_TOK = 322,
132 FASTCC_TOK = 323,
133 COLDCC_TOK = 324,
134 X86_STDCALLCC_TOK = 325,
135 X86_FASTCALLCC_TOK = 326,
136 DATALAYOUT = 327,
137 RET = 328,
138 BR = 329,
139 SWITCH = 330,
140 INVOKE = 331,
141 UNWIND = 332,
142 UNREACHABLE = 333,
143 ADD = 334,
144 SUB = 335,
145 MUL = 336,
146 UDIV = 337,
147 SDIV = 338,
148 FDIV = 339,
149 UREM = 340,
150 SREM = 341,
151 FREM = 342,
152 AND = 343,
153 OR = 344,
154 XOR = 345,
155 ICMP = 346,
156 FCMP = 347,
157 EQ = 348,
158 NE = 349,
159 SLT = 350,
160 SGT = 351,
161 SLE = 352,
162 SGE = 353,
163 ULT = 354,
164 UGT = 355,
165 ULE = 356,
166 UGE = 357,
167 OEQ = 358,
168 ONE = 359,
169 OLT = 360,
170 OGT = 361,
171 OLE = 362,
172 OGE = 363,
173 ORD = 364,
174 UNO = 365,
175 UEQ = 366,
176 UNE = 367,
177 MALLOC = 368,
178 ALLOCA = 369,
179 FREE = 370,
180 LOAD = 371,
181 STORE = 372,
182 GETELEMENTPTR = 373,
183 TRUNC = 374,
184 ZEXT = 375,
185 SEXT = 376,
186 FPTRUNC = 377,
187 FPEXT = 378,
188 BITCAST = 379,
189 UITOFP = 380,
190 SITOFP = 381,
191 FPTOUI = 382,
192 FPTOSI = 383,
193 INTTOPTR = 384,
194 PTRTOINT = 385,
195 PHI_TOK = 386,
196 SELECT = 387,
197 SHL = 388,
198 LSHR = 389,
199 ASHR = 390,
200 VAARG = 391,
201 EXTRACTELEMENT = 392,
202 INSERTELEMENT = 393,
203 SHUFFLEVECTOR = 394
Reid Spencer3822ff52006-11-08 06:47:33 +0000204 };
205#endif
Reid Spencere4d87aa2006-12-23 06:05:41 +0000206/* Tokens. */
Reid Spencer3822ff52006-11-08 06:47:33 +0000207#define ESINT64VAL 258
208#define EUINT64VAL 259
209#define SINTVAL 260
210#define UINTVAL 261
211#define FPVAL 262
212#define VOID 263
213#define BOOL 264
214#define SBYTE 265
215#define UBYTE 266
216#define SHORT 267
217#define USHORT 268
218#define INT 269
219#define UINT 270
220#define LONG 271
221#define ULONG 272
222#define FLOAT 273
223#define DOUBLE 274
Reid Spencer6fd36ab2006-12-29 20:35:03 +0000224#define LABEL 275
225#define TYPE 276
Reid Spencer3822ff52006-11-08 06:47:33 +0000226#define VAR_ID 277
227#define LABELSTR 278
228#define STRINGCONSTANT 279
229#define IMPLEMENTATION 280
230#define ZEROINITIALIZER 281
231#define TRUETOK 282
232#define FALSETOK 283
233#define BEGINTOK 284
234#define ENDTOK 285
235#define DECLARE 286
Reid Spencer6fd36ab2006-12-29 20:35:03 +0000236#define DEFINE 287
237#define GLOBAL 288
238#define CONSTANT 289
239#define SECTION 290
240#define VOLATILE 291
241#define TO 292
242#define DOTDOTDOT 293
243#define NULL_TOK 294
244#define UNDEF 295
245#define CONST 296
246#define INTERNAL 297
247#define LINKONCE 298
248#define WEAK 299
249#define APPENDING 300
250#define DLLIMPORT 301
251#define DLLEXPORT 302
252#define EXTERN_WEAK 303
253#define OPAQUE 304
254#define NOT 305
255#define EXTERNAL 306
256#define TARGET 307
257#define TRIPLE 308
258#define ENDIAN 309
259#define POINTERSIZE 310
260#define LITTLE 311
261#define BIG 312
262#define ALIGN 313
263#define DEPLIBS 314
264#define CALL 315
265#define TAIL 316
266#define ASM_TOK 317
267#define MODULE 318
268#define SIDEEFFECT 319
269#define CC_TOK 320
270#define CCC_TOK 321
271#define CSRETCC_TOK 322
272#define FASTCC_TOK 323
273#define COLDCC_TOK 324
274#define X86_STDCALLCC_TOK 325
275#define X86_FASTCALLCC_TOK 326
276#define DATALAYOUT 327
277#define RET 328
278#define BR 329
279#define SWITCH 330
280#define INVOKE 331
281#define UNWIND 332
282#define UNREACHABLE 333
283#define ADD 334
284#define SUB 335
285#define MUL 336
286#define UDIV 337
287#define SDIV 338
288#define FDIV 339
289#define UREM 340
290#define SREM 341
291#define FREM 342
292#define AND 343
293#define OR 344
294#define XOR 345
295#define ICMP 346
296#define FCMP 347
297#define EQ 348
298#define NE 349
299#define SLT 350
300#define SGT 351
301#define SLE 352
302#define SGE 353
303#define ULT 354
304#define UGT 355
305#define ULE 356
306#define UGE 357
307#define OEQ 358
308#define ONE 359
309#define OLT 360
310#define OGT 361
311#define OLE 362
312#define OGE 363
313#define ORD 364
314#define UNO 365
315#define UEQ 366
316#define UNE 367
317#define MALLOC 368
318#define ALLOCA 369
319#define FREE 370
320#define LOAD 371
321#define STORE 372
322#define GETELEMENTPTR 373
323#define TRUNC 374
324#define ZEXT 375
325#define SEXT 376
326#define FPTRUNC 377
327#define FPEXT 378
328#define BITCAST 379
329#define UITOFP 380
330#define SITOFP 381
331#define FPTOUI 382
332#define FPTOSI 383
333#define INTTOPTR 384
334#define PTRTOINT 385
335#define PHI_TOK 386
336#define SELECT 387
337#define SHL 388
338#define LSHR 389
339#define ASHR 390
340#define VAARG 391
341#define EXTRACTELEMENT 392
342#define INSERTELEMENT 393
343#define SHUFFLEVECTOR 394
Reid Spencer3822ff52006-11-08 06:47:33 +0000344
345
346
347
348/* Copy the first part of user declarations. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +0000349#line 14 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000350
351#include "ParserInternals.h"
352#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000353#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354#include "llvm/Instructions.h"
355#include "llvm/Module.h"
356#include "llvm/SymbolTable.h"
357#include "llvm/Support/GetElementPtrTypeIterator.h"
358#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000359#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000360#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000361#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000362#include <list>
363#include <utility>
364
Reid Spencere4f47592006-08-18 17:32:55 +0000365// The following is a gross hack. In order to rid the libAsmParser library of
366// exceptions, we have to have a way of getting the yyparse function to go into
367// an error situation. So, whenever we want an error to occur, the GenerateError
368// function (see bottom of file) sets TriggerError. Then, at the end of each
369// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
370// (a goto) to put YACC in error state. Furthermore, several calls to
371// GenerateError are made from inside productions and they must simulate the
372// previous exception behavior by exiting the production immediately. We have
373// replaced these with the GEN_ERROR macro which calls GeneratError and then
374// immediately invokes YYERROR. This would be so much cleaner if it was a
375// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000376static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000377#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000378#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
379
Reid Spencer68a24bd2005-08-27 18:50:39 +0000380int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
381int yylex(); // declaration" of xxx warnings.
382int yyparse();
383
384namespace llvm {
385 std::string CurFilename;
386}
387using namespace llvm;
388
389static Module *ParserResult;
390
391// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
392// relating to upreferences in the input stream.
393//
394//#define DEBUG_UPREFS 1
395#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000396#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000397#else
398#define UR_OUT(X)
399#endif
400
401#define YYERROR_VERBOSE 1
402
Chris Lattnerb475c422005-11-12 18:22:38 +0000403static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000404
405
406// This contains info used when building the body of a function. It is
407// destroyed when the function is completed.
408//
409typedef std::vector<Value *> ValueList; // Numbered defs
410static void
411ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
412 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
413
414static struct PerModuleInfo {
415 Module *CurrentModule;
416 std::map<const Type *, ValueList> Values; // Module level numbered definitions
417 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000418 std::vector<PATypeHolder> Types;
419 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000420
421 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000422 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000423 /// that we can resolve them later and print error messages as appropriate.
424 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
425
426 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
427 // references to global values. Global values may be referenced before they
428 // are defined, and if so, the temporary object that they represent is held
429 // here. This is used for forward references of GlobalValues.
430 //
431 typedef std::map<std::pair<const PointerType *,
432 ValID>, GlobalValue*> GlobalRefsType;
433 GlobalRefsType GlobalRefs;
434
435 void ModuleDone() {
436 // If we could not resolve some functions at function compilation time
437 // (calls to functions before they are defined), resolve them now... Types
438 // are resolved when the constant pool has been completely parsed.
439 //
440 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000441 if (TriggerError)
442 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000443
444 // Check to make sure that all global value forward references have been
445 // resolved!
446 //
447 if (!GlobalRefs.empty()) {
448 std::string UndefinedReferences = "Unresolved global references exist:\n";
449
450 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
451 I != E; ++I) {
452 UndefinedReferences += " " + I->first.first->getDescription() + " " +
453 I->first.second.getName() + "\n";
454 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000455 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000456 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000457 }
458
459 Values.clear(); // Clear out function local definitions
460 Types.clear();
461 CurrentModule = 0;
462 }
463
Reid Spencer68a24bd2005-08-27 18:50:39 +0000464 // GetForwardRefForGlobal - Check to see if there is a forward reference
465 // for this global. If so, remove it from the GlobalRefs map and return it.
466 // If not, just return null.
467 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
468 // Check to see if there is a forward reference to this global variable...
469 // if there is, eliminate it and patch the reference to use the new def'n.
470 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
471 GlobalValue *Ret = 0;
472 if (I != GlobalRefs.end()) {
473 Ret = I->second;
474 GlobalRefs.erase(I);
475 }
476 return Ret;
477 }
478} CurModule;
479
480static struct PerFunctionInfo {
481 Function *CurrentFunction; // Pointer to current function being created
482
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000483 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000484 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000485 bool isDeclare; // Is this function a forward declararation?
486 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000487
488 /// BBForwardRefs - When we see forward references to basic blocks, keep
489 /// track of them here.
490 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
491 std::vector<BasicBlock*> NumberedBlocks;
492 unsigned NextBBNum;
493
494 inline PerFunctionInfo() {
495 CurrentFunction = 0;
496 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000497 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000498 }
499
500 inline void FunctionStart(Function *M) {
501 CurrentFunction = M;
502 NextBBNum = 0;
503 }
504
505 void FunctionDone() {
506 NumberedBlocks.clear();
507
508 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000509 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000510 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000511 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000512 return;
513 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000514
515 // Resolve all forward references now.
516 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
517
518 Values.clear(); // Clear out function local definitions
519 CurrentFunction = 0;
520 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000521 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000522 }
523} CurFun; // Info for the current function...
524
525static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
526
527
528//===----------------------------------------------------------------------===//
529// Code to handle definitions of all the types
530//===----------------------------------------------------------------------===//
531
532static int InsertValue(Value *V,
533 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
534 if (V->hasName()) return -1; // Is this a numbered definition?
535
536 // Yes, insert the value into the value table...
537 ValueList &List = ValueTab[V->getType()];
538 List.push_back(V);
539 return List.size()-1;
540}
541
542static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
543 switch (D.Type) {
544 case ValID::NumberVal: // Is it a numbered definition?
545 // Module constants occupy the lowest numbered slots...
546 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer861d9d62006-11-28 07:29:44 +0000547 return CurModule.Types[(unsigned)D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000548 break;
549 case ValID::NameVal: // Is it a named definition?
550 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
551 D.destroy(); // Free old strdup'd memory...
552 return N;
553 }
554 break;
555 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000556 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000557 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558 }
559
560 // If we reached here, we referenced either a symbol that we don't know about
561 // or an id number that hasn't been read yet. We may be referencing something
562 // forward, so just create an entry to be resolved later and get to it...
563 //
564 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
565
566
567 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000568 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000569 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000570 return 0;
571 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000572 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000573 return 0;
574 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000575 }
576
Reid Spencer861d9d62006-11-28 07:29:44 +0000577 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000578 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000579 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000580
Reid Spencer861d9d62006-11-28 07:29:44 +0000581 Type *Typ = OpaqueType::get();
582 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
583 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000584 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000585
586static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
587 SymbolTable &SymTab =
588 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
589 CurModule.CurrentModule->getSymbolTable();
590 return SymTab.lookup(Ty, Name);
591}
592
593// getValNonImprovising - Look up the value specified by the provided type and
594// the provided ValID. If the value exists and has already been defined, return
595// it. Otherwise return null.
596//
597static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000598 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000599 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000600 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000601 return 0;
602 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000603
604 switch (D.Type) {
605 case ValID::NumberVal: { // Is it a numbered definition?
606 unsigned Num = (unsigned)D.Num;
607
608 // Module constants occupy the lowest numbered slots...
609 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
610 if (VI != CurModule.Values.end()) {
611 if (Num < VI->second.size())
612 return VI->second[Num];
613 Num -= VI->second.size();
614 }
615
616 // Make sure that our type is within bounds
617 VI = CurFun.Values.find(Ty);
618 if (VI == CurFun.Values.end()) return 0;
619
620 // Check that the number is within bounds...
621 if (VI->second.size() <= Num) return 0;
622
623 return VI->second[Num];
624 }
625
626 case ValID::NameVal: { // Is it a named definition?
627 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
628 if (N == 0) return 0;
629
630 D.destroy(); // Free old strdup'd memory...
631 return N;
632 }
633
634 // Check to make sure that "Ty" is an integral type, and that our
635 // value will fit into the specified type...
636 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000637 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000638 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000639 itostr(D.ConstPool64) + "' is invalid for type '" +
640 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000641 return 0;
642 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000643 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000644
645 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000646 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
647 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000648 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000649 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000650 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000651 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000652 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000653 }
654 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000655 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000656 }
657
658 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000659 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000660 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000661 return 0;
662 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000663 return ConstantFP::get(Ty, D.ConstPoolFP);
664
665 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000666 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000667 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000668 return 0;
669 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000670 return ConstantPointerNull::get(cast<PointerType>(Ty));
671
672 case ValID::ConstUndefVal: // Is it an undef value?
673 return UndefValue::get(Ty);
674
Chris Lattner7aa61892005-12-21 17:53:23 +0000675 case ValID::ConstZeroVal: // Is it a zero value?
676 return Constant::getNullValue(Ty);
677
Reid Spencer68a24bd2005-08-27 18:50:39 +0000678 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000679 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000680 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000681 return 0;
682 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000683 return D.ConstantValue;
684
Chris Lattner0e9c3762006-01-25 22:27:16 +0000685 case ValID::InlineAsmVal: { // Inline asm expression
686 const PointerType *PTy = dyn_cast<PointerType>(Ty);
687 const FunctionType *FTy =
688 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000689 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000690 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000691 return 0;
692 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000693 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
694 D.IAD->HasSideEffects);
695 D.destroy(); // Free InlineAsmDescriptor.
696 return IA;
697 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000698 default:
699 assert(0 && "Unhandled case!");
700 return 0;
701 } // End of switch
702
703 assert(0 && "Unhandled case!");
704 return 0;
705}
706
707// getVal - This function is identical to getValNonImprovising, except that if a
708// value is not already defined, it "improvises" by creating a placeholder var
709// that looks and acts just like the requested variable. When the value is
710// defined later, all uses of the placeholder variable are replaced with the
711// real thing.
712//
713static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000714 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000715 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000716 return 0;
717 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000718
719 // See if the value has already been defined.
720 Value *V = getValNonImprovising(Ty, ID);
721 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000722 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000723
Reid Spencer5b7e7532006-09-28 19:28:24 +0000724 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000725 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000726 return 0;
727 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000728
729 // If we reached here, we referenced either a symbol that we don't know about
730 // or an id number that hasn't been read yet. We may be referencing something
731 // forward, so just create an entry to be resolved later and get to it...
732 //
733 V = new Argument(Ty);
734
735 // Remember where this forward reference came from. FIXME, shouldn't we try
736 // to recycle these things??
737 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
738 llvmAsmlineno)));
739
740 if (inFunctionScope())
741 InsertValue(V, CurFun.LateResolveValues);
742 else
743 InsertValue(V, CurModule.LateResolveValues);
744 return V;
745}
746
747/// getBBVal - This is used for two purposes:
748/// * If isDefinition is true, a new basic block with the specified ID is being
749/// defined.
750/// * If isDefinition is true, this is a reference to a basic block, which may
751/// or may not be a forward reference.
752///
753static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
754 assert(inFunctionScope() && "Can't get basic block at global scope!");
755
756 std::string Name;
757 BasicBlock *BB = 0;
758 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000759 default:
760 GenerateError("Illegal label reference " + ID.getName());
761 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000762 case ValID::NumberVal: // Is it a numbered definition?
763 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
764 CurFun.NumberedBlocks.resize(ID.Num+1);
765 BB = CurFun.NumberedBlocks[ID.Num];
766 break;
767 case ValID::NameVal: // Is it a named definition?
768 Name = ID.Name;
769 if (Value *N = CurFun.CurrentFunction->
770 getSymbolTable().lookup(Type::LabelTy, Name))
771 BB = cast<BasicBlock>(N);
772 break;
773 }
774
775 // See if the block has already been defined.
776 if (BB) {
777 // If this is the definition of the block, make sure the existing value was
778 // just a forward reference. If it was a forward reference, there will be
779 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000780 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000781 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000782 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000783 return 0;
784 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000785
786 ID.destroy(); // Free strdup'd memory.
787 return BB;
788 }
789
790 // Otherwise this block has not been seen before.
791 BB = new BasicBlock("", CurFun.CurrentFunction);
792 if (ID.Type == ValID::NameVal) {
793 BB->setName(ID.Name);
794 } else {
795 CurFun.NumberedBlocks[ID.Num] = BB;
796 }
797
798 // If this is not a definition, keep track of it so we can use it as a forward
799 // reference.
800 if (!isDefinition) {
801 // Remember where this forward reference came from.
802 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
803 } else {
804 // The forward declaration could have been inserted anywhere in the
805 // function: insert it into the correct place now.
806 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
807 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
808 }
809 ID.destroy();
810 return BB;
811}
812
813
814//===----------------------------------------------------------------------===//
815// Code to handle forward references in instructions
816//===----------------------------------------------------------------------===//
817//
818// This code handles the late binding needed with statements that reference
819// values not defined yet... for example, a forward branch, or the PHI node for
820// a loop body.
821//
822// This keeps a table (CurFun.LateResolveValues) of all such forward references
823// and back patchs after we are done.
824//
825
826// ResolveDefinitions - If we could not resolve some defs at parsing
827// time (forward branches, phi functions for loops, etc...) resolve the
828// defs now...
829//
830static void
831ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
832 std::map<const Type*,ValueList> *FutureLateResolvers) {
833 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
834 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
835 E = LateResolvers.end(); LRI != E; ++LRI) {
836 ValueList &List = LRI->second;
837 while (!List.empty()) {
838 Value *V = List.back();
839 List.pop_back();
840
841 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
842 CurModule.PlaceHolderInfo.find(V);
843 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
844
845 ValID &DID = PHI->second.first;
846
847 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000848 if (TriggerError)
849 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000850 if (TheRealValue) {
851 V->replaceAllUsesWith(TheRealValue);
852 delete V;
853 CurModule.PlaceHolderInfo.erase(PHI);
854 } else if (FutureLateResolvers) {
855 // Functions have their unresolved items forwarded to the module late
856 // resolver table
857 InsertValue(V, *FutureLateResolvers);
858 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000859 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000860 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000861 "' of type '" + V->getType()->getDescription() + "'",
862 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000863 return;
864 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000865 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000866 itostr(DID.Num) + " of type '" +
867 V->getType()->getDescription() + "'",
868 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000869 return;
870 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000871 }
872 }
873 }
874
875 LateResolvers.clear();
876}
877
878// ResolveTypeTo - A brand new type was just declared. This means that (if
879// name is not null) things referencing Name can be resolved. Otherwise, things
880// refering to the number can be resolved. Do this now.
881//
882static void ResolveTypeTo(char *Name, const Type *ToTy) {
883 ValID D;
884 if (Name) D = ValID::create(Name);
885 else D = ValID::create((int)CurModule.Types.size());
886
Reid Spencer861d9d62006-11-28 07:29:44 +0000887 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000888 CurModule.LateResolveTypes.find(D);
889 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000890 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000891 CurModule.LateResolveTypes.erase(I);
892 }
893}
894
895// setValueName - Set the specified value to the name given. The name may be
896// null potentially, in which case this is a noop. The string passed in is
897// assumed to be a malloc'd string buffer, and is free'd by this function.
898//
899static void setValueName(Value *V, char *NameStr) {
900 if (NameStr) {
901 std::string Name(NameStr); // Copy string
902 free(NameStr); // Free old string
903
Reid Spencer5b7e7532006-09-28 19:28:24 +0000904 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000905 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000906 return;
907 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000908
909 assert(inFunctionScope() && "Must be in function scope!");
910 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000911 if (ST.lookup(V->getType(), Name)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000912 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000913 V->getType()->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000914 return;
915 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000916
917 // Set the name.
918 V->setName(Name);
919 }
920}
921
922/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
923/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000924static GlobalVariable *
925ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
926 bool isConstantGlobal, const Type *Ty,
927 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000928 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000929 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000930 return 0;
931 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000932
933 const PointerType *PTy = PointerType::get(Ty);
934
935 std::string Name;
936 if (NameStr) {
937 Name = NameStr; // Copy string
938 free(NameStr); // Free old string
939 }
940
941 // See if this global value was forward referenced. If so, recycle the
942 // object.
943 ValID ID;
944 if (!Name.empty()) {
945 ID = ValID::create((char*)Name.c_str());
946 } else {
947 ID = ValID::create((int)CurModule.Values[PTy].size());
948 }
949
950 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
951 // Move the global to the end of the list, from whereever it was
952 // previously inserted.
953 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
954 CurModule.CurrentModule->getGlobalList().remove(GV);
955 CurModule.CurrentModule->getGlobalList().push_back(GV);
956 GV->setInitializer(Initializer);
957 GV->setLinkage(Linkage);
958 GV->setConstant(isConstantGlobal);
959 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000960 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000961 }
962
963 // If this global has a name, check to see if there is already a definition
964 // of this global in the module. If so, merge as appropriate. Note that
965 // this is really just a hack around problems in the CFE. :(
966 if (!Name.empty()) {
967 // We are a simple redefinition of a value, check to see if it is defined
968 // the same as the old one.
969 if (GlobalVariable *EGV =
970 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
971 // We are allowed to redefine a global variable in two circumstances:
972 // 1. If at least one of the globals is uninitialized or
973 // 2. If both initializers have the same value.
974 //
975 if (!EGV->hasInitializer() || !Initializer ||
976 EGV->getInitializer() == Initializer) {
977
978 // Make sure the existing global version gets the initializer! Make
979 // sure that it also gets marked const if the new version is.
980 if (Initializer && !EGV->hasInitializer())
981 EGV->setInitializer(Initializer);
982 if (isConstantGlobal)
983 EGV->setConstant(true);
984 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000985 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000986 }
987
Reid Spencer61c83e02006-08-18 08:43:06 +0000988 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000989 "' in the '" + Ty->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000990 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000991 }
992 }
993
994 // Otherwise there is no existing GV to use, create one now.
995 GlobalVariable *GV =
996 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
997 CurModule.CurrentModule);
998 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000999 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001000}
1001
1002// setTypeName - Set the specified type to the name given. The name may be
1003// null potentially, in which case this is a noop. The string passed in is
1004// assumed to be a malloc'd string buffer, and is freed by this function.
1005//
1006// This function returns true if the type has already been defined, but is
1007// allowed to be redefined in the specified context. If the name is a new name
1008// for the type plane, it is inserted and false is returned.
1009static bool setTypeName(const Type *T, char *NameStr) {
1010 assert(!inFunctionScope() && "Can't give types function-local names!");
1011 if (NameStr == 0) return false;
1012
1013 std::string Name(NameStr); // Copy string
1014 free(NameStr); // Free old string
1015
1016 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001017 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001018 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001019 return false;
1020 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001021
1022 // Set the type name, checking for conflicts as we do so.
1023 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1024
1025 if (AlreadyExists) { // Inserting a name that is already defined???
1026 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1027 assert(Existing && "Conflict but no matching type?");
1028
1029 // There is only one case where this is allowed: when we are refining an
1030 // opaque type. In this case, Existing will be an opaque type.
1031 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1032 // We ARE replacing an opaque type!
1033 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1034 return true;
1035 }
1036
1037 // Otherwise, this is an attempt to redefine a type. That's okay if
1038 // the redefinition is identical to the original. This will be so if
1039 // Existing and T point to the same Type object. In this one case we
1040 // allow the equivalent redefinition.
1041 if (Existing == T) return true; // Yes, it's equal.
1042
1043 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer61c83e02006-08-18 08:43:06 +00001044 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00001045 T->getDescription() + "' type plane!");
1046 }
1047
1048 return false;
1049}
1050
1051//===----------------------------------------------------------------------===//
1052// Code for handling upreferences in type names...
1053//
1054
1055// TypeContains - Returns true if Ty directly contains E in it.
1056//
1057static bool TypeContains(const Type *Ty, const Type *E) {
1058 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1059 E) != Ty->subtype_end();
1060}
1061
1062namespace {
1063 struct UpRefRecord {
1064 // NestingLevel - The number of nesting levels that need to be popped before
1065 // this type is resolved.
1066 unsigned NestingLevel;
1067
1068 // LastContainedTy - This is the type at the current binding level for the
1069 // type. Every time we reduce the nesting level, this gets updated.
1070 const Type *LastContainedTy;
1071
1072 // UpRefTy - This is the actual opaque type that the upreference is
1073 // represented with.
1074 OpaqueType *UpRefTy;
1075
1076 UpRefRecord(unsigned NL, OpaqueType *URTy)
1077 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1078 };
1079}
1080
1081// UpRefs - A list of the outstanding upreferences that need to be resolved.
1082static std::vector<UpRefRecord> UpRefs;
1083
1084/// HandleUpRefs - Every time we finish a new layer of types, this function is
1085/// called. It loops through the UpRefs vector, which is a list of the
1086/// currently active types. For each type, if the up reference is contained in
1087/// the newly completed type, we decrement the level count. When the level
1088/// count reaches zero, the upreferenced type is the type that is passed in:
1089/// thus we can complete the cycle.
1090///
1091static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001092 // If Ty isn't abstract, or if there are no up-references in it, then there is
1093 // nothing to resolve here.
1094 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1095
Reid Spencer68a24bd2005-08-27 18:50:39 +00001096 PATypeHolder Ty(ty);
1097 UR_OUT("Type '" << Ty->getDescription() <<
1098 "' newly formed. Resolving upreferences.\n" <<
1099 UpRefs.size() << " upreferences active!\n");
1100
1101 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1102 // to zero), we resolve them all together before we resolve them to Ty. At
1103 // the end of the loop, if there is anything to resolve to Ty, it will be in
1104 // this variable.
1105 OpaqueType *TypeToResolve = 0;
1106
1107 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1108 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1109 << UpRefs[i].second->getDescription() << ") = "
1110 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1111 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1112 // Decrement level of upreference
1113 unsigned Level = --UpRefs[i].NestingLevel;
1114 UpRefs[i].LastContainedTy = Ty;
1115 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1116 if (Level == 0) { // Upreference should be resolved!
1117 if (!TypeToResolve) {
1118 TypeToResolve = UpRefs[i].UpRefTy;
1119 } else {
1120 UR_OUT(" * Resolving upreference for "
1121 << UpRefs[i].second->getDescription() << "\n";
1122 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1123 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1124 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1125 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1126 }
1127 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1128 --i; // Do not skip the next element...
1129 }
1130 }
1131 }
1132
1133 if (TypeToResolve) {
1134 UR_OUT(" * Resolving upreference for "
1135 << UpRefs[i].second->getDescription() << "\n";
1136 std::string OldName = TypeToResolve->getDescription());
1137 TypeToResolve->refineAbstractTypeTo(Ty);
1138 }
1139
1140 return Ty;
1141}
1142
Reid Spencer68a24bd2005-08-27 18:50:39 +00001143// common code from the two 'RunVMAsmParser' functions
Reid Spencer5b7e7532006-09-28 19:28:24 +00001144static Module* RunParser(Module * M) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001145
1146 llvmAsmlineno = 1; // Reset the current line number...
Reid Spencer68a24bd2005-08-27 18:50:39 +00001147 CurModule.CurrentModule = M;
Reid Spencerf63697d2006-10-09 17:36:59 +00001148
1149 // Check to make sure the parser succeeded
1150 if (yyparse()) {
1151 if (ParserResult)
1152 delete ParserResult;
1153 return 0;
1154 }
1155
1156 // Check to make sure that parsing produced a result
Reid Spencer61c83e02006-08-18 08:43:06 +00001157 if (!ParserResult)
1158 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001159
Reid Spencerf63697d2006-10-09 17:36:59 +00001160 // Reset ParserResult variable while saving its value for the result.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001161 Module *Result = ParserResult;
1162 ParserResult = 0;
1163
Reid Spencer68a24bd2005-08-27 18:50:39 +00001164 return Result;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001165}
Reid Spencer68a24bd2005-08-27 18:50:39 +00001166
1167//===----------------------------------------------------------------------===//
1168// RunVMAsmParser - Define an interface to this parser
1169//===----------------------------------------------------------------------===//
1170//
1171Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1172 set_scan_file(F);
1173
1174 CurFilename = Filename;
1175 return RunParser(new Module(CurFilename));
1176}
1177
1178Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1179 set_scan_string(AsmString);
1180
1181 CurFilename = "from_memory";
1182 if (M == NULL) {
1183 return RunParser(new Module (CurFilename));
1184 } else {
1185 return RunParser(M);
1186 }
1187}
1188
1189
Reid Spencer3822ff52006-11-08 06:47:33 +00001190
1191/* Enabling traces. */
1192#ifndef YYDEBUG
1193# define YYDEBUG 0
1194#endif
1195
1196/* Enabling verbose error messages. */
1197#ifdef YYERROR_VERBOSE
1198# undef YYERROR_VERBOSE
1199# define YYERROR_VERBOSE 1
1200#else
1201# define YYERROR_VERBOSE 0
1202#endif
1203
Reid Spencere4d87aa2006-12-23 06:05:41 +00001204/* Enabling the token table. */
1205#ifndef YYTOKEN_TABLE
1206# define YYTOKEN_TABLE 0
1207#endif
1208
Andrew Lenharth6353e052006-12-08 18:07:09 +00001209#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001210#line 855 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00001211typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001212 llvm::Module *ModuleVal;
1213 llvm::Function *FunctionVal;
Reid Spencera132e042006-12-03 05:46:11 +00001214 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001215 llvm::BasicBlock *BasicBlockVal;
1216 llvm::TerminatorInst *TermInstVal;
1217 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001218 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001219
Reid Spencera132e042006-12-03 05:46:11 +00001220 const llvm::Type *PrimType;
1221 llvm::PATypeHolder *TypeVal;
1222 llvm::Value *ValueVal;
1223
1224 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1225 std::vector<llvm::Value*> *ValueList;
1226 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001227 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001228 std::list<std::pair<llvm::Value*,
1229 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001230 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001231 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001232
1233 llvm::GlobalValue::LinkageTypes Linkage;
1234 int64_t SInt64Val;
1235 uint64_t UInt64Val;
1236 int SIntVal;
1237 unsigned UIntVal;
1238 double FPVal;
1239 bool BoolVal;
1240
1241 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001242 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001243
Reid Spencera132e042006-12-03 05:46:11 +00001244 llvm::Instruction::BinaryOps BinaryOpVal;
1245 llvm::Instruction::TermOps TermOpVal;
1246 llvm::Instruction::MemoryOps MemOpVal;
1247 llvm::Instruction::CastOps CastOpVal;
1248 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001249 llvm::Module::Endianness Endianness;
Reid Spencera132e042006-12-03 05:46:11 +00001250 llvm::ICmpInst::Predicate IPredicate;
1251 llvm::FCmpInst::Predicate FPredicate;
Andrew Lenharth6353e052006-12-08 18:07:09 +00001252} YYSTYPE;
Reid Spencere4d87aa2006-12-23 06:05:41 +00001253/* Line 196 of yacc.c. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001254#line 1255 "llvmAsmParser.tab.c"
Reid Spencer3822ff52006-11-08 06:47:33 +00001255# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1256# define YYSTYPE_IS_DECLARED 1
1257# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001258#endif
1259
1260
1261
Reid Spencer3822ff52006-11-08 06:47:33 +00001262/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001263
1264
Reid Spencere4d87aa2006-12-23 06:05:41 +00001265/* Line 219 of yacc.c. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001266#line 1267 "llvmAsmParser.tab.c"
Reid Spencere4d87aa2006-12-23 06:05:41 +00001267
1268#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1269# define YYSIZE_T __SIZE_TYPE__
1270#endif
1271#if ! defined (YYSIZE_T) && defined (size_t)
1272# define YYSIZE_T size_t
1273#endif
1274#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1275# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1276# define YYSIZE_T size_t
1277#endif
1278#if ! defined (YYSIZE_T)
1279# define YYSIZE_T unsigned int
1280#endif
1281
1282#ifndef YY_
1283# if YYENABLE_NLS
1284# if ENABLE_NLS
1285# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1286# define YY_(msgid) dgettext ("bison-runtime", msgid)
1287# endif
1288# endif
1289# ifndef YY_
1290# define YY_(msgid) msgid
1291# endif
1292#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001293
Andrew Lenharth6353e052006-12-08 18:07:09 +00001294#if ! defined (yyoverflow) || YYERROR_VERBOSE
Bill Wendlinge8156192006-12-07 01:30:32 +00001295
Reid Spencer3822ff52006-11-08 06:47:33 +00001296/* The parser invokes alloca or malloc; define the necessary symbols. */
1297
1298# ifdef YYSTACK_USE_ALLOCA
1299# if YYSTACK_USE_ALLOCA
1300# ifdef __GNUC__
1301# define YYSTACK_ALLOC __builtin_alloca
Reid Spencere4d87aa2006-12-23 06:05:41 +00001302# else
1303# define YYSTACK_ALLOC alloca
1304# if defined (__STDC__) || defined (__cplusplus)
1305# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1306# define YYINCLUDED_STDLIB_H
1307# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00001308# endif
1309# endif
1310# endif
1311
1312# ifdef YYSTACK_ALLOC
Andrew Lenharth6353e052006-12-08 18:07:09 +00001313 /* Pacify GCC's `empty if-body' warning. */
1314# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00001315# ifndef YYSTACK_ALLOC_MAXIMUM
1316 /* The OS might guarantee only one guard page at the bottom of the stack,
1317 and a page size can be as small as 4096 bytes. So we cannot safely
1318 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1319 to allow for a few compiler-allocated temporary stack slots. */
1320# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Andrew Lenharth6353e052006-12-08 18:07:09 +00001321# endif
Reid Spencere4d87aa2006-12-23 06:05:41 +00001322# else
Reid Spencer3822ff52006-11-08 06:47:33 +00001323# define YYSTACK_ALLOC YYMALLOC
1324# define YYSTACK_FREE YYFREE
Reid Spencere4d87aa2006-12-23 06:05:41 +00001325# ifndef YYSTACK_ALLOC_MAXIMUM
1326# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1327# endif
1328# ifdef __cplusplus
1329extern "C" {
1330# endif
1331# ifndef YYMALLOC
1332# define YYMALLOC malloc
1333# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1334 && (defined (__STDC__) || defined (__cplusplus)))
1335void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1336# endif
1337# endif
1338# ifndef YYFREE
1339# define YYFREE free
1340# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1341 && (defined (__STDC__) || defined (__cplusplus)))
1342void free (void *); /* INFRINGES ON USER NAME SPACE */
1343# endif
1344# endif
1345# ifdef __cplusplus
1346}
1347# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00001348# endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00001349#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Reid Spencer3822ff52006-11-08 06:47:33 +00001350
1351
Andrew Lenharth6353e052006-12-08 18:07:09 +00001352#if (! defined (yyoverflow) \
1353 && (! defined (__cplusplus) \
1354 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer3822ff52006-11-08 06:47:33 +00001355
1356/* A type that is properly aligned for any stack member. */
1357union yyalloc
1358{
Reid Spencere4d87aa2006-12-23 06:05:41 +00001359 short int yyss;
Reid Spencer3822ff52006-11-08 06:47:33 +00001360 YYSTYPE yyvs;
1361 };
1362
1363/* The size of the maximum gap between one aligned stack and the next. */
1364# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1365
1366/* The size of an array large to enough to hold all stacks, each with
1367 N elements. */
1368# define YYSTACK_BYTES(N) \
Reid Spencere4d87aa2006-12-23 06:05:41 +00001369 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Reid Spencer3822ff52006-11-08 06:47:33 +00001370 + YYSTACK_GAP_MAXIMUM)
1371
1372/* Copy COUNT objects from FROM to TO. The source and destination do
1373 not overlap. */
1374# ifndef YYCOPY
Andrew Lenharth6353e052006-12-08 18:07:09 +00001375# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer3822ff52006-11-08 06:47:33 +00001376# define YYCOPY(To, From, Count) \
1377 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1378# else
1379# define YYCOPY(To, From, Count) \
1380 do \
1381 { \
Reid Spencere4d87aa2006-12-23 06:05:41 +00001382 YYSIZE_T yyi; \
Reid Spencer3822ff52006-11-08 06:47:33 +00001383 for (yyi = 0; yyi < (Count); yyi++) \
1384 (To)[yyi] = (From)[yyi]; \
1385 } \
Andrew Lenharth6353e052006-12-08 18:07:09 +00001386 while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00001387# endif
1388# endif
1389
1390/* Relocate STACK from its old location to the new one. The
1391 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1392 elements in the stack, and YYPTR gives the new location of the
1393 stack. Advance YYPTR to a properly aligned location for the next
1394 stack. */
1395# define YYSTACK_RELOCATE(Stack) \
1396 do \
1397 { \
1398 YYSIZE_T yynewbytes; \
1399 YYCOPY (&yyptr->Stack, Stack, yysize); \
1400 Stack = &yyptr->Stack; \
1401 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1402 yyptr += yynewbytes / sizeof (*yyptr); \
1403 } \
Andrew Lenharth6353e052006-12-08 18:07:09 +00001404 while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001405
1406#endif
1407
Andrew Lenharth6353e052006-12-08 18:07:09 +00001408#if defined (__STDC__) || defined (__cplusplus)
1409 typedef signed char yysigned_char;
1410#else
Reid Spencere4d87aa2006-12-23 06:05:41 +00001411 typedef short int yysigned_char;
Andrew Lenharth6353e052006-12-08 18:07:09 +00001412#endif
1413
1414/* YYFINAL -- State number of the termination state. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001415#define YYFINAL 37
Reid Spencer3822ff52006-11-08 06:47:33 +00001416/* YYLAST -- Last index in YYTABLE. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001417#define YYLAST 1478
Reid Spencer3822ff52006-11-08 06:47:33 +00001418
Andrew Lenharth6353e052006-12-08 18:07:09 +00001419/* YYNTOKENS -- Number of terminals. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001420#define YYNTOKENS 154
Andrew Lenharth6353e052006-12-08 18:07:09 +00001421/* YYNNTS -- Number of nonterminals. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001422#define YYNNTS 78
Andrew Lenharth6353e052006-12-08 18:07:09 +00001423/* YYNRULES -- Number of rules. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001424#define YYNRULES 293
Andrew Lenharth6353e052006-12-08 18:07:09 +00001425/* YYNRULES -- Number of states. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001426#define YYNSTATES 564
Reid Spencer3822ff52006-11-08 06:47:33 +00001427
1428/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1429#define YYUNDEFTOK 2
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001430#define YYMAXUTOK 394
Reid Spencer3822ff52006-11-08 06:47:33 +00001431
Reid Spencere4d87aa2006-12-23 06:05:41 +00001432#define YYTRANSLATE(YYX) \
Reid Spencer3822ff52006-11-08 06:47:33 +00001433 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1434
1435/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00001436static const unsigned char yytranslate[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001437{
1438 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1439 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1440 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001442 143, 144, 152, 2, 141, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001444 148, 140, 149, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001447 2, 145, 142, 147, 2, 2, 2, 2, 2, 153,
Reid Spencer3822ff52006-11-08 06:47:33 +00001448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001450 146, 2, 2, 150, 2, 151, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1455 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1456 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1457 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1458 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1459 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1460 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1462 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1463 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1464 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1465 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1466 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1467 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1468 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1469 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1470 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1471 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1472 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1473 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
Reid Spencer3da59db2006-11-27 01:05:10 +00001474 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
Reid Spencera132e042006-12-03 05:46:11 +00001475 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1476 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001477 135, 136, 137, 138, 139
Reid Spencer3822ff52006-11-08 06:47:33 +00001478};
1479
1480#if YYDEBUG
1481/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1482 YYRHS. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001483static const unsigned short int yyprhs[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001484{
1485 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1486 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1487 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1488 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
Reid Spencer3da59db2006-11-27 01:05:10 +00001489 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
Reid Spencera132e042006-12-03 05:46:11 +00001490 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1491 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001492 140, 141, 143, 145, 147, 149, 151, 153, 155, 157,
1493 158, 160, 162, 164, 166, 168, 170, 171, 172, 174,
1494 176, 178, 180, 182, 184, 187, 188, 191, 192, 196,
1495 199, 200, 202, 203, 207, 209, 212, 214, 216, 218,
1496 220, 222, 224, 226, 228, 230, 232, 234, 236, 238,
1497 240, 242, 244, 246, 248, 250, 252, 255, 260, 266,
1498 272, 276, 279, 285, 290, 293, 295, 299, 301, 305,
1499 307, 308, 313, 317, 321, 326, 331, 335, 338, 341,
1500 344, 347, 350, 353, 356, 359, 362, 365, 368, 371,
1501 378, 384, 393, 400, 407, 415, 423, 430, 437, 446,
1502 455, 459, 461, 463, 465, 467, 468, 470, 473, 474,
1503 478, 479, 483, 487, 489, 493, 494, 500, 501, 508,
1504 509, 516, 519, 523, 525, 527, 529, 533, 537, 541,
1505 545, 549, 553, 555, 556, 558, 560, 562, 563, 566,
1506 570, 572, 574, 578, 580, 581, 590, 592, 594, 598,
1507 600, 602, 605, 608, 609, 611, 613, 615, 617, 619,
1508 621, 623, 625, 627, 631, 633, 639, 641, 643, 645,
1509 647, 650, 653, 656, 660, 663, 664, 666, 669, 672,
1510 676, 686, 696, 705, 719, 721, 723, 730, 736, 739,
1511 746, 754, 756, 760, 762, 763, 766, 768, 774, 780,
1512 787, 794, 797, 802, 807, 814, 819, 824, 831, 838,
1513 841, 849, 851, 854, 855, 857, 858, 862, 869, 873,
1514 880, 883, 888, 895
Reid Spencer3822ff52006-11-08 06:47:33 +00001515};
1516
Andrew Lenharth6353e052006-12-08 18:07:09 +00001517/* YYRHS -- A `-1'-separated list of the rules' RHS. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001518static const short int yyrhs[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001519{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001520 189, 0, -1, 5, -1, 6, -1, 79, -1, 80,
1521 -1, 81, -1, 82, -1, 83, -1, 84, -1, 85,
1522 -1, 86, -1, 87, -1, 88, -1, 89, -1, 90,
1523 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
1524 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
1525 -1, 129, -1, 130, -1, 133, -1, 134, -1, 135,
1526 -1, 93, -1, 94, -1, 95, -1, 96, -1, 97,
1527 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
1528 -1, 103, -1, 104, -1, 105, -1, 106, -1, 107,
1529 -1, 108, -1, 109, -1, 110, -1, 111, -1, 112,
1530 -1, 99, -1, 100, -1, 101, -1, 102, -1, 27,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001531 -1, 28, -1, 16, -1, 14, -1, 12, -1, 10,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001532 -1, 17, -1, 15, -1, 13, -1, 11, -1, 162,
1533 -1, 163, -1, 18, -1, 19, -1, 202, 140, -1,
1534 -1, 42, -1, 44, -1, 43, -1, 45, -1, 47,
1535 -1, 46, -1, 48, -1, 51, -1, -1, 46, -1,
1536 48, -1, 42, -1, 43, -1, 44, -1, 47, -1,
1537 -1, -1, 66, -1, 67, -1, 68, -1, 69, -1,
1538 70, -1, 71, -1, 65, 4, -1, -1, 58, 4,
1539 -1, -1, 141, 58, 4, -1, 35, 24, -1, -1,
1540 174, -1, -1, 141, 177, 176, -1, 174, -1, 58,
1541 4, -1, 180, -1, 8, -1, 182, -1, 8, -1,
1542 182, -1, 9, -1, 10, -1, 11, -1, 12, -1,
1543 13, -1, 14, -1, 15, -1, 16, -1, 17, -1,
1544 18, -1, 19, -1, 20, -1, 49, -1, 181, -1,
1545 215, -1, 142, 4, -1, 179, 143, 184, 144, -1,
1546 145, 4, 146, 182, 147, -1, 148, 4, 146, 182,
1547 149, -1, 150, 183, 151, -1, 150, 151, -1, 148,
1548 150, 183, 151, 149, -1, 148, 150, 151, 149, -1,
1549 182, 152, -1, 182, -1, 183, 141, 182, -1, 183,
1550 -1, 183, 141, 38, -1, 38, -1, -1, 180, 145,
1551 187, 147, -1, 180, 145, 147, -1, 180, 153, 24,
1552 -1, 180, 148, 187, 149, -1, 180, 150, 187, 151,
1553 -1, 180, 150, 151, -1, 180, 39, -1, 180, 40,
1554 -1, 180, 215, -1, 180, 186, -1, 180, 26, -1,
1555 162, 3, -1, 162, 4, -1, 163, 4, -1, 163,
1556 3, -1, 9, 27, -1, 9, 28, -1, 165, 7,
1557 -1, 158, 143, 185, 37, 180, 144, -1, 118, 143,
1558 185, 229, 144, -1, 132, 143, 185, 141, 185, 141,
1559 185, 144, -1, 156, 143, 185, 141, 185, 144, -1,
1560 157, 143, 185, 141, 185, 144, -1, 91, 160, 143,
1561 185, 141, 185, 144, -1, 92, 161, 143, 185, 141,
1562 185, 144, -1, 159, 143, 185, 141, 185, 144, -1,
1563 137, 143, 185, 141, 185, 144, -1, 138, 143, 185,
1564 141, 185, 141, 185, 144, -1, 139, 143, 185, 141,
1565 185, 141, 185, 144, -1, 187, 141, 185, -1, 185,
1566 -1, 33, -1, 34, -1, 190, -1, -1, 191, -1,
1567 190, 191, -1, -1, 32, 192, 211, -1, -1, 31,
1568 193, 212, -1, 63, 62, 197, -1, 25, -1, 166,
1569 21, 178, -1, -1, 166, 188, 185, 194, 176, -1,
1570 -1, 166, 167, 188, 185, 195, 176, -1, -1, 166,
1571 168, 188, 180, 196, 176, -1, 52, 199, -1, 59,
1572 140, 200, -1, 24, -1, 57, -1, 56, -1, 54,
1573 140, 198, -1, 55, 140, 4, -1, 53, 140, 24,
1574 -1, 72, 140, 24, -1, 145, 201, 147, -1, 201,
1575 141, 24, -1, 24, -1, -1, 22, -1, 24, -1,
1576 202, -1, -1, 180, 203, -1, 205, 141, 204, -1,
1577 204, -1, 205, -1, 205, 141, 38, -1, 38, -1,
1578 -1, 171, 178, 202, 143, 206, 144, 175, 172, -1,
1579 29, -1, 150, -1, 170, 207, 208, -1, 30, -1,
1580 151, -1, 218, 210, -1, 169, 207, -1, -1, 64,
1581 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
1582 -1, 39, -1, 40, -1, 26, -1, 148, 187, 149,
1583 -1, 186, -1, 62, 213, 24, 141, 24, -1, 155,
1584 -1, 202, -1, 215, -1, 214, -1, 180, 216, -1,
1585 218, 219, -1, 209, 219, -1, 220, 166, 221, -1,
1586 220, 223, -1, -1, 23, -1, 73, 217, -1, 73,
1587 8, -1, 74, 20, 216, -1, 74, 9, 216, 141,
1588 20, 216, 141, 20, 216, -1, 75, 164, 216, 141,
1589 20, 216, 145, 222, 147, -1, 75, 164, 216, 141,
1590 20, 216, 145, 147, -1, 76, 171, 178, 216, 143,
1591 226, 144, 37, 20, 216, 77, 20, 216, -1, 77,
1592 -1, 78, -1, 222, 164, 214, 141, 20, 216, -1,
1593 164, 214, 141, 20, 216, -1, 166, 228, -1, 180,
1594 145, 216, 141, 216, 147, -1, 224, 141, 145, 216,
1595 141, 216, 147, -1, 217, -1, 225, 141, 217, -1,
1596 225, -1, -1, 61, 60, -1, 60, -1, 156, 180,
1597 216, 141, 216, -1, 157, 180, 216, 141, 216, -1,
1598 91, 160, 180, 216, 141, 216, -1, 92, 161, 180,
1599 216, 141, 216, -1, 50, 217, -1, 159, 217, 141,
1600 217, -1, 158, 217, 37, 180, -1, 132, 217, 141,
1601 217, 141, 217, -1, 136, 217, 141, 180, -1, 137,
1602 217, 141, 217, -1, 138, 217, 141, 217, 141, 217,
1603 -1, 139, 217, 141, 217, 141, 217, -1, 131, 224,
1604 -1, 227, 171, 178, 216, 143, 226, 144, -1, 231,
1605 -1, 141, 225, -1, -1, 36, -1, -1, 113, 180,
1606 173, -1, 113, 180, 141, 15, 216, 173, -1, 114,
1607 180, 173, -1, 114, 180, 141, 15, 216, 173, -1,
1608 115, 217, -1, 230, 116, 180, 216, -1, 230, 117,
1609 217, 141, 180, 216, -1, 118, 180, 216, 229, -1
Reid Spencer3822ff52006-11-08 06:47:33 +00001610};
1611
1612/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001613static const unsigned short int yyrline[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001614{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001615 0, 989, 989, 990, 1000, 1000, 1000, 1000, 1000, 1000,
1616 1000, 1000, 1000, 1001, 1001, 1001, 1002, 1002, 1002, 1002,
1617 1002, 1002, 1003, 1003, 1003, 1003, 1003, 1003, 1004, 1004,
1618 1004, 1006, 1006, 1007, 1007, 1008, 1008, 1009, 1009, 1010,
1619 1010, 1014, 1014, 1015, 1015, 1016, 1016, 1017, 1017, 1018,
1620 1018, 1019, 1019, 1020, 1020, 1021, 1022, 1027, 1027, 1027,
1621 1027, 1028, 1028, 1028, 1028, 1029, 1029, 1030, 1030, 1033,
1622 1037, 1043, 1044, 1045, 1046, 1047, 1051, 1052, 1053, 1057,
1623 1058, 1059, 1063, 1064, 1065, 1066, 1067, 1070, 1071, 1072,
1624 1073, 1074, 1075, 1076, 1077, 1086, 1087, 1093, 1094, 1102,
1625 1110, 1111, 1116, 1117, 1118, 1123, 1137, 1137, 1138, 1138,
1626 1140, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1151, 1151,
1627 1151, 1151, 1151, 1152, 1156, 1160, 1168, 1176, 1189, 1194,
1628 1206, 1216, 1220, 1230, 1234, 1245, 1250, 1256, 1257, 1261,
1629 1265, 1276, 1302, 1316, 1346, 1372, 1393, 1406, 1416, 1421,
1630 1482, 1489, 1497, 1503, 1509, 1515, 1521, 1525, 1529, 1537,
1631 1549, 1570, 1578, 1584, 1595, 1600, 1605, 1614, 1620, 1626,
1632 1635, 1639, 1647, 1647, 1658, 1663, 1671, 1672, 1676, 1676,
1633 1680, 1680, 1683, 1686, 1698, 1720, 1720, 1729, 1729, 1737,
1634 1737, 1745, 1748, 1754, 1767, 1768, 1770, 1774, 1783, 1787,
1635 1792, 1794, 1799, 1804, 1813, 1813, 1814, 1814, 1816, 1823,
1636 1829, 1836, 1840, 1846, 1851, 1856, 1951, 1951, 1953, 1961,
1637 1961, 1963, 1968, 1978, 1982, 1987, 1991, 1995, 1999, 2003,
1638 2007, 2011, 2015, 2019, 2044, 2048, 2062, 2066, 2072, 2072,
1639 2078, 2083, 2087, 2096, 2107, 2116, 2128, 2141, 2145, 2149,
1640 2154, 2163, 2182, 2191, 2247, 2251, 2258, 2269, 2282, 2291,
1641 2300, 2310, 2314, 2321, 2321, 2323, 2327, 2332, 2351, 2366,
1642 2377, 2388, 2401, 2410, 2421, 2429, 2434, 2440, 2446, 2452,
1643 2467, 2526, 2533, 2536, 2541, 2545, 2552, 2557, 2563, 2568,
1644 2574, 2582, 2594, 2609
Reid Spencer3822ff52006-11-08 06:47:33 +00001645};
1646#endif
1647
Reid Spencere4d87aa2006-12-23 06:05:41 +00001648#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1649/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Andrew Lenharth6353e052006-12-08 18:07:09 +00001650 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer3822ff52006-11-08 06:47:33 +00001651static const char *const yytname[] =
1652{
1653 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1654 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001655 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "LABEL", "TYPE",
Reid Spencer3822ff52006-11-08 06:47:33 +00001656 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1657 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001658 "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
Reid Spencer3822ff52006-11-08 06:47:33 +00001659 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
1660 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1661 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
1662 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1663 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
1664 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1665 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1666 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
Reid Spencere4d87aa2006-12-23 06:05:41 +00001667 "XOR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
1668 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
1669 "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE",
1670 "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST",
1671 "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT",
1672 "PHI_TOK", "SELECT", "SHL", "LSHR", "ASHR", "VAARG", "EXTRACTELEMENT",
Reid Spencercd42c582006-12-05 23:29:42 +00001673 "INSERTELEMENT", "SHUFFLEVECTOR", "'='", "','", "'\\\\'", "'('", "')'",
1674 "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept",
Reid Spencere4d87aa2006-12-23 06:05:41 +00001675 "INTVAL", "ArithmeticOps", "LogicalOps", "CastOps", "ShiftOps",
1676 "IPredicates", "FPredicates", "SIntType", "UIntType", "IntType",
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001677 "FPType", "OptAssign", "GVInternalLinkage", "GVExternalLinkage",
1678 "FnDeclareLinkage", "FunctionLinkage", "OptCallingConv", "OptAlign",
Reid Spencere4d87aa2006-12-23 06:05:41 +00001679 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
1680 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
1681 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001682 "ConstVector", "GlobalType", "Module", "DefinitionList", "Definition",
1683 "@1", "@2", "@3", "@4", "@5", "AsmBlock", "BigOrLittle",
1684 "TargetDefinition", "LibrariesDefinition", "LibList", "Name", "OptName",
1685 "ArgVal", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1686 "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect",
1687 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1688 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1689 "JumpTable", "Inst", "PHIList", "ValueRefList", "ValueRefListE",
1690 "OptTailCall", "InstVal", "IndexList", "OptVolatile", "MemoryInst", 0
Reid Spencer3822ff52006-11-08 06:47:33 +00001691};
1692#endif
1693
1694# ifdef YYPRINT
1695/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1696 token YYLEX-NUM. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001697static const unsigned short int yytoknum[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001698{
1699 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1700 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1701 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1702 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1703 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1704 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1705 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1706 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1707 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1708 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1709 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
Reid Spencer3da59db2006-11-27 01:05:10 +00001710 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
Reid Spencera132e042006-12-03 05:46:11 +00001711 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001712 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1713 61, 44, 92, 40, 41, 91, 120, 93, 60, 62,
1714 123, 125, 42, 99
Reid Spencer3822ff52006-11-08 06:47:33 +00001715};
1716# endif
1717
1718/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00001719static const unsigned char yyr1[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001720{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001721 0, 154, 155, 155, 156, 156, 156, 156, 156, 156,
1722 156, 156, 156, 157, 157, 157, 158, 158, 158, 158,
1723 158, 158, 158, 158, 158, 158, 158, 158, 159, 159,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001724 159, 160, 160, 160, 160, 160, 160, 160, 160, 160,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001725 160, 161, 161, 161, 161, 161, 161, 161, 161, 161,
1726 161, 161, 161, 161, 161, 161, 161, 162, 162, 162,
1727 162, 163, 163, 163, 163, 164, 164, 165, 165, 166,
1728 166, 167, 167, 167, 167, 167, 168, 168, 168, 169,
1729 169, 169, 170, 170, 170, 170, 170, 171, 171, 171,
1730 171, 171, 171, 171, 171, 172, 172, 173, 173, 174,
1731 175, 175, 176, 176, 177, 177, 178, 178, 179, 179,
1732 180, 181, 181, 181, 181, 181, 181, 181, 181, 181,
1733 181, 181, 181, 182, 182, 182, 182, 182, 182, 182,
1734 182, 182, 182, 182, 182, 183, 183, 184, 184, 184,
1735 184, 185, 185, 185, 185, 185, 185, 185, 185, 185,
1736 185, 185, 185, 185, 185, 185, 185, 185, 185, 186,
1737 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
1738 187, 187, 188, 188, 189, 189, 190, 190, 192, 191,
1739 193, 191, 191, 191, 191, 194, 191, 195, 191, 196,
1740 191, 191, 191, 197, 198, 198, 199, 199, 199, 199,
1741 200, 201, 201, 201, 202, 202, 203, 203, 204, 205,
1742 205, 206, 206, 206, 206, 207, 208, 208, 209, 210,
1743 210, 211, 212, 213, 213, 214, 214, 214, 214, 214,
1744 214, 214, 214, 214, 214, 214, 215, 215, 216, 216,
1745 217, 218, 218, 219, 220, 220, 220, 221, 221, 221,
1746 221, 221, 221, 221, 221, 221, 222, 222, 223, 224,
1747 224, 225, 225, 226, 226, 227, 227, 228, 228, 228,
1748 228, 228, 228, 228, 228, 228, 228, 228, 228, 228,
1749 228, 228, 229, 229, 230, 230, 231, 231, 231, 231,
1750 231, 231, 231, 231
Reid Spencer3822ff52006-11-08 06:47:33 +00001751};
1752
1753/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00001754static const unsigned char yyr2[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001755{
1756 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1757 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1758 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3822ff52006-11-08 06:47:33 +00001759 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001760 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001761 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001762 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001763 0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1764 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
1765 1, 1, 1, 1, 2, 0, 2, 0, 3, 2,
1766 0, 1, 0, 3, 1, 2, 1, 1, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001767 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001768 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1769 3, 2, 5, 4, 2, 1, 3, 1, 3, 1,
1770 0, 4, 3, 3, 4, 4, 3, 2, 2, 2,
1771 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
1772 5, 8, 6, 6, 7, 7, 6, 6, 8, 8,
1773 3, 1, 1, 1, 1, 0, 1, 2, 0, 3,
1774 0, 3, 3, 1, 3, 0, 5, 0, 6, 0,
1775 6, 2, 3, 1, 1, 1, 3, 3, 3, 3,
1776 3, 3, 1, 0, 1, 1, 1, 0, 2, 3,
1777 1, 1, 3, 1, 0, 8, 1, 1, 3, 1,
1778 1, 2, 2, 0, 1, 1, 1, 1, 1, 1,
1779 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
1780 2, 2, 2, 3, 2, 0, 1, 2, 2, 3,
1781 9, 9, 8, 13, 1, 1, 6, 5, 2, 6,
1782 7, 1, 3, 1, 0, 2, 1, 5, 5, 6,
1783 6, 2, 4, 4, 6, 4, 4, 6, 6, 2,
1784 7, 1, 2, 0, 1, 0, 3, 6, 3, 6,
1785 2, 4, 6, 4
Reid Spencer3822ff52006-11-08 06:47:33 +00001786};
1787
1788/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1789 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1790 means the default is an error. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001791static const unsigned short int yydefact[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001792{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001793 70, 204, 205, 183, 180, 178, 0, 0, 0, 0,
1794 0, 70, 176, 0, 79, 86, 0, 0, 0, 0,
1795 191, 0, 0, 0, 172, 173, 71, 73, 72, 74,
1796 76, 75, 77, 78, 0, 0, 0, 1, 177, 69,
1797 80, 81, 87, 181, 82, 83, 84, 85, 87, 245,
1798 179, 245, 0, 0, 0, 0, 203, 192, 193, 182,
1799 2, 3, 107, 111, 112, 113, 114, 115, 116, 117,
1800 118, 119, 120, 121, 122, 123, 0, 0, 0, 0,
1801 236, 184, 0, 106, 124, 110, 237, 125, 0, 0,
1802 109, 111, 112, 113, 114, 115, 116, 117, 118, 119,
1803 120, 121, 0, 0, 0, 0, 185, 0, 88, 89,
1804 90, 91, 92, 93, 0, 222, 0, 246, 242, 70,
1805 219, 220, 221, 241, 198, 195, 194, 196, 197, 199,
1806 202, 0, 126, 0, 0, 0, 131, 135, 0, 140,
1807 134, 187, 189, 156, 157, 152, 153, 155, 154, 158,
1808 151, 147, 148, 4, 5, 6, 7, 8, 9, 10,
1809 11, 12, 13, 14, 15, 0, 0, 0, 16, 17,
1810 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1811 0, 28, 29, 30, 0, 0, 0, 0, 0, 0,
1812 0, 0, 0, 0, 0, 150, 149, 102, 94, 0,
1813 216, 217, 218, 285, 244, 0, 200, 0, 0, 0,
1814 0, 0, 130, 139, 137, 0, 102, 102, 31, 32,
1815 33, 34, 35, 36, 37, 38, 39, 40, 0, 55,
1816 56, 51, 52, 53, 54, 41, 42, 43, 44, 45,
1817 46, 47, 48, 49, 50, 0, 0, 0, 0, 0,
1818 0, 142, 171, 0, 0, 146, 0, 143, 0, 0,
1819 0, 0, 0, 186, 0, 284, 0, 266, 0, 0,
1820 0, 0, 87, 254, 255, 0, 0, 0, 0, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00001821 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001822 0, 243, 87, 258, 0, 281, 201, 108, 108, 133,
1823 0, 136, 0, 127, 188, 190, 0, 0, 283, 0,
1824 0, 0, 0, 0, 141, 144, 145, 0, 0, 0,
1825 0, 0, 0, 104, 102, 214, 0, 271, 265, 248,
1826 247, 0, 0, 60, 64, 59, 63, 58, 62, 57,
1827 61, 65, 66, 0, 0, 0, 0, 97, 97, 290,
1828 0, 0, 279, 0, 0, 0, 0, 0, 0, 0,
1829 0, 0, 0, 0, 0, 128, 129, 132, 138, 0,
1830 0, 0, 0, 0, 0, 0, 0, 170, 0, 0,
1831 0, 0, 99, 105, 103, 213, 207, 210, 211, 0,
1832 225, 226, 227, 232, 228, 229, 230, 231, 223, 0,
1833 234, 239, 238, 240, 0, 249, 0, 0, 0, 0,
1834 0, 286, 0, 288, 283, 0, 0, 0, 0, 0,
1835 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1836 0, 261, 282, 160, 0, 0, 0, 0, 0, 0,
1837 0, 0, 206, 208, 0, 100, 224, 0, 0, 0,
1838 0, 0, 0, 0, 0, 0, 0, 293, 0, 0,
1839 0, 275, 276, 0, 0, 0, 0, 273, 272, 0,
1840 291, 0, 0, 0, 0, 0, 167, 0, 0, 162,
1841 163, 159, 166, 212, 209, 101, 95, 0, 233, 0,
1842 0, 264, 0, 0, 97, 98, 97, 0, 0, 0,
1843 0, 0, 267, 268, 264, 0, 164, 165, 262, 0,
1844 0, 0, 0, 215, 0, 0, 0, 263, 0, 269,
1845 270, 0, 287, 289, 0, 0, 274, 277, 278, 0,
1846 292, 161, 168, 169, 96, 235, 0, 0, 0, 259,
1847 0, 280, 0, 252, 0, 0, 0, 260, 250, 0,
1848 251, 0, 0, 0, 0, 0, 0, 0, 0, 257,
1849 0, 0, 256, 253
Reid Spencer3822ff52006-11-08 06:47:33 +00001850};
1851
Andrew Lenharth6353e052006-12-08 18:07:09 +00001852/* YYDEFGOTO[NTERM-NUM]. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001853static const short int yydefgoto[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001854{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001855 -1, 80, 191, 192, 193, 194, 228, 245, 102, 103,
1856 343, 104, 9, 34, 35, 42, 48, 114, 513, 411,
1857 323, 486, 263, 324, 81, 82, 105, 84, 85, 138,
1858 215, 252, 400, 253, 36, 10, 11, 12, 15, 14,
1859 197, 216, 217, 59, 127, 20, 57, 131, 86, 443,
1860 387, 388, 389, 115, 202, 49, 122, 50, 43, 447,
1861 401, 87, 403, 431, 51, 118, 119, 291, 545, 204,
1862 352, 517, 518, 292, 293, 372, 294, 295
Reid Spencer3822ff52006-11-08 06:47:33 +00001863};
1864
1865/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1866 STATE-NUM. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001867#define YYPACT_NINF -420
Reid Spencere4d87aa2006-12-23 06:05:41 +00001868static const short int yypact[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001869{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001870 64, -420, -420, -420, -420, -420, 45, -80, 49, 59,
1871 124, 118, -420, -14, -33, 159, 8, 11, 32, 38,
1872 -420, -10, 121, 1149, -420, -420, -420, -420, -420, -420,
1873 -420, -420, -420, -420, 141, 141, 1195, -420, -420, -420,
1874 -420, -420, 143, -420, -420, -420, -420, -420, 143, 157,
1875 -420, -12, 191, 148, 179, 197, 201, -420, -420, -420,
1876 -420, -420, 90, -420, -420, -420, -420, -420, -420, -420,
1877 -420, -420, -420, -420, -420, -420, 227, 233, 4, 34,
1878 -420, -420, 99, -420, -420, -62, -420, -420, 1195, 1240,
1879 -420, 190, 216, 220, 232, 241, 247, 267, 269, 271,
1880 246, 285, 275, 277, 287, 523, -420, 278, -420, -420,
1881 -420, -420, -420, -420, 1149, -420, -19, -420, -420, 63,
1882 -420, -420, -420, -420, -420, -420, -420, -420, -420, -420,
1883 -420, -13, -420, 149, 150, 574, -420, -62, -84, 934,
1884 -420, -420, -420, -420, -420, -420, -420, -420, -420, -420,
1885 -420, -420, -420, -420, -420, -420, -420, -420, -420, -420,
1886 -420, -420, -420, -420, -420, 231, 87, 154, -420, -420,
1887 -420, -420, -420, -420, -420, -420, -420, -420, -420, -420,
1888 155, -420, -420, -420, 156, 158, 160, 982, 1195, 669,
1889 280, 162, 163, 165, 166, -420, -420, 169, -420, 63,
1890 -420, -420, -420, 1339, -420, 288, -420, 1240, 1240, 164,
1891 -57, 1240, -420, -420, 170, 173, 169, 169, -420, -420,
1892 -420, -420, -420, -420, -420, -420, -420, -420, 171, -420,
1893 -420, -420, -420, -420, -420, -420, -420, -420, -420, -420,
1894 -420, -420, -420, -420, -420, 175, 1195, 1195, 1195, 1195,
1895 1195, -420, -420, 5, -86, -420, -32, -420, 1195, 1195,
1896 1195, 1195, 24, -420, 176, -420, 1240, -420, 260, 1260,
1897 88, 147, 143, -420, -420, 231, 87, 1240, 1240, 1240,
1898 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
1899 1240, -420, 143, -420, 168, -420, -420, 19, -5, -420,
1900 185, -62, 1002, -420, -420, -420, 1195, 1195, 194, 195,
1901 196, 202, 203, 1195, -420, -420, -420, 204, 205, 301,
1902 206, 318, 345, -420, 169, 1047, 704, -420, -420, 90,
1903 -420, 704, 704, -420, -420, -420, -420, -420, -420, -420,
1904 -420, -420, -420, 704, 1149, 1240, 1240, 209, 210, -420,
1905 704, 207, 219, 221, 222, 226, 228, 229, 704, 704,
1906 331, 230, 1149, 1240, 1240, -420, -420, -420, -420, 234,
1907 235, 1240, 236, 1195, 1195, 1195, 1195, -420, 1195, 1195,
1908 1240, 1195, -420, -420, -420, -420, 63, -420, 237, 238,
1909 -420, -420, -420, -420, -420, -420, -420, -420, 309, 1195,
1910 -420, -420, -420, -420, 240, -420, 244, 704, 704, 704,
1911 20, -420, 21, -420, 194, 704, 243, 1240, 1240, 1240,
1912 1240, 1240, 245, 248, 1240, 1240, 704, 704, 249, 1195,
1913 1195, -420, 250, -420, 251, 255, 252, 259, 261, 262,
1914 268, 270, -420, -420, 1093, 339, -420, 353, -28, 359,
1915 383, 272, 263, 276, 704, 414, 704, -420, 279, 704,
1916 283, -420, -420, 284, 286, 704, 704, -420, -420, 289,
1917 -420, 1240, 292, 293, 1240, 1195, -420, 1195, 1195, -420,
1918 -420, -420, -420, -420, -420, -420, 370, 290, -420, 704,
1919 704, 1240, 704, 704, 297, -420, 297, 704, 298, 1240,
1920 1240, 1240, -420, -420, 1240, 704, -420, -420, -420, 296,
1921 299, 300, 425, -420, 406, 304, 307, 250, 312, -420,
1922 -420, 375, -420, -420, 294, 704, -420, -420, -420, 315,
1923 -420, -420, -420, -420, -420, -420, 422, 9, 416, -420,
1924 313, -420, 704, -420, 841, 60, 441, -420, -420, 322,
1925 -420, 841, 704, 444, 324, 389, 704, 447, 449, -420,
1926 704, 704, -420, -420
Reid Spencer3822ff52006-11-08 06:47:33 +00001927};
1928
1929/* YYPGOTO[NTERM-NUM]. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001930static const short int yypgoto[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001931{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001932 -420, -420, 291, 295, 302, 303, 198, 199, -269, -268,
1933 -415, -420, 351, -420, -420, -420, -420, -231, -420, -341,
1934 26, -420, -188, -420, -110, -420, -23, -420, -70, -6,
1935 -420, -20, 367, -183, 256, -420, -420, 463, -420, -420,
1936 -420, -420, -420, -420, -420, -420, -420, -420, 1, -420,
1937 35, -420, -420, 432, -420, -420, -420, -420, -420, -420,
1938 -419, -43, 76, -252, -420, 435, -420, -420, -420, -420,
1939 -420, 116, -16, -420, -420, 75, -420, -420
Reid Spencer3822ff52006-11-08 06:47:33 +00001940};
1941
1942/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1943 positive, shift that token. If negative, reduce the rule which
1944 number is the opposite. If zero, do what YYDEFACT says.
1945 If YYTABLE_NINF, syntax error. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001946#define YYTABLE_NINF -176
Reid Spencere4d87aa2006-12-23 06:05:41 +00001947static const short int yytable[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001948{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001949 83, 13, 341, 342, 199, 254, 256, 413, 134, 137,
1950 200, 117, 13, 40, 327, 41, 106, 330, 120, 333,
1951 334, 335, 336, 337, 338, 339, 340, 349, 304, 305,
1952 353, 354, 355, 356, 357, 454, 456, 360, 361, 60,
1953 61, 344, 90, 63, 64, 65, 66, 67, 68, 69,
1954 70, 71, 72, 73, 74, 313, 1, 211, 2, 321,
1955 21, 362, 196, 315, -175, 137, 142, 212, 141, 137,
1956 333, 334, 335, 336, 337, 338, 339, 340, 455, 455,
1957 23, -108, 322, 75, 211, 1, 1, 2, 2, 3,
1958 140, 83, 24, 25, 300, 4, 5, 331, 16, 17,
1959 18, 26, 27, 28, 29, 30, 31, 32, 332, 313,
1960 33, 22, 428, 313, 229, 230, 6, 19, -174, 316,
1961 13, 488, 544, 7, 37, 549, 39, 8, 205, 210,
1962 551, 201, 554, 214, 206, 56, 384, 297, 298, 121,
1963 1, 301, 2, 3, 366, 58, 313, 140, 52, 4,
1964 5, 53, 314, 522, 135, 523, 543, 333, 334, 335,
1965 336, 337, 338, 339, 340, 460, 365, 462, 463, 464,
1966 6, 140, 54, 468, 24, 25, 76, 7, 55, 77,
1967 117, 8, 78, 128, 79, 136, 231, 232, 233, 234,
1968 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,
1969 264, 44, 45, 46, 125, 126, 47, 550, 107, 108,
1970 109, 110, 111, 112, 113, 124, 448, 143, 144, -60,
1971 -60, 129, 508, -64, -64, 130, 308, 309, 310, 311,
1972 312, 132, 301, -109, 407, -59, -59, 133, 317, 318,
1973 319, 320, 139, 326, -63, -63, 326, 526, 527, 528,
1974 -58, -58, 426, -67, 347, 348, 326, 350, 351, 326,
1975 326, 326, 326, 326, 358, 359, 326, 326, 341, 342,
1976 -62, -62, -57, -57, -61, -61, 341, 342, 145, 146,
1977 147, 148, 198, 402, 363, 364, 369, 370, 402, 402,
1978 88, 89, -68, 377, 149, 207, 208, 246, 247, 248,
1979 402, 249, 386, 250, 257, 258, 259, 402, 260, 261,
1980 262, 302, 296, 299, 306, 402, 402, 303, 307, 325,
1981 328, 83, 408, 409, 218, 219, 220, 221, 222, 223,
1982 224, 225, 226, 227, 367, 371, 373, 374, 380, 83,
1983 427, 326, 382, 375, 376, 378, 379, 381, 326, 383,
1984 410, 412, 415, 434, 435, 436, 437, 440, 438, 439,
1985 416, 441, 417, 418, 402, 402, 402, 419, 424, 420,
1986 421, 425, 402, 446, 321, 429, 430, 487, 444, 489,
1987 433, 449, 445, 402, 402, 450, 465, 442, 459, 466,
1988 471, 474, 475, 477, 326, 461, 326, 326, 326, 476,
1989 478, 467, 326, 490, 492, 479, 480, 404, 405, 472,
1990 473, 402, 481, 402, 482, 491, 402, 493, 495, 406,
1991 497, 386, 402, 402, 499, 500, 414, 501, 512, 534,
1992 535, 514, 504, 455, 422, 423, 506, 507, 521, 525,
1993 531, 539, 542, 532, 533, 536, 402, 402, 505, 402,
1994 402, 326, 537, 546, 402, 509, 538, 510, 511, 541,
1995 547, 552, 402, 553, 556, 557, 558, 560, 326, 561,
1996 203, 485, 195, 345, 38, 346, 326, 326, 326, 484,
1997 116, 326, 402, 451, 452, 453, 123, 432, 529, 457,
1998 0, 458, 0, 0, 287, 0, 0, 0, 288, 402,
1999 0, 0, 469, 470, 0, 289, 290, 0, 0, 402,
2000 0, 0, 0, 402, 0, 0, 0, 402, 402, 0,
2001 0, 0, 0, 0, 0, 0, 0, 0, 60, 61,
2002 494, 0, 496, 0, 0, 498, 0, 0, 0, 0,
2003 0, 502, 503, 0, 0, 1, 0, 2, 0, 150,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002004 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002005 0, 0, 151, 152, 0, 515, 516, 0, 519, 520,
2006 0, 0, 0, 524, 0, 0, 0, 0, 0, 60,
2007 61, 530, 90, 63, 64, 65, 66, 67, 68, 69,
2008 70, 71, 72, 73, 74, 0, 1, 0, 2, 0,
2009 0, 540, 153, 154, 155, 156, 157, 158, 159, 160,
2010 161, 162, 163, 164, 165, 166, 0, 0, 548, 0,
2011 0, 0, 0, 75, 0, 0, 0, 0, 555, 0,
2012 0, 0, 559, 0, 0, 0, 562, 563, 0, 0,
2013 0, 167, 168, 169, 170, 171, 172, 173, 174, 175,
2014 176, 177, 178, 179, 0, 180, 181, 182, 183, 0,
2015 184, 185, 186, 0, 0, 0, 0, 0, 187, 0,
2016 0, 188, 0, 189, 60, 61, 190, 90, 91, 92,
2017 93, 94, 95, 96, 97, 98, 99, 100, 101, 74,
2018 0, 1, 0, 2, 0, 0, 0, 0, 0, 0,
2019 0, 0, 0, 0, 0, 0, 0, 390, 391, 60,
2020 61, 392, 0, 0, 0, 0, 76, 0, 75, 77,
2021 0, 0, 78, 0, 79, 209, 1, 0, 2, 0,
2022 393, 394, 395, 0, 0, 0, 0, 0, 0, 0,
2023 0, 0, 0, 396, 397, 0, 0, 0, 0, 0,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002024 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002025 0, 0, 0, 0, 0, 0, 398, 0, 0, 0,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002026 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002027 0, 0, 0, 153, 154, 155, 156, 157, 158, 159,
2028 160, 161, 162, 163, 164, 165, 166, 0, 0, 0,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002029 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002030 0, 76, 0, 0, 77, 0, 0, 78, 0, 79,
2031 255, 0, 167, 168, 169, 170, 171, 172, 173, 174,
2032 175, 176, 177, 178, 179, 0, 180, 181, 182, 183,
2033 0, 184, 185, 186, 390, 391, 0, 0, 392, 0,
2034 0, 0, 399, 0, 0, 0, 0, 0, 0, 0,
2035 0, 0, 0, 0, 0, 0, 0, 393, 394, 395,
2036 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2037 396, 397, 0, 0, 0, 0, 0, 0, 0, 0,
2038 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2039 0, 0, 0, 398, 0, 0, 0, 0, 0, 0,
2040 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002041 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002042 163, 164, 165, 166, 0, 0, 0, 0, 0, 60,
2043 61, 0, 90, 63, 64, 65, 66, 67, 68, 69,
2044 70, 71, 72, 73, 74, 0, 1, 0, 2, 167,
2045 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
2046 178, 179, 213, 180, 181, 182, 183, 0, 184, 185,
2047 186, 0, 0, 75, 0, 0, 0, 60, 61, 399,
2048 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
2049 100, 101, 74, 0, 1, 0, 2, 60, 61, 0,
2050 90, 63, 64, 65, 66, 67, 68, 69, 70, 71,
2051 72, 73, 74, 0, 1, 0, 2, 0, 0, 0,
2052 0, 75, 0, 0, 0, 0, 0, 0, 0, 0,
2053 368, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2054 0, 75, 60, 61, 0, 90, 63, 64, 65, 66,
2055 67, 68, 69, 70, 71, 72, 73, 74, 0, 1,
2056 0, 2, 0, 0, 0, 0, 76, 0, 0, 77,
2057 0, 0, 78, 0, 79, 385, 0, 0, 0, 0,
2058 0, 0, 0, 0, 0, 0, 75, 0, 60, 61,
2059 0, 90, 63, 64, 65, 66, 67, 68, 69, 70,
2060 71, 72, 73, 74, 0, 1, 0, 2, 0, 0,
2061 0, 0, 0, 0, 76, 0, 0, 77, 0, 251,
2062 78, 483, 79, 0, 0, 0, 0, 0, 0, 0,
2063 0, 0, 75, 0, 76, 0, 0, 77, 0, 0,
2064 78, 0, 79, 0, 60, 61, 0, 62, 63, 64,
2065 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2066 0, 1, 0, 2, 0, 0, 0, 0, 0, 0,
2067 0, 0, 0, 0, 0, 0, 0, 0, 0, 76,
2068 0, 0, 77, 0, 0, 78, 0, 79, 75, 0,
2069 60, 61, 0, 90, 91, 92, 93, 94, 95, 96,
2070 97, 98, 99, 100, 101, 74, 0, 1, 0, 2,
2071 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2072 0, 0, 0, 0, 0, 76, 0, 0, 77, 0,
2073 0, 78, 0, 79, 75, 60, 61, 0, 90, 63,
2074 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
2075 74, 0, 1, 0, 2, 60, 61, 0, 329, 63,
2076 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
2077 74, 0, 1, 0, 2, 0, 0, 0, 0, 75,
2078 0, 76, 0, 0, 77, 0, 0, 78, 0, 79,
2079 0, 0, 0, 0, 0, 0, 0, 0, 0, 75,
2080 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2081 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2082 0, 0, 0, 0, 0, 0, 0, 76, 0, 0,
2083 77, 0, 0, 78, 0, 79, 0, 0, 0, 0,
2084 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2085 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2086 0, 0, 0, 0, 0, 265, 0, 0, 0, 0,
2087 0, 0, 76, 0, 0, 77, 0, 0, 78, 266,
2088 79, 0, 0, 0, 0, 0, 0, 0, 0, 267,
2089 268, 0, 76, 0, 0, 77, 0, 0, 78, 0,
2090 79, 0, 269, 270, 271, 272, 273, 274, 153, 154,
2091 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
2092 275, 276, 0, 0, 0, 0, 0, 0, 0, 0,
2093 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2094 0, 0, 277, 278, 279, 0, 0, 280, 168, 169,
2095 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
2096 281, 282, 181, 182, 183, 283, 284, 285, 286
Reid Spencer3822ff52006-11-08 06:47:33 +00002097};
2098
Reid Spencere4d87aa2006-12-23 06:05:41 +00002099static const short int yycheck[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00002100{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002101 23, 0, 271, 271, 114, 188, 189, 348, 4, 79,
2102 29, 23, 11, 46, 266, 48, 36, 269, 30, 10,
2103 11, 12, 13, 14, 15, 16, 17, 279, 216, 217,
2104 282, 283, 284, 285, 286, 15, 15, 289, 290, 5,
2105 6, 272, 8, 9, 10, 11, 12, 13, 14, 15,
2106 16, 17, 18, 19, 20, 141, 22, 141, 24, 35,
2107 140, 292, 105, 149, 0, 135, 89, 151, 88, 139,
2108 10, 11, 12, 13, 14, 15, 16, 17, 58, 58,
2109 21, 143, 58, 49, 141, 22, 22, 24, 24, 25,
2110 152, 114, 33, 34, 151, 31, 32, 9, 53, 54,
2111 55, 42, 43, 44, 45, 46, 47, 48, 20, 141,
2112 51, 62, 364, 141, 27, 28, 52, 72, 0, 151,
2113 119, 149, 537, 59, 0, 544, 140, 63, 141, 135,
2114 545, 150, 551, 139, 147, 145, 324, 207, 208, 151,
2115 22, 211, 24, 25, 149, 24, 141, 152, 140, 31,
2116 32, 140, 147, 494, 150, 496, 147, 10, 11, 12,
2117 13, 14, 15, 16, 17, 417, 147, 419, 420, 421,
2118 52, 152, 140, 425, 33, 34, 142, 59, 140, 145,
2119 23, 63, 148, 4, 150, 151, 99, 100, 101, 102,
2120 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
2121 199, 42, 43, 44, 56, 57, 47, 147, 65, 66,
2122 67, 68, 69, 70, 71, 24, 399, 27, 28, 3,
2123 4, 24, 474, 3, 4, 24, 246, 247, 248, 249,
2124 250, 4, 302, 143, 344, 3, 4, 4, 258, 259,
2125 260, 261, 143, 266, 3, 4, 269, 499, 500, 501,
2126 3, 4, 362, 7, 277, 278, 279, 280, 281, 282,
2127 283, 284, 285, 286, 287, 288, 289, 290, 537, 537,
2128 3, 4, 3, 4, 3, 4, 545, 545, 3, 4,
2129 3, 4, 4, 326, 116, 117, 306, 307, 331, 332,
2130 34, 35, 7, 313, 7, 146, 146, 143, 143, 143,
2131 343, 143, 325, 143, 24, 143, 143, 350, 143, 143,
2132 141, 141, 24, 149, 143, 358, 359, 144, 143, 143,
2133 60, 344, 345, 346, 93, 94, 95, 96, 97, 98,
2134 99, 100, 101, 102, 149, 141, 141, 141, 37, 362,
2135 363, 364, 24, 141, 141, 141, 141, 141, 371, 4,
2136 141, 141, 145, 373, 374, 375, 376, 380, 378, 379,
2137 141, 381, 141, 141, 407, 408, 409, 141, 37, 141,
2138 141, 141, 415, 64, 35, 141, 141, 24, 141, 20,
2139 144, 141, 144, 426, 427, 141, 141, 386, 145, 141,
2140 141, 141, 141, 141, 417, 418, 419, 420, 421, 144,
2141 141, 424, 425, 20, 141, 144, 144, 331, 332, 429,
2142 430, 454, 144, 456, 144, 143, 459, 141, 4, 343,
2143 141, 444, 465, 466, 141, 141, 350, 141, 58, 4,
2144 24, 141, 143, 58, 358, 359, 144, 144, 141, 141,
2145 144, 147, 20, 144, 144, 141, 489, 490, 471, 492,
2146 493, 474, 145, 37, 497, 475, 144, 477, 478, 144,
2147 147, 20, 505, 141, 20, 141, 77, 20, 491, 20,
2148 119, 445, 105, 275, 11, 276, 499, 500, 501, 444,
2149 48, 504, 525, 407, 408, 409, 51, 371, 504, 414,
2150 -1, 415, -1, -1, 203, -1, -1, -1, 203, 542,
2151 -1, -1, 426, 427, -1, 203, 203, -1, -1, 552,
2152 -1, -1, -1, 556, -1, -1, -1, 560, 561, -1,
2153 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
2154 454, -1, 456, -1, -1, 459, -1, -1, -1, -1,
2155 -1, 465, 466, -1, -1, 22, -1, 24, -1, 26,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002156 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002157 -1, -1, 39, 40, -1, 489, 490, -1, 492, 493,
2158 -1, -1, -1, 497, -1, -1, -1, -1, -1, 5,
2159 6, 505, 8, 9, 10, 11, 12, 13, 14, 15,
2160 16, 17, 18, 19, 20, -1, 22, -1, 24, -1,
2161 -1, 525, 79, 80, 81, 82, 83, 84, 85, 86,
2162 87, 88, 89, 90, 91, 92, -1, -1, 542, -1,
2163 -1, -1, -1, 49, -1, -1, -1, -1, 552, -1,
2164 -1, -1, 556, -1, -1, -1, 560, 561, -1, -1,
2165 -1, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2166 127, 128, 129, 130, -1, 132, 133, 134, 135, -1,
2167 137, 138, 139, -1, -1, -1, -1, -1, 145, -1,
2168 -1, 148, -1, 150, 5, 6, 153, 8, 9, 10,
Reid Spencer4012e832006-12-04 05:24:24 +00002169 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002170 -1, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2171 -1, -1, -1, -1, -1, -1, -1, 3, 4, 5,
2172 6, 7, -1, -1, -1, -1, 142, -1, 49, 145,
2173 -1, -1, 148, -1, 150, 151, 22, -1, 24, -1,
2174 26, 27, 28, -1, -1, -1, -1, -1, -1, -1,
2175 -1, -1, -1, 39, 40, -1, -1, -1, -1, -1,
2176 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2177 -1, -1, -1, -1, -1, -1, 62, -1, -1, -1,
2178 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2179 -1, -1, -1, 79, 80, 81, 82, 83, 84, 85,
2180 86, 87, 88, 89, 90, 91, 92, -1, -1, -1,
2181 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2182 -1, 142, -1, -1, 145, -1, -1, 148, -1, 150,
2183 151, -1, 118, 119, 120, 121, 122, 123, 124, 125,
2184 126, 127, 128, 129, 130, -1, 132, 133, 134, 135,
2185 -1, 137, 138, 139, 3, 4, -1, -1, 7, -1,
2186 -1, -1, 148, -1, -1, -1, -1, -1, -1, -1,
2187 -1, -1, -1, -1, -1, -1, -1, 26, 27, 28,
2188 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2189 39, 40, -1, -1, -1, -1, -1, -1, -1, -1,
2190 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2191 -1, -1, -1, 62, -1, -1, -1, -1, -1, -1,
2192 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2193 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2194 89, 90, 91, 92, -1, -1, -1, -1, -1, 5,
2195 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
2196 16, 17, 18, 19, 20, -1, 22, -1, 24, 118,
2197 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2198 129, 130, 38, 132, 133, 134, 135, -1, 137, 138,
2199 139, -1, -1, 49, -1, -1, -1, 5, 6, 148,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002200 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002201 18, 19, 20, -1, 22, -1, 24, 5, 6, -1,
2202 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2203 18, 19, 20, -1, 22, -1, 24, -1, -1, -1,
2204 -1, 49, -1, -1, -1, -1, -1, -1, -1, -1,
2205 38, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2206 -1, 49, 5, 6, -1, 8, 9, 10, 11, 12,
2207 13, 14, 15, 16, 17, 18, 19, 20, -1, 22,
2208 -1, 24, -1, -1, -1, -1, 142, -1, -1, 145,
2209 -1, -1, 148, -1, 150, 38, -1, -1, -1, -1,
2210 -1, -1, -1, -1, -1, -1, 49, -1, 5, 6,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002211 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002212 17, 18, 19, 20, -1, 22, -1, 24, -1, -1,
2213 -1, -1, -1, -1, 142, -1, -1, 145, -1, 147,
2214 148, 38, 150, -1, -1, -1, -1, -1, -1, -1,
2215 -1, -1, 49, -1, 142, -1, -1, 145, -1, -1,
2216 148, -1, 150, -1, 5, 6, -1, 8, 9, 10,
2217 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2218 -1, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2219 -1, -1, -1, -1, -1, -1, -1, -1, -1, 142,
2220 -1, -1, 145, -1, -1, 148, -1, 150, 49, -1,
2221 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2222 15, 16, 17, 18, 19, 20, -1, 22, -1, 24,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002223 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002224 -1, -1, -1, -1, -1, 142, -1, -1, 145, -1,
2225 -1, 148, -1, 150, 49, 5, 6, -1, 8, 9,
2226 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2227 20, -1, 22, -1, 24, 5, 6, -1, 8, 9,
2228 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2229 20, -1, 22, -1, 24, -1, -1, -1, -1, 49,
2230 -1, 142, -1, -1, 145, -1, -1, 148, -1, 150,
2231 -1, -1, -1, -1, -1, -1, -1, -1, -1, 49,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002232 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002233 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2234 -1, -1, -1, -1, -1, -1, -1, 142, -1, -1,
2235 145, -1, -1, 148, -1, 150, -1, -1, -1, -1,
2236 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2237 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2238 -1, -1, -1, -1, -1, 36, -1, -1, -1, -1,
2239 -1, -1, 142, -1, -1, 145, -1, -1, 148, 50,
2240 150, -1, -1, -1, -1, -1, -1, -1, -1, 60,
2241 61, -1, 142, -1, -1, 145, -1, -1, 148, -1,
2242 150, -1, 73, 74, 75, 76, 77, 78, 79, 80,
2243 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2244 91, 92, -1, -1, -1, -1, -1, -1, -1, -1,
2245 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2246 -1, -1, 113, 114, 115, -1, -1, 118, 119, 120,
2247 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
2248 131, 132, 133, 134, 135, 136, 137, 138, 139
Reid Spencer3822ff52006-11-08 06:47:33 +00002249};
2250
2251/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2252 symbol of state STATE-NUM. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002253static const unsigned char yystos[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00002254{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002255 0, 22, 24, 25, 31, 32, 52, 59, 63, 166,
2256 189, 190, 191, 202, 193, 192, 53, 54, 55, 72,
2257 199, 140, 62, 21, 33, 34, 42, 43, 44, 45,
2258 46, 47, 48, 51, 167, 168, 188, 0, 191, 140,
2259 46, 48, 169, 212, 42, 43, 44, 47, 170, 209,
2260 211, 218, 140, 140, 140, 140, 145, 200, 24, 197,
2261 5, 6, 8, 9, 10, 11, 12, 13, 14, 15,
2262 16, 17, 18, 19, 20, 49, 142, 145, 148, 150,
2263 155, 178, 179, 180, 181, 182, 202, 215, 188, 188,
2264 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2265 18, 19, 162, 163, 165, 180, 185, 65, 66, 67,
2266 68, 69, 70, 71, 171, 207, 207, 23, 219, 220,
2267 30, 151, 210, 219, 24, 56, 57, 198, 4, 24,
2268 24, 201, 4, 4, 4, 150, 151, 182, 183, 143,
2269 152, 185, 180, 27, 28, 3, 4, 3, 4, 7,
2270 26, 39, 40, 79, 80, 81, 82, 83, 84, 85,
2271 86, 87, 88, 89, 90, 91, 92, 118, 119, 120,
2272 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
2273 132, 133, 134, 135, 137, 138, 139, 145, 148, 150,
2274 153, 156, 157, 158, 159, 186, 215, 194, 4, 178,
2275 29, 150, 208, 166, 223, 141, 147, 146, 146, 151,
2276 183, 141, 151, 38, 183, 184, 195, 196, 93, 94,
2277 95, 96, 97, 98, 99, 100, 101, 102, 160, 27,
2278 28, 99, 100, 101, 102, 103, 104, 105, 106, 107,
2279 108, 109, 110, 111, 112, 161, 143, 143, 143, 143,
2280 143, 147, 185, 187, 187, 151, 187, 24, 143, 143,
2281 143, 143, 141, 176, 202, 36, 50, 60, 61, 73,
2282 74, 75, 76, 77, 78, 91, 92, 113, 114, 115,
2283 118, 131, 132, 136, 137, 138, 139, 156, 157, 158,
2284 159, 221, 227, 228, 230, 231, 24, 182, 182, 149,
2285 151, 182, 141, 144, 176, 176, 143, 143, 185, 185,
2286 185, 185, 185, 141, 147, 149, 151, 185, 185, 185,
2287 185, 35, 58, 174, 177, 143, 180, 217, 60, 8,
2288 217, 9, 20, 10, 11, 12, 13, 14, 15, 16,
2289 17, 162, 163, 164, 171, 160, 161, 180, 180, 217,
2290 180, 180, 224, 217, 217, 217, 217, 217, 180, 180,
2291 217, 217, 171, 116, 117, 147, 149, 149, 38, 185,
2292 185, 141, 229, 141, 141, 141, 141, 185, 141, 141,
2293 37, 141, 24, 4, 176, 38, 180, 204, 205, 206,
2294 3, 4, 7, 26, 27, 28, 39, 40, 62, 148,
2295 186, 214, 215, 216, 216, 216, 216, 178, 180, 180,
2296 141, 173, 141, 173, 216, 145, 141, 141, 141, 141,
2297 141, 141, 216, 216, 37, 141, 178, 180, 217, 141,
2298 141, 217, 225, 144, 185, 185, 185, 185, 185, 185,
2299 180, 185, 202, 203, 141, 144, 64, 213, 187, 141,
2300 141, 216, 216, 216, 15, 58, 15, 229, 216, 145,
2301 217, 180, 217, 217, 217, 141, 141, 180, 217, 216,
2302 216, 141, 185, 185, 141, 141, 144, 141, 141, 144,
2303 144, 144, 144, 38, 204, 174, 175, 24, 149, 20,
2304 20, 143, 141, 141, 216, 4, 216, 141, 216, 141,
2305 141, 141, 216, 216, 143, 180, 144, 144, 217, 185,
2306 185, 185, 58, 172, 141, 216, 216, 225, 226, 216,
2307 216, 141, 173, 173, 216, 141, 217, 217, 217, 226,
2308 216, 144, 144, 144, 4, 24, 141, 145, 144, 147,
2309 216, 144, 20, 147, 164, 222, 37, 147, 216, 214,
2310 147, 164, 20, 141, 214, 216, 20, 141, 77, 216,
2311 20, 20, 216, 216
Reid Spencer3822ff52006-11-08 06:47:33 +00002312};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002313
2314#define yyerrok (yyerrstatus = 0)
2315#define yyclearin (yychar = YYEMPTY)
Reid Spencer3822ff52006-11-08 06:47:33 +00002316#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002317#define YYEOF 0
Reid Spencer3822ff52006-11-08 06:47:33 +00002318
Reid Spencer68a24bd2005-08-27 18:50:39 +00002319#define YYACCEPT goto yyacceptlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002320#define YYABORT goto yyabortlab
2321#define YYERROR goto yyerrorlab
2322
2323
2324/* Like YYERROR except do call yyerror. This remains here temporarily
2325 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002326 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002327
Reid Spencer68a24bd2005-08-27 18:50:39 +00002328#define YYFAIL goto yyerrlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002329
Reid Spencer68a24bd2005-08-27 18:50:39 +00002330#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002331
2332#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002333do \
2334 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3822ff52006-11-08 06:47:33 +00002335 { \
2336 yychar = (Token); \
2337 yylval = (Value); \
2338 yytoken = YYTRANSLATE (yychar); \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002339 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002340 goto yybackup; \
2341 } \
2342 else \
Reid Spencere4d87aa2006-12-23 06:05:41 +00002343 { \
2344 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer3822ff52006-11-08 06:47:33 +00002345 YYERROR; \
2346 } \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002347while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002348
Reid Spencere4d87aa2006-12-23 06:05:41 +00002349
Reid Spencer68a24bd2005-08-27 18:50:39 +00002350#define YYTERROR 1
2351#define YYERRCODE 256
2352
Reid Spencer3822ff52006-11-08 06:47:33 +00002353
Reid Spencere4d87aa2006-12-23 06:05:41 +00002354/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2355 If N is 0, then set CURRENT to the empty location which ends
2356 the previous symbol: RHS[0] (always defined). */
2357
2358#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer3822ff52006-11-08 06:47:33 +00002359#ifndef YYLLOC_DEFAULT
Reid Spencere4d87aa2006-12-23 06:05:41 +00002360# define YYLLOC_DEFAULT(Current, Rhs, N) \
2361 do \
2362 if (N) \
2363 { \
2364 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2365 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2366 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2367 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2368 } \
2369 else \
2370 { \
2371 (Current).first_line = (Current).last_line = \
2372 YYRHSLOC (Rhs, 0).last_line; \
2373 (Current).first_column = (Current).last_column = \
2374 YYRHSLOC (Rhs, 0).last_column; \
2375 } \
2376 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002377#endif
2378
Reid Spencere4d87aa2006-12-23 06:05:41 +00002379
2380/* YY_LOCATION_PRINT -- Print the location on the stream.
2381 This macro was not mandated originally: define only if we know
2382 we won't break user code: when these are the locations we know. */
2383
2384#ifndef YY_LOCATION_PRINT
2385# if YYLTYPE_IS_TRIVIAL
2386# define YY_LOCATION_PRINT(File, Loc) \
2387 fprintf (File, "%d.%d-%d.%d", \
2388 (Loc).first_line, (Loc).first_column, \
2389 (Loc).last_line, (Loc).last_column)
2390# else
2391# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2392# endif
2393#endif
2394
2395
Reid Spencer3822ff52006-11-08 06:47:33 +00002396/* YYLEX -- calling `yylex' with the right arguments. */
2397
Reid Spencer68a24bd2005-08-27 18:50:39 +00002398#ifdef YYLEX_PARAM
Reid Spencer3822ff52006-11-08 06:47:33 +00002399# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002400#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002401# define YYLEX yylex ()
Chris Lattnerf49c1762006-11-08 05:58:47 +00002402#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002403
2404/* Enable debugging if requested. */
2405#if YYDEBUG
2406
2407# ifndef YYFPRINTF
2408# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2409# define YYFPRINTF fprintf
2410# endif
2411
2412# define YYDPRINTF(Args) \
2413do { \
2414 if (yydebug) \
2415 YYFPRINTF Args; \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002416} while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002417
Reid Spencere4d87aa2006-12-23 06:05:41 +00002418# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002419do { \
2420 if (yydebug) \
2421 { \
2422 YYFPRINTF (stderr, "%s ", Title); \
Reid Spencere4d87aa2006-12-23 06:05:41 +00002423 yysymprint (stderr, \
2424 Type, Value); \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002425 YYFPRINTF (stderr, "\n"); \
2426 } \
2427} while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002428
2429/*------------------------------------------------------------------.
2430| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2431| TOP (included). |
2432`------------------------------------------------------------------*/
2433
Andrew Lenharth6353e052006-12-08 18:07:09 +00002434#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002435static void
Reid Spencere4d87aa2006-12-23 06:05:41 +00002436yy_stack_print (short int *bottom, short int *top)
Chris Lattnerf49c1762006-11-08 05:58:47 +00002437#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002438static void
2439yy_stack_print (bottom, top)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002440 short int *bottom;
2441 short int *top;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002442#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002443{
2444 YYFPRINTF (stderr, "Stack now");
Andrew Lenharth6353e052006-12-08 18:07:09 +00002445 for (/* Nothing. */; bottom <= top; ++bottom)
Reid Spencer3822ff52006-11-08 06:47:33 +00002446 YYFPRINTF (stderr, " %d", *bottom);
2447 YYFPRINTF (stderr, "\n");
2448}
2449
2450# define YY_STACK_PRINT(Bottom, Top) \
2451do { \
2452 if (yydebug) \
2453 yy_stack_print ((Bottom), (Top)); \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002454} while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002455
2456
2457/*------------------------------------------------.
2458| Report that the YYRULE is going to be reduced. |
2459`------------------------------------------------*/
2460
Andrew Lenharth6353e052006-12-08 18:07:09 +00002461#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002462static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002463yy_reduce_print (int yyrule)
Reid Spencer3822ff52006-11-08 06:47:33 +00002464#else
2465static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002466yy_reduce_print (yyrule)
Reid Spencer3822ff52006-11-08 06:47:33 +00002467 int yyrule;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002468#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002469{
2470 int yyi;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002471 unsigned long int yylno = yyrline[yyrule];
2472 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
Andrew Lenharth6353e052006-12-08 18:07:09 +00002473 yyrule - 1, yylno);
2474 /* Print the symbols being reduced, and their result. */
2475 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002476 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2477 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Reid Spencer3822ff52006-11-08 06:47:33 +00002478}
Reid Spencer21be8652006-10-22 07:03:43 +00002479
Reid Spencer3822ff52006-11-08 06:47:33 +00002480# define YY_REDUCE_PRINT(Rule) \
2481do { \
2482 if (yydebug) \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002483 yy_reduce_print (Rule); \
2484} while (0)
Reid Spencer21be8652006-10-22 07:03:43 +00002485
Reid Spencer3822ff52006-11-08 06:47:33 +00002486/* Nonzero means print parse trace. It is left uninitialized so that
2487 multiple parsers can coexist. */
2488int yydebug;
2489#else /* !YYDEBUG */
2490# define YYDPRINTF(Args)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002491# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Reid Spencer3822ff52006-11-08 06:47:33 +00002492# define YY_STACK_PRINT(Bottom, Top)
2493# define YY_REDUCE_PRINT(Rule)
2494#endif /* !YYDEBUG */
Reid Spencer21be8652006-10-22 07:03:43 +00002495
Reid Spencer21be8652006-10-22 07:03:43 +00002496
Reid Spencer3822ff52006-11-08 06:47:33 +00002497/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002498#ifndef YYINITDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002499# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002500#endif
2501
Reid Spencer3822ff52006-11-08 06:47:33 +00002502/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2503 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002504
Reid Spencer3822ff52006-11-08 06:47:33 +00002505 Do not make this value too large; the results are undefined if
Reid Spencere4d87aa2006-12-23 06:05:41 +00002506 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer3822ff52006-11-08 06:47:33 +00002507 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002508
2509#ifndef YYMAXDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002510# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002511#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002512
Reid Spencer68a24bd2005-08-27 18:50:39 +00002513
2514
Reid Spencer3822ff52006-11-08 06:47:33 +00002515#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002516
Reid Spencer3822ff52006-11-08 06:47:33 +00002517# ifndef yystrlen
Andrew Lenharth6353e052006-12-08 18:07:09 +00002518# if defined (__GLIBC__) && defined (_STRING_H)
Reid Spencer3822ff52006-11-08 06:47:33 +00002519# define yystrlen strlen
2520# else
2521/* Return the length of YYSTR. */
2522static YYSIZE_T
Andrew Lenharth6353e052006-12-08 18:07:09 +00002523# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002524yystrlen (const char *yystr)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002525# else
Reid Spencer3822ff52006-11-08 06:47:33 +00002526yystrlen (yystr)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002527 const char *yystr;
2528# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002529{
Reid Spencere4d87aa2006-12-23 06:05:41 +00002530 const char *yys = yystr;
Andrew Lenharth6353e052006-12-08 18:07:09 +00002531
2532 while (*yys++ != '\0')
Reid Spencer3822ff52006-11-08 06:47:33 +00002533 continue;
Andrew Lenharth6353e052006-12-08 18:07:09 +00002534
2535 return yys - yystr - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002536}
Reid Spencer3822ff52006-11-08 06:47:33 +00002537# endif
2538# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002539
Reid Spencer3822ff52006-11-08 06:47:33 +00002540# ifndef yystpcpy
Andrew Lenharth6353e052006-12-08 18:07:09 +00002541# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Reid Spencer3822ff52006-11-08 06:47:33 +00002542# define yystpcpy stpcpy
2543# else
2544/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2545 YYDEST. */
2546static char *
Andrew Lenharth6353e052006-12-08 18:07:09 +00002547# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002548yystpcpy (char *yydest, const char *yysrc)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002549# else
Reid Spencer3822ff52006-11-08 06:47:33 +00002550yystpcpy (yydest, yysrc)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002551 char *yydest;
2552 const char *yysrc;
2553# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002554{
Reid Spencere4d87aa2006-12-23 06:05:41 +00002555 char *yyd = yydest;
2556 const char *yys = yysrc;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002557
Reid Spencer3822ff52006-11-08 06:47:33 +00002558 while ((*yyd++ = *yys++) != '\0')
2559 continue;
2560
2561 return yyd - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002562}
Reid Spencer3822ff52006-11-08 06:47:33 +00002563# endif
2564# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002565
Reid Spencere4d87aa2006-12-23 06:05:41 +00002566# ifndef yytnamerr
2567/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2568 quotes and backslashes, so that it's suitable for yyerror. The
2569 heuristic is that double-quoting is unnecessary unless the string
2570 contains an apostrophe, a comma, or backslash (other than
2571 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2572 null, do not copy; instead, return the length of what the result
2573 would have been. */
2574static YYSIZE_T
2575yytnamerr (char *yyres, const char *yystr)
2576{
2577 if (*yystr == '"')
2578 {
2579 size_t yyn = 0;
2580 char const *yyp = yystr;
2581
2582 for (;;)
2583 switch (*++yyp)
2584 {
2585 case '\'':
2586 case ',':
2587 goto do_not_strip_quotes;
2588
2589 case '\\':
2590 if (*++yyp != '\\')
2591 goto do_not_strip_quotes;
2592 /* Fall through. */
2593 default:
2594 if (yyres)
2595 yyres[yyn] = *yyp;
2596 yyn++;
2597 break;
2598
2599 case '"':
2600 if (yyres)
2601 yyres[yyn] = '\0';
2602 return yyn;
2603 }
2604 do_not_strip_quotes: ;
2605 }
2606
2607 if (! yyres)
2608 return yystrlen (yystr);
2609
2610 return yystpcpy (yyres, yystr) - yyres;
2611}
2612# endif
2613
2614#endif /* YYERROR_VERBOSE */
Reid Spencer3822ff52006-11-08 06:47:33 +00002615
Reid Spencer21be8652006-10-22 07:03:43 +00002616
2617
Andrew Lenharth6353e052006-12-08 18:07:09 +00002618#if YYDEBUG
2619/*--------------------------------.
2620| Print this symbol on YYOUTPUT. |
2621`--------------------------------*/
Reid Spencer3822ff52006-11-08 06:47:33 +00002622
Andrew Lenharth6353e052006-12-08 18:07:09 +00002623#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002624static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002625yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Reid Spencer3822ff52006-11-08 06:47:33 +00002626#else
2627static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002628yysymprint (yyoutput, yytype, yyvaluep)
2629 FILE *yyoutput;
Reid Spencer3822ff52006-11-08 06:47:33 +00002630 int yytype;
2631 YYSTYPE *yyvaluep;
2632#endif
2633{
Andrew Lenharth6353e052006-12-08 18:07:09 +00002634 /* Pacify ``unused variable'' warnings. */
2635 (void) yyvaluep;
Reid Spencer3822ff52006-11-08 06:47:33 +00002636
Andrew Lenharth6353e052006-12-08 18:07:09 +00002637 if (yytype < YYNTOKENS)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002638 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
Andrew Lenharth6353e052006-12-08 18:07:09 +00002639 else
2640 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2641
Reid Spencere4d87aa2006-12-23 06:05:41 +00002642
2643# ifdef YYPRINT
2644 if (yytype < YYNTOKENS)
2645 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2646# endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00002647 switch (yytype)
2648 {
2649 default:
2650 break;
2651 }
2652 YYFPRINTF (yyoutput, ")");
2653}
2654
2655#endif /* ! YYDEBUG */
2656/*-----------------------------------------------.
2657| Release the memory associated to this symbol. |
2658`-----------------------------------------------*/
2659
2660#if defined (__STDC__) || defined (__cplusplus)
2661static void
Reid Spencere4d87aa2006-12-23 06:05:41 +00002662yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002663#else
2664static void
Reid Spencere4d87aa2006-12-23 06:05:41 +00002665yydestruct (yymsg, yytype, yyvaluep)
2666 const char *yymsg;
Andrew Lenharth6353e052006-12-08 18:07:09 +00002667 int yytype;
2668 YYSTYPE *yyvaluep;
2669#endif
2670{
2671 /* Pacify ``unused variable'' warnings. */
2672 (void) yyvaluep;
Reid Spencer3822ff52006-11-08 06:47:33 +00002673
Reid Spencere4d87aa2006-12-23 06:05:41 +00002674 if (!yymsg)
2675 yymsg = "Deleting";
2676 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2677
Reid Spencer3822ff52006-11-08 06:47:33 +00002678 switch (yytype)
2679 {
2680
2681 default:
Andrew Lenharth6353e052006-12-08 18:07:09 +00002682 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00002683 }
2684}
2685
2686
2687/* Prevent warnings from -Wmissing-prototypes. */
2688
2689#ifdef YYPARSE_PARAM
Andrew Lenharth6353e052006-12-08 18:07:09 +00002690# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002691int yyparse (void *YYPARSE_PARAM);
Andrew Lenharth6353e052006-12-08 18:07:09 +00002692# else
Reid Spencer3822ff52006-11-08 06:47:33 +00002693int yyparse ();
Andrew Lenharth6353e052006-12-08 18:07:09 +00002694# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002695#else /* ! YYPARSE_PARAM */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002696#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002697int yyparse (void);
Chris Lattnerf49c1762006-11-08 05:58:47 +00002698#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002699int yyparse ();
2700#endif
2701#endif /* ! YYPARSE_PARAM */
2702
2703
2704
Reid Spencere4d87aa2006-12-23 06:05:41 +00002705/* The look-ahead symbol. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002706int yychar;
2707
Reid Spencere4d87aa2006-12-23 06:05:41 +00002708/* The semantic value of the look-ahead symbol. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002709YYSTYPE yylval;
2710
2711/* Number of syntax errors so far. */
2712int yynerrs;
2713
2714
2715
2716/*----------.
2717| yyparse. |
2718`----------*/
2719
2720#ifdef YYPARSE_PARAM
Andrew Lenharth6353e052006-12-08 18:07:09 +00002721# if defined (__STDC__) || defined (__cplusplus)
2722int yyparse (void *YYPARSE_PARAM)
2723# else
2724int yyparse (YYPARSE_PARAM)
2725 void *YYPARSE_PARAM;
2726# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002727#else /* ! YYPARSE_PARAM */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002728#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002729int
2730yyparse (void)
2731#else
2732int
2733yyparse ()
2734
2735#endif
2736#endif
2737{
2738
Reid Spencere4d87aa2006-12-23 06:05:41 +00002739 int yystate;
2740 int yyn;
Reid Spencer3822ff52006-11-08 06:47:33 +00002741 int yyresult;
2742 /* Number of tokens to shift before error messages enabled. */
2743 int yyerrstatus;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002744 /* Look-ahead token as an internal (translated) token number. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002745 int yytoken = 0;
2746
2747 /* Three stacks and their tools:
2748 `yyss': related to states,
2749 `yyvs': related to semantic values,
2750 `yyls': related to locations.
2751
2752 Refer to the stacks thru separate pointers, to allow yyoverflow
2753 to reallocate them elsewhere. */
2754
2755 /* The state stack. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00002756 short int yyssa[YYINITDEPTH];
2757 short int *yyss = yyssa;
2758 short int *yyssp;
Reid Spencer3822ff52006-11-08 06:47:33 +00002759
2760 /* The semantic value stack. */
2761 YYSTYPE yyvsa[YYINITDEPTH];
2762 YYSTYPE *yyvs = yyvsa;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002763 YYSTYPE *yyvsp;
Reid Spencer3822ff52006-11-08 06:47:33 +00002764
2765
2766
Andrew Lenharth6353e052006-12-08 18:07:09 +00002767#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002768
Reid Spencer3822ff52006-11-08 06:47:33 +00002769 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002770
Reid Spencer3822ff52006-11-08 06:47:33 +00002771 /* The variables used to return semantic value and location from the
2772 action routines. */
2773 YYSTYPE yyval;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002774
2775
Andrew Lenharth6353e052006-12-08 18:07:09 +00002776 /* When reducing, the number of symbols on the RHS of the reduced
2777 rule. */
2778 int yylen;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002779
Reid Spencer3822ff52006-11-08 06:47:33 +00002780 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002781
Reid Spencer68a24bd2005-08-27 18:50:39 +00002782 yystate = 0;
2783 yyerrstatus = 0;
2784 yynerrs = 0;
2785 yychar = YYEMPTY; /* Cause a token to be read. */
2786
2787 /* Initialize stack pointers.
2788 Waste one element of value and location stack
2789 so that they stay on the same level as the state stack.
2790 The wasted elements are never initialized. */
2791
Reid Spencer3822ff52006-11-08 06:47:33 +00002792 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002793 yyvsp = yyvs;
2794
Reid Spencer3822ff52006-11-08 06:47:33 +00002795 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002796
Reid Spencer3822ff52006-11-08 06:47:33 +00002797/*------------------------------------------------------------.
2798| yynewstate -- Push a new state, which is found in yystate. |
2799`------------------------------------------------------------*/
2800 yynewstate:
2801 /* In all cases, when you get here, the value and location stacks
Andrew Lenharth6353e052006-12-08 18:07:09 +00002802 have just been pushed. so pushing a state here evens the stacks.
2803 */
Reid Spencer3822ff52006-11-08 06:47:33 +00002804 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002805
Reid Spencer3822ff52006-11-08 06:47:33 +00002806 yysetstate:
2807 *yyssp = yystate;
2808
2809 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002810 {
2811 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002812 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002813
2814#ifdef yyoverflow
Reid Spencer3822ff52006-11-08 06:47:33 +00002815 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00002816 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer3822ff52006-11-08 06:47:33 +00002817 these so that the &'s don't force the real ones into
2818 memory. */
2819 YYSTYPE *yyvs1 = yyvs;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002820 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002821
Reid Spencer3822ff52006-11-08 06:47:33 +00002822
2823 /* Each stack pointer address is followed by the size of the
2824 data in use in that stack, in bytes. This used to be a
2825 conditional around just the two extra args, but that might
2826 be undefined if yyoverflow is a macro. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00002827 yyoverflow (YY_("memory exhausted"),
Reid Spencer3822ff52006-11-08 06:47:33 +00002828 &yyss1, yysize * sizeof (*yyssp),
2829 &yyvs1, yysize * sizeof (*yyvsp),
2830
2831 &yystacksize);
2832
2833 yyss = yyss1;
2834 yyvs = yyvs1;
2835 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002836#else /* no yyoverflow */
Reid Spencer3822ff52006-11-08 06:47:33 +00002837# ifndef YYSTACK_RELOCATE
Reid Spencere4d87aa2006-12-23 06:05:41 +00002838 goto yyexhaustedlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00002839# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002840 /* Extend the stack our own way. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002841 if (YYMAXDEPTH <= yystacksize)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002842 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002843 yystacksize *= 2;
Reid Spencer3822ff52006-11-08 06:47:33 +00002844 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002845 yystacksize = YYMAXDEPTH;
Reid Spencer3822ff52006-11-08 06:47:33 +00002846
2847 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00002848 short int *yyss1 = yyss;
Reid Spencer3822ff52006-11-08 06:47:33 +00002849 union yyalloc *yyptr =
2850 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2851 if (! yyptr)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002852 goto yyexhaustedlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00002853 YYSTACK_RELOCATE (yyss);
2854 YYSTACK_RELOCATE (yyvs);
2855
2856# undef YYSTACK_RELOCATE
2857 if (yyss1 != yyssa)
2858 YYSTACK_FREE (yyss1);
2859 }
2860# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002861#endif /* no yyoverflow */
2862
Reid Spencer3822ff52006-11-08 06:47:33 +00002863 yyssp = yyss + yysize - 1;
2864 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002865
2866
Reid Spencer3822ff52006-11-08 06:47:33 +00002867 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2868 (unsigned long int) yystacksize));
2869
2870 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002871 YYABORT;
2872 }
2873
Reid Spencer3822ff52006-11-08 06:47:33 +00002874 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002875
2876 goto yybackup;
Reid Spencer3822ff52006-11-08 06:47:33 +00002877
2878/*-----------.
2879| yybackup. |
2880`-----------*/
2881yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002882
Andrew Lenharth6353e052006-12-08 18:07:09 +00002883/* Do appropriate processing given the current state. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00002884/* Read a look-ahead token if we need one and don't already have one. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002885/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002886
Reid Spencere4d87aa2006-12-23 06:05:41 +00002887 /* First try to decide what to do without reference to look-ahead token. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002888
Reid Spencer68a24bd2005-08-27 18:50:39 +00002889 yyn = yypact[yystate];
Reid Spencer3822ff52006-11-08 06:47:33 +00002890 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002891 goto yydefault;
2892
Reid Spencere4d87aa2006-12-23 06:05:41 +00002893 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002894
Reid Spencere4d87aa2006-12-23 06:05:41 +00002895 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002896 if (yychar == YYEMPTY)
2897 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002898 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002899 yychar = YYLEX;
2900 }
2901
Reid Spencer3822ff52006-11-08 06:47:33 +00002902 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002903 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002904 yychar = yytoken = YYEOF;
2905 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002906 }
2907 else
2908 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002909 yytoken = YYTRANSLATE (yychar);
Reid Spencere4d87aa2006-12-23 06:05:41 +00002910 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002911 }
2912
Reid Spencer3822ff52006-11-08 06:47:33 +00002913 /* If the proper action on seeing token YYTOKEN is to reduce or to
2914 detect an error, take that action. */
2915 yyn += yytoken;
2916 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002917 goto yydefault;
2918 yyn = yytable[yyn];
Reid Spencer3822ff52006-11-08 06:47:33 +00002919 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002920 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002921 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002922 goto yyerrlab;
2923 yyn = -yyn;
2924 goto yyreduce;
2925 }
2926
2927 if (yyn == YYFINAL)
2928 YYACCEPT;
2929
Reid Spencere4d87aa2006-12-23 06:05:41 +00002930 /* Shift the look-ahead token. */
2931 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Andrew Lenharth6353e052006-12-08 18:07:09 +00002932
2933 /* Discard the token being shifted unless it is eof. */
2934 if (yychar != YYEOF)
2935 yychar = YYEMPTY;
2936
2937 *++yyvsp = yylval;
2938
2939
Reid Spencer3822ff52006-11-08 06:47:33 +00002940 /* Count tokens shifted since error; after three, turn off error
2941 status. */
2942 if (yyerrstatus)
2943 yyerrstatus--;
Chris Lattner224f84f2006-08-18 17:34:45 +00002944
Reid Spencer68a24bd2005-08-27 18:50:39 +00002945 yystate = yyn;
2946 goto yynewstate;
2947
Chris Lattnerf49c1762006-11-08 05:58:47 +00002948
Reid Spencer3822ff52006-11-08 06:47:33 +00002949/*-----------------------------------------------------------.
2950| yydefault -- do the default action for the current state. |
2951`-----------------------------------------------------------*/
2952yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002953 yyn = yydefact[yystate];
2954 if (yyn == 0)
2955 goto yyerrlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00002956 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002957
Reid Spencer3822ff52006-11-08 06:47:33 +00002958
2959/*-----------------------------.
2960| yyreduce -- Do a reduction. |
2961`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002962yyreduce:
Reid Spencer3822ff52006-11-08 06:47:33 +00002963 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002964 yylen = yyr2[yyn];
2965
Reid Spencer3822ff52006-11-08 06:47:33 +00002966 /* If YYLEN is nonzero, implement the default value of the action:
2967 `$$ = $1'.
2968
2969 Otherwise, the following line sets YYVAL to garbage.
2970 This behavior is undocumented and Bison
2971 users should not rely upon it. Assigning to YYVAL
2972 unconditionally makes the parser a bit smaller, and it avoids a
2973 GCC warning that YYVAL may be used uninitialized. */
2974 yyval = yyvsp[1-yylen];
2975
2976
2977 YY_REDUCE_PRINT (yyn);
2978 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002979 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002980 case 3:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002981#line 990 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00002982 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00002983 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00002984 GEN_ERROR("Value too large for type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00002985 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00002986 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00002987;}
2988 break;
2989
Reid Spencere4d87aa2006-12-23 06:05:41 +00002990 case 31:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002991#line 1006 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00002992 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
2993 break;
2994
2995 case 32:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002996#line 1006 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00002997 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
2998 break;
2999
3000 case 33:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003001#line 1007 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003002 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3003 break;
3004
3005 case 34:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003006#line 1007 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003007 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3008 break;
3009
3010 case 35:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003011#line 1008 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003012 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3013 break;
3014
3015 case 36:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003016#line 1008 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003017 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3018 break;
3019
3020 case 37:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003021#line 1009 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003022 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3023 break;
3024
3025 case 38:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003026#line 1009 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003027 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003028 break;
3029
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003030 case 39:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003031#line 1010 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003032 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003033 break;
3034
3035 case 40:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003036#line 1010 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003037 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003038 break;
3039
3040 case 41:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003041#line 1014 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003042 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003043 break;
3044
3045 case 42:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003046#line 1014 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003047 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003048 break;
3049
3050 case 43:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003051#line 1015 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003052 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003053 break;
3054
3055 case 44:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003056#line 1015 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003057 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003058 break;
3059
3060 case 45:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003061#line 1016 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003062 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003063 break;
3064
3065 case 46:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003066#line 1016 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003067 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003068 break;
3069
3070 case 47:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003071#line 1017 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003072 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003073 break;
3074
3075 case 48:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003076#line 1017 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003077 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003078 break;
3079
3080 case 49:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003081#line 1018 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003082 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003083 break;
3084
3085 case 50:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003086#line 1018 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003087 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003088 break;
3089
3090 case 51:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003091#line 1019 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003092 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003093 break;
3094
3095 case 52:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003096#line 1019 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003097 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003098 break;
3099
3100 case 53:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003101#line 1020 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003102 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003103 break;
3104
3105 case 54:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003106#line 1020 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003107 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003108 break;
3109
3110 case 55:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003111#line 1021 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003112 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003113 break;
3114
3115 case 56:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003116#line 1022 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003117 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003118 break;
3119
Reid Spencere4d87aa2006-12-23 06:05:41 +00003120 case 69:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003121#line 1033 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003122 {
3123 (yyval.StrVal) = (yyvsp[-1].StrVal);
3124 CHECK_FOR_ERROR
3125 ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003126 break;
3127
Reid Spencere4d87aa2006-12-23 06:05:41 +00003128 case 70:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003129#line 1037 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003130 {
3131 (yyval.StrVal) = 0;
3132 CHECK_FOR_ERROR
3133 ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003134 break;
3135
Reid Spencere4d87aa2006-12-23 06:05:41 +00003136 case 71:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003137#line 1043 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003138 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003139 break;
3140
Reid Spencere4d87aa2006-12-23 06:05:41 +00003141 case 72:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003142#line 1044 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003143 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003144 break;
3145
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003146 case 73:
3147#line 1045 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3148 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3149 break;
3150
Reid Spencere4d87aa2006-12-23 06:05:41 +00003151 case 74:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003152#line 1046 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003153 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003154 break;
3155
Reid Spencere4d87aa2006-12-23 06:05:41 +00003156 case 75:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003157#line 1047 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003158 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003159 break;
3160
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003161 case 76:
3162#line 1051 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3163 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3164 break;
3165
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003166 case 77:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003167#line 1052 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003168 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003169 break;
3170
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003171 case 78:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003172#line 1053 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003173 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003174 break;
3175
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003176 case 79:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003177#line 1057 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3178 { /*default*/ ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003179 break;
3180
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003181 case 80:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003182#line 1058 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3183 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003184 break;
3185
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003186 case 81:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003187#line 1059 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3188 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003189 break;
3190
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003191 case 82:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003192#line 1063 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3193 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003194 break;
3195
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003196 case 83:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003197#line 1064 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3198 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003199 break;
3200
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003201 case 84:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003202#line 1065 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3203 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003204 break;
3205
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003206 case 85:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003207#line 1066 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3208 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003209 break;
3210
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003211 case 86:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003212#line 1067 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3213 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3214 break;
3215
3216 case 87:
3217#line 1070 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3218 { (yyval.UIntVal) = CallingConv::C; ;}
3219 break;
3220
3221 case 88:
3222#line 1071 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3223 { (yyval.UIntVal) = CallingConv::C; ;}
3224 break;
3225
3226 case 89:
3227#line 1072 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3228 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3229 break;
3230
3231 case 90:
3232#line 1073 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3233 { (yyval.UIntVal) = CallingConv::Fast; ;}
3234 break;
3235
3236 case 91:
3237#line 1074 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3238 { (yyval.UIntVal) = CallingConv::Cold; ;}
3239 break;
3240
3241 case 92:
3242#line 1075 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3243 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3244 break;
3245
3246 case 93:
3247#line 1076 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3248 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3249 break;
3250
3251 case 94:
3252#line 1077 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003253 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003254 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003255 GEN_ERROR("Calling conv too large!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003256 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003257 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003258 ;}
3259 break;
3260
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003261 case 95:
3262#line 1086 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003263 { (yyval.UIntVal) = 0; ;}
3264 break;
3265
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003266 case 96:
3267#line 1087 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003268 {
3269 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3270 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3271 GEN_ERROR("Alignment must be a power of two!");
3272 CHECK_FOR_ERROR
3273;}
3274 break;
3275
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003276 case 97:
3277#line 1093 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003278 { (yyval.UIntVal) = 0; ;}
3279 break;
3280
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003281 case 98:
3282#line 1094 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003283 {
3284 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3285 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3286 GEN_ERROR("Alignment must be a power of two!");
3287 CHECK_FOR_ERROR
3288;}
3289 break;
3290
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003291 case 99:
3292#line 1102 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003293 {
3294 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3295 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
3296 GEN_ERROR("Invalid character in section name!");
3297 (yyval.StrVal) = (yyvsp[0].StrVal);
3298 CHECK_FOR_ERROR
3299;}
3300 break;
3301
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003302 case 100:
3303#line 1110 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003304 { (yyval.StrVal) = 0; ;}
3305 break;
3306
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003307 case 101:
3308#line 1111 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003309 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3310 break;
3311
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003312 case 102:
3313#line 1116 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003314 {;}
3315 break;
3316
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003317 case 103:
3318#line 1117 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003319 {;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003320 break;
3321
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003322 case 104:
3323#line 1118 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003324 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003325 CurGV->setSection((yyvsp[0].StrVal));
3326 free((yyvsp[0].StrVal));
3327 CHECK_FOR_ERROR
3328 ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003329 break;
3330
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003331 case 105:
3332#line 1123 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003333 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003334 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
3335 GEN_ERROR("Alignment must be a power of two!");
3336 CurGV->setAlignment((yyvsp[0].UInt64Val));
3337 CHECK_FOR_ERROR
3338 ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003339 break;
3340
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003341 case 107:
3342#line 1137 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003343 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003344 break;
3345
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003346 case 109:
3347#line 1138 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003348 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003349 break;
3350
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003351 case 110:
3352#line 1140 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003353 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003354 if (!UpRefs.empty())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003355 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3356 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003357 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003358 ;}
3359 break;
3360
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003361 case 123:
3362#line 1152 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003363 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003364 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencera132e042006-12-03 05:46:11 +00003365 CHECK_FOR_ERROR
3366 ;}
3367 break;
3368
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003369 case 124:
3370#line 1156 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003371 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003372 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencera132e042006-12-03 05:46:11 +00003373 CHECK_FOR_ERROR
3374 ;}
3375 break;
3376
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003377 case 125:
3378#line 1160 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003379 { // Named types are also simple types...
Reid Spencere4d87aa2006-12-23 06:05:41 +00003380 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer3da59db2006-11-27 01:05:10 +00003381 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00003382 (yyval.TypeVal) = new PATypeHolder(tmp);
Reid Spencer3da59db2006-11-27 01:05:10 +00003383;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003384 break;
3385
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003386 case 126:
3387#line 1168 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003388 { // Type UpReference
Reid Spencere4d87aa2006-12-23 06:05:41 +00003389 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer3da59db2006-11-27 01:05:10 +00003390 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencere4d87aa2006-12-23 06:05:41 +00003391 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3392 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer3da59db2006-11-27 01:05:10 +00003393 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003394 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003395 ;}
3396 break;
3397
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003398 case 127:
3399#line 1176 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003400 { // Function derived type?
3401 std::vector<const Type*> Params;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003402 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3403 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00003404 Params.push_back(*I);
Reid Spencer3da59db2006-11-27 01:05:10 +00003405 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3406 if (isVarArg) Params.pop_back();
3407
Reid Spencere4d87aa2006-12-23 06:05:41 +00003408 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg)));
3409 delete (yyvsp[-1].TypeList); // Delete the argument list
3410 delete (yyvsp[-3].TypeVal); // Delete the return type handle
3411 CHECK_FOR_ERROR
3412 ;}
3413 break;
3414
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003415 case 128:
3416#line 1189 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003417 { // Sized array type?
3418 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3419 delete (yyvsp[-1].TypeVal);
3420 CHECK_FOR_ERROR
3421 ;}
3422 break;
3423
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003424 case 129:
3425#line 1194 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003426 { // Packed array type?
3427 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3428 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
3429 GEN_ERROR("Unsigned result not equal to signed result");
3430 if (!ElemTy->isPrimitiveType())
3431 GEN_ERROR("Elemental type of a PackedType must be primitive");
3432 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
3433 GEN_ERROR("Vector length should be a power of 2!");
3434 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3435 delete (yyvsp[-1].TypeVal);
3436 CHECK_FOR_ERROR
3437 ;}
3438 break;
3439
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003440 case 130:
3441#line 1206 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003442 { // Structure type?
3443 std::vector<const Type*> Elements;
3444 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3445 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
3446 Elements.push_back(*I);
3447
3448 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3449 delete (yyvsp[-1].TypeList);
3450 CHECK_FOR_ERROR
3451 ;}
3452 break;
3453
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003454 case 131:
3455#line 1216 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003456 { // Empty structure type?
3457 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
3458 CHECK_FOR_ERROR
3459 ;}
3460 break;
3461
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003462 case 132:
3463#line 1220 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003464 {
3465 std::vector<const Type*> Elements;
3466 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3467 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
3468 Elements.push_back(*I);
3469
3470 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3471 delete (yyvsp[-2].TypeList);
3472 CHECK_FOR_ERROR
3473 ;}
3474 break;
3475
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003476 case 133:
3477#line 1230 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003478 { // Empty structure type?
3479 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
3480 CHECK_FOR_ERROR
3481 ;}
3482 break;
3483
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003484 case 134:
3485#line 1234 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003486 { // Pointer type?
3487 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
3488 GEN_ERROR("Cannot form a pointer to a basic block");
3489 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3490 delete (yyvsp[-1].TypeVal);
3491 CHECK_FOR_ERROR
3492 ;}
3493 break;
3494
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003495 case 135:
3496#line 1245 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003497 {
3498 (yyval.TypeList) = new std::list<PATypeHolder>();
3499 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003500 CHECK_FOR_ERROR
3501 ;}
3502 break;
3503
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003504 case 136:
3505#line 1250 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003506 {
3507 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003508 CHECK_FOR_ERROR
3509 ;}
3510 break;
3511
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003512 case 138:
3513#line 1257 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003514 {
3515 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy);
Reid Spencer3da59db2006-11-27 01:05:10 +00003516 CHECK_FOR_ERROR
3517 ;}
3518 break;
3519
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003520 case 139:
3521#line 1261 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003522 {
3523 ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Reid Spencer3da59db2006-11-27 01:05:10 +00003524 CHECK_FOR_ERROR
3525 ;}
3526 break;
3527
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003528 case 140:
3529#line 1265 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003530 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003531 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer3da59db2006-11-27 01:05:10 +00003532 CHECK_FOR_ERROR
3533 ;}
3534 break;
3535
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003536 case 141:
3537#line 1276 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003538 { // Nonempty unsized arr
3539 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
3540 if (ATy == 0)
3541 GEN_ERROR("Cannot make array constant with type: '" +
3542 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
3543 const Type *ETy = ATy->getElementType();
3544 int NumElements = ATy->getNumElements();
3545
3546 // Verify that we have the correct size...
3547 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
3548 GEN_ERROR("Type mismatch: constant sized array initialized with " +
3549 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
3550 itostr(NumElements) + "!");
3551
3552 // Verify all elements are correct type!
3553 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3554 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
3555 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3556 ETy->getDescription() +"' as required!\nIt is of type '"+
3557 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
3558 }
3559
3560 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3561 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer3da59db2006-11-27 01:05:10 +00003562 CHECK_FOR_ERROR
3563 ;}
3564 break;
3565
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003566 case 142:
3567#line 1302 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003568 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003569 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003570 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003571 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003572 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003573
Andrew Lenharth6353e052006-12-08 18:07:09 +00003574 int NumElements = ATy->getNumElements();
3575 if (NumElements != -1 && NumElements != 0)
3576 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
3577 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003578 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3579 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003580 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003581 ;}
3582 break;
3583
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003584 case 143:
3585#line 1316 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003586 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003587 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003588 if (ATy == 0)
3589 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003590 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003591
Andrew Lenharth6353e052006-12-08 18:07:09 +00003592 int NumElements = ATy->getNumElements();
3593 const Type *ETy = ATy->getElementType();
Reid Spencere4d87aa2006-12-23 06:05:41 +00003594 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3595 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003596 GEN_ERROR("Can't build string constant of size " +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003597 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Andrew Lenharth6353e052006-12-08 18:07:09 +00003598 " when array has size " + itostr(NumElements) + "!");
3599 std::vector<Constant*> Vals;
3600 if (ETy == Type::SByteTy) {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003601 for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C)
Andrew Lenharth6353e052006-12-08 18:07:09 +00003602 Vals.push_back(ConstantInt::get(ETy, *C));
3603 } else if (ETy == Type::UByteTy) {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003604 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003605 C != (unsigned char*)EndStr; ++C)
3606 Vals.push_back(ConstantInt::get(ETy, *C));
3607 } else {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003608 free((yyvsp[0].StrVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00003609 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
3610 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00003611 free((yyvsp[0].StrVal));
3612 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3613 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003614 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003615 ;}
3616 break;
3617
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003618 case 144:
3619#line 1346 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003620 { // Nonempty unsized arr
Reid Spencere4d87aa2006-12-23 06:05:41 +00003621 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003622 if (PTy == 0)
3623 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003624 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003625 const Type *ETy = PTy->getElementType();
3626 int NumElements = PTy->getNumElements();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003627
Andrew Lenharth6353e052006-12-08 18:07:09 +00003628 // Verify that we have the correct size...
Reid Spencere4d87aa2006-12-23 06:05:41 +00003629 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003630 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003631 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Andrew Lenharth6353e052006-12-08 18:07:09 +00003632 itostr(NumElements) + "!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003633
Andrew Lenharth6353e052006-12-08 18:07:09 +00003634 // Verify all elements are correct type!
Reid Spencere4d87aa2006-12-23 06:05:41 +00003635 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3636 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003637 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3638 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencere4d87aa2006-12-23 06:05:41 +00003639 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003640 }
3641
Reid Spencere4d87aa2006-12-23 06:05:41 +00003642 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3643 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003644 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003645 ;}
3646 break;
3647
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003648 case 145:
3649#line 1372 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003650 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003651 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003652 if (STy == 0)
3653 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003654 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003655
Reid Spencere4d87aa2006-12-23 06:05:41 +00003656 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003657 GEN_ERROR("Illegal number of initializers for structure type!");
3658
3659 // Check to ensure that constants are compatible with the type initializer!
Reid Spencere4d87aa2006-12-23 06:05:41 +00003660 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3661 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003662 GEN_ERROR("Expected type '" +
3663 STy->getElementType(i)->getDescription() +
3664 "' for element #" + utostr(i) +
3665 " of structure initializer!");
3666
Reid Spencere4d87aa2006-12-23 06:05:41 +00003667 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3668 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003669 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003670 ;}
3671 break;
3672
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003673 case 146:
3674#line 1393 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003675 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003676 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003677 if (STy == 0)
3678 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003679 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003680
3681 if (STy->getNumContainedTypes() != 0)
3682 GEN_ERROR("Illegal number of initializers for structure type!");
3683
Reid Spencere4d87aa2006-12-23 06:05:41 +00003684 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3685 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003686 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003687 ;}
3688 break;
3689
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003690 case 147:
3691#line 1406 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003692 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003693 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003694 if (PTy == 0)
3695 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003696 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003697
Reid Spencere4d87aa2006-12-23 06:05:41 +00003698 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3699 delete (yyvsp[-1].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003700 CHECK_FOR_ERROR
3701 ;}
3702 break;
3703
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003704 case 148:
3705#line 1416 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003706 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003707 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3708 delete (yyvsp[-1].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003709 CHECK_FOR_ERROR
3710 ;}
3711 break;
3712
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003713 case 149:
3714#line 1421 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003715 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003716 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003717 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003718 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003719
3720 // ConstExprs can exist in the body of a function, thus creating
3721 // GlobalValues whenever they refer to a variable. Because we are in
3722 // the context of a function, getValNonImprovising will search the functions
3723 // symbol table instead of the module symbol table for the global symbol,
3724 // which throws things all off. To get around this, we just tell
3725 // getValNonImprovising that we are at global scope here.
3726 //
3727 Function *SavedCurFn = CurFun.CurrentFunction;
3728 CurFun.CurrentFunction = 0;
3729
Reid Spencere4d87aa2006-12-23 06:05:41 +00003730 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003731 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003732
3733 CurFun.CurrentFunction = SavedCurFn;
3734
3735 // If this is an initializer for a constant pointer, which is referencing a
3736 // (currently) undefined variable, create a stub now that shall be replaced
3737 // in the future with the right type of variable.
3738 //
3739 if (V == 0) {
3740 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3741 const PointerType *PT = cast<PointerType>(Ty);
3742
3743 // First check to see if the forward references value is already created!
3744 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencere4d87aa2006-12-23 06:05:41 +00003745 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003746
3747 if (I != CurModule.GlobalRefs.end()) {
3748 V = I->second; // Placeholder already exists, use it...
Reid Spencere4d87aa2006-12-23 06:05:41 +00003749 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003750 } else {
3751 std::string Name;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003752 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003753
3754 // Create the forward referenced global.
3755 GlobalValue *GV;
3756 if (const FunctionType *FTy =
3757 dyn_cast<FunctionType>(PT->getElementType())) {
3758 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3759 CurModule.CurrentModule);
3760 } else {
3761 GV = new GlobalVariable(PT->getElementType(), false,
3762 GlobalValue::ExternalLinkage, 0,
3763 Name, CurModule.CurrentModule);
3764 }
3765
3766 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencere4d87aa2006-12-23 06:05:41 +00003767 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003768 V = GV;
3769 }
3770 }
3771
Reid Spencere4d87aa2006-12-23 06:05:41 +00003772 (yyval.ConstVal) = cast<GlobalValue>(V);
3773 delete (yyvsp[-1].TypeVal); // Free the type handle
3774 CHECK_FOR_ERROR
3775 ;}
3776 break;
3777
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003778 case 150:
3779#line 1482 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003780 {
3781 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
3782 GEN_ERROR("Mismatched types for constant expression!");
3783 (yyval.ConstVal) = (yyvsp[0].ConstVal);
3784 delete (yyvsp[-1].TypeVal);
3785 CHECK_FOR_ERROR
3786 ;}
3787 break;
3788
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003789 case 151:
3790#line 1489 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003791 {
3792 const Type *Ty = (yyvsp[-1].TypeVal)->get();
3793 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3794 GEN_ERROR("Cannot create a null initialized value of this type!");
3795 (yyval.ConstVal) = Constant::getNullValue(Ty);
3796 delete (yyvsp[-1].TypeVal);
3797 CHECK_FOR_ERROR
3798 ;}
3799 break;
3800
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003801 case 152:
3802#line 1497 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003803 { // integral constants
3804 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
3805 GEN_ERROR("Constant value doesn't fit in type!");
3806 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
3807 CHECK_FOR_ERROR
3808 ;}
3809 break;
3810
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003811 case 153:
3812#line 1503 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003813 { // integral constants
3814 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
3815 GEN_ERROR("Constant value doesn't fit in type!");
3816 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
3817 CHECK_FOR_ERROR
3818 ;}
3819 break;
3820
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003821 case 154:
3822#line 1509 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003823 { // integral constants
3824 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
3825 GEN_ERROR("Constant value doesn't fit in type!");
3826 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
3827 CHECK_FOR_ERROR
3828 ;}
3829 break;
3830
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003831 case 155:
3832#line 1515 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003833 {
3834 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
3835 GEN_ERROR("Constant value doesn't fit in type!");
3836 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
3837 CHECK_FOR_ERROR
3838 ;}
3839 break;
3840
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003841 case 156:
3842#line 1521 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003843 { // Boolean constants
3844 (yyval.ConstVal) = ConstantBool::getTrue();
3845 CHECK_FOR_ERROR
3846 ;}
3847 break;
3848
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003849 case 157:
3850#line 1525 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003851 { // Boolean constants
3852 (yyval.ConstVal) = ConstantBool::getFalse();
Reid Spencer61c83e02006-08-18 08:43:06 +00003853 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003854 ;}
3855 break;
3856
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003857 case 158:
3858#line 1529 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003859 { // Float & Double constants
3860 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
3861 GEN_ERROR("Floating point constant invalid for type!!");
3862 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003863 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003864 ;}
3865 break;
3866
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003867 case 159:
3868#line 1537 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003869 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003870 Constant *Val = (yyvsp[-3].ConstVal);
3871 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer3da59db2006-11-27 01:05:10 +00003872 if (!Val->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003873 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003874 Val->getType()->getDescription() + "'!");
3875 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003876 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003877 Ty->getDescription() + "'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003878 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get());
3879 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00003880 ;}
3881 break;
3882
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003883 case 160:
3884#line 1549 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003885 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003886 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003887 GEN_ERROR("GetElementPtr requires a pointer operand!");
3888
3889 const Type *IdxTy =
Reid Spencere4d87aa2006-12-23 06:05:41 +00003890 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003891 if (!IdxTy)
3892 GEN_ERROR("Index list invalid for constant getelementptr!");
3893
3894 std::vector<Constant*> IdxVec;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003895 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
3896 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003897 IdxVec.push_back(C);
3898 else
3899 GEN_ERROR("Indices to constant getelementptr must be constants!");
3900
Reid Spencere4d87aa2006-12-23 06:05:41 +00003901 delete (yyvsp[-1].ValueList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003902
Reid Spencere4d87aa2006-12-23 06:05:41 +00003903 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
3904 CHECK_FOR_ERROR
3905 ;}
3906 break;
3907
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003908 case 161:
3909#line 1570 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003910 {
3911 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
3912 GEN_ERROR("Select condition must be of boolean type!");
3913 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3914 GEN_ERROR("Select operand types must match!");
3915 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3916 CHECK_FOR_ERROR
3917 ;}
3918 break;
3919
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003920 case 162:
3921#line 1578 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003922 {
3923 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3924 GEN_ERROR("Binary operator types must match!");
3925 CHECK_FOR_ERROR;
3926 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3927 ;}
3928 break;
3929
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003930 case 163:
3931#line 1584 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003932 {
3933 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3934 GEN_ERROR("Logical operator types must match!");
3935 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
3936 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
3937 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
3938 GEN_ERROR("Logical operator requires integral operands!");
3939 }
3940 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3941 CHECK_FOR_ERROR
3942 ;}
3943 break;
3944
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003945 case 164:
3946#line 1595 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003947 {
3948 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3949 GEN_ERROR("icmp operand types must match!");
3950 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3951 ;}
3952 break;
3953
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003954 case 165:
3955#line 1600 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003956 {
3957 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3958 GEN_ERROR("fcmp operand types must match!");
3959 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3960 ;}
3961 break;
3962
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003963 case 166:
3964#line 1605 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003965 {
3966 if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy)
3967 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
3968 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
3969 GEN_ERROR("Shift constant expression requires integer operand!");
3970 CHECK_FOR_ERROR;
3971 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00003972 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003973 ;}
3974 break;
3975
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003976 case 167:
3977#line 1614 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003978 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003979 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3980 GEN_ERROR("Invalid extractelement operands!");
3981 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003982 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003983 ;}
3984 break;
3985
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003986 case 168:
3987#line 1620 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003988 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003989 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3990 GEN_ERROR("Invalid insertelement operands!");
3991 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3992 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003993 ;}
3994 break;
3995
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003996 case 169:
3997#line 1626 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003998 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003999 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
4000 GEN_ERROR("Invalid shufflevector operands!");
4001 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004002 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00004003 ;}
4004 break;
4005
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004006 case 170:
4007#line 1635 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00004008 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004009 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004010 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00004011 ;}
4012 break;
4013
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004014 case 171:
4015#line 1639 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00004016 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004017 (yyval.ConstVector) = new std::vector<Constant*>();
4018 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
4019 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004020 ;}
4021 break;
4022
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004023 case 172:
4024#line 1647 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004025 { (yyval.BoolVal) = false; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004026 break;
4027
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004028 case 173:
4029#line 1647 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004030 { (yyval.BoolVal) = true; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004031 break;
4032
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004033 case 174:
4034#line 1658 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004035 {
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004036 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4037 CurModule.ModuleDone();
4038 CHECK_FOR_ERROR;
4039 ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004040 break;
4041
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004042 case 175:
4043#line 1663 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004044 {
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004045 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4046 CurModule.ModuleDone();
4047 CHECK_FOR_ERROR;
4048 ;}
4049 break;
4050
4051 case 178:
4052#line 1676 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4053 { CurFun.isDeclare = false ;}
4054 break;
4055
4056 case 179:
4057#line 1676 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4058 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004059 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004060 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004061 ;}
4062 break;
4063
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004064 case 180:
4065#line 1680 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4066 { CurFun.isDeclare = true; ;}
4067 break;
4068
4069 case 181:
4070#line 1680 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004071 {
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004072 CHECK_FOR_ERROR
4073 ;}
4074 break;
4075
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004076 case 182:
4077#line 1683 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004078 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00004079 CHECK_FOR_ERROR
4080 ;}
4081 break;
4082
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004083 case 183:
4084#line 1686 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004085 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004086 // Emit an error if there are any unresolved types left.
4087 if (!CurModule.LateResolveTypes.empty()) {
4088 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00004089 if (DID.Type == ValID::NameVal) {
4090 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4091 } else {
4092 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4093 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004094 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004095 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004096 ;}
4097 break;
4098
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004099 case 184:
4100#line 1698 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004101 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004102 // Eagerly resolve types. This is not an optimization, this is a
4103 // requirement that is due to the fact that we could have this:
4104 //
4105 // %list = type { %list * }
4106 // %list = type { %list * } ; repeated type decl
4107 //
4108 // If types are not resolved eagerly, then the two types will not be
4109 // determined to be the same type!
4110 //
Reid Spencere4d87aa2006-12-23 06:05:41 +00004111 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004112
Reid Spencere4d87aa2006-12-23 06:05:41 +00004113 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004114 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004115 // If this is a named type that is not a redefinition, add it to the slot
4116 // table.
Reid Spencere4d87aa2006-12-23 06:05:41 +00004117 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004118 }
Reid Spencera132e042006-12-03 05:46:11 +00004119
Reid Spencere4d87aa2006-12-23 06:05:41 +00004120 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004121 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004122 ;}
4123 break;
4124
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004125 case 185:
4126#line 1720 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4127 { /* "Externally Visible" Linkage */
4128 if ((yyvsp[0].ConstVal) == 0)
4129 GEN_ERROR("Global value initializer is not a constant!");
4130 CurGV = ParseGlobalVariable((yyvsp[-2].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal),
4131 (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004132 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004133 ;}
4134 break;
4135
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004136 case 186:
4137#line 1726 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4138 {
4139 CurGV = 0;
Reid Spencer3822ff52006-11-08 06:47:33 +00004140 ;}
4141 break;
4142
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004143 case 187:
4144#line 1729 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004145 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004146 if ((yyvsp[0].ConstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004147 GEN_ERROR("Global value initializer is not a constant!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004148 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
4149 CHECK_FOR_ERROR
4150 ;}
4151 break;
4152
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004153 case 188:
4154#line 1734 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004155 {
4156 CurGV = 0;
4157 ;}
4158 break;
4159
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004160 case 189:
4161#line 1737 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004162 {
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004163 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004164 CHECK_FOR_ERROR
4165 delete (yyvsp[0].TypeVal);
4166 ;}
4167 break;
4168
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004169 case 190:
4170#line 1741 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004171 {
4172 CurGV = 0;
4173 CHECK_FOR_ERROR
4174 ;}
4175 break;
4176
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004177 case 191:
4178#line 1745 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004179 {
4180 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004181 ;}
4182 break;
4183
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004184 case 192:
4185#line 1748 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004186 {
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004187 CHECK_FOR_ERROR
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004188 ;}
4189 break;
4190
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004191 case 193:
4192#line 1754 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004193 {
Chris Lattner66316012006-01-24 04:14:29 +00004194 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencere4d87aa2006-12-23 06:05:41 +00004195 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4196 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4197 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004198
4199 if (AsmSoFar.empty())
4200 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4201 else
4202 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004203 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004204;}
4205 break;
4206
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004207 case 194:
4208#line 1767 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004209 { (yyval.Endianness) = Module::BigEndian; ;}
4210 break;
4211
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004212 case 195:
4213#line 1768 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004214 { (yyval.Endianness) = Module::LittleEndian; ;}
4215 break;
4216
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004217 case 196:
4218#line 1770 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004219 {
4220 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
4221 CHECK_FOR_ERROR
4222 ;}
4223 break;
4224
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004225 case 197:
4226#line 1774 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004227 {
4228 if ((yyvsp[0].UInt64Val) == 32)
4229 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
4230 else if ((yyvsp[0].UInt64Val) == 64)
4231 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4232 else
4233 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
4234 CHECK_FOR_ERROR
4235 ;}
4236 break;
4237
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004238 case 198:
4239#line 1783 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004240 {
4241 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4242 free((yyvsp[0].StrVal));
4243 ;}
4244 break;
4245
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004246 case 199:
4247#line 1787 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004248 {
4249 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4250 free((yyvsp[0].StrVal));
4251 ;}
4252 break;
4253
Reid Spencere4d87aa2006-12-23 06:05:41 +00004254 case 201:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004255#line 1794 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4256 {
4257 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4258 free((yyvsp[0].StrVal));
4259 CHECK_FOR_ERROR
4260 ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004261 break;
4262
4263 case 202:
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004264#line 1799 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4265 {
4266 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4267 free((yyvsp[0].StrVal));
4268 CHECK_FOR_ERROR
4269 ;}
4270 break;
4271
4272 case 203:
4273#line 1804 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4274 {
4275 CHECK_FOR_ERROR
4276 ;}
4277 break;
4278
4279 case 207:
4280#line 1814 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4281 { (yyval.StrVal) = 0; ;}
4282 break;
4283
4284 case 208:
4285#line 1816 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004286 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004287 if (*(yyvsp[-1].TypeVal) == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004288 GEN_ERROR("void typed arguments are invalid!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004289 (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004290 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004291;}
4292 break;
4293
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004294 case 209:
4295#line 1823 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004296 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004297 (yyval.ArgList) = (yyvsp[-2].ArgList);
4298 (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal));
4299 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004300 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004301 ;}
4302 break;
4303
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004304 case 210:
4305#line 1829 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004306 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004307 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4308 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4309 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004310 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004311 ;}
4312 break;
4313
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004314 case 211:
4315#line 1836 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004316 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004317 (yyval.ArgList) = (yyvsp[0].ArgList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004318 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004319 ;}
4320 break;
4321
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004322 case 212:
4323#line 1840 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004324 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004325 (yyval.ArgList) = (yyvsp[-2].ArgList);
4326 (yyval.ArgList)->push_back(std::pair<PATypeHolder*,
Andrew Lenharth6353e052006-12-08 18:07:09 +00004327 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004328 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004329 ;}
4330 break;
4331
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004332 case 213:
4333#line 1846 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004334 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004335 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4336 (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004337 CHECK_FOR_ERROR
4338 ;}
4339 break;
4340
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004341 case 214:
4342#line 1851 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004343 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004344 (yyval.ArgList) = 0;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004345 CHECK_FOR_ERROR
4346 ;}
4347 break;
4348
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004349 case 215:
4350#line 1857 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004351 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004352 UnEscapeLexed((yyvsp[-5].StrVal));
4353 std::string FunctionName((yyvsp[-5].StrVal));
4354 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004355
Reid Spencere4d87aa2006-12-23 06:05:41 +00004356 if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004357 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004358
4359 std::vector<const Type*> ParamTypeList;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004360 if ((yyvsp[-3].ArgList)) { // If there are arguments...
4361 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4362 I != (yyvsp[-3].ArgList)->end(); ++I)
Reid Spencera132e042006-12-03 05:46:11 +00004363 ParamTypeList.push_back(I->first->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004364 }
4365
4366 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4367 if (isVarArg) ParamTypeList.pop_back();
4368
Reid Spencere4d87aa2006-12-23 06:05:41 +00004369 const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004370 const PointerType *PFT = PointerType::get(FT);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004371 delete (yyvsp[-6].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004372
4373 ValID ID;
4374 if (!FunctionName.empty()) {
4375 ID = ValID::create((char*)FunctionName.c_str());
4376 } else {
4377 ID = ValID::create((int)CurModule.Values[PFT].size());
4378 }
4379
4380 Function *Fn = 0;
4381 // See if this function was forward referenced. If so, recycle the object.
4382 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4383 // Move the function to the end of the list, from whereever it was
4384 // previously inserted.
4385 Fn = cast<Function>(FWRef);
4386 CurModule.CurrentModule->getFunctionList().remove(Fn);
4387 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4388 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4389 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4390 // If this is the case, either we need to be a forward decl, or it needs
4391 // to be.
4392 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004393 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004394
4395 // Make sure to strip off any argument names so we can't get conflicts.
4396 if (Fn->isExternal())
4397 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4398 AI != AE; ++AI)
4399 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004400 } else { // Not already defined?
4401 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4402 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004403
Reid Spencer68a24bd2005-08-27 18:50:39 +00004404 InsertValue(Fn, CurModule.Values);
4405 }
4406
4407 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004408
4409 if (CurFun.isDeclare) {
4410 // If we have declaration, always overwrite linkage. This will allow us to
4411 // correctly handle cases, when pointer to function is passed as argument to
4412 // another function.
4413 Fn->setLinkage(CurFun.Linkage);
4414 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00004415 Fn->setCallingConv((yyvsp[-7].UIntVal));
4416 Fn->setAlignment((yyvsp[0].UIntVal));
4417 if ((yyvsp[-1].StrVal)) {
4418 Fn->setSection((yyvsp[-1].StrVal));
4419 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004420 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004421
4422 // Add all of the arguments we parsed to the function...
Reid Spencere4d87aa2006-12-23 06:05:41 +00004423 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004424 if (isVarArg) { // Nuke the last entry
Reid Spencere4d87aa2006-12-23 06:05:41 +00004425 assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&&
Reid Spencera132e042006-12-03 05:46:11 +00004426 "Not a varargs marker!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004427 delete (yyvsp[-3].ArgList)->back().first;
4428 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004429 }
4430 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencere4d87aa2006-12-23 06:05:41 +00004431 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4432 I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencera132e042006-12-03 05:46:11 +00004433 delete I->first; // Delete the typeholder...
4434
Reid Spencer68a24bd2005-08-27 18:50:39 +00004435 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004436 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004437 InsertValue(ArgIt);
4438 }
Reid Spencera132e042006-12-03 05:46:11 +00004439
Reid Spencere4d87aa2006-12-23 06:05:41 +00004440 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004441 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004442 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004443;}
4444 break;
4445
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004446 case 218:
4447#line 1953 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004448 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004449 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004450
4451 // Make sure that we keep track of the linkage type even if there was a
4452 // previous "declare".
Reid Spencere4d87aa2006-12-23 06:05:41 +00004453 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
Reid Spencer3822ff52006-11-08 06:47:33 +00004454;}
4455 break;
4456
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004457 case 221:
4458#line 1963 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004459 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004460 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004461 CHECK_FOR_ERROR
4462;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004463 break;
4464
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004465 case 222:
4466#line 1968 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004467 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004468 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004469 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004470 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004471 ;}
4472 break;
4473
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004474 case 223:
4475#line 1978 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004476 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004477 (yyval.BoolVal) = false;
4478 CHECK_FOR_ERROR
4479 ;}
4480 break;
4481
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004482 case 224:
4483#line 1982 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004484 {
4485 (yyval.BoolVal) = true;
4486 CHECK_FOR_ERROR
4487 ;}
4488 break;
4489
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004490 case 225:
4491#line 1987 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004492 { // A reference to a direct constant
4493 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
4494 CHECK_FOR_ERROR
4495 ;}
4496 break;
4497
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004498 case 226:
4499#line 1991 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004500 {
4501 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
4502 CHECK_FOR_ERROR
4503 ;}
4504 break;
4505
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004506 case 227:
4507#line 1995 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004508 { // Perhaps it's an FP constant?
4509 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
4510 CHECK_FOR_ERROR
4511 ;}
4512 break;
4513
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004514 case 228:
4515#line 1999 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004516 {
4517 (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue());
4518 CHECK_FOR_ERROR
4519 ;}
4520 break;
4521
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004522 case 229:
4523#line 2003 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004524 {
4525 (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse());
4526 CHECK_FOR_ERROR
4527 ;}
4528 break;
4529
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004530 case 230:
4531#line 2007 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004532 {
4533 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004534 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004535 ;}
4536 break;
4537
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004538 case 231:
4539#line 2011 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004540 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004541 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004542 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004543 ;}
4544 break;
4545
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004546 case 232:
4547#line 2015 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004548 { // A vector zero constant.
4549 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004550 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004551 ;}
4552 break;
4553
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004554 case 233:
4555#line 2019 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004556 { // Nonempty unsized packed vector
Reid Spencere4d87aa2006-12-23 06:05:41 +00004557 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4558 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004559
4560 PackedType* pt = PackedType::get(ETy, NumElements);
4561 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004562 HandleUpRefs(
4563 PackedType::get(
4564 ETy,
4565 NumElements)
4566 )
4567 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004568
4569 // Verify all elements are correct type!
Reid Spencere4d87aa2006-12-23 06:05:41 +00004570 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4571 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004572 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004573 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00004574 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004575 }
4576
Reid Spencere4d87aa2006-12-23 06:05:41 +00004577 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4578 delete PTy; delete (yyvsp[-1].ConstVector);
4579 CHECK_FOR_ERROR
4580 ;}
4581 break;
4582
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004583 case 234:
4584#line 2044 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004585 {
4586 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
4587 CHECK_FOR_ERROR
4588 ;}
4589 break;
4590
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004591 case 235:
4592#line 2048 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004593 {
4594 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4595 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4596 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4597 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4598 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4599 free((yyvsp[-2].StrVal));
4600 free((yyvsp[0].StrVal));
4601 CHECK_FOR_ERROR
4602 ;}
4603 break;
4604
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004605 case 236:
4606#line 2062 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004607 { // Is it an integer reference...?
4608 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4609 CHECK_FOR_ERROR
4610 ;}
4611 break;
4612
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004613 case 237:
4614#line 2066 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004615 { // Is it a named reference...?
4616 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4617 CHECK_FOR_ERROR
4618 ;}
4619 break;
4620
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004621 case 240:
4622#line 2078 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004623 {
4624 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal);
Reid Spencer21be8652006-10-22 07:03:43 +00004625 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004626 ;}
4627 break;
4628
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004629 case 241:
4630#line 2083 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004631 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004632 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004633 CHECK_FOR_ERROR
4634 ;}
4635 break;
4636
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004637 case 242:
4638#line 2087 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004639 { // Do not allow functions with 0 basic blocks
4640 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004641 CHECK_FOR_ERROR
4642 ;}
4643 break;
4644
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004645 case 243:
4646#line 2096 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004647 {
4648 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4649 CHECK_FOR_ERROR
4650 InsertValue((yyvsp[0].TermInstVal));
4651
4652 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4653 InsertValue((yyvsp[-2].BasicBlockVal));
4654 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004655 CHECK_FOR_ERROR
4656 ;}
4657 break;
4658
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004659 case 244:
4660#line 2107 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004661 {
4662 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
4663 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4664 if (CI2->getParent() == 0)
4665 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
4666 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4667 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
4668 CHECK_FOR_ERROR
4669 ;}
4670 break;
4671
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004672 case 245:
4673#line 2116 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004674 {
4675 (yyval.BasicBlockVal) = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
4676 CHECK_FOR_ERROR
4677
4678 // Make sure to move the basic block to the correct location in the
4679 // function, instead of leaving it inserted wherever it was first
4680 // referenced.
4681 Function::BasicBlockListType &BBL =
4682 CurFun.CurrentFunction->getBasicBlockList();
4683 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
4684 CHECK_FOR_ERROR
4685 ;}
4686 break;
4687
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004688 case 246:
4689#line 2128 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004690 {
4691 (yyval.BasicBlockVal) = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
4692 CHECK_FOR_ERROR
4693
4694 // Make sure to move the basic block to the correct location in the
4695 // function, instead of leaving it inserted wherever it was first
4696 // referenced.
4697 Function::BasicBlockListType &BBL =
4698 CurFun.CurrentFunction->getBasicBlockList();
4699 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004700 CHECK_FOR_ERROR
4701 ;}
4702 break;
4703
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004704 case 247:
4705#line 2141 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004706 { // Return with a result...
4707 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004708 CHECK_FOR_ERROR
4709 ;}
4710 break;
4711
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004712 case 248:
4713#line 2145 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004714 { // Return with no result...
4715 (yyval.TermInstVal) = new ReturnInst();
Reid Spencer3822ff52006-11-08 06:47:33 +00004716 CHECK_FOR_ERROR
4717 ;}
4718 break;
4719
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004720 case 249:
4721#line 2149 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004722 { // Unconditional Branch...
4723 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004724 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004725 (yyval.TermInstVal) = new BranchInst(tmpBB);
Reid Spencer3822ff52006-11-08 06:47:33 +00004726 ;}
4727 break;
4728
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004729 case 250:
4730#line 2154 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004731 {
4732 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004733 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004734 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004735 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004736 Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal));
4737 CHECK_FOR_ERROR
4738 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004739 ;}
4740 break;
4741
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004742 case 251:
4743#line 2163 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004744 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004745 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004746 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004747 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
4748 CHECK_FOR_ERROR
4749 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
4750 (yyval.TermInstVal) = S;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004751
Reid Spencere4d87aa2006-12-23 06:05:41 +00004752 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4753 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004754 for (; I != E; ++I) {
4755 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4756 S->addCase(CI, I->second);
4757 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004758 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004759 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00004760 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00004761 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004762 ;}
4763 break;
4764
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004765 case 252:
4766#line 2182 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004767 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004768 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004769 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004770 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004771 CHECK_FOR_ERROR
4772 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004773 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004774 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004775 ;}
4776 break;
4777
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004778 case 253:
4779#line 2192 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004780 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00004781 const PointerType *PFTy;
4782 const FunctionType *Ty;
Reid Spencer3822ff52006-11-08 06:47:33 +00004783
Reid Spencere4d87aa2006-12-23 06:05:41 +00004784 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004785 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4786 // Pull out the types of all of the arguments...
4787 std::vector<const Type*> ParamTypes;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004788 if ((yyvsp[-7].ValueList)) {
4789 for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004790 I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00004791 ParamTypes.push_back((*I)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004792 }
4793
4794 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4795 if (isVarArg) ParamTypes.pop_back();
4796
Reid Spencere4d87aa2006-12-23 06:05:41 +00004797 Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004798 PFTy = PointerType::get(Ty);
4799 }
4800
Reid Spencere4d87aa2006-12-23 06:05:41 +00004801 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004802 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004803 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004804 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004805 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004806 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004807
4808 // Create the call node...
Reid Spencere4d87aa2006-12-23 06:05:41 +00004809 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
4810 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004811 } else { // Has arguments?
4812 // Loop through FunctionType's arguments and ensure they are specified
4813 // correctly!
4814 //
4815 FunctionType::param_iterator I = Ty->param_begin();
4816 FunctionType::param_iterator E = Ty->param_end();
Reid Spencere4d87aa2006-12-23 06:05:41 +00004817 std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004818
Reid Spencera132e042006-12-03 05:46:11 +00004819 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4820 if ((*ArgI)->getType() != *I)
4821 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
4822 (*I)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004823
4824 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004825 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004826
Reid Spencere4d87aa2006-12-23 06:05:41 +00004827 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004828 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00004829 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004830
Reid Spencere4d87aa2006-12-23 06:05:41 +00004831 delete (yyvsp[-10].TypeVal);
4832 delete (yyvsp[-7].ValueList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004833 CHECK_FOR_ERROR
4834 ;}
4835 break;
4836
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004837 case 254:
4838#line 2247 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004839 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004840 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004841 CHECK_FOR_ERROR
4842 ;}
4843 break;
4844
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004845 case 255:
4846#line 2251 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004847 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004848 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004849 CHECK_FOR_ERROR
4850 ;}
4851 break;
4852
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004853 case 256:
4854#line 2258 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004855 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004856 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
4857 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004858 CHECK_FOR_ERROR
4859 if (V == 0)
4860 GEN_ERROR("May only switch on a constant pool value!");
4861
Reid Spencere4d87aa2006-12-23 06:05:41 +00004862 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004863 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004864 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004865 ;}
4866 break;
4867
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004868 case 257:
4869#line 2269 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004870 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004871 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
4872 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004873 CHECK_FOR_ERROR
4874
4875 if (V == 0)
4876 GEN_ERROR("May only switch on a constant pool value!");
4877
Reid Spencere4d87aa2006-12-23 06:05:41 +00004878 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004879 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004880 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004881 ;}
4882 break;
4883
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004884 case 258:
4885#line 2282 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004886 {
4887 // Is this definition named?? if so, assign the name...
Reid Spencere4d87aa2006-12-23 06:05:41 +00004888 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004889 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004890 InsertValue((yyvsp[0].InstVal));
4891 (yyval.InstVal) = (yyvsp[0].InstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004892 CHECK_FOR_ERROR
4893;}
4894 break;
4895
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004896 case 259:
4897#line 2291 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004898 { // Used for PHI nodes
Reid Spencere4d87aa2006-12-23 06:05:41 +00004899 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
4900 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004901 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004902 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004903 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004904 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4905 delete (yyvsp[-5].TypeVal);
4906 ;}
4907 break;
4908
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004909 case 260:
4910#line 2300 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004911 {
4912 (yyval.PHIList) = (yyvsp[-6].PHIList);
4913 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
4914 CHECK_FOR_ERROR
4915 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
4916 CHECK_FOR_ERROR
4917 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4918 ;}
4919 break;
4920
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004921 case 261:
4922#line 2310 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004923 { // Used for call statements, and memory insts...
4924 (yyval.ValueList) = new std::vector<Value*>();
4925 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
4926 ;}
4927 break;
4928
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004929 case 262:
4930#line 2314 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004931 {
4932 (yyval.ValueList) = (yyvsp[-2].ValueList);
4933 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
4934 CHECK_FOR_ERROR
4935 ;}
4936 break;
4937
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004938 case 264:
4939#line 2321 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004940 { (yyval.ValueList) = 0; ;}
4941 break;
4942
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004943 case 265:
4944#line 2323 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004945 {
4946 (yyval.BoolVal) = true;
4947 CHECK_FOR_ERROR
4948 ;}
4949 break;
4950
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004951 case 266:
4952#line 2327 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004953 {
4954 (yyval.BoolVal) = false;
4955 CHECK_FOR_ERROR
Andrew Lenharth6353e052006-12-08 18:07:09 +00004956 ;}
4957 break;
4958
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004959 case 267:
4960#line 2332 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004961 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004962 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
4963 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
4964 GEN_ERROR(
4965 "Arithmetic operator requires integer, FP, or packed operands!");
4966 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) &&
4967 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
4968 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
4969 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
4970 GEN_ERROR("U/S/FRem not supported on packed types!");
4971 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004972 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004973 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004974 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004975 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
4976 if ((yyval.InstVal) == 0)
4977 GEN_ERROR("binary operator returned null!");
4978 delete (yyvsp[-3].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004979 ;}
4980 break;
4981
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004982 case 268:
4983#line 2351 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004984 {
4985 if (!(*(yyvsp[-3].TypeVal))->isIntegral()) {
4986 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
4987 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral())
4988 GEN_ERROR("Logical operator requires integral operands!");
4989 }
4990 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
4991 CHECK_FOR_ERROR
4992 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
4993 CHECK_FOR_ERROR
4994 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
4995 if ((yyval.InstVal) == 0)
4996 GEN_ERROR("binary operator returned null!");
4997 delete (yyvsp[-3].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004998 ;}
4999 break;
5000
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005001 case 269:
5002#line 2366 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005003 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005004 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005005 GEN_ERROR("Packed types not supported by icmp instruction");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005006 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005007 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005008 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005009 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005010 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5011 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005012 GEN_ERROR("icmp operator returned null!");
5013 ;}
5014 break;
5015
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005016 case 270:
5017#line 2377 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005018 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005019 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005020 GEN_ERROR("Packed types not supported by fcmp instruction");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005021 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005022 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005023 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005024 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005025 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5026 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005027 GEN_ERROR("fcmp operator returned null!");
5028 ;}
5029 break;
5030
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005031 case 271:
5032#line 2388 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005033 {
5034 cerr << "WARNING: Use of eliminated 'not' instruction:"
5035 << " Replacing with 'xor'.\n";
5036
Reid Spencere4d87aa2006-12-23 06:05:41 +00005037 Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Andrew Lenharth6353e052006-12-08 18:07:09 +00005038 if (Ones == 0)
5039 GEN_ERROR("Expected integral type for not instruction!");
5040
Reid Spencere4d87aa2006-12-23 06:05:41 +00005041 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
5042 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005043 GEN_ERROR("Could not create a xor instruction!");
5044 CHECK_FOR_ERROR
5045 ;}
5046 break;
5047
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005048 case 272:
5049#line 2401 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005050 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005051 if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005052 GEN_ERROR("Shift amount must be ubyte!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005053 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
Andrew Lenharth6353e052006-12-08 18:07:09 +00005054 GEN_ERROR("Shift constant expression requires integer operand!");
5055 CHECK_FOR_ERROR;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005056 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005057 CHECK_FOR_ERROR
5058 ;}
5059 break;
5060
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005061 case 273:
5062#line 2410 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005063 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005064 Value* Val = (yyvsp[-2].ValueVal);
5065 const Type* Ty = (yyvsp[0].TypeVal)->get();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005066 if (!Val->getType()->isFirstClassType())
5067 GEN_ERROR("cast from a non-primitive type: '" +
5068 Val->getType()->getDescription() + "'!");
5069 if (!Ty->isFirstClassType())
5070 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005071 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].TypeVal)->get());
5072 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005073 ;}
5074 break;
5075
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005076 case 274:
5077#line 2421 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005078 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005079 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005080 GEN_ERROR("select condition must be boolean!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005081 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Andrew Lenharth6353e052006-12-08 18:07:09 +00005082 GEN_ERROR("select value types should match!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005083 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005084 CHECK_FOR_ERROR
5085 ;}
5086 break;
5087
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005088 case 275:
5089#line 2429 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005090 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005091 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5092 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005093 CHECK_FOR_ERROR
5094 ;}
5095 break;
5096
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005097 case 276:
5098#line 2434 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005099 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005100 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005101 GEN_ERROR("Invalid extractelement operands!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005102 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005103 CHECK_FOR_ERROR
5104 ;}
5105 break;
5106
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005107 case 277:
5108#line 2440 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005109 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005110 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005111 GEN_ERROR("Invalid insertelement operands!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005112 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005113 CHECK_FOR_ERROR
5114 ;}
5115 break;
5116
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005117 case 278:
5118#line 2446 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005119 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005120 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005121 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005122 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005123 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005124 ;}
5125 break;
5126
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005127 case 279:
5128#line 2452 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005129 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005130 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005131 if (!Ty->isFirstClassType())
5132 GEN_ERROR("PHI node operands must be of first class type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005133 (yyval.InstVal) = new PHINode(Ty);
5134 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5135 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5136 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005137 GEN_ERROR("All elements of a PHI node must be of the same type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005138 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5139 (yyvsp[0].PHIList)->pop_front();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005140 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00005141 delete (yyvsp[0].PHIList); // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005142 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005143 ;}
5144 break;
5145
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005146 case 280:
5147#line 2467 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005148 {
5149 const PointerType *PFTy = 0;
5150 const FunctionType *Ty = 0;
5151
Reid Spencere4d87aa2006-12-23 06:05:41 +00005152 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005153 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5154 // Pull out the types of all of the arguments...
5155 std::vector<const Type*> ParamTypes;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005156 if ((yyvsp[-1].ValueList)) {
5157 for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005158 I != E; ++I)
5159 ParamTypes.push_back((*I)->getType());
5160 }
5161
5162 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5163 if (isVarArg) ParamTypes.pop_back();
5164
Reid Spencere4d87aa2006-12-23 06:05:41 +00005165 if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005166 GEN_ERROR("LLVM functions cannot return aggregate types!");
5167
Reid Spencere4d87aa2006-12-23 06:05:41 +00005168 Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005169 PFTy = PointerType::get(Ty);
5170 }
5171
Reid Spencere4d87aa2006-12-23 06:05:41 +00005172 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005173 CHECK_FOR_ERROR
5174
5175 // Create the call node...
Reid Spencere4d87aa2006-12-23 06:05:41 +00005176 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005177 // Make sure no arguments is a good thing!
5178 if (Ty->getNumParams() != 0)
5179 GEN_ERROR("No arguments passed to a function that "
5180 "expects arguments!");
5181
Reid Spencere4d87aa2006-12-23 06:05:41 +00005182 (yyval.InstVal) = new CallInst(V, std::vector<Value*>());
Andrew Lenharth6353e052006-12-08 18:07:09 +00005183 } else { // Has arguments?
5184 // Loop through FunctionType's arguments and ensure they are specified
5185 // correctly!
5186 //
5187 FunctionType::param_iterator I = Ty->param_begin();
5188 FunctionType::param_iterator E = Ty->param_end();
Reid Spencere4d87aa2006-12-23 06:05:41 +00005189 std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005190
5191 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5192 if ((*ArgI)->getType() != *I)
5193 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
5194 (*I)->getDescription() + "'!");
5195
5196 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5197 GEN_ERROR("Invalid number of parameters detected!");
5198
Reid Spencere4d87aa2006-12-23 06:05:41 +00005199 (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005200 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00005201 cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal));
5202 cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal));
5203 delete (yyvsp[-4].TypeVal);
5204 delete (yyvsp[-1].ValueList);
5205 CHECK_FOR_ERROR
5206 ;}
5207 break;
5208
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005209 case 281:
5210#line 2526 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005211 {
5212 (yyval.InstVal) = (yyvsp[0].InstVal);
5213 CHECK_FOR_ERROR
5214 ;}
5215 break;
5216
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005217 case 282:
5218#line 2533 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005219 {
5220 (yyval.ValueList) = (yyvsp[0].ValueList);
5221 CHECK_FOR_ERROR
5222 ;}
5223 break;
5224
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005225 case 283:
5226#line 2536 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005227 {
5228 (yyval.ValueList) = new std::vector<Value*>();
5229 CHECK_FOR_ERROR
5230 ;}
5231 break;
5232
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005233 case 284:
5234#line 2541 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005235 {
5236 (yyval.BoolVal) = true;
5237 CHECK_FOR_ERROR
5238 ;}
5239 break;
5240
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005241 case 285:
5242#line 2545 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005243 {
5244 (yyval.BoolVal) = false;
5245 CHECK_FOR_ERROR
5246 ;}
5247 break;
5248
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005249 case 286:
5250#line 2552 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005251 {
5252 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5253 delete (yyvsp[-1].TypeVal);
5254 CHECK_FOR_ERROR
5255 ;}
5256 break;
5257
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005258 case 287:
5259#line 2557 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005260 {
5261 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
5262 CHECK_FOR_ERROR
5263 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5264 delete (yyvsp[-4].TypeVal);
5265 ;}
5266 break;
5267
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005268 case 288:
5269#line 2563 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005270 {
5271 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5272 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005273 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005274 ;}
5275 break;
5276
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005277 case 289:
5278#line 2568 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005279 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005280 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005281 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005282 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5283 delete (yyvsp[-4].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005284 ;}
5285 break;
5286
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005287 case 290:
5288#line 2574 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005289 {
5290 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
5291 GEN_ERROR("Trying to free nonpointer type " +
5292 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
5293 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005294 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005295 ;}
5296 break;
5297
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005298 case 291:
5299#line 2582 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005300 {
5301 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
5302 GEN_ERROR("Can't load from nonpointer type: " +
5303 (*(yyvsp[-1].TypeVal))->getDescription());
5304 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
5305 GEN_ERROR("Can't load from pointer of non-first-class type: " +
5306 (*(yyvsp[-1].TypeVal))->getDescription());
5307 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005308 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005309 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5310 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005311 ;}
5312 break;
5313
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005314 case 292:
5315#line 2594 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005316 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005317 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
5318 if (!PT)
5319 GEN_ERROR("Can't store to a nonpointer type: " +
5320 (*(yyvsp[-1].TypeVal))->getDescription());
5321 const Type *ElTy = PT->getElementType();
5322 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5323 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
5324 "' into space of type '" + ElTy->getDescription() + "'!");
5325
5326 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005327 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005328 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5329 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005330 ;}
5331 break;
5332
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005333 case 293:
5334#line 2609 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005335 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005336 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005337 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005338
Reid Spencere4d87aa2006-12-23 06:05:41 +00005339 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005340 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00005341 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
5342 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005343 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005344 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
5345 delete (yyvsp[-2].TypeVal);
5346 delete (yyvsp[0].ValueList);
Reid Spencer3822ff52006-11-08 06:47:33 +00005347 ;}
5348 break;
5349
5350
Reid Spencere4d87aa2006-12-23 06:05:41 +00005351 default: break;
Reid Spencer3822ff52006-11-08 06:47:33 +00005352 }
5353
Reid Spencere4d87aa2006-12-23 06:05:41 +00005354/* Line 1126 of yacc.c. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005355#line 5356 "llvmAsmParser.tab.c"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005356
5357 yyvsp -= yylen;
5358 yyssp -= yylen;
5359
5360
Reid Spencer3822ff52006-11-08 06:47:33 +00005361 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005362
5363 *++yyvsp = yyval;
5364
5365
Reid Spencer3822ff52006-11-08 06:47:33 +00005366 /* Now `shift' the result of the reduction. Determine what state
5367 that goes to, based on the state we popped back to and the rule
5368 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005369
5370 yyn = yyr1[yyn];
5371
Reid Spencer3822ff52006-11-08 06:47:33 +00005372 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5373 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005374 yystate = yytable[yystate];
5375 else
Reid Spencer3822ff52006-11-08 06:47:33 +00005376 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005377
5378 goto yynewstate;
5379
5380
Reid Spencer3822ff52006-11-08 06:47:33 +00005381/*------------------------------------.
5382| yyerrlab -- here on detecting error |
5383`------------------------------------*/
5384yyerrlab:
5385 /* If not already recovering from an error, report this error. */
5386 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005387 {
5388 ++yynerrs;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005389#if YYERROR_VERBOSE
5390 yyn = yypact[yystate];
Bill Wendlinge8156192006-12-07 01:30:32 +00005391
Andrew Lenharth6353e052006-12-08 18:07:09 +00005392 if (YYPACT_NINF < yyn && yyn < YYLAST)
5393 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00005394 int yytype = YYTRANSLATE (yychar);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005395 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5396 YYSIZE_T yysize = yysize0;
5397 YYSIZE_T yysize1;
5398 int yysize_overflow = 0;
5399 char *yymsg = 0;
5400# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5401 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
Andrew Lenharth6353e052006-12-08 18:07:09 +00005402 int yyx;
5403
Reid Spencere4d87aa2006-12-23 06:05:41 +00005404#if 0
5405 /* This is so xgettext sees the translatable formats that are
5406 constructed on the fly. */
5407 YY_("syntax error, unexpected %s");
5408 YY_("syntax error, unexpected %s, expecting %s");
5409 YY_("syntax error, unexpected %s, expecting %s or %s");
5410 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5411 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5412#endif
5413 char *yyfmt;
5414 char const *yyf;
5415 static char const yyunexpected[] = "syntax error, unexpected %s";
5416 static char const yyexpecting[] = ", expecting %s";
5417 static char const yyor[] = " or %s";
5418 char yyformat[sizeof yyunexpected
5419 + sizeof yyexpecting - 1
5420 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5421 * (sizeof yyor - 1))];
5422 char const *yyprefix = yyexpecting;
5423
Andrew Lenharth6353e052006-12-08 18:07:09 +00005424 /* Start YYX at -YYN if negative to avoid negative indexes in
5425 YYCHECK. */
5426 int yyxbegin = yyn < 0 ? -yyn : 0;
5427
5428 /* Stay within bounds of both yycheck and yytname. */
5429 int yychecklim = YYLAST - yyn;
5430 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005431 int yycount = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005432
Reid Spencere4d87aa2006-12-23 06:05:41 +00005433 yyarg[0] = yytname[yytype];
5434 yyfmt = yystpcpy (yyformat, yyunexpected);
5435
Andrew Lenharth6353e052006-12-08 18:07:09 +00005436 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5437 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5438 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005439 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005440 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005441 yycount = 1;
5442 yysize = yysize0;
5443 yyformat[sizeof yyunexpected - 1] = '\0';
Andrew Lenharth6353e052006-12-08 18:07:09 +00005444 break;
5445 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00005446 yyarg[yycount++] = yytname[yyx];
5447 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5448 yysize_overflow |= yysize1 < yysize;
5449 yysize = yysize1;
5450 yyfmt = yystpcpy (yyfmt, yyprefix);
5451 yyprefix = yyor;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005452 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005453
Reid Spencere4d87aa2006-12-23 06:05:41 +00005454 yyf = YY_(yyformat);
5455 yysize1 = yysize + yystrlen (yyf);
5456 yysize_overflow |= yysize1 < yysize;
5457 yysize = yysize1;
5458
5459 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5460 yymsg = (char *) YYSTACK_ALLOC (yysize);
5461 if (yymsg)
5462 {
5463 /* Avoid sprintf, as that infringes on the user's name space.
5464 Don't have undefined behavior even if the translation
5465 produced a string with the wrong number of "%s"s. */
5466 char *yyp = yymsg;
5467 int yyi = 0;
5468 while ((*yyp = *yyf))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005469 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005470 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5471 {
5472 yyp += yytnamerr (yyp, yyarg[yyi++]);
5473 yyf += 2;
5474 }
5475 else
5476 {
5477 yyp++;
5478 yyf++;
5479 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005480 }
5481 yyerror (yymsg);
5482 YYSTACK_FREE (yymsg);
5483 }
5484 else
Reid Spencere4d87aa2006-12-23 06:05:41 +00005485 {
5486 yyerror (YY_("syntax error"));
5487 goto yyexhaustedlab;
5488 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005489 }
5490 else
5491#endif /* YYERROR_VERBOSE */
Reid Spencere4d87aa2006-12-23 06:05:41 +00005492 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005493 }
5494
Reid Spencer3822ff52006-11-08 06:47:33 +00005495
Reid Spencer68a24bd2005-08-27 18:50:39 +00005496
5497 if (yyerrstatus == 3)
5498 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005499 /* If just tried and failed to reuse look-ahead token after an
Reid Spencer3822ff52006-11-08 06:47:33 +00005500 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005501
Reid Spencer3822ff52006-11-08 06:47:33 +00005502 if (yychar <= YYEOF)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005503 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005504 /* Return failure if at end of input. */
Reid Spencer3822ff52006-11-08 06:47:33 +00005505 if (yychar == YYEOF)
Reid Spencere4d87aa2006-12-23 06:05:41 +00005506 YYABORT;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005507 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005508 else
5509 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005510 yydestruct ("Error: discarding", yytoken, &yylval);
Reid Spencer3822ff52006-11-08 06:47:33 +00005511 yychar = YYEMPTY;
5512 }
5513 }
5514
Reid Spencere4d87aa2006-12-23 06:05:41 +00005515 /* Else will try to reuse look-ahead token after shifting the error
Reid Spencer3822ff52006-11-08 06:47:33 +00005516 token. */
5517 goto yyerrlab1;
5518
5519
5520/*---------------------------------------------------.
5521| yyerrorlab -- error raised explicitly by YYERROR. |
5522`---------------------------------------------------*/
5523yyerrorlab:
5524
Reid Spencere4d87aa2006-12-23 06:05:41 +00005525 /* Pacify compilers like GCC when the user code never invokes
5526 YYERROR and the label yyerrorlab therefore never appears in user
5527 code. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00005528 if (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00005529 goto yyerrorlab;
5530
Reid Spencere4d87aa2006-12-23 06:05:41 +00005531yyvsp -= yylen;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005532 yyssp -= yylen;
Reid Spencer3822ff52006-11-08 06:47:33 +00005533 yystate = *yyssp;
5534 goto yyerrlab1;
5535
5536
5537/*-------------------------------------------------------------.
5538| yyerrlab1 -- common code for both syntax error and YYERROR. |
5539`-------------------------------------------------------------*/
5540yyerrlab1:
5541 yyerrstatus = 3; /* Each real token shifted decrements this. */
5542
5543 for (;;)
5544 {
5545 yyn = yypact[yystate];
5546 if (yyn != YYPACT_NINF)
5547 {
5548 yyn += YYTERROR;
5549 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5550 {
5551 yyn = yytable[yyn];
5552 if (0 < yyn)
5553 break;
5554 }
5555 }
5556
5557 /* Pop the current state because it cannot handle the error token. */
5558 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005559 YYABORT;
5560
Reid Spencere4d87aa2006-12-23 06:05:41 +00005561
5562 yydestruct ("Error: popping", yystos[yystate], yyvsp);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005563 YYPOPSTACK;
Reid Spencer3822ff52006-11-08 06:47:33 +00005564 yystate = *yyssp;
5565 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005566 }
5567
5568 if (yyn == YYFINAL)
5569 YYACCEPT;
5570
Reid Spencer68a24bd2005-08-27 18:50:39 +00005571 *++yyvsp = yylval;
Reid Spencer3822ff52006-11-08 06:47:33 +00005572
5573
Reid Spencere4d87aa2006-12-23 06:05:41 +00005574 /* Shift the error token. */
5575 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
5576
Reid Spencer68a24bd2005-08-27 18:50:39 +00005577 yystate = yyn;
5578 goto yynewstate;
5579
Chris Lattnerf49c1762006-11-08 05:58:47 +00005580
Reid Spencer3822ff52006-11-08 06:47:33 +00005581/*-------------------------------------.
5582| yyacceptlab -- YYACCEPT comes here. |
5583`-------------------------------------*/
5584yyacceptlab:
5585 yyresult = 0;
5586 goto yyreturn;
5587
5588/*-----------------------------------.
5589| yyabortlab -- YYABORT comes here. |
5590`-----------------------------------*/
5591yyabortlab:
5592 yyresult = 1;
5593 goto yyreturn;
5594
5595#ifndef yyoverflow
Reid Spencere4d87aa2006-12-23 06:05:41 +00005596/*-------------------------------------------------.
5597| yyexhaustedlab -- memory exhaustion comes here. |
5598`-------------------------------------------------*/
5599yyexhaustedlab:
5600 yyerror (YY_("memory exhausted"));
Reid Spencer3822ff52006-11-08 06:47:33 +00005601 yyresult = 2;
5602 /* Fall through. */
Chris Lattnerf49c1762006-11-08 05:58:47 +00005603#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00005604
5605yyreturn:
Reid Spencere4d87aa2006-12-23 06:05:41 +00005606 if (yychar != YYEOF && yychar != YYEMPTY)
5607 yydestruct ("Cleanup: discarding lookahead",
5608 yytoken, &yylval);
5609 while (yyssp != yyss)
5610 {
5611 yydestruct ("Cleanup: popping",
5612 yystos[*yyssp], yyvsp);
5613 YYPOPSTACK;
5614 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005615#ifndef yyoverflow
5616 if (yyss != yyssa)
5617 YYSTACK_FREE (yyss);
5618#endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00005619 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005620}
Reid Spencer3822ff52006-11-08 06:47:33 +00005621
5622
Reid Spencer6fd36ab2006-12-29 20:35:03 +00005623#line 2624 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005624
5625
5626void llvm::GenerateError(const std::string &message, int LineNo) {
5627 if (LineNo == -1) LineNo = llvmAsmlineno;
5628 // TODO: column number in exception
5629 if (TheParseError)
5630 TheParseError->setError(CurFilename, message, LineNo);
5631 TriggerError = 1;
5632}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005633
5634int yyerror(const char *ErrorMsg) {
5635 std::string where
5636 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5637 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5638 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5639 if (yychar == YYEMPTY || yychar == 0)
5640 errMsg += "end-of-file.";
5641 else
5642 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005643 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005644 return 0;
5645}
Reid Spencer3822ff52006-11-08 06:47:33 +00005646