blob: 50f7a82126727affaf57a8c219efb01afb4af456 [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,
84 TYPE = 275,
85 LABEL = 276,
86 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,
96 GLOBAL = 287,
97 CONSTANT = 288,
98 SECTION = 289,
99 VOLATILE = 290,
100 TO = 291,
101 DOTDOTDOT = 292,
102 NULL_TOK = 293,
103 UNDEF = 294,
104 CONST = 295,
105 INTERNAL = 296,
106 LINKONCE = 297,
107 WEAK = 298,
108 APPENDING = 299,
109 DLLIMPORT = 300,
110 DLLEXPORT = 301,
111 EXTERN_WEAK = 302,
112 OPAQUE = 303,
113 NOT = 304,
114 EXTERNAL = 305,
115 TARGET = 306,
116 TRIPLE = 307,
117 ENDIAN = 308,
118 POINTERSIZE = 309,
119 LITTLE = 310,
120 BIG = 311,
121 ALIGN = 312,
122 DEPLIBS = 313,
123 CALL = 314,
124 TAIL = 315,
125 ASM_TOK = 316,
126 MODULE = 317,
127 SIDEEFFECT = 318,
128 CC_TOK = 319,
129 CCC_TOK = 320,
130 CSRETCC_TOK = 321,
131 FASTCC_TOK = 322,
132 COLDCC_TOK = 323,
133 X86_STDCALLCC_TOK = 324,
134 X86_FASTCALLCC_TOK = 325,
135 DATALAYOUT = 326,
136 RET = 327,
137 BR = 328,
138 SWITCH = 329,
139 INVOKE = 330,
140 UNWIND = 331,
141 UNREACHABLE = 332,
142 ADD = 333,
143 SUB = 334,
144 MUL = 335,
145 UDIV = 336,
146 SDIV = 337,
147 FDIV = 338,
148 UREM = 339,
149 SREM = 340,
150 FREM = 341,
151 AND = 342,
152 OR = 343,
153 XOR = 344,
Reid Spencere4d87aa2006-12-23 06:05:41 +0000154 ICMP = 345,
155 FCMP = 346,
156 EQ = 347,
157 NE = 348,
158 SLT = 349,
159 SGT = 350,
160 SLE = 351,
161 SGE = 352,
162 ULT = 353,
163 UGT = 354,
164 ULE = 355,
165 UGE = 356,
166 OEQ = 357,
167 ONE = 358,
168 OLT = 359,
169 OGT = 360,
170 OLE = 361,
171 OGE = 362,
172 ORD = 363,
173 UNO = 364,
174 UEQ = 365,
175 UNE = 366,
176 MALLOC = 367,
177 ALLOCA = 368,
178 FREE = 369,
179 LOAD = 370,
180 STORE = 371,
181 GETELEMENTPTR = 372,
182 TRUNC = 373,
183 ZEXT = 374,
184 SEXT = 375,
185 FPTRUNC = 376,
186 FPEXT = 377,
187 BITCAST = 378,
188 UITOFP = 379,
189 SITOFP = 380,
190 FPTOUI = 381,
191 FPTOSI = 382,
192 INTTOPTR = 383,
193 PTRTOINT = 384,
194 PHI_TOK = 385,
195 SELECT = 386,
196 SHL = 387,
197 LSHR = 388,
198 ASHR = 389,
199 VAARG = 390,
200 EXTRACTELEMENT = 391,
201 INSERTELEMENT = 392,
202 SHUFFLEVECTOR = 393
Reid Spencer3822ff52006-11-08 06:47:33 +0000203 };
204#endif
Reid Spencere4d87aa2006-12-23 06:05:41 +0000205/* Tokens. */
Reid Spencer3822ff52006-11-08 06:47:33 +0000206#define ESINT64VAL 258
207#define EUINT64VAL 259
208#define SINTVAL 260
209#define UINTVAL 261
210#define FPVAL 262
211#define VOID 263
212#define BOOL 264
213#define SBYTE 265
214#define UBYTE 266
215#define SHORT 267
216#define USHORT 268
217#define INT 269
218#define UINT 270
219#define LONG 271
220#define ULONG 272
221#define FLOAT 273
222#define DOUBLE 274
223#define TYPE 275
224#define LABEL 276
225#define VAR_ID 277
226#define LABELSTR 278
227#define STRINGCONSTANT 279
228#define IMPLEMENTATION 280
229#define ZEROINITIALIZER 281
230#define TRUETOK 282
231#define FALSETOK 283
232#define BEGINTOK 284
233#define ENDTOK 285
234#define DECLARE 286
235#define GLOBAL 287
236#define CONSTANT 288
237#define SECTION 289
238#define VOLATILE 290
239#define TO 291
240#define DOTDOTDOT 292
241#define NULL_TOK 293
242#define UNDEF 294
243#define CONST 295
244#define INTERNAL 296
245#define LINKONCE 297
246#define WEAK 298
247#define APPENDING 299
248#define DLLIMPORT 300
249#define DLLEXPORT 301
250#define EXTERN_WEAK 302
251#define OPAQUE 303
252#define NOT 304
253#define EXTERNAL 305
254#define TARGET 306
255#define TRIPLE 307
256#define ENDIAN 308
257#define POINTERSIZE 309
258#define LITTLE 310
259#define BIG 311
260#define ALIGN 312
261#define DEPLIBS 313
262#define CALL 314
263#define TAIL 315
264#define ASM_TOK 316
265#define MODULE 317
266#define SIDEEFFECT 318
267#define CC_TOK 319
268#define CCC_TOK 320
269#define CSRETCC_TOK 321
270#define FASTCC_TOK 322
271#define COLDCC_TOK 323
272#define X86_STDCALLCC_TOK 324
273#define X86_FASTCALLCC_TOK 325
274#define DATALAYOUT 326
275#define RET 327
276#define BR 328
277#define SWITCH 329
278#define INVOKE 330
279#define UNWIND 331
280#define UNREACHABLE 332
281#define ADD 333
282#define SUB 334
283#define MUL 335
284#define UDIV 336
285#define SDIV 337
286#define FDIV 338
287#define UREM 339
288#define SREM 340
289#define FREM 341
290#define AND 342
291#define OR 343
292#define XOR 344
Reid Spencere4d87aa2006-12-23 06:05:41 +0000293#define ICMP 345
294#define FCMP 346
295#define EQ 347
296#define NE 348
297#define SLT 349
298#define SGT 350
299#define SLE 351
300#define SGE 352
301#define ULT 353
302#define UGT 354
303#define ULE 355
304#define UGE 356
305#define OEQ 357
306#define ONE 358
307#define OLT 359
308#define OGT 360
309#define OLE 361
310#define OGE 362
311#define ORD 363
312#define UNO 364
313#define UEQ 365
314#define UNE 366
315#define MALLOC 367
316#define ALLOCA 368
317#define FREE 369
318#define LOAD 370
319#define STORE 371
320#define GETELEMENTPTR 372
321#define TRUNC 373
322#define ZEXT 374
323#define SEXT 375
324#define FPTRUNC 376
325#define FPEXT 377
326#define BITCAST 378
327#define UITOFP 379
328#define SITOFP 380
329#define FPTOUI 381
330#define FPTOSI 382
331#define INTTOPTR 383
332#define PTRTOINT 384
333#define PHI_TOK 385
334#define SELECT 386
335#define SHL 387
336#define LSHR 388
337#define ASHR 389
338#define VAARG 390
339#define EXTRACTELEMENT 391
340#define INSERTELEMENT 392
341#define SHUFFLEVECTOR 393
Reid Spencer3822ff52006-11-08 06:47:33 +0000342
343
344
345
346/* Copy the first part of user declarations. */
Reid Spencere4d87aa2006-12-23 06:05:41 +0000347#line 14 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000348
349#include "ParserInternals.h"
350#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000351#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000352#include "llvm/Instructions.h"
353#include "llvm/Module.h"
354#include "llvm/SymbolTable.h"
355#include "llvm/Support/GetElementPtrTypeIterator.h"
356#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000357#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000358#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000359#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000360#include <list>
361#include <utility>
362
Reid Spencere4f47592006-08-18 17:32:55 +0000363// The following is a gross hack. In order to rid the libAsmParser library of
364// exceptions, we have to have a way of getting the yyparse function to go into
365// an error situation. So, whenever we want an error to occur, the GenerateError
366// function (see bottom of file) sets TriggerError. Then, at the end of each
367// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
368// (a goto) to put YACC in error state. Furthermore, several calls to
369// GenerateError are made from inside productions and they must simulate the
370// previous exception behavior by exiting the production immediately. We have
371// replaced these with the GEN_ERROR macro which calls GeneratError and then
372// immediately invokes YYERROR. This would be so much cleaner if it was a
373// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000374static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000375#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000376#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
377
Reid Spencer68a24bd2005-08-27 18:50:39 +0000378int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
379int yylex(); // declaration" of xxx warnings.
380int yyparse();
381
382namespace llvm {
383 std::string CurFilename;
384}
385using namespace llvm;
386
387static Module *ParserResult;
388
389// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
390// relating to upreferences in the input stream.
391//
392//#define DEBUG_UPREFS 1
393#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000394#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000395#else
396#define UR_OUT(X)
397#endif
398
399#define YYERROR_VERBOSE 1
400
Chris Lattnerb475c422005-11-12 18:22:38 +0000401static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000402
403
404// This contains info used when building the body of a function. It is
405// destroyed when the function is completed.
406//
407typedef std::vector<Value *> ValueList; // Numbered defs
408static void
409ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
410 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
411
412static struct PerModuleInfo {
413 Module *CurrentModule;
414 std::map<const Type *, ValueList> Values; // Module level numbered definitions
415 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000416 std::vector<PATypeHolder> Types;
417 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000418
419 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000420 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000421 /// that we can resolve them later and print error messages as appropriate.
422 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
423
424 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
425 // references to global values. Global values may be referenced before they
426 // are defined, and if so, the temporary object that they represent is held
427 // here. This is used for forward references of GlobalValues.
428 //
429 typedef std::map<std::pair<const PointerType *,
430 ValID>, GlobalValue*> GlobalRefsType;
431 GlobalRefsType GlobalRefs;
432
433 void ModuleDone() {
434 // If we could not resolve some functions at function compilation time
435 // (calls to functions before they are defined), resolve them now... Types
436 // are resolved when the constant pool has been completely parsed.
437 //
438 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000439 if (TriggerError)
440 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000441
442 // Check to make sure that all global value forward references have been
443 // resolved!
444 //
445 if (!GlobalRefs.empty()) {
446 std::string UndefinedReferences = "Unresolved global references exist:\n";
447
448 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
449 I != E; ++I) {
450 UndefinedReferences += " " + I->first.first->getDescription() + " " +
451 I->first.second.getName() + "\n";
452 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000453 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000454 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000455 }
456
457 Values.clear(); // Clear out function local definitions
458 Types.clear();
459 CurrentModule = 0;
460 }
461
Reid Spencer68a24bd2005-08-27 18:50:39 +0000462 // GetForwardRefForGlobal - Check to see if there is a forward reference
463 // for this global. If so, remove it from the GlobalRefs map and return it.
464 // If not, just return null.
465 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
466 // Check to see if there is a forward reference to this global variable...
467 // if there is, eliminate it and patch the reference to use the new def'n.
468 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
469 GlobalValue *Ret = 0;
470 if (I != GlobalRefs.end()) {
471 Ret = I->second;
472 GlobalRefs.erase(I);
473 }
474 return Ret;
475 }
476} CurModule;
477
478static struct PerFunctionInfo {
479 Function *CurrentFunction; // Pointer to current function being created
480
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000481 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000482 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000483 bool isDeclare; // Is this function a forward declararation?
484 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000485
486 /// BBForwardRefs - When we see forward references to basic blocks, keep
487 /// track of them here.
488 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
489 std::vector<BasicBlock*> NumberedBlocks;
490 unsigned NextBBNum;
491
492 inline PerFunctionInfo() {
493 CurrentFunction = 0;
494 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000495 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000496 }
497
498 inline void FunctionStart(Function *M) {
499 CurrentFunction = M;
500 NextBBNum = 0;
501 }
502
503 void FunctionDone() {
504 NumberedBlocks.clear();
505
506 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000507 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000508 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000509 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000510 return;
511 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000512
513 // Resolve all forward references now.
514 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
515
516 Values.clear(); // Clear out function local definitions
517 CurrentFunction = 0;
518 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000519 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000520 }
521} CurFun; // Info for the current function...
522
523static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
524
525
526//===----------------------------------------------------------------------===//
527// Code to handle definitions of all the types
528//===----------------------------------------------------------------------===//
529
530static int InsertValue(Value *V,
531 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
532 if (V->hasName()) return -1; // Is this a numbered definition?
533
534 // Yes, insert the value into the value table...
535 ValueList &List = ValueTab[V->getType()];
536 List.push_back(V);
537 return List.size()-1;
538}
539
540static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
541 switch (D.Type) {
542 case ValID::NumberVal: // Is it a numbered definition?
543 // Module constants occupy the lowest numbered slots...
544 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer861d9d62006-11-28 07:29:44 +0000545 return CurModule.Types[(unsigned)D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000546 break;
547 case ValID::NameVal: // Is it a named definition?
548 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
549 D.destroy(); // Free old strdup'd memory...
550 return N;
551 }
552 break;
553 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000554 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000555 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000556 }
557
558 // If we reached here, we referenced either a symbol that we don't know about
559 // or an id number that hasn't been read yet. We may be referencing something
560 // forward, so just create an entry to be resolved later and get to it...
561 //
562 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
563
564
565 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000566 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000567 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000568 return 0;
569 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000570 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000571 return 0;
572 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000573 }
574
Reid Spencer861d9d62006-11-28 07:29:44 +0000575 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000576 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000577 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000578
Reid Spencer861d9d62006-11-28 07:29:44 +0000579 Type *Typ = OpaqueType::get();
580 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
581 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000582 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000583
584static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
585 SymbolTable &SymTab =
586 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
587 CurModule.CurrentModule->getSymbolTable();
588 return SymTab.lookup(Ty, Name);
589}
590
591// getValNonImprovising - Look up the value specified by the provided type and
592// the provided ValID. If the value exists and has already been defined, return
593// it. Otherwise return null.
594//
595static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000596 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000597 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000598 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000599 return 0;
600 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000601
602 switch (D.Type) {
603 case ValID::NumberVal: { // Is it a numbered definition?
604 unsigned Num = (unsigned)D.Num;
605
606 // Module constants occupy the lowest numbered slots...
607 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
608 if (VI != CurModule.Values.end()) {
609 if (Num < VI->second.size())
610 return VI->second[Num];
611 Num -= VI->second.size();
612 }
613
614 // Make sure that our type is within bounds
615 VI = CurFun.Values.find(Ty);
616 if (VI == CurFun.Values.end()) return 0;
617
618 // Check that the number is within bounds...
619 if (VI->second.size() <= Num) return 0;
620
621 return VI->second[Num];
622 }
623
624 case ValID::NameVal: { // Is it a named definition?
625 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
626 if (N == 0) return 0;
627
628 D.destroy(); // Free old strdup'd memory...
629 return N;
630 }
631
632 // Check to make sure that "Ty" is an integral type, and that our
633 // value will fit into the specified type...
634 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000635 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000636 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000637 itostr(D.ConstPool64) + "' is invalid for type '" +
638 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000639 return 0;
640 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000641 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000642
643 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000644 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
645 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000646 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000647 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000648 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000649 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000650 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000651 }
652 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000653 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000654 }
655
656 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000657 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000658 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000659 return 0;
660 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000661 return ConstantFP::get(Ty, D.ConstPoolFP);
662
663 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000664 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000665 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000666 return 0;
667 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000668 return ConstantPointerNull::get(cast<PointerType>(Ty));
669
670 case ValID::ConstUndefVal: // Is it an undef value?
671 return UndefValue::get(Ty);
672
Chris Lattner7aa61892005-12-21 17:53:23 +0000673 case ValID::ConstZeroVal: // Is it a zero value?
674 return Constant::getNullValue(Ty);
675
Reid Spencer68a24bd2005-08-27 18:50:39 +0000676 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000677 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000678 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000679 return 0;
680 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000681 return D.ConstantValue;
682
Chris Lattner0e9c3762006-01-25 22:27:16 +0000683 case ValID::InlineAsmVal: { // Inline asm expression
684 const PointerType *PTy = dyn_cast<PointerType>(Ty);
685 const FunctionType *FTy =
686 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000687 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000688 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000689 return 0;
690 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000691 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
692 D.IAD->HasSideEffects);
693 D.destroy(); // Free InlineAsmDescriptor.
694 return IA;
695 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000696 default:
697 assert(0 && "Unhandled case!");
698 return 0;
699 } // End of switch
700
701 assert(0 && "Unhandled case!");
702 return 0;
703}
704
705// getVal - This function is identical to getValNonImprovising, except that if a
706// value is not already defined, it "improvises" by creating a placeholder var
707// that looks and acts just like the requested variable. When the value is
708// defined later, all uses of the placeholder variable are replaced with the
709// real thing.
710//
711static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000712 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000713 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000714 return 0;
715 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000716
717 // See if the value has already been defined.
718 Value *V = getValNonImprovising(Ty, ID);
719 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000720 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000721
Reid Spencer5b7e7532006-09-28 19:28:24 +0000722 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000723 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000724 return 0;
725 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000726
727 // If we reached here, we referenced either a symbol that we don't know about
728 // or an id number that hasn't been read yet. We may be referencing something
729 // forward, so just create an entry to be resolved later and get to it...
730 //
731 V = new Argument(Ty);
732
733 // Remember where this forward reference came from. FIXME, shouldn't we try
734 // to recycle these things??
735 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
736 llvmAsmlineno)));
737
738 if (inFunctionScope())
739 InsertValue(V, CurFun.LateResolveValues);
740 else
741 InsertValue(V, CurModule.LateResolveValues);
742 return V;
743}
744
745/// getBBVal - This is used for two purposes:
746/// * If isDefinition is true, a new basic block with the specified ID is being
747/// defined.
748/// * If isDefinition is true, this is a reference to a basic block, which may
749/// or may not be a forward reference.
750///
751static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
752 assert(inFunctionScope() && "Can't get basic block at global scope!");
753
754 std::string Name;
755 BasicBlock *BB = 0;
756 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000757 default:
758 GenerateError("Illegal label reference " + ID.getName());
759 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000760 case ValID::NumberVal: // Is it a numbered definition?
761 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
762 CurFun.NumberedBlocks.resize(ID.Num+1);
763 BB = CurFun.NumberedBlocks[ID.Num];
764 break;
765 case ValID::NameVal: // Is it a named definition?
766 Name = ID.Name;
767 if (Value *N = CurFun.CurrentFunction->
768 getSymbolTable().lookup(Type::LabelTy, Name))
769 BB = cast<BasicBlock>(N);
770 break;
771 }
772
773 // See if the block has already been defined.
774 if (BB) {
775 // If this is the definition of the block, make sure the existing value was
776 // just a forward reference. If it was a forward reference, there will be
777 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000778 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000779 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000780 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000781 return 0;
782 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000783
784 ID.destroy(); // Free strdup'd memory.
785 return BB;
786 }
787
788 // Otherwise this block has not been seen before.
789 BB = new BasicBlock("", CurFun.CurrentFunction);
790 if (ID.Type == ValID::NameVal) {
791 BB->setName(ID.Name);
792 } else {
793 CurFun.NumberedBlocks[ID.Num] = BB;
794 }
795
796 // If this is not a definition, keep track of it so we can use it as a forward
797 // reference.
798 if (!isDefinition) {
799 // Remember where this forward reference came from.
800 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
801 } else {
802 // The forward declaration could have been inserted anywhere in the
803 // function: insert it into the correct place now.
804 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
805 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
806 }
807 ID.destroy();
808 return BB;
809}
810
811
812//===----------------------------------------------------------------------===//
813// Code to handle forward references in instructions
814//===----------------------------------------------------------------------===//
815//
816// This code handles the late binding needed with statements that reference
817// values not defined yet... for example, a forward branch, or the PHI node for
818// a loop body.
819//
820// This keeps a table (CurFun.LateResolveValues) of all such forward references
821// and back patchs after we are done.
822//
823
824// ResolveDefinitions - If we could not resolve some defs at parsing
825// time (forward branches, phi functions for loops, etc...) resolve the
826// defs now...
827//
828static void
829ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
830 std::map<const Type*,ValueList> *FutureLateResolvers) {
831 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
832 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
833 E = LateResolvers.end(); LRI != E; ++LRI) {
834 ValueList &List = LRI->second;
835 while (!List.empty()) {
836 Value *V = List.back();
837 List.pop_back();
838
839 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
840 CurModule.PlaceHolderInfo.find(V);
841 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
842
843 ValID &DID = PHI->second.first;
844
845 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000846 if (TriggerError)
847 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000848 if (TheRealValue) {
849 V->replaceAllUsesWith(TheRealValue);
850 delete V;
851 CurModule.PlaceHolderInfo.erase(PHI);
852 } else if (FutureLateResolvers) {
853 // Functions have their unresolved items forwarded to the module late
854 // resolver table
855 InsertValue(V, *FutureLateResolvers);
856 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000857 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000858 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000859 "' of type '" + V->getType()->getDescription() + "'",
860 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000861 return;
862 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000863 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000864 itostr(DID.Num) + " of type '" +
865 V->getType()->getDescription() + "'",
866 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000867 return;
868 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000869 }
870 }
871 }
872
873 LateResolvers.clear();
874}
875
876// ResolveTypeTo - A brand new type was just declared. This means that (if
877// name is not null) things referencing Name can be resolved. Otherwise, things
878// refering to the number can be resolved. Do this now.
879//
880static void ResolveTypeTo(char *Name, const Type *ToTy) {
881 ValID D;
882 if (Name) D = ValID::create(Name);
883 else D = ValID::create((int)CurModule.Types.size());
884
Reid Spencer861d9d62006-11-28 07:29:44 +0000885 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000886 CurModule.LateResolveTypes.find(D);
887 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000888 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000889 CurModule.LateResolveTypes.erase(I);
890 }
891}
892
893// setValueName - Set the specified value to the name given. The name may be
894// null potentially, in which case this is a noop. The string passed in is
895// assumed to be a malloc'd string buffer, and is free'd by this function.
896//
897static void setValueName(Value *V, char *NameStr) {
898 if (NameStr) {
899 std::string Name(NameStr); // Copy string
900 free(NameStr); // Free old string
901
Reid Spencer5b7e7532006-09-28 19:28:24 +0000902 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000903 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000904 return;
905 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000906
907 assert(inFunctionScope() && "Must be in function scope!");
908 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000909 if (ST.lookup(V->getType(), Name)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000910 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000911 V->getType()->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000912 return;
913 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000914
915 // Set the name.
916 V->setName(Name);
917 }
918}
919
920/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
921/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000922static GlobalVariable *
923ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
924 bool isConstantGlobal, const Type *Ty,
925 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000926 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000927 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000928 return 0;
929 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000930
931 const PointerType *PTy = PointerType::get(Ty);
932
933 std::string Name;
934 if (NameStr) {
935 Name = NameStr; // Copy string
936 free(NameStr); // Free old string
937 }
938
939 // See if this global value was forward referenced. If so, recycle the
940 // object.
941 ValID ID;
942 if (!Name.empty()) {
943 ID = ValID::create((char*)Name.c_str());
944 } else {
945 ID = ValID::create((int)CurModule.Values[PTy].size());
946 }
947
948 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
949 // Move the global to the end of the list, from whereever it was
950 // previously inserted.
951 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
952 CurModule.CurrentModule->getGlobalList().remove(GV);
953 CurModule.CurrentModule->getGlobalList().push_back(GV);
954 GV->setInitializer(Initializer);
955 GV->setLinkage(Linkage);
956 GV->setConstant(isConstantGlobal);
957 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000958 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000959 }
960
961 // If this global has a name, check to see if there is already a definition
962 // of this global in the module. If so, merge as appropriate. Note that
963 // this is really just a hack around problems in the CFE. :(
964 if (!Name.empty()) {
965 // We are a simple redefinition of a value, check to see if it is defined
966 // the same as the old one.
967 if (GlobalVariable *EGV =
968 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
969 // We are allowed to redefine a global variable in two circumstances:
970 // 1. If at least one of the globals is uninitialized or
971 // 2. If both initializers have the same value.
972 //
973 if (!EGV->hasInitializer() || !Initializer ||
974 EGV->getInitializer() == Initializer) {
975
976 // Make sure the existing global version gets the initializer! Make
977 // sure that it also gets marked const if the new version is.
978 if (Initializer && !EGV->hasInitializer())
979 EGV->setInitializer(Initializer);
980 if (isConstantGlobal)
981 EGV->setConstant(true);
982 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000983 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000984 }
985
Reid Spencer61c83e02006-08-18 08:43:06 +0000986 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000987 "' in the '" + Ty->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000988 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000989 }
990 }
991
992 // Otherwise there is no existing GV to use, create one now.
993 GlobalVariable *GV =
994 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
995 CurModule.CurrentModule);
996 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000997 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000998}
999
1000// setTypeName - Set the specified type to the name given. The name may be
1001// null potentially, in which case this is a noop. The string passed in is
1002// assumed to be a malloc'd string buffer, and is freed by this function.
1003//
1004// This function returns true if the type has already been defined, but is
1005// allowed to be redefined in the specified context. If the name is a new name
1006// for the type plane, it is inserted and false is returned.
1007static bool setTypeName(const Type *T, char *NameStr) {
1008 assert(!inFunctionScope() && "Can't give types function-local names!");
1009 if (NameStr == 0) return false;
1010
1011 std::string Name(NameStr); // Copy string
1012 free(NameStr); // Free old string
1013
1014 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001015 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001016 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001017 return false;
1018 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001019
1020 // Set the type name, checking for conflicts as we do so.
1021 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1022
1023 if (AlreadyExists) { // Inserting a name that is already defined???
1024 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1025 assert(Existing && "Conflict but no matching type?");
1026
1027 // There is only one case where this is allowed: when we are refining an
1028 // opaque type. In this case, Existing will be an opaque type.
1029 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1030 // We ARE replacing an opaque type!
1031 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1032 return true;
1033 }
1034
1035 // Otherwise, this is an attempt to redefine a type. That's okay if
1036 // the redefinition is identical to the original. This will be so if
1037 // Existing and T point to the same Type object. In this one case we
1038 // allow the equivalent redefinition.
1039 if (Existing == T) return true; // Yes, it's equal.
1040
1041 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer61c83e02006-08-18 08:43:06 +00001042 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00001043 T->getDescription() + "' type plane!");
1044 }
1045
1046 return false;
1047}
1048
1049//===----------------------------------------------------------------------===//
1050// Code for handling upreferences in type names...
1051//
1052
1053// TypeContains - Returns true if Ty directly contains E in it.
1054//
1055static bool TypeContains(const Type *Ty, const Type *E) {
1056 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1057 E) != Ty->subtype_end();
1058}
1059
1060namespace {
1061 struct UpRefRecord {
1062 // NestingLevel - The number of nesting levels that need to be popped before
1063 // this type is resolved.
1064 unsigned NestingLevel;
1065
1066 // LastContainedTy - This is the type at the current binding level for the
1067 // type. Every time we reduce the nesting level, this gets updated.
1068 const Type *LastContainedTy;
1069
1070 // UpRefTy - This is the actual opaque type that the upreference is
1071 // represented with.
1072 OpaqueType *UpRefTy;
1073
1074 UpRefRecord(unsigned NL, OpaqueType *URTy)
1075 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1076 };
1077}
1078
1079// UpRefs - A list of the outstanding upreferences that need to be resolved.
1080static std::vector<UpRefRecord> UpRefs;
1081
1082/// HandleUpRefs - Every time we finish a new layer of types, this function is
1083/// called. It loops through the UpRefs vector, which is a list of the
1084/// currently active types. For each type, if the up reference is contained in
1085/// the newly completed type, we decrement the level count. When the level
1086/// count reaches zero, the upreferenced type is the type that is passed in:
1087/// thus we can complete the cycle.
1088///
1089static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001090 // If Ty isn't abstract, or if there are no up-references in it, then there is
1091 // nothing to resolve here.
1092 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1093
Reid Spencer68a24bd2005-08-27 18:50:39 +00001094 PATypeHolder Ty(ty);
1095 UR_OUT("Type '" << Ty->getDescription() <<
1096 "' newly formed. Resolving upreferences.\n" <<
1097 UpRefs.size() << " upreferences active!\n");
1098
1099 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1100 // to zero), we resolve them all together before we resolve them to Ty. At
1101 // the end of the loop, if there is anything to resolve to Ty, it will be in
1102 // this variable.
1103 OpaqueType *TypeToResolve = 0;
1104
1105 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1106 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1107 << UpRefs[i].second->getDescription() << ") = "
1108 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1109 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1110 // Decrement level of upreference
1111 unsigned Level = --UpRefs[i].NestingLevel;
1112 UpRefs[i].LastContainedTy = Ty;
1113 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1114 if (Level == 0) { // Upreference should be resolved!
1115 if (!TypeToResolve) {
1116 TypeToResolve = UpRefs[i].UpRefTy;
1117 } else {
1118 UR_OUT(" * Resolving upreference for "
1119 << UpRefs[i].second->getDescription() << "\n";
1120 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1121 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1122 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1123 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1124 }
1125 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1126 --i; // Do not skip the next element...
1127 }
1128 }
1129 }
1130
1131 if (TypeToResolve) {
1132 UR_OUT(" * Resolving upreference for "
1133 << UpRefs[i].second->getDescription() << "\n";
1134 std::string OldName = TypeToResolve->getDescription());
1135 TypeToResolve->refineAbstractTypeTo(Ty);
1136 }
1137
1138 return Ty;
1139}
1140
Reid Spencer68a24bd2005-08-27 18:50:39 +00001141// common code from the two 'RunVMAsmParser' functions
Reid Spencer5b7e7532006-09-28 19:28:24 +00001142static Module* RunParser(Module * M) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001143
1144 llvmAsmlineno = 1; // Reset the current line number...
Reid Spencer68a24bd2005-08-27 18:50:39 +00001145 CurModule.CurrentModule = M;
Reid Spencerf63697d2006-10-09 17:36:59 +00001146
1147 // Check to make sure the parser succeeded
1148 if (yyparse()) {
1149 if (ParserResult)
1150 delete ParserResult;
1151 return 0;
1152 }
1153
1154 // Check to make sure that parsing produced a result
Reid Spencer61c83e02006-08-18 08:43:06 +00001155 if (!ParserResult)
1156 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001157
Reid Spencerf63697d2006-10-09 17:36:59 +00001158 // Reset ParserResult variable while saving its value for the result.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001159 Module *Result = ParserResult;
1160 ParserResult = 0;
1161
Reid Spencer68a24bd2005-08-27 18:50:39 +00001162 return Result;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001163}
Reid Spencer68a24bd2005-08-27 18:50:39 +00001164
1165//===----------------------------------------------------------------------===//
1166// RunVMAsmParser - Define an interface to this parser
1167//===----------------------------------------------------------------------===//
1168//
1169Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1170 set_scan_file(F);
1171
1172 CurFilename = Filename;
1173 return RunParser(new Module(CurFilename));
1174}
1175
1176Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1177 set_scan_string(AsmString);
1178
1179 CurFilename = "from_memory";
1180 if (M == NULL) {
1181 return RunParser(new Module (CurFilename));
1182 } else {
1183 return RunParser(M);
1184 }
1185}
1186
1187
Reid Spencer3822ff52006-11-08 06:47:33 +00001188
1189/* Enabling traces. */
1190#ifndef YYDEBUG
1191# define YYDEBUG 0
1192#endif
1193
1194/* Enabling verbose error messages. */
1195#ifdef YYERROR_VERBOSE
1196# undef YYERROR_VERBOSE
1197# define YYERROR_VERBOSE 1
1198#else
1199# define YYERROR_VERBOSE 0
1200#endif
1201
Reid Spencere4d87aa2006-12-23 06:05:41 +00001202/* Enabling the token table. */
1203#ifndef YYTOKEN_TABLE
1204# define YYTOKEN_TABLE 0
1205#endif
1206
Andrew Lenharth6353e052006-12-08 18:07:09 +00001207#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencere4d87aa2006-12-23 06:05:41 +00001208#line 855 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00001209typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001210 llvm::Module *ModuleVal;
1211 llvm::Function *FunctionVal;
Reid Spencera132e042006-12-03 05:46:11 +00001212 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001213 llvm::BasicBlock *BasicBlockVal;
1214 llvm::TerminatorInst *TermInstVal;
1215 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001216 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001217
Reid Spencera132e042006-12-03 05:46:11 +00001218 const llvm::Type *PrimType;
1219 llvm::PATypeHolder *TypeVal;
1220 llvm::Value *ValueVal;
1221
1222 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1223 std::vector<llvm::Value*> *ValueList;
1224 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001225 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001226 std::list<std::pair<llvm::Value*,
1227 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001228 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001229 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001230
1231 llvm::GlobalValue::LinkageTypes Linkage;
1232 int64_t SInt64Val;
1233 uint64_t UInt64Val;
1234 int SIntVal;
1235 unsigned UIntVal;
1236 double FPVal;
1237 bool BoolVal;
1238
1239 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001240 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001241
Reid Spencera132e042006-12-03 05:46:11 +00001242 llvm::Instruction::BinaryOps BinaryOpVal;
1243 llvm::Instruction::TermOps TermOpVal;
1244 llvm::Instruction::MemoryOps MemOpVal;
1245 llvm::Instruction::CastOps CastOpVal;
1246 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001247 llvm::Module::Endianness Endianness;
Reid Spencera132e042006-12-03 05:46:11 +00001248 llvm::ICmpInst::Predicate IPredicate;
1249 llvm::FCmpInst::Predicate FPredicate;
Andrew Lenharth6353e052006-12-08 18:07:09 +00001250} YYSTYPE;
Reid Spencere4d87aa2006-12-23 06:05:41 +00001251/* Line 196 of yacc.c. */
1252#line 1253 "llvmAsmParser.tab.c"
Reid Spencer3822ff52006-11-08 06:47:33 +00001253# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1254# define YYSTYPE_IS_DECLARED 1
1255# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001256#endif
1257
1258
1259
Reid Spencer3822ff52006-11-08 06:47:33 +00001260/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001261
1262
Reid Spencere4d87aa2006-12-23 06:05:41 +00001263/* Line 219 of yacc.c. */
1264#line 1265 "llvmAsmParser.tab.c"
1265
1266#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1267# define YYSIZE_T __SIZE_TYPE__
1268#endif
1269#if ! defined (YYSIZE_T) && defined (size_t)
1270# define YYSIZE_T size_t
1271#endif
1272#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1273# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1274# define YYSIZE_T size_t
1275#endif
1276#if ! defined (YYSIZE_T)
1277# define YYSIZE_T unsigned int
1278#endif
1279
1280#ifndef YY_
1281# if YYENABLE_NLS
1282# if ENABLE_NLS
1283# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1284# define YY_(msgid) dgettext ("bison-runtime", msgid)
1285# endif
1286# endif
1287# ifndef YY_
1288# define YY_(msgid) msgid
1289# endif
1290#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001291
Andrew Lenharth6353e052006-12-08 18:07:09 +00001292#if ! defined (yyoverflow) || YYERROR_VERBOSE
Bill Wendlinge8156192006-12-07 01:30:32 +00001293
Reid Spencer3822ff52006-11-08 06:47:33 +00001294/* The parser invokes alloca or malloc; define the necessary symbols. */
1295
1296# ifdef YYSTACK_USE_ALLOCA
1297# if YYSTACK_USE_ALLOCA
1298# ifdef __GNUC__
1299# define YYSTACK_ALLOC __builtin_alloca
Reid Spencere4d87aa2006-12-23 06:05:41 +00001300# else
1301# define YYSTACK_ALLOC alloca
1302# if defined (__STDC__) || defined (__cplusplus)
1303# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1304# define YYINCLUDED_STDLIB_H
1305# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00001306# endif
1307# endif
1308# endif
1309
1310# ifdef YYSTACK_ALLOC
Andrew Lenharth6353e052006-12-08 18:07:09 +00001311 /* Pacify GCC's `empty if-body' warning. */
1312# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00001313# ifndef YYSTACK_ALLOC_MAXIMUM
1314 /* The OS might guarantee only one guard page at the bottom of the stack,
1315 and a page size can be as small as 4096 bytes. So we cannot safely
1316 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1317 to allow for a few compiler-allocated temporary stack slots. */
1318# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Andrew Lenharth6353e052006-12-08 18:07:09 +00001319# endif
Reid Spencere4d87aa2006-12-23 06:05:41 +00001320# else
Reid Spencer3822ff52006-11-08 06:47:33 +00001321# define YYSTACK_ALLOC YYMALLOC
1322# define YYSTACK_FREE YYFREE
Reid Spencere4d87aa2006-12-23 06:05:41 +00001323# ifndef YYSTACK_ALLOC_MAXIMUM
1324# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1325# endif
1326# ifdef __cplusplus
1327extern "C" {
1328# endif
1329# ifndef YYMALLOC
1330# define YYMALLOC malloc
1331# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1332 && (defined (__STDC__) || defined (__cplusplus)))
1333void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1334# endif
1335# endif
1336# ifndef YYFREE
1337# define YYFREE free
1338# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1339 && (defined (__STDC__) || defined (__cplusplus)))
1340void free (void *); /* INFRINGES ON USER NAME SPACE */
1341# endif
1342# endif
1343# ifdef __cplusplus
1344}
1345# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00001346# endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00001347#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Reid Spencer3822ff52006-11-08 06:47:33 +00001348
1349
Andrew Lenharth6353e052006-12-08 18:07:09 +00001350#if (! defined (yyoverflow) \
1351 && (! defined (__cplusplus) \
1352 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer3822ff52006-11-08 06:47:33 +00001353
1354/* A type that is properly aligned for any stack member. */
1355union yyalloc
1356{
Reid Spencere4d87aa2006-12-23 06:05:41 +00001357 short int yyss;
Reid Spencer3822ff52006-11-08 06:47:33 +00001358 YYSTYPE yyvs;
1359 };
1360
1361/* The size of the maximum gap between one aligned stack and the next. */
1362# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1363
1364/* The size of an array large to enough to hold all stacks, each with
1365 N elements. */
1366# define YYSTACK_BYTES(N) \
Reid Spencere4d87aa2006-12-23 06:05:41 +00001367 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Reid Spencer3822ff52006-11-08 06:47:33 +00001368 + YYSTACK_GAP_MAXIMUM)
1369
1370/* Copy COUNT objects from FROM to TO. The source and destination do
1371 not overlap. */
1372# ifndef YYCOPY
Andrew Lenharth6353e052006-12-08 18:07:09 +00001373# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer3822ff52006-11-08 06:47:33 +00001374# define YYCOPY(To, From, Count) \
1375 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1376# else
1377# define YYCOPY(To, From, Count) \
1378 do \
1379 { \
Reid Spencere4d87aa2006-12-23 06:05:41 +00001380 YYSIZE_T yyi; \
Reid Spencer3822ff52006-11-08 06:47:33 +00001381 for (yyi = 0; yyi < (Count); yyi++) \
1382 (To)[yyi] = (From)[yyi]; \
1383 } \
Andrew Lenharth6353e052006-12-08 18:07:09 +00001384 while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00001385# endif
1386# endif
1387
1388/* Relocate STACK from its old location to the new one. The
1389 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1390 elements in the stack, and YYPTR gives the new location of the
1391 stack. Advance YYPTR to a properly aligned location for the next
1392 stack. */
1393# define YYSTACK_RELOCATE(Stack) \
1394 do \
1395 { \
1396 YYSIZE_T yynewbytes; \
1397 YYCOPY (&yyptr->Stack, Stack, yysize); \
1398 Stack = &yyptr->Stack; \
1399 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1400 yyptr += yynewbytes / sizeof (*yyptr); \
1401 } \
Andrew Lenharth6353e052006-12-08 18:07:09 +00001402 while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001403
1404#endif
1405
Andrew Lenharth6353e052006-12-08 18:07:09 +00001406#if defined (__STDC__) || defined (__cplusplus)
1407 typedef signed char yysigned_char;
1408#else
Reid Spencere4d87aa2006-12-23 06:05:41 +00001409 typedef short int yysigned_char;
Andrew Lenharth6353e052006-12-08 18:07:09 +00001410#endif
1411
1412/* YYFINAL -- State number of the termination state. */
Reid Spencer3822ff52006-11-08 06:47:33 +00001413#define YYFINAL 4
1414/* YYLAST -- Last index in YYTABLE. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001415#define YYLAST 1390
Reid Spencer3822ff52006-11-08 06:47:33 +00001416
Andrew Lenharth6353e052006-12-08 18:07:09 +00001417/* YYNTOKENS -- Number of terminals. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001418#define YYNTOKENS 153
Andrew Lenharth6353e052006-12-08 18:07:09 +00001419/* YYNNTS -- Number of nonterminals. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001420#define YYNNTS 76
Andrew Lenharth6353e052006-12-08 18:07:09 +00001421/* YYNRULES -- Number of rules. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001422#define YYNRULES 291
Andrew Lenharth6353e052006-12-08 18:07:09 +00001423/* YYNRULES -- Number of states. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001424#define YYNSTATES 567
Reid Spencer3822ff52006-11-08 06:47:33 +00001425
1426/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1427#define YYUNDEFTOK 2
Reid Spencere4d87aa2006-12-23 06:05:41 +00001428#define YYMAXUTOK 393
Reid Spencer3822ff52006-11-08 06:47:33 +00001429
Reid Spencere4d87aa2006-12-23 06:05:41 +00001430#define YYTRANSLATE(YYX) \
Reid Spencer3822ff52006-11-08 06:47:33 +00001431 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1432
1433/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00001434static const unsigned char yytranslate[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001435{
1436 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1439 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001440 142, 143, 151, 2, 140, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001442 147, 139, 148, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001445 2, 144, 141, 146, 2, 2, 2, 2, 2, 152,
Reid Spencer3822ff52006-11-08 06:47:33 +00001446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001448 145, 2, 2, 149, 2, 150, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1451 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, 1, 2, 3, 4,
1462 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1463 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1464 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1465 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1466 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1467 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1468 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1469 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1470 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1471 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
Reid Spencer3da59db2006-11-27 01:05:10 +00001472 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
Reid Spencera132e042006-12-03 05:46:11 +00001473 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1474 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001475 135, 136, 137, 138
Reid Spencer3822ff52006-11-08 06:47:33 +00001476};
1477
1478#if YYDEBUG
1479/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1480 YYRHS. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001481static const unsigned short int yyprhs[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001482{
1483 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1484 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1485 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1486 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
Reid Spencer3da59db2006-11-27 01:05:10 +00001487 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
Reid Spencera132e042006-12-03 05:46:11 +00001488 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1489 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001490 140, 141, 143, 145, 147, 149, 151, 153, 155, 156,
1491 157, 159, 161, 163, 165, 167, 169, 172, 173, 176,
1492 177, 181, 184, 185, 187, 188, 192, 194, 197, 199,
1493 201, 203, 205, 207, 209, 211, 213, 215, 217, 219,
Reid Spencera132e042006-12-03 05:46:11 +00001494 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001495 242, 247, 253, 259, 263, 266, 272, 277, 280, 282,
1496 286, 288, 292, 294, 295, 300, 304, 308, 313, 318,
1497 322, 325, 328, 331, 334, 337, 340, 343, 346, 349,
1498 352, 355, 358, 365, 371, 380, 387, 394, 402, 410,
1499 417, 424, 433, 442, 446, 448, 450, 452, 454, 457,
1500 460, 465, 468, 470, 475, 478, 483, 484, 492, 493,
1501 501, 502, 510, 511, 519, 523, 528, 529, 531, 533,
1502 535, 539, 543, 547, 551, 555, 559, 561, 562, 564,
1503 566, 568, 569, 572, 576, 578, 580, 584, 586, 587,
1504 596, 598, 600, 604, 606, 608, 611, 612, 614, 616,
1505 617, 622, 623, 625, 627, 629, 631, 633, 635, 637,
1506 639, 641, 645, 647, 653, 655, 657, 659, 661, 664,
1507 667, 670, 674, 677, 678, 680, 683, 686, 690, 700,
1508 710, 719, 733, 735, 737, 744, 750, 753, 760, 768,
1509 770, 774, 776, 777, 780, 782, 788, 794, 801, 808,
1510 811, 816, 821, 828, 833, 838, 845, 852, 855, 863,
1511 865, 868, 869, 871, 872, 876, 883, 887, 894, 897,
1512 902, 909
Reid Spencer3822ff52006-11-08 06:47:33 +00001513};
1514
Andrew Lenharth6353e052006-12-08 18:07:09 +00001515/* YYRHS -- A `-1'-separated list of the rules' RHS. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001516static const short int yyrhs[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001517{
Reid Spencere4d87aa2006-12-23 06:05:41 +00001518 185, 0, -1, 5, -1, 6, -1, 78, -1, 79,
1519 -1, 80, -1, 81, -1, 82, -1, 83, -1, 84,
1520 -1, 85, -1, 86, -1, 87, -1, 88, -1, 89,
1521 -1, 118, -1, 119, -1, 120, -1, 121, -1, 122,
1522 -1, 123, -1, 124, -1, 125, -1, 126, -1, 127,
1523 -1, 128, -1, 129, -1, 132, -1, 133, -1, 134,
1524 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1525 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1526 -1, 102, -1, 103, -1, 104, -1, 105, -1, 106,
1527 -1, 107, -1, 108, -1, 109, -1, 110, -1, 111,
1528 -1, 98, -1, 99, -1, 100, -1, 101, -1, 27,
1529 -1, 28, -1, 16, -1, 14, -1, 12, -1, 10,
1530 -1, 17, -1, 15, -1, 13, -1, 11, -1, 161,
1531 -1, 162, -1, 18, -1, 19, -1, 197, 139, -1,
1532 -1, 41, -1, 42, -1, 43, -1, 44, -1, 45,
1533 -1, 46, -1, 47, -1, -1, -1, 65, -1, 66,
1534 -1, 67, -1, 68, -1, 69, -1, 70, -1, 64,
1535 4, -1, -1, 57, 4, -1, -1, 140, 57, 4,
1536 -1, 34, 24, -1, -1, 170, -1, -1, 140, 173,
1537 172, -1, 170, -1, 57, 4, -1, 176, -1, 8,
1538 -1, 178, -1, 8, -1, 178, -1, 9, -1, 10,
1539 -1, 11, -1, 12, -1, 13, -1, 14, -1, 15,
1540 -1, 16, -1, 17, -1, 18, -1, 19, -1, 20,
1541 -1, 21, -1, 48, -1, 177, -1, 212, -1, 141,
1542 4, -1, 175, 142, 180, 143, -1, 144, 4, 145,
1543 178, 146, -1, 147, 4, 145, 178, 148, -1, 149,
1544 179, 150, -1, 149, 150, -1, 147, 149, 179, 150,
1545 148, -1, 147, 149, 150, 148, -1, 178, 151, -1,
1546 178, -1, 179, 140, 178, -1, 179, -1, 179, 140,
1547 37, -1, 37, -1, -1, 176, 144, 183, 146, -1,
1548 176, 144, 146, -1, 176, 152, 24, -1, 176, 147,
1549 183, 148, -1, 176, 149, 183, 150, -1, 176, 149,
1550 150, -1, 176, 38, -1, 176, 39, -1, 176, 212,
1551 -1, 176, 182, -1, 176, 26, -1, 161, 3, -1,
1552 161, 4, -1, 162, 4, -1, 162, 3, -1, 9,
1553 27, -1, 9, 28, -1, 164, 7, -1, 157, 142,
1554 181, 36, 176, 143, -1, 117, 142, 181, 226, 143,
1555 -1, 131, 142, 181, 140, 181, 140, 181, 143, -1,
1556 155, 142, 181, 140, 181, 143, -1, 156, 142, 181,
1557 140, 181, 143, -1, 90, 159, 142, 181, 140, 181,
1558 143, -1, 91, 160, 142, 181, 140, 181, 143, -1,
1559 158, 142, 181, 140, 181, 143, -1, 136, 142, 181,
1560 140, 181, 143, -1, 137, 142, 181, 140, 181, 140,
1561 181, 143, -1, 138, 142, 181, 140, 181, 140, 181,
1562 143, -1, 183, 140, 181, -1, 181, -1, 32, -1,
1563 33, -1, 186, -1, 186, 206, -1, 186, 208, -1,
1564 186, 62, 61, 192, -1, 186, 25, -1, 187, -1,
1565 187, 165, 20, 174, -1, 187, 208, -1, 187, 62,
1566 61, 192, -1, -1, 187, 165, 166, 184, 181, 188,
1567 172, -1, -1, 187, 165, 50, 184, 176, 189, 172,
1568 -1, -1, 187, 165, 45, 184, 176, 190, 172, -1,
1569 -1, 187, 165, 47, 184, 176, 191, 172, -1, 187,
1570 51, 194, -1, 187, 58, 139, 195, -1, -1, 24,
1571 -1, 56, -1, 55, -1, 53, 139, 193, -1, 54,
1572 139, 4, -1, 52, 139, 24, -1, 71, 139, 24,
1573 -1, 144, 196, 146, -1, 196, 140, 24, -1, 24,
1574 -1, -1, 22, -1, 24, -1, 197, -1, -1, 176,
1575 198, -1, 200, 140, 199, -1, 199, -1, 200, -1,
1576 200, 140, 37, -1, 37, -1, -1, 167, 174, 197,
1577 142, 201, 143, 171, 168, -1, 29, -1, 149, -1,
1578 166, 202, 203, -1, 30, -1, 150, -1, 215, 205,
1579 -1, -1, 45, -1, 47, -1, -1, 31, 209, 207,
1580 202, -1, -1, 63, -1, 3, -1, 4, -1, 7,
1581 -1, 27, -1, 28, -1, 38, -1, 39, -1, 26,
1582 -1, 147, 183, 148, -1, 182, -1, 61, 210, 24,
1583 140, 24, -1, 154, -1, 197, -1, 212, -1, 211,
1584 -1, 176, 213, -1, 215, 216, -1, 204, 216, -1,
1585 217, 165, 218, -1, 217, 220, -1, -1, 23, -1,
1586 72, 214, -1, 72, 8, -1, 73, 21, 213, -1,
1587 73, 9, 213, 140, 21, 213, 140, 21, 213, -1,
1588 74, 163, 213, 140, 21, 213, 144, 219, 146, -1,
1589 74, 163, 213, 140, 21, 213, 144, 146, -1, 75,
1590 167, 174, 213, 142, 223, 143, 36, 21, 213, 76,
1591 21, 213, -1, 76, -1, 77, -1, 219, 163, 211,
1592 140, 21, 213, -1, 163, 211, 140, 21, 213, -1,
1593 165, 225, -1, 176, 144, 213, 140, 213, 146, -1,
1594 221, 140, 144, 213, 140, 213, 146, -1, 214, -1,
1595 222, 140, 214, -1, 222, -1, -1, 60, 59, -1,
1596 59, -1, 155, 176, 213, 140, 213, -1, 156, 176,
1597 213, 140, 213, -1, 90, 159, 176, 213, 140, 213,
1598 -1, 91, 160, 176, 213, 140, 213, -1, 49, 214,
1599 -1, 158, 214, 140, 214, -1, 157, 214, 36, 176,
1600 -1, 131, 214, 140, 214, 140, 214, -1, 135, 214,
1601 140, 176, -1, 136, 214, 140, 214, -1, 137, 214,
1602 140, 214, 140, 214, -1, 138, 214, 140, 214, 140,
1603 214, -1, 130, 221, -1, 224, 167, 174, 213, 142,
1604 223, 143, -1, 228, -1, 140, 222, -1, -1, 35,
1605 -1, -1, 112, 176, 169, -1, 112, 176, 140, 15,
1606 213, 169, -1, 113, 176, 169, -1, 113, 176, 140,
1607 15, 213, 169, -1, 114, 214, -1, 227, 115, 176,
1608 213, -1, 227, 116, 214, 140, 176, 213, -1, 117,
1609 176, 213, 226, -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 Spencere4d87aa2006-12-23 06:05:41 +00001615 0, 988, 988, 989, 999, 999, 999, 999, 999, 999,
1616 999, 999, 999, 1000, 1000, 1000, 1001, 1001, 1001, 1001,
1617 1001, 1001, 1002, 1002, 1002, 1002, 1002, 1002, 1003, 1003,
1618 1003, 1005, 1005, 1006, 1006, 1007, 1007, 1008, 1008, 1009,
1619 1009, 1013, 1013, 1014, 1014, 1015, 1015, 1016, 1016, 1017,
1620 1017, 1018, 1018, 1019, 1019, 1020, 1021, 1026, 1026, 1026,
1621 1026, 1027, 1027, 1027, 1027, 1028, 1028, 1029, 1029, 1032,
1622 1036, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1050,
1623 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1066, 1067, 1073,
1624 1074, 1082, 1090, 1091, 1096, 1097, 1098, 1103, 1117, 1117,
1625 1118, 1118, 1120, 1130, 1130, 1130, 1130, 1130, 1130, 1130,
1626 1131, 1131, 1131, 1131, 1131, 1131, 1132, 1136, 1140, 1148,
1627 1156, 1169, 1174, 1186, 1196, 1200, 1210, 1214, 1225, 1230,
1628 1236, 1237, 1241, 1245, 1256, 1282, 1296, 1326, 1352, 1373,
1629 1386, 1396, 1401, 1462, 1469, 1477, 1483, 1489, 1495, 1501,
1630 1505, 1509, 1517, 1529, 1550, 1558, 1564, 1575, 1580, 1585,
1631 1594, 1600, 1606, 1615, 1619, 1627, 1627, 1637, 1645, 1650,
1632 1654, 1658, 1662, 1677, 1699, 1702, 1705, 1705, 1713, 1713,
1633 1721, 1721, 1729, 1729, 1738, 1741, 1744, 1748, 1761, 1762,
1634 1764, 1768, 1777, 1781, 1786, 1788, 1793, 1798, 1807, 1807,
1635 1808, 1808, 1810, 1817, 1823, 1830, 1834, 1840, 1845, 1850,
1636 1945, 1945, 1947, 1955, 1955, 1957, 1962, 1963, 1964, 1966,
1637 1966, 1976, 1980, 1985, 1989, 1993, 1997, 2001, 2005, 2009,
1638 2013, 2017, 2042, 2046, 2060, 2064, 2070, 2070, 2076, 2081,
1639 2085, 2094, 2105, 2114, 2126, 2139, 2143, 2147, 2152, 2161,
1640 2180, 2189, 2245, 2249, 2256, 2267, 2280, 2289, 2298, 2308,
1641 2312, 2319, 2319, 2321, 2325, 2330, 2349, 2364, 2375, 2386,
1642 2399, 2408, 2419, 2427, 2432, 2438, 2444, 2450, 2465, 2524,
1643 2531, 2534, 2539, 2543, 2550, 2555, 2561, 2566, 2572, 2580,
1644 2592, 2607
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",
1655 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1656 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1657 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1658 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1659 "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",
1677 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
1678 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
1679 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
1680 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
1681 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
1682 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
1683 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
1684 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
1685 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
1686 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
Reid Spencercd42c582006-12-05 23:29:42 +00001687 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1688 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList",
1689 "ValueRefListE", "OptTailCall", "InstVal", "IndexList", "OptVolatile",
1690 "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 Spencere4d87aa2006-12-23 06:05:41 +00001712 385, 386, 387, 388, 389, 390, 391, 392, 393, 61,
1713 44, 92, 40, 41, 91, 120, 93, 60, 62, 123,
1714 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 Spencere4d87aa2006-12-23 06:05:41 +00001721 0, 153, 154, 154, 155, 155, 155, 155, 155, 155,
1722 155, 155, 155, 156, 156, 156, 157, 157, 157, 157,
1723 157, 157, 157, 157, 157, 157, 157, 157, 158, 158,
1724 158, 159, 159, 159, 159, 159, 159, 159, 159, 159,
1725 159, 160, 160, 160, 160, 160, 160, 160, 160, 160,
1726 160, 160, 160, 160, 160, 160, 160, 161, 161, 161,
1727 161, 162, 162, 162, 162, 163, 163, 164, 164, 165,
1728 165, 166, 166, 166, 166, 166, 166, 166, 166, 167,
1729 167, 167, 167, 167, 167, 167, 167, 168, 168, 169,
1730 169, 170, 171, 171, 172, 172, 173, 173, 174, 174,
1731 175, 175, 176, 177, 177, 177, 177, 177, 177, 177,
1732 177, 177, 177, 177, 177, 177, 178, 178, 178, 178,
1733 178, 178, 178, 178, 178, 178, 178, 178, 179, 179,
1734 180, 180, 180, 180, 181, 181, 181, 181, 181, 181,
1735 181, 181, 181, 181, 181, 181, 181, 181, 181, 181,
1736 181, 181, 182, 182, 182, 182, 182, 182, 182, 182,
1737 182, 182, 182, 183, 183, 184, 184, 185, 186, 186,
1738 186, 186, 186, 187, 187, 187, 188, 187, 189, 187,
1739 190, 187, 191, 187, 187, 187, 187, 192, 193, 193,
1740 194, 194, 194, 194, 195, 196, 196, 196, 197, 197,
1741 198, 198, 199, 200, 200, 201, 201, 201, 201, 202,
1742 203, 203, 204, 205, 205, 206, 207, 207, 207, 209,
1743 208, 210, 210, 211, 211, 211, 211, 211, 211, 211,
1744 211, 211, 211, 211, 212, 212, 213, 213, 214, 215,
1745 215, 216, 217, 217, 217, 218, 218, 218, 218, 218,
1746 218, 218, 218, 218, 219, 219, 220, 221, 221, 222,
1747 222, 223, 223, 224, 224, 225, 225, 225, 225, 225,
1748 225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
1749 226, 226, 227, 227, 228, 228, 228, 228, 228, 228,
1750 228, 228
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,
1763 0, 1, 1, 1, 1, 1, 1, 1, 0, 0,
1764 1, 1, 1, 1, 1, 1, 2, 0, 2, 0,
1765 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001766 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001767 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
1768 4, 5, 5, 3, 2, 5, 4, 2, 1, 3,
1769 1, 3, 1, 0, 4, 3, 3, 4, 4, 3,
1770 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1771 2, 2, 6, 5, 8, 6, 6, 7, 7, 6,
1772 6, 8, 8, 3, 1, 1, 1, 1, 2, 2,
1773 4, 2, 1, 4, 2, 4, 0, 7, 0, 7,
1774 0, 7, 0, 7, 3, 4, 0, 1, 1, 1,
1775 3, 3, 3, 3, 3, 3, 1, 0, 1, 1,
1776 1, 0, 2, 3, 1, 1, 3, 1, 0, 8,
1777 1, 1, 3, 1, 1, 2, 0, 1, 1, 0,
1778 4, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1779 1, 3, 1, 5, 1, 1, 1, 1, 2, 2,
1780 2, 3, 2, 0, 1, 2, 2, 3, 9, 9,
1781 8, 13, 1, 1, 6, 5, 2, 6, 7, 1,
1782 3, 1, 0, 2, 1, 5, 5, 6, 6, 2,
1783 4, 4, 6, 4, 4, 6, 6, 2, 7, 1,
1784 2, 0, 1, 0, 3, 6, 3, 6, 2, 4,
1785 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 Spencere4d87aa2006-12-23 06:05:41 +00001793 186, 0, 78, 172, 1, 171, 219, 71, 72, 73,
1794 74, 75, 76, 77, 0, 79, 243, 168, 169, 243,
1795 198, 199, 0, 0, 0, 78, 0, 174, 216, 0,
1796 0, 80, 81, 82, 83, 84, 85, 0, 0, 244,
1797 240, 70, 213, 214, 215, 239, 0, 0, 0, 0,
1798 184, 0, 0, 0, 0, 0, 0, 0, 69, 217,
1799 218, 79, 187, 170, 86, 2, 3, 99, 103, 104,
1800 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1801 115, 116, 0, 0, 0, 0, 234, 0, 0, 98,
1802 117, 102, 235, 118, 210, 211, 212, 283, 242, 0,
1803 0, 0, 0, 197, 185, 175, 173, 165, 166, 0,
1804 0, 0, 0, 220, 119, 0, 0, 0, 101, 124,
1805 128, 0, 0, 133, 127, 282, 0, 264, 0, 0,
1806 0, 0, 79, 252, 253, 4, 5, 6, 7, 8,
1807 9, 10, 11, 12, 13, 14, 15, 0, 0, 0,
1808 0, 0, 0, 16, 17, 18, 19, 20, 21, 22,
1809 23, 24, 25, 26, 27, 0, 0, 28, 29, 30,
1810 0, 0, 0, 0, 0, 0, 0, 0, 241, 79,
1811 256, 0, 279, 192, 189, 188, 190, 191, 193, 196,
1812 0, 180, 182, 178, 103, 104, 105, 106, 107, 108,
1813 109, 110, 111, 112, 113, 0, 0, 0, 0, 176,
1814 0, 0, 0, 0, 0, 123, 208, 132, 130, 0,
1815 0, 269, 263, 246, 245, 0, 0, 60, 64, 59,
1816 63, 58, 62, 57, 61, 65, 66, 0, 0, 31,
1817 32, 33, 34, 35, 36, 37, 38, 39, 40, 0,
1818 55, 56, 51, 52, 53, 54, 41, 42, 43, 44,
1819 45, 46, 47, 48, 49, 50, 0, 89, 89, 288,
1820 0, 0, 277, 0, 0, 0, 0, 0, 0, 0,
1821 0, 0, 0, 0, 0, 0, 194, 94, 94, 94,
1822 149, 150, 145, 146, 148, 147, 151, 144, 140, 141,
Reid Spencer3822ff52006-11-08 06:47:33 +00001823 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencere4d87aa2006-12-23 06:05:41 +00001824 0, 0, 0, 0, 0, 143, 142, 94, 100, 100,
1825 126, 0, 129, 207, 201, 204, 205, 0, 0, 120,
1826 223, 224, 225, 230, 226, 227, 228, 229, 221, 0,
1827 232, 237, 236, 238, 0, 247, 0, 0, 0, 0,
1828 0, 284, 0, 286, 281, 0, 0, 0, 0, 0,
1829 0, 0, 0, 0, 0, 0, 0, 0, 0, 195,
1830 0, 181, 183, 179, 0, 0, 0, 0, 0, 0,
1831 0, 135, 164, 0, 0, 139, 0, 136, 0, 0,
1832 0, 0, 177, 121, 122, 125, 200, 202, 0, 92,
1833 131, 222, 0, 0, 0, 0, 0, 0, 0, 0,
1834 0, 0, 0, 291, 0, 0, 0, 273, 274, 0,
1835 0, 0, 0, 271, 270, 0, 289, 0, 0, 0,
1836 96, 94, 0, 0, 281, 0, 0, 0, 0, 0,
1837 134, 137, 138, 0, 0, 0, 0, 206, 203, 93,
1838 87, 0, 231, 0, 0, 262, 0, 0, 89, 90,
1839 89, 259, 280, 0, 0, 0, 0, 0, 265, 266,
1840 262, 0, 91, 97, 95, 0, 0, 0, 0, 0,
1841 0, 0, 163, 0, 0, 0, 0, 0, 209, 0,
1842 0, 0, 261, 0, 267, 268, 0, 285, 287, 0,
1843 0, 0, 272, 275, 276, 0, 290, 0, 0, 153,
1844 0, 0, 0, 0, 0, 0, 0, 0, 88, 233,
1845 0, 0, 0, 260, 257, 0, 278, 0, 0, 0,
1846 160, 0, 0, 155, 156, 152, 159, 0, 250, 0,
1847 0, 0, 258, 157, 158, 0, 0, 0, 248, 0,
1848 249, 0, 0, 154, 161, 162, 0, 0, 0, 0,
1849 0, 0, 255, 0, 0, 254, 251
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 Spencere4d87aa2006-12-23 06:05:41 +00001855 -1, 86, 311, 312, 313, 314, 249, 266, 205, 206,
1856 237, 207, 25, 15, 37, 488, 351, 430, 450, 371,
1857 431, 87, 88, 208, 90, 91, 121, 219, 382, 340,
1858 383, 109, 1, 2, 3, 317, 289, 287, 288, 63,
1859 186, 50, 104, 190, 92, 397, 325, 326, 327, 38,
1860 96, 16, 44, 17, 61, 18, 28, 402, 341, 93,
1861 343, 461, 19, 40, 41, 178, 540, 98, 272, 492,
1862 493, 179, 180, 413, 181, 182
Reid Spencer3822ff52006-11-08 06:47:33 +00001863};
1864
1865/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1866 STATE-NUM. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001867#define YYPACT_NINF -514
1868static const short int yypact[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001869{
Reid Spencere4d87aa2006-12-23 06:05:41 +00001870 -514, 47, 80, 817, -514, -514, -514, -514, -514, -514,
1871 -514, -514, -514, -514, -3, 79, 67, -514, -514, -9,
1872 -514, -514, 33, -46, 42, 139, -29, -514, -2, 95,
1873 126, -514, -514, -514, -514, -514, -514, 1112, -18, -514,
1874 -514, 96, -514, -514, -514, -514, -7, 29, 56, 61,
1875 -514, 34, 95, 1112, 74, 74, 74, 74, -514, -514,
1876 -514, 79, -514, -514, -514, -514, -514, 45, -514, -514,
1877 -514, -514, -514, -514, -514, -514, -514, -514, -514, -514,
1878 -514, -514, 209, 211, 2, 538, -514, 96, 77, -514,
1879 -514, -118, -514, -514, -514, -514, -514, 1252, -514, 201,
1880 102, 224, 206, 215, -514, -514, -514, -514, -514, 1153,
1881 1153, 1153, 1173, -514, -514, 112, 115, 598, -514, -514,
1882 -118, -111, 99, 643, -514, -514, 1153, -514, 207, 1214,
1883 14, 239, 79, -514, -514, -514, -514, -514, -514, -514,
1884 -514, -514, -514, -514, -514, -514, -514, 110, 190, 1153,
1885 1153, 1153, 1153, -514, -514, -514, -514, -514, -514, -514,
1886 -514, -514, -514, -514, -514, 1153, 1153, -514, -514, -514,
1887 1153, 1153, 1153, 1153, 1153, 1153, 1153, 1153, -514, 79,
1888 -514, 48, -514, -514, -514, -514, -514, -514, -514, -514,
1889 -94, -514, -514, -514, 138, 171, 173, 187, 189, 195,
1890 218, 220, 230, 258, 260, 232, 234, 267, 393, -514,
1891 1153, 1153, 129, -99, 1153, -514, 967, -514, 140, 135,
1892 691, -514, -514, 45, -514, 691, 691, -514, -514, -514,
1893 -514, -514, -514, -514, -514, -514, -514, 691, 1112, -514,
1894 -514, -514, -514, -514, -514, -514, -514, -514, -514, 1153,
1895 -514, -514, -514, -514, -514, -514, -514, -514, -514, -514,
1896 -514, -514, -514, -514, -514, -514, 1153, 145, 146, -514,
1897 691, 158, 163, 164, 165, 167, 169, 170, 691, 691,
1898 243, 172, 1112, 1153, 1153, 287, -514, 174, 174, 174,
1899 -514, -514, -514, -514, -514, -514, -514, -514, -514, -514,
1900 110, 190, 176, 177, 188, 191, 192, 914, 1173, 618,
1901 289, 193, 194, 196, 197, -514, -514, 174, -119, -60,
1902 -514, 181, -118, -514, 96, -514, 175, 198, 1008, -514,
1903 -514, -514, -514, -514, -514, -514, -514, -514, 274, 1173,
1904 -514, -514, -514, -514, 200, -514, 203, 691, 691, 691,
1905 0, -514, 13, -514, 204, 691, 202, 1153, 1153, 1153,
1906 1153, 1153, 205, 212, 1153, 1153, 691, 691, 213, -514,
1907 -17, -514, -514, -514, 214, 216, 1173, 1173, 1173, 1173,
1908 1173, -514, -514, 15, -32, -514, -69, -514, 1173, 1173,
1909 1173, 1173, -514, -514, -514, -514, -514, -514, 1059, 313,
1910 -514, -514, 327, -31, 333, 334, 217, 222, 223, 691,
1911 356, 691, 1153, -514, 225, 691, 226, -514, -514, 227,
1912 238, 691, 691, -514, -514, 228, -514, 1153, 357, 376,
1913 -514, 174, 1173, 1173, 204, 244, 248, 249, 254, 1173,
1914 -514, -514, -514, 255, 256, 347, 257, -514, -514, -514,
1915 345, 263, -514, 691, 691, 1153, 691, 691, 266, -514,
1916 266, -514, 268, 691, 269, 1153, 1153, 1153, -514, -514,
1917 1153, 691, -514, -514, -514, 272, 273, 264, 1173, 1173,
1918 1173, 1173, -514, 1173, 1173, 1153, 1173, 410, -514, 392,
1919 280, 277, 268, 283, -514, -514, 366, -514, -514, 1153,
1920 281, 691, -514, -514, -514, 291, -514, 1173, 1173, -514,
1921 295, 293, 297, 298, 296, 299, 300, 301, -514, -514,
1922 419, 51, 405, -514, -514, 304, -514, 302, 303, 1173,
1923 -514, 1173, 1173, -514, -514, -514, -514, 691, -514, 827,
1924 85, 430, -514, -514, -514, 309, 311, 312, -514, 316,
1925 -514, 827, 691, -514, -514, -514, 436, 318, 385, 691,
1926 442, 443, -514, 691, 691, -514, -514
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 Spencere4d87aa2006-12-23 06:05:41 +00001932 -514, -514, 368, 369, 370, 371, 185, 168, -130, -129,
1933 -503, -514, 429, 461, -110, -514, -264, 88, -514, -281,
1934 -514, -50, -514, -37, -514, -41, 39, -514, -107, 282,
1935 -289, 22, -514, -514, -514, -514, -514, -514, -514, 437,
1936 -514, -514, -514, -514, 7, -514, 90, -514, -514, 432,
1937 -514, -514, -514, -514, -514, 493, -514, -514, -513, -195,
1938 38, -117, -514, 478, -514, -514, -514, -514, -514, 86,
1939 30, -514, -514, 65, -514, -514
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 Spencere4d87aa2006-12-23 06:05:41 +00001946#define YYTABLE_NINF -168
1947static const short int yytable[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001948{
Reid Spencere4d87aa2006-12-23 06:05:41 +00001949 89, 235, 236, 106, 353, 209, 116, 372, 373, 221,
1950 26, 94, 224, 316, 39, 409, 89, 428, 539, 384,
1951 386, 42, 238, 225, -100, 342, 549, 393, 411, 214,
1952 342, 342, 124, 124, 269, 226, 392, 551, 557, 215,
1953 429, 214, 342, 59, 120, 60, 285, 4, 26, 273,
1954 403, 321, 286, 274, 275, 276, 277, 410, 29, 280,
1955 281, 227, 228, 229, 230, 231, 232, 233, 234, 282,
1956 410, 439, 191, 192, 193, 342, 120, 110, 111, 112,
1957 -167, 442, 120, 342, 342, 46, 47, 48, 394, 220,
1958 39, 124, 220, 51, 122, 227, 228, 229, 230, 231,
1959 232, 233, 234, 52, 49, 5, 107, 108, 439, 439,
1960 58, 6, 267, 268, 220, 270, 441, 452, 20, 62,
1961 21, 7, 8, 9, 10, 11, 12, 13, 271, 220,
1962 64, 95, 99, 220, 220, 220, 220, 278, 279, 220,
1963 220, 43, 14, 30, 31, 32, 33, 34, 35, 36,
1964 474, 117, 342, 342, 342, 439, 213, 184, 185, 53,
1965 342, 440, 218, 283, 284, 290, 291, 368, 100, 318,
1966 319, 342, 342, 322, -60, -60, -64, -64, 103, 324,
1967 7, 8, 9, 10, 54, 12, 55, -101, 347, 56,
1968 -59, -59, -63, -63, 497, 101, 498, 538, -58, -58,
1969 102, 89, 239, 240, 241, 242, 243, 244, 245, 246,
1970 247, 248, 348, 114, 342, 115, 342, 250, 251, 123,
1971 342, -62, -62, -57, -57, 183, 342, 342, 187, 349,
1972 188, 550, 366, -61, -61, 292, 293, 294, 295, 189,
1973 416, 216, 418, 419, 420, 89, 367, 220, 424, 227,
1974 228, 229, 230, 231, 232, 233, 234, 210, 342, 342,
1975 211, 342, 342, 344, 345, -67, 222, -68, 342, 434,
1976 435, 436, 437, 438, 296, 346, 342, 320, 329, 364,
1977 328, 443, 444, 445, 446, 350, 352, 322, 252, 253,
1978 254, 255, 256, 257, 258, 259, 260, 261, 262, 263,
1979 264, 265, 355, 356, 357, 358, 342, 359, 354, 360,
1980 361, 369, 365, 387, 370, 398, 362, 363, 376, 377,
1981 220, 417, 220, 220, 220, 475, 476, 423, 220, 395,
1982 378, 396, 482, 379, 380, 388, 389, 401, 390, 391,
1983 404, 399, 342, 405, 412, 421, 415, 428, 502, 503,
1984 504, 451, 422, 427, 453, 454, 432, 342, 433, 455,
1985 459, 324, 456, 457, 342, 463, 465, 466, 342, 342,
1986 470, 510, 511, 512, 513, 220, 514, 515, 467, 517,
1987 473, 472, 523, 485, 478, 406, 407, 408, 479, 480,
1988 471, 235, 236, 414, 481, 483, 484, 486, 65, 66,
1989 527, 528, 487, 489, 425, 426, 496, 509, 499, 501,
1990 235, 236, 507, 508, 518, 20, 519, 21, 220, 297,
1991 520, 521, 545, 410, 546, 547, 522, 524, 220, 220,
1992 220, 298, 299, 220, 526, 529, 530, 531, 532, 533,
1993 537, 541, 534, 535, 536, 543, 544, 458, 516, 460,
1994 542, 552, 553, 464, 554, 555, 556, 559, 560, 468,
1995 469, 561, 220, 563, 564, 174, 175, 176, 177, 375,
1996 97, 135, 136, 137, 138, 139, 140, 141, 142, 143,
1997 144, 145, 146, 300, 301, 374, 57, 449, 448, 105,
1998 315, 490, 491, 113, 494, 495, 27, 45, 462, 477,
1999 505, 500, 0, 0, 0, 0, 0, 0, 0, 506,
2000 302, 153, 154, 155, 156, 157, 158, 159, 160, 161,
2001 162, 163, 164, 0, 303, 167, 168, 169, 0, 304,
2002 305, 306, 0, 0, 0, 0, 0, 307, 0, 525,
2003 308, 0, 309, 65, 66, 310, 118, 68, 69, 70,
Andrew Lenharth6353e052006-12-08 18:07:09 +00002004 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002005 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002006 0, 0, 0, 0, 0, 548, 0, 0, 0, 0,
2007 0, 0, 0, 0, 0, 0, 81, 0, 0, 0,
2008 558, 0, 0, 0, 0, 0, 0, 562, 0, 0,
2009 0, 565, 566, 65, 66, 0, 118, 68, 69, 70,
2010 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2011 20, 0, 21, 65, 66, 0, 118, 194, 195, 196,
2012 197, 198, 199, 200, 201, 202, 203, 204, 79, 80,
2013 20, 0, 21, 0, 0, 0, 81, 0, 65, 66,
2014 0, 118, 68, 69, 70, 71, 72, 73, 74, 75,
2015 76, 77, 78, 79, 80, 20, 81, 21, 0, 0,
2016 0, 0, 0, 0, 0, 0, 0, 0, 0, 82,
2017 217, 0, 83, 0, 0, 84, 0, 85, 119, 0,
2018 0, 81, 0, 0, 330, 331, 65, 66, 332, 0,
2019 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2020 0, 0, 0, 20, 0, 21, 0, 333, 334, 335,
2021 0, 0, 0, 0, 0, 0, 0, 0, 0, 336,
2022 337, 0, 0, 0, 0, 0, 0, 0, 0, 82,
2023 0, 0, 83, 0, 0, 84, 0, 85, 212, 0,
2024 0, 0, 338, 0, 0, 0, 0, 0, 0, 82,
2025 0, 0, 83, 0, 0, 84, 0, 85, 385, 135,
2026 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
2027 146, 300, 301, 0, 82, 0, 0, 83, 0, 0,
2028 84, 0, 85, 0, 0, 0, 0, 0, 0, 0,
2029 0, 0, 0, 0, 0, 0, 0, 0, 302, 153,
2030 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
2031 164, 0, 303, 167, 168, 169, 0, 304, 305, 306,
2032 330, 331, 0, 0, 332, 0, 0, -70, 339, 20,
2033 0, 21, 0, 0, 0, 0, 0, 0, 6, -70,
2034 -70, 0, 0, 333, 334, 335, 0, 0, -70, -70,
2035 -70, -70, -70, -70, -70, 336, 337, -70, 22, 0,
2036 0, 0, 0, 0, 0, 23, 0, 0, 0, 24,
2037 0, 0, 0, 0, 0, 0, 0, 0, 338, 0,
2038 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2039 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2040 140, 141, 142, 143, 144, 145, 146, 300, 301, 65,
2041 66, 0, 118, 194, 195, 196, 197, 198, 199, 200,
2042 201, 202, 203, 204, 79, 80, 20, 0, 21, 0,
2043 0, 0, 0, 0, 302, 153, 154, 155, 156, 157,
2044 158, 159, 160, 161, 162, 163, 164, 0, 303, 167,
2045 168, 169, 81, 304, 305, 306, 0, 0, 0, 0,
2046 0, 0, 65, 66, 339, 118, 68, 69, 70, 71,
2047 72, 73, 74, 75, 76, 77, 78, 79, 80, 20,
2048 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2049 0, 0, 0, 0, 323, 0, 0, 0, 0, 0,
2050 0, 0, 0, 65, 66, 81, 118, 68, 69, 70,
2051 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2052 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2053 0, 0, 0, 0, 0, 400, 0, 0, 0, 0,
2054 0, 0, 0, 0, 0, 82, 81, 0, 83, 0,
2055 381, 84, 0, 85, 65, 66, 0, 118, 68, 69,
Reid Spencercd42c582006-12-05 23:29:42 +00002056 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2057 80, 20, 0, 21, 0, 0, 0, 0, 0, 0,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002058 0, 0, 0, 0, 0, 0, 447, 0, 0, 0,
2059 0, 0, 0, 0, 0, 0, 0, 81, 82, 0,
2060 0, 83, 0, 0, 84, 0, 85, 65, 66, 0,
2061 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2062 77, 78, 79, 80, 20, 0, 21, 0, 0, 0,
2063 0, 0, 0, 0, 0, 0, 0, 0, 0, 82,
2064 0, 0, 83, 0, 0, 84, 0, 85, 65, 66,
2065 81, 118, 68, 69, 70, 71, 72, 73, 74, 75,
2066 76, 77, 78, 79, 80, 20, 0, 21, 65, 66,
2067 0, 118, 194, 195, 196, 197, 198, 199, 200, 201,
2068 202, 203, 204, 79, 80, 20, 0, 21, 0, 0,
2069 82, 81, 0, 83, 0, 0, 84, 0, 85, 0,
2070 0, 0, 0, 0, 0, 0, 0, 0, 0, 65,
2071 66, 81, 223, 68, 69, 70, 71, 72, 73, 74,
2072 75, 76, 77, 78, 79, 80, 20, 0, 21, 0,
2073 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Andrew Lenharth6353e052006-12-08 18:07:09 +00002074 0, 0, 0, 82, 0, 0, 83, 0, 0, 84,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002075 0, 85, 81, 0, 0, 0, 0, 0, 0, 0,
2076 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2077 0, 0, 0, 0, 0, 0, 0, 125, 0, 0,
2078 0, 0, 0, 0, 82, 0, 0, 83, 0, 0,
2079 84, 126, 85, 0, 0, 0, 0, 0, 0, 0,
2080 0, 127, 128, 0, 82, 0, 0, 83, 0, 0,
2081 84, 0, 85, 0, 129, 130, 131, 132, 133, 134,
2082 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2083 145, 146, 147, 148, 0, 0, 0, 0, 0, 0,
2084 0, 0, 0, 0, 0, 82, 0, 0, 83, 0,
2085 0, 84, 0, 85, 149, 150, 151, 0, 0, 152,
2086 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
2087 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2088 173
Reid Spencer3822ff52006-11-08 06:47:33 +00002089};
2090
Reid Spencere4d87aa2006-12-23 06:05:41 +00002091static const short int yycheck[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00002092{
Reid Spencere4d87aa2006-12-23 06:05:41 +00002093 37, 131, 131, 53, 268, 112, 4, 288, 289, 126,
2094 3, 29, 129, 208, 23, 15, 53, 34, 521, 308,
2095 309, 30, 132, 9, 142, 220, 539, 146, 15, 140,
2096 225, 226, 151, 151, 151, 21, 317, 540, 551, 150,
2097 57, 140, 237, 45, 85, 47, 140, 0, 41, 166,
2098 339, 150, 146, 170, 171, 172, 173, 57, 61, 176,
2099 177, 10, 11, 12, 13, 14, 15, 16, 17, 179,
2100 57, 140, 109, 110, 111, 270, 117, 55, 56, 57,
2101 0, 150, 123, 278, 279, 52, 53, 54, 148, 126,
2102 23, 151, 129, 139, 87, 10, 11, 12, 13, 14,
2103 15, 16, 17, 61, 71, 25, 32, 33, 140, 140,
2104 139, 31, 149, 150, 151, 152, 148, 148, 22, 24,
2105 24, 41, 42, 43, 44, 45, 46, 47, 165, 166,
2106 4, 149, 139, 170, 171, 172, 173, 174, 175, 176,
2107 177, 150, 62, 64, 65, 66, 67, 68, 69, 70,
2108 431, 149, 347, 348, 349, 140, 117, 55, 56, 20,
2109 355, 146, 123, 115, 116, 27, 28, 284, 139, 210,
2110 211, 366, 367, 214, 3, 4, 3, 4, 144, 216,
2111 41, 42, 43, 44, 45, 46, 47, 142, 238, 50,
2112 3, 4, 3, 4, 458, 139, 460, 146, 3, 4,
2113 139, 238, 92, 93, 94, 95, 96, 97, 98, 99,
2114 100, 101, 249, 4, 409, 4, 411, 27, 28, 142,
2115 415, 3, 4, 3, 4, 24, 421, 422, 4, 266,
2116 24, 146, 282, 3, 4, 3, 4, 3, 4, 24,
2117 357, 142, 359, 360, 361, 282, 283, 284, 365, 10,
2118 11, 12, 13, 14, 15, 16, 17, 145, 453, 454,
2119 145, 456, 457, 225, 226, 7, 59, 7, 463, 376,
2120 377, 378, 379, 380, 7, 237, 471, 148, 143, 36,
2121 140, 388, 389, 390, 391, 140, 140, 328, 98, 99,
2122 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
2123 110, 111, 144, 140, 140, 140, 501, 140, 270, 140,
2124 140, 24, 140, 24, 140, 140, 278, 279, 142, 142,
2125 357, 358, 359, 360, 361, 432, 433, 364, 365, 148,
2126 142, 324, 439, 142, 142, 142, 142, 63, 142, 142,
2127 140, 143, 537, 140, 140, 140, 144, 34, 465, 466,
2128 467, 24, 140, 140, 21, 21, 142, 552, 142, 142,
2129 4, 398, 140, 140, 559, 140, 140, 140, 563, 564,
2130 142, 478, 479, 480, 481, 412, 483, 484, 140, 486,
2131 4, 24, 499, 36, 140, 347, 348, 349, 140, 140,
2132 427, 521, 521, 355, 140, 140, 140, 140, 5, 6,
2133 507, 508, 57, 140, 366, 367, 140, 143, 140, 140,
2134 540, 540, 140, 140, 4, 22, 24, 24, 455, 26,
2135 140, 144, 529, 57, 531, 532, 143, 146, 465, 466,
2136 467, 38, 39, 470, 143, 140, 143, 140, 140, 143,
2137 21, 36, 143, 143, 143, 143, 143, 409, 485, 411,
2138 146, 21, 143, 415, 143, 143, 140, 21, 140, 421,
2139 422, 76, 499, 21, 21, 97, 97, 97, 97, 301,
2140 41, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2141 87, 88, 89, 90, 91, 300, 25, 399, 398, 52,
2142 208, 453, 454, 61, 456, 457, 3, 19, 412, 434,
2143 470, 463, -1, -1, -1, -1, -1, -1, -1, 471,
2144 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2145 127, 128, 129, -1, 131, 132, 133, 134, -1, 136,
2146 137, 138, -1, -1, -1, -1, -1, 144, -1, 501,
2147 147, -1, 149, 5, 6, 152, 8, 9, 10, 11,
2148 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2149 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2150 -1, -1, -1, -1, -1, 537, -1, -1, -1, -1,
2151 -1, -1, -1, -1, -1, -1, 48, -1, -1, -1,
2152 552, -1, -1, -1, -1, -1, -1, 559, -1, -1,
2153 -1, 563, 564, 5, 6, -1, 8, 9, 10, 11,
2154 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2155 22, -1, 24, 5, 6, -1, 8, 9, 10, 11,
2156 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2157 22, -1, 24, -1, -1, -1, 48, -1, 5, 6,
2158 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2159 17, 18, 19, 20, 21, 22, 48, 24, -1, -1,
2160 -1, -1, -1, -1, -1, -1, -1, -1, -1, 141,
2161 37, -1, 144, -1, -1, 147, -1, 149, 150, -1,
2162 -1, 48, -1, -1, 3, 4, 5, 6, 7, -1,
2163 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2164 -1, -1, -1, 22, -1, 24, -1, 26, 27, 28,
2165 -1, -1, -1, -1, -1, -1, -1, -1, -1, 38,
2166 39, -1, -1, -1, -1, -1, -1, -1, -1, 141,
2167 -1, -1, 144, -1, -1, 147, -1, 149, 150, -1,
2168 -1, -1, 61, -1, -1, -1, -1, -1, -1, 141,
2169 -1, -1, 144, -1, -1, 147, -1, 149, 150, 78,
2170 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2171 89, 90, 91, -1, 141, -1, -1, 144, -1, -1,
2172 147, -1, 149, -1, -1, -1, -1, -1, -1, -1,
2173 -1, -1, -1, -1, -1, -1, -1, -1, 117, 118,
2174 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2175 129, -1, 131, 132, 133, 134, -1, 136, 137, 138,
2176 3, 4, -1, -1, 7, -1, -1, 20, 147, 22,
2177 -1, 24, -1, -1, -1, -1, -1, -1, 31, 32,
2178 33, -1, -1, 26, 27, 28, -1, -1, 41, 42,
2179 43, 44, 45, 46, 47, 38, 39, 50, 51, -1,
2180 -1, -1, -1, -1, -1, 58, -1, -1, -1, 62,
2181 -1, -1, -1, -1, -1, -1, -1, -1, 61, -1,
2182 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2183 -1, -1, -1, -1, -1, 78, 79, 80, 81, 82,
2184 83, 84, 85, 86, 87, 88, 89, 90, 91, 5,
2185 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
2186 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2187 -1, -1, -1, -1, 117, 118, 119, 120, 121, 122,
2188 123, 124, 125, 126, 127, 128, 129, -1, 131, 132,
2189 133, 134, 48, 136, 137, 138, -1, -1, -1, -1,
2190 -1, -1, 5, 6, 147, 8, 9, 10, 11, 12,
Andrew Lenharth6353e052006-12-08 18:07:09 +00002191 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002192 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2193 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
2194 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
Reid Spencercd42c582006-12-05 23:29:42 +00002195 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2196 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
Andrew Lenharth6353e052006-12-08 18:07:09 +00002197 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002198 -1, -1, -1, -1, -1, 141, 48, -1, 144, -1,
2199 146, 147, -1, 149, 5, 6, -1, 8, 9, 10,
Reid Spencer4012e832006-12-04 05:24:24 +00002200 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Reid Spencercd42c582006-12-05 23:29:42 +00002201 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2202 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002203 -1, -1, -1, -1, -1, -1, -1, 48, 141, -1,
2204 -1, 144, -1, -1, 147, -1, 149, 5, 6, -1,
2205 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2206 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
2207 -1, -1, -1, -1, -1, -1, -1, -1, -1, 141,
2208 -1, -1, 144, -1, -1, 147, -1, 149, 5, 6,
2209 48, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2210 17, 18, 19, 20, 21, 22, -1, 24, 5, 6,
2211 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2212 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
2213 141, 48, -1, 144, -1, -1, 147, -1, 149, -1,
2214 -1, -1, -1, -1, -1, -1, -1, -1, -1, 5,
2215 6, 48, 8, 9, 10, 11, 12, 13, 14, 15,
2216 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2217 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2218 -1, -1, -1, 141, -1, -1, 144, -1, -1, 147,
2219 -1, 149, 48, -1, -1, -1, -1, -1, -1, -1,
2220 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2221 -1, -1, -1, -1, -1, -1, -1, 35, -1, -1,
2222 -1, -1, -1, -1, 141, -1, -1, 144, -1, -1,
2223 147, 49, 149, -1, -1, -1, -1, -1, -1, -1,
2224 -1, 59, 60, -1, 141, -1, -1, 144, -1, -1,
2225 147, -1, 149, -1, 72, 73, 74, 75, 76, 77,
2226 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
2227 88, 89, 90, 91, -1, -1, -1, -1, -1, -1,
2228 -1, -1, -1, -1, -1, 141, -1, -1, 144, -1,
2229 -1, 147, -1, 149, 112, 113, 114, -1, -1, 117,
2230 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2231 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
2232 138
Reid Spencer3822ff52006-11-08 06:47:33 +00002233};
2234
2235/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2236 symbol of state STATE-NUM. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002237static const unsigned char yystos[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00002238{
Reid Spencere4d87aa2006-12-23 06:05:41 +00002239 0, 185, 186, 187, 0, 25, 31, 41, 42, 43,
2240 44, 45, 46, 47, 62, 166, 204, 206, 208, 215,
2241 22, 24, 51, 58, 62, 165, 197, 208, 209, 61,
2242 64, 65, 66, 67, 68, 69, 70, 167, 202, 23,
2243 216, 217, 30, 150, 205, 216, 52, 53, 54, 71,
2244 194, 139, 61, 20, 45, 47, 50, 166, 139, 45,
2245 47, 207, 24, 192, 4, 5, 6, 8, 9, 10,
Reid Spencer3822ff52006-11-08 06:47:33 +00002246 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002247 21, 48, 141, 144, 147, 149, 154, 174, 175, 176,
2248 177, 178, 197, 212, 29, 149, 203, 165, 220, 139,
2249 139, 139, 139, 144, 195, 192, 174, 32, 33, 184,
2250 184, 184, 184, 202, 4, 4, 4, 149, 8, 150,
2251 178, 179, 197, 142, 151, 35, 49, 59, 60, 72,
Andrew Lenharth6353e052006-12-08 18:07:09 +00002252 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002253 83, 84, 85, 86, 87, 88, 89, 90, 91, 112,
2254 113, 114, 117, 118, 119, 120, 121, 122, 123, 124,
Andrew Lenharth6353e052006-12-08 18:07:09 +00002255 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002256 135, 136, 137, 138, 155, 156, 157, 158, 218, 224,
2257 225, 227, 228, 24, 55, 56, 193, 4, 24, 24,
2258 196, 176, 176, 176, 9, 10, 11, 12, 13, 14,
2259 15, 16, 17, 18, 19, 161, 162, 164, 176, 181,
2260 145, 145, 150, 179, 140, 150, 142, 37, 179, 180,
2261 176, 214, 59, 8, 214, 9, 21, 10, 11, 12,
2262 13, 14, 15, 16, 17, 161, 162, 163, 167, 92,
2263 93, 94, 95, 96, 97, 98, 99, 100, 101, 159,
2264 27, 28, 98, 99, 100, 101, 102, 103, 104, 105,
2265 106, 107, 108, 109, 110, 111, 160, 176, 176, 214,
2266 176, 176, 221, 214, 214, 214, 214, 214, 176, 176,
2267 214, 214, 167, 115, 116, 140, 146, 190, 191, 189,
2268 27, 28, 3, 4, 3, 4, 7, 26, 38, 39,
2269 90, 91, 117, 131, 136, 137, 138, 144, 147, 149,
2270 152, 155, 156, 157, 158, 182, 212, 188, 178, 178,
2271 148, 150, 178, 37, 176, 199, 200, 201, 140, 143,
2272 3, 4, 7, 26, 27, 28, 38, 39, 61, 147,
2273 182, 211, 212, 213, 213, 213, 213, 174, 176, 176,
2274 140, 169, 140, 169, 213, 144, 140, 140, 140, 140,
2275 140, 140, 213, 213, 36, 140, 174, 176, 214, 24,
2276 140, 172, 172, 172, 159, 160, 142, 142, 142, 142,
2277 142, 146, 181, 183, 183, 150, 183, 24, 142, 142,
2278 142, 142, 172, 146, 148, 148, 197, 198, 140, 143,
2279 37, 63, 210, 183, 140, 140, 213, 213, 213, 15,
2280 57, 15, 140, 226, 213, 144, 214, 176, 214, 214,
2281 214, 140, 140, 176, 214, 213, 213, 140, 34, 57,
2282 170, 173, 142, 142, 181, 181, 181, 181, 181, 140,
2283 146, 148, 150, 181, 181, 181, 181, 37, 199, 170,
2284 171, 24, 148, 21, 21, 142, 140, 140, 213, 4,
2285 213, 214, 222, 140, 213, 140, 140, 140, 213, 213,
2286 142, 176, 24, 4, 172, 181, 181, 226, 140, 140,
2287 140, 140, 181, 140, 140, 36, 140, 57, 168, 140,
2288 213, 213, 222, 223, 213, 213, 140, 169, 169, 140,
2289 213, 140, 214, 214, 214, 223, 213, 140, 140, 143,
2290 181, 181, 181, 181, 181, 181, 176, 181, 4, 24,
2291 140, 144, 143, 214, 146, 213, 143, 181, 181, 140,
2292 143, 140, 140, 143, 143, 143, 143, 21, 146, 163,
2293 219, 36, 146, 143, 143, 181, 181, 181, 213, 211,
2294 146, 163, 21, 143, 143, 143, 140, 211, 213, 21,
2295 140, 76, 213, 21, 21, 213, 213
Reid Spencer3822ff52006-11-08 06:47:33 +00002296};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002297
2298#define yyerrok (yyerrstatus = 0)
2299#define yyclearin (yychar = YYEMPTY)
Reid Spencer3822ff52006-11-08 06:47:33 +00002300#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002301#define YYEOF 0
Reid Spencer3822ff52006-11-08 06:47:33 +00002302
Reid Spencer68a24bd2005-08-27 18:50:39 +00002303#define YYACCEPT goto yyacceptlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002304#define YYABORT goto yyabortlab
2305#define YYERROR goto yyerrorlab
2306
2307
2308/* Like YYERROR except do call yyerror. This remains here temporarily
2309 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002310 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002311
Reid Spencer68a24bd2005-08-27 18:50:39 +00002312#define YYFAIL goto yyerrlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002313
Reid Spencer68a24bd2005-08-27 18:50:39 +00002314#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002315
2316#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002317do \
2318 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3822ff52006-11-08 06:47:33 +00002319 { \
2320 yychar = (Token); \
2321 yylval = (Value); \
2322 yytoken = YYTRANSLATE (yychar); \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002323 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002324 goto yybackup; \
2325 } \
2326 else \
Reid Spencere4d87aa2006-12-23 06:05:41 +00002327 { \
2328 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer3822ff52006-11-08 06:47:33 +00002329 YYERROR; \
2330 } \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002331while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002332
Reid Spencere4d87aa2006-12-23 06:05:41 +00002333
Reid Spencer68a24bd2005-08-27 18:50:39 +00002334#define YYTERROR 1
2335#define YYERRCODE 256
2336
Reid Spencer3822ff52006-11-08 06:47:33 +00002337
Reid Spencere4d87aa2006-12-23 06:05:41 +00002338/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2339 If N is 0, then set CURRENT to the empty location which ends
2340 the previous symbol: RHS[0] (always defined). */
2341
2342#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer3822ff52006-11-08 06:47:33 +00002343#ifndef YYLLOC_DEFAULT
Reid Spencere4d87aa2006-12-23 06:05:41 +00002344# define YYLLOC_DEFAULT(Current, Rhs, N) \
2345 do \
2346 if (N) \
2347 { \
2348 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2349 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2350 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2351 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2352 } \
2353 else \
2354 { \
2355 (Current).first_line = (Current).last_line = \
2356 YYRHSLOC (Rhs, 0).last_line; \
2357 (Current).first_column = (Current).last_column = \
2358 YYRHSLOC (Rhs, 0).last_column; \
2359 } \
2360 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002361#endif
2362
Reid Spencere4d87aa2006-12-23 06:05:41 +00002363
2364/* YY_LOCATION_PRINT -- Print the location on the stream.
2365 This macro was not mandated originally: define only if we know
2366 we won't break user code: when these are the locations we know. */
2367
2368#ifndef YY_LOCATION_PRINT
2369# if YYLTYPE_IS_TRIVIAL
2370# define YY_LOCATION_PRINT(File, Loc) \
2371 fprintf (File, "%d.%d-%d.%d", \
2372 (Loc).first_line, (Loc).first_column, \
2373 (Loc).last_line, (Loc).last_column)
2374# else
2375# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2376# endif
2377#endif
2378
2379
Reid Spencer3822ff52006-11-08 06:47:33 +00002380/* YYLEX -- calling `yylex' with the right arguments. */
2381
Reid Spencer68a24bd2005-08-27 18:50:39 +00002382#ifdef YYLEX_PARAM
Reid Spencer3822ff52006-11-08 06:47:33 +00002383# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002384#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002385# define YYLEX yylex ()
Chris Lattnerf49c1762006-11-08 05:58:47 +00002386#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002387
2388/* Enable debugging if requested. */
2389#if YYDEBUG
2390
2391# ifndef YYFPRINTF
2392# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2393# define YYFPRINTF fprintf
2394# endif
2395
2396# define YYDPRINTF(Args) \
2397do { \
2398 if (yydebug) \
2399 YYFPRINTF Args; \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002400} while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002401
Reid Spencere4d87aa2006-12-23 06:05:41 +00002402# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002403do { \
2404 if (yydebug) \
2405 { \
2406 YYFPRINTF (stderr, "%s ", Title); \
Reid Spencere4d87aa2006-12-23 06:05:41 +00002407 yysymprint (stderr, \
2408 Type, Value); \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002409 YYFPRINTF (stderr, "\n"); \
2410 } \
2411} while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002412
2413/*------------------------------------------------------------------.
2414| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2415| TOP (included). |
2416`------------------------------------------------------------------*/
2417
Andrew Lenharth6353e052006-12-08 18:07:09 +00002418#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002419static void
Reid Spencere4d87aa2006-12-23 06:05:41 +00002420yy_stack_print (short int *bottom, short int *top)
Chris Lattnerf49c1762006-11-08 05:58:47 +00002421#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002422static void
2423yy_stack_print (bottom, top)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002424 short int *bottom;
2425 short int *top;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002426#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002427{
2428 YYFPRINTF (stderr, "Stack now");
Andrew Lenharth6353e052006-12-08 18:07:09 +00002429 for (/* Nothing. */; bottom <= top; ++bottom)
Reid Spencer3822ff52006-11-08 06:47:33 +00002430 YYFPRINTF (stderr, " %d", *bottom);
2431 YYFPRINTF (stderr, "\n");
2432}
2433
2434# define YY_STACK_PRINT(Bottom, Top) \
2435do { \
2436 if (yydebug) \
2437 yy_stack_print ((Bottom), (Top)); \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002438} while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002439
2440
2441/*------------------------------------------------.
2442| Report that the YYRULE is going to be reduced. |
2443`------------------------------------------------*/
2444
Andrew Lenharth6353e052006-12-08 18:07:09 +00002445#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002446static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002447yy_reduce_print (int yyrule)
Reid Spencer3822ff52006-11-08 06:47:33 +00002448#else
2449static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002450yy_reduce_print (yyrule)
Reid Spencer3822ff52006-11-08 06:47:33 +00002451 int yyrule;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002452#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002453{
2454 int yyi;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002455 unsigned long int yylno = yyrline[yyrule];
2456 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
Andrew Lenharth6353e052006-12-08 18:07:09 +00002457 yyrule - 1, yylno);
2458 /* Print the symbols being reduced, and their result. */
2459 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002460 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2461 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Reid Spencer3822ff52006-11-08 06:47:33 +00002462}
Reid Spencer21be8652006-10-22 07:03:43 +00002463
Reid Spencer3822ff52006-11-08 06:47:33 +00002464# define YY_REDUCE_PRINT(Rule) \
2465do { \
2466 if (yydebug) \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002467 yy_reduce_print (Rule); \
2468} while (0)
Reid Spencer21be8652006-10-22 07:03:43 +00002469
Reid Spencer3822ff52006-11-08 06:47:33 +00002470/* Nonzero means print parse trace. It is left uninitialized so that
2471 multiple parsers can coexist. */
2472int yydebug;
2473#else /* !YYDEBUG */
2474# define YYDPRINTF(Args)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002475# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Reid Spencer3822ff52006-11-08 06:47:33 +00002476# define YY_STACK_PRINT(Bottom, Top)
2477# define YY_REDUCE_PRINT(Rule)
2478#endif /* !YYDEBUG */
Reid Spencer21be8652006-10-22 07:03:43 +00002479
Reid Spencer21be8652006-10-22 07:03:43 +00002480
Reid Spencer3822ff52006-11-08 06:47:33 +00002481/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002482#ifndef YYINITDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002483# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002484#endif
2485
Reid Spencer3822ff52006-11-08 06:47:33 +00002486/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2487 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002488
Reid Spencer3822ff52006-11-08 06:47:33 +00002489 Do not make this value too large; the results are undefined if
Reid Spencere4d87aa2006-12-23 06:05:41 +00002490 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer3822ff52006-11-08 06:47:33 +00002491 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002492
2493#ifndef YYMAXDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002494# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002495#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002496
Reid Spencer68a24bd2005-08-27 18:50:39 +00002497
2498
Reid Spencer3822ff52006-11-08 06:47:33 +00002499#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002500
Reid Spencer3822ff52006-11-08 06:47:33 +00002501# ifndef yystrlen
Andrew Lenharth6353e052006-12-08 18:07:09 +00002502# if defined (__GLIBC__) && defined (_STRING_H)
Reid Spencer3822ff52006-11-08 06:47:33 +00002503# define yystrlen strlen
2504# else
2505/* Return the length of YYSTR. */
2506static YYSIZE_T
Andrew Lenharth6353e052006-12-08 18:07:09 +00002507# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002508yystrlen (const char *yystr)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002509# else
Reid Spencer3822ff52006-11-08 06:47:33 +00002510yystrlen (yystr)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002511 const char *yystr;
2512# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002513{
Reid Spencere4d87aa2006-12-23 06:05:41 +00002514 const char *yys = yystr;
Andrew Lenharth6353e052006-12-08 18:07:09 +00002515
2516 while (*yys++ != '\0')
Reid Spencer3822ff52006-11-08 06:47:33 +00002517 continue;
Andrew Lenharth6353e052006-12-08 18:07:09 +00002518
2519 return yys - yystr - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002520}
Reid Spencer3822ff52006-11-08 06:47:33 +00002521# endif
2522# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002523
Reid Spencer3822ff52006-11-08 06:47:33 +00002524# ifndef yystpcpy
Andrew Lenharth6353e052006-12-08 18:07:09 +00002525# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Reid Spencer3822ff52006-11-08 06:47:33 +00002526# define yystpcpy stpcpy
2527# else
2528/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2529 YYDEST. */
2530static char *
Andrew Lenharth6353e052006-12-08 18:07:09 +00002531# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002532yystpcpy (char *yydest, const char *yysrc)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002533# else
Reid Spencer3822ff52006-11-08 06:47:33 +00002534yystpcpy (yydest, yysrc)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002535 char *yydest;
2536 const char *yysrc;
2537# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002538{
Reid Spencere4d87aa2006-12-23 06:05:41 +00002539 char *yyd = yydest;
2540 const char *yys = yysrc;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002541
Reid Spencer3822ff52006-11-08 06:47:33 +00002542 while ((*yyd++ = *yys++) != '\0')
2543 continue;
2544
2545 return yyd - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002546}
Reid Spencer3822ff52006-11-08 06:47:33 +00002547# endif
2548# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002549
Reid Spencere4d87aa2006-12-23 06:05:41 +00002550# ifndef yytnamerr
2551/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2552 quotes and backslashes, so that it's suitable for yyerror. The
2553 heuristic is that double-quoting is unnecessary unless the string
2554 contains an apostrophe, a comma, or backslash (other than
2555 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2556 null, do not copy; instead, return the length of what the result
2557 would have been. */
2558static YYSIZE_T
2559yytnamerr (char *yyres, const char *yystr)
2560{
2561 if (*yystr == '"')
2562 {
2563 size_t yyn = 0;
2564 char const *yyp = yystr;
2565
2566 for (;;)
2567 switch (*++yyp)
2568 {
2569 case '\'':
2570 case ',':
2571 goto do_not_strip_quotes;
2572
2573 case '\\':
2574 if (*++yyp != '\\')
2575 goto do_not_strip_quotes;
2576 /* Fall through. */
2577 default:
2578 if (yyres)
2579 yyres[yyn] = *yyp;
2580 yyn++;
2581 break;
2582
2583 case '"':
2584 if (yyres)
2585 yyres[yyn] = '\0';
2586 return yyn;
2587 }
2588 do_not_strip_quotes: ;
2589 }
2590
2591 if (! yyres)
2592 return yystrlen (yystr);
2593
2594 return yystpcpy (yyres, yystr) - yyres;
2595}
2596# endif
2597
2598#endif /* YYERROR_VERBOSE */
Reid Spencer3822ff52006-11-08 06:47:33 +00002599
Reid Spencer21be8652006-10-22 07:03:43 +00002600
2601
Andrew Lenharth6353e052006-12-08 18:07:09 +00002602#if YYDEBUG
2603/*--------------------------------.
2604| Print this symbol on YYOUTPUT. |
2605`--------------------------------*/
Reid Spencer3822ff52006-11-08 06:47:33 +00002606
Andrew Lenharth6353e052006-12-08 18:07:09 +00002607#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002608static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002609yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Reid Spencer3822ff52006-11-08 06:47:33 +00002610#else
2611static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002612yysymprint (yyoutput, yytype, yyvaluep)
2613 FILE *yyoutput;
Reid Spencer3822ff52006-11-08 06:47:33 +00002614 int yytype;
2615 YYSTYPE *yyvaluep;
2616#endif
2617{
Andrew Lenharth6353e052006-12-08 18:07:09 +00002618 /* Pacify ``unused variable'' warnings. */
2619 (void) yyvaluep;
Reid Spencer3822ff52006-11-08 06:47:33 +00002620
Andrew Lenharth6353e052006-12-08 18:07:09 +00002621 if (yytype < YYNTOKENS)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002622 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
Andrew Lenharth6353e052006-12-08 18:07:09 +00002623 else
2624 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2625
Reid Spencere4d87aa2006-12-23 06:05:41 +00002626
2627# ifdef YYPRINT
2628 if (yytype < YYNTOKENS)
2629 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2630# endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00002631 switch (yytype)
2632 {
2633 default:
2634 break;
2635 }
2636 YYFPRINTF (yyoutput, ")");
2637}
2638
2639#endif /* ! YYDEBUG */
2640/*-----------------------------------------------.
2641| Release the memory associated to this symbol. |
2642`-----------------------------------------------*/
2643
2644#if defined (__STDC__) || defined (__cplusplus)
2645static void
Reid Spencere4d87aa2006-12-23 06:05:41 +00002646yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002647#else
2648static void
Reid Spencere4d87aa2006-12-23 06:05:41 +00002649yydestruct (yymsg, yytype, yyvaluep)
2650 const char *yymsg;
Andrew Lenharth6353e052006-12-08 18:07:09 +00002651 int yytype;
2652 YYSTYPE *yyvaluep;
2653#endif
2654{
2655 /* Pacify ``unused variable'' warnings. */
2656 (void) yyvaluep;
Reid Spencer3822ff52006-11-08 06:47:33 +00002657
Reid Spencere4d87aa2006-12-23 06:05:41 +00002658 if (!yymsg)
2659 yymsg = "Deleting";
2660 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2661
Reid Spencer3822ff52006-11-08 06:47:33 +00002662 switch (yytype)
2663 {
2664
2665 default:
Andrew Lenharth6353e052006-12-08 18:07:09 +00002666 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00002667 }
2668}
2669
2670
2671/* Prevent warnings from -Wmissing-prototypes. */
2672
2673#ifdef YYPARSE_PARAM
Andrew Lenharth6353e052006-12-08 18:07:09 +00002674# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002675int yyparse (void *YYPARSE_PARAM);
Andrew Lenharth6353e052006-12-08 18:07:09 +00002676# else
Reid Spencer3822ff52006-11-08 06:47:33 +00002677int yyparse ();
Andrew Lenharth6353e052006-12-08 18:07:09 +00002678# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002679#else /* ! YYPARSE_PARAM */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002680#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002681int yyparse (void);
Chris Lattnerf49c1762006-11-08 05:58:47 +00002682#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002683int yyparse ();
2684#endif
2685#endif /* ! YYPARSE_PARAM */
2686
2687
2688
Reid Spencere4d87aa2006-12-23 06:05:41 +00002689/* The look-ahead symbol. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002690int yychar;
2691
Reid Spencere4d87aa2006-12-23 06:05:41 +00002692/* The semantic value of the look-ahead symbol. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002693YYSTYPE yylval;
2694
2695/* Number of syntax errors so far. */
2696int yynerrs;
2697
2698
2699
2700/*----------.
2701| yyparse. |
2702`----------*/
2703
2704#ifdef YYPARSE_PARAM
Andrew Lenharth6353e052006-12-08 18:07:09 +00002705# if defined (__STDC__) || defined (__cplusplus)
2706int yyparse (void *YYPARSE_PARAM)
2707# else
2708int yyparse (YYPARSE_PARAM)
2709 void *YYPARSE_PARAM;
2710# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002711#else /* ! YYPARSE_PARAM */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002712#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002713int
2714yyparse (void)
2715#else
2716int
2717yyparse ()
2718
2719#endif
2720#endif
2721{
2722
Reid Spencere4d87aa2006-12-23 06:05:41 +00002723 int yystate;
2724 int yyn;
Reid Spencer3822ff52006-11-08 06:47:33 +00002725 int yyresult;
2726 /* Number of tokens to shift before error messages enabled. */
2727 int yyerrstatus;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002728 /* Look-ahead token as an internal (translated) token number. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002729 int yytoken = 0;
2730
2731 /* Three stacks and their tools:
2732 `yyss': related to states,
2733 `yyvs': related to semantic values,
2734 `yyls': related to locations.
2735
2736 Refer to the stacks thru separate pointers, to allow yyoverflow
2737 to reallocate them elsewhere. */
2738
2739 /* The state stack. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00002740 short int yyssa[YYINITDEPTH];
2741 short int *yyss = yyssa;
2742 short int *yyssp;
Reid Spencer3822ff52006-11-08 06:47:33 +00002743
2744 /* The semantic value stack. */
2745 YYSTYPE yyvsa[YYINITDEPTH];
2746 YYSTYPE *yyvs = yyvsa;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002747 YYSTYPE *yyvsp;
Reid Spencer3822ff52006-11-08 06:47:33 +00002748
2749
2750
Andrew Lenharth6353e052006-12-08 18:07:09 +00002751#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002752
Reid Spencer3822ff52006-11-08 06:47:33 +00002753 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002754
Reid Spencer3822ff52006-11-08 06:47:33 +00002755 /* The variables used to return semantic value and location from the
2756 action routines. */
2757 YYSTYPE yyval;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002758
2759
Andrew Lenharth6353e052006-12-08 18:07:09 +00002760 /* When reducing, the number of symbols on the RHS of the reduced
2761 rule. */
2762 int yylen;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002763
Reid Spencer3822ff52006-11-08 06:47:33 +00002764 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002765
Reid Spencer68a24bd2005-08-27 18:50:39 +00002766 yystate = 0;
2767 yyerrstatus = 0;
2768 yynerrs = 0;
2769 yychar = YYEMPTY; /* Cause a token to be read. */
2770
2771 /* Initialize stack pointers.
2772 Waste one element of value and location stack
2773 so that they stay on the same level as the state stack.
2774 The wasted elements are never initialized. */
2775
Reid Spencer3822ff52006-11-08 06:47:33 +00002776 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002777 yyvsp = yyvs;
2778
Reid Spencer3822ff52006-11-08 06:47:33 +00002779 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002780
Reid Spencer3822ff52006-11-08 06:47:33 +00002781/*------------------------------------------------------------.
2782| yynewstate -- Push a new state, which is found in yystate. |
2783`------------------------------------------------------------*/
2784 yynewstate:
2785 /* In all cases, when you get here, the value and location stacks
Andrew Lenharth6353e052006-12-08 18:07:09 +00002786 have just been pushed. so pushing a state here evens the stacks.
2787 */
Reid Spencer3822ff52006-11-08 06:47:33 +00002788 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002789
Reid Spencer3822ff52006-11-08 06:47:33 +00002790 yysetstate:
2791 *yyssp = yystate;
2792
2793 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002794 {
2795 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002796 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002797
2798#ifdef yyoverflow
Reid Spencer3822ff52006-11-08 06:47:33 +00002799 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00002800 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer3822ff52006-11-08 06:47:33 +00002801 these so that the &'s don't force the real ones into
2802 memory. */
2803 YYSTYPE *yyvs1 = yyvs;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002804 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002805
Reid Spencer3822ff52006-11-08 06:47:33 +00002806
2807 /* Each stack pointer address is followed by the size of the
2808 data in use in that stack, in bytes. This used to be a
2809 conditional around just the two extra args, but that might
2810 be undefined if yyoverflow is a macro. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00002811 yyoverflow (YY_("memory exhausted"),
Reid Spencer3822ff52006-11-08 06:47:33 +00002812 &yyss1, yysize * sizeof (*yyssp),
2813 &yyvs1, yysize * sizeof (*yyvsp),
2814
2815 &yystacksize);
2816
2817 yyss = yyss1;
2818 yyvs = yyvs1;
2819 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002820#else /* no yyoverflow */
Reid Spencer3822ff52006-11-08 06:47:33 +00002821# ifndef YYSTACK_RELOCATE
Reid Spencere4d87aa2006-12-23 06:05:41 +00002822 goto yyexhaustedlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00002823# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002824 /* Extend the stack our own way. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002825 if (YYMAXDEPTH <= yystacksize)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002826 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002827 yystacksize *= 2;
Reid Spencer3822ff52006-11-08 06:47:33 +00002828 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002829 yystacksize = YYMAXDEPTH;
Reid Spencer3822ff52006-11-08 06:47:33 +00002830
2831 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00002832 short int *yyss1 = yyss;
Reid Spencer3822ff52006-11-08 06:47:33 +00002833 union yyalloc *yyptr =
2834 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2835 if (! yyptr)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002836 goto yyexhaustedlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00002837 YYSTACK_RELOCATE (yyss);
2838 YYSTACK_RELOCATE (yyvs);
2839
2840# undef YYSTACK_RELOCATE
2841 if (yyss1 != yyssa)
2842 YYSTACK_FREE (yyss1);
2843 }
2844# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002845#endif /* no yyoverflow */
2846
Reid Spencer3822ff52006-11-08 06:47:33 +00002847 yyssp = yyss + yysize - 1;
2848 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002849
2850
Reid Spencer3822ff52006-11-08 06:47:33 +00002851 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2852 (unsigned long int) yystacksize));
2853
2854 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002855 YYABORT;
2856 }
2857
Reid Spencer3822ff52006-11-08 06:47:33 +00002858 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002859
2860 goto yybackup;
Reid Spencer3822ff52006-11-08 06:47:33 +00002861
2862/*-----------.
2863| yybackup. |
2864`-----------*/
2865yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002866
Andrew Lenharth6353e052006-12-08 18:07:09 +00002867/* Do appropriate processing given the current state. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00002868/* Read a look-ahead token if we need one and don't already have one. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002869/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002870
Reid Spencere4d87aa2006-12-23 06:05:41 +00002871 /* First try to decide what to do without reference to look-ahead token. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002872
Reid Spencer68a24bd2005-08-27 18:50:39 +00002873 yyn = yypact[yystate];
Reid Spencer3822ff52006-11-08 06:47:33 +00002874 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002875 goto yydefault;
2876
Reid Spencere4d87aa2006-12-23 06:05:41 +00002877 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002878
Reid Spencere4d87aa2006-12-23 06:05:41 +00002879 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002880 if (yychar == YYEMPTY)
2881 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002882 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002883 yychar = YYLEX;
2884 }
2885
Reid Spencer3822ff52006-11-08 06:47:33 +00002886 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002887 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002888 yychar = yytoken = YYEOF;
2889 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002890 }
2891 else
2892 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002893 yytoken = YYTRANSLATE (yychar);
Reid Spencere4d87aa2006-12-23 06:05:41 +00002894 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002895 }
2896
Reid Spencer3822ff52006-11-08 06:47:33 +00002897 /* If the proper action on seeing token YYTOKEN is to reduce or to
2898 detect an error, take that action. */
2899 yyn += yytoken;
2900 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002901 goto yydefault;
2902 yyn = yytable[yyn];
Reid Spencer3822ff52006-11-08 06:47:33 +00002903 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002904 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002905 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002906 goto yyerrlab;
2907 yyn = -yyn;
2908 goto yyreduce;
2909 }
2910
2911 if (yyn == YYFINAL)
2912 YYACCEPT;
2913
Reid Spencere4d87aa2006-12-23 06:05:41 +00002914 /* Shift the look-ahead token. */
2915 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Andrew Lenharth6353e052006-12-08 18:07:09 +00002916
2917 /* Discard the token being shifted unless it is eof. */
2918 if (yychar != YYEOF)
2919 yychar = YYEMPTY;
2920
2921 *++yyvsp = yylval;
2922
2923
Reid Spencer3822ff52006-11-08 06:47:33 +00002924 /* Count tokens shifted since error; after three, turn off error
2925 status. */
2926 if (yyerrstatus)
2927 yyerrstatus--;
Chris Lattner224f84f2006-08-18 17:34:45 +00002928
Reid Spencer68a24bd2005-08-27 18:50:39 +00002929 yystate = yyn;
2930 goto yynewstate;
2931
Chris Lattnerf49c1762006-11-08 05:58:47 +00002932
Reid Spencer3822ff52006-11-08 06:47:33 +00002933/*-----------------------------------------------------------.
2934| yydefault -- do the default action for the current state. |
2935`-----------------------------------------------------------*/
2936yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002937 yyn = yydefact[yystate];
2938 if (yyn == 0)
2939 goto yyerrlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00002940 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002941
Reid Spencer3822ff52006-11-08 06:47:33 +00002942
2943/*-----------------------------.
2944| yyreduce -- Do a reduction. |
2945`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002946yyreduce:
Reid Spencer3822ff52006-11-08 06:47:33 +00002947 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002948 yylen = yyr2[yyn];
2949
Reid Spencer3822ff52006-11-08 06:47:33 +00002950 /* If YYLEN is nonzero, implement the default value of the action:
2951 `$$ = $1'.
2952
2953 Otherwise, the following line sets YYVAL to garbage.
2954 This behavior is undocumented and Bison
2955 users should not rely upon it. Assigning to YYVAL
2956 unconditionally makes the parser a bit smaller, and it avoids a
2957 GCC warning that YYVAL may be used uninitialized. */
2958 yyval = yyvsp[1-yylen];
2959
2960
2961 YY_REDUCE_PRINT (yyn);
2962 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002963 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002964 case 3:
Reid Spencere4d87aa2006-12-23 06:05:41 +00002965#line 989 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00002966 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00002967 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00002968 GEN_ERROR("Value too large for type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00002969 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00002970 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00002971;}
2972 break;
2973
Reid Spencere4d87aa2006-12-23 06:05:41 +00002974 case 31:
2975#line 1005 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
2976 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
2977 break;
2978
2979 case 32:
2980#line 1005 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
2981 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
2982 break;
2983
2984 case 33:
2985#line 1006 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
2986 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
2987 break;
2988
2989 case 34:
2990#line 1006 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
2991 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
2992 break;
2993
2994 case 35:
2995#line 1007 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
2996 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
2997 break;
2998
2999 case 36:
3000#line 1007 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3001 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3002 break;
3003
3004 case 37:
3005#line 1008 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3006 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3007 break;
3008
3009 case 38:
3010#line 1008 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3011 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003012 break;
3013
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003014 case 39:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003015#line 1009 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3016 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003017 break;
3018
3019 case 40:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003020#line 1009 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3021 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003022 break;
3023
3024 case 41:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003025#line 1013 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3026 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003027 break;
3028
3029 case 42:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003030#line 1013 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3031 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003032 break;
3033
3034 case 43:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003035#line 1014 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3036 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003037 break;
3038
3039 case 44:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003040#line 1014 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3041 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003042 break;
3043
3044 case 45:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003045#line 1015 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3046 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003047 break;
3048
3049 case 46:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003050#line 1015 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3051 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003052 break;
3053
3054 case 47:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003055#line 1016 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3056 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003057 break;
3058
3059 case 48:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003060#line 1016 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3061 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003062 break;
3063
3064 case 49:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003065#line 1017 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3066 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003067 break;
3068
3069 case 50:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003070#line 1017 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3071 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003072 break;
3073
3074 case 51:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003075#line 1018 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3076 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003077 break;
3078
3079 case 52:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003080#line 1018 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3081 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003082 break;
3083
3084 case 53:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003085#line 1019 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3086 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003087 break;
3088
3089 case 54:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003090#line 1019 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3091 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003092 break;
3093
3094 case 55:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003095#line 1020 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3096 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003097 break;
3098
3099 case 56:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003100#line 1021 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3101 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003102 break;
3103
Reid Spencere4d87aa2006-12-23 06:05:41 +00003104 case 69:
3105#line 1032 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3106 {
3107 (yyval.StrVal) = (yyvsp[-1].StrVal);
3108 CHECK_FOR_ERROR
3109 ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003110 break;
3111
Reid Spencere4d87aa2006-12-23 06:05:41 +00003112 case 70:
3113#line 1036 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3114 {
3115 (yyval.StrVal) = 0;
3116 CHECK_FOR_ERROR
3117 ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003118 break;
3119
Reid Spencere4d87aa2006-12-23 06:05:41 +00003120 case 71:
3121#line 1041 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3122 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003123 break;
3124
Reid Spencere4d87aa2006-12-23 06:05:41 +00003125 case 72:
3126#line 1042 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3127 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003128 break;
3129
Reid Spencere4d87aa2006-12-23 06:05:41 +00003130 case 73:
3131#line 1043 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3132 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003133 break;
3134
Reid Spencere4d87aa2006-12-23 06:05:41 +00003135 case 74:
3136#line 1044 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3137 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003138 break;
3139
Reid Spencere4d87aa2006-12-23 06:05:41 +00003140 case 75:
3141#line 1045 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3142 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003143 break;
3144
Reid Spencere4d87aa2006-12-23 06:05:41 +00003145 case 76:
3146#line 1046 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3147 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003148 break;
3149
3150 case 77:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003151#line 1047 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3152 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003153 break;
3154
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003155 case 78:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003156#line 1048 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3157 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003158 break;
3159
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003160 case 79:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003161#line 1050 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3162 { (yyval.UIntVal) = CallingConv::C; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003163 break;
3164
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003165 case 80:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003166#line 1051 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3167 { (yyval.UIntVal) = CallingConv::C; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003168 break;
3169
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003170 case 81:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003171#line 1052 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3172 { (yyval.UIntVal) = CallingConv::CSRet; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003173 break;
3174
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003175 case 82:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003176#line 1053 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3177 { (yyval.UIntVal) = CallingConv::Fast; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003178 break;
3179
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003180 case 83:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003181#line 1054 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3182 { (yyval.UIntVal) = CallingConv::Cold; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003183 break;
3184
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003185 case 84:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003186#line 1055 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3187 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003188 break;
3189
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003190 case 85:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003191#line 1056 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3192 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003193 break;
3194
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003195 case 86:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003196#line 1057 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003197 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003198 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003199 GEN_ERROR("Calling conv too large!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003200 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003201 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003202 ;}
3203 break;
3204
Reid Spencere4d87aa2006-12-23 06:05:41 +00003205 case 87:
3206#line 1066 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3207 { (yyval.UIntVal) = 0; ;}
3208 break;
3209
3210 case 88:
3211#line 1067 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3212 {
3213 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3214 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3215 GEN_ERROR("Alignment must be a power of two!");
3216 CHECK_FOR_ERROR
3217;}
3218 break;
3219
3220 case 89:
3221#line 1073 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3222 { (yyval.UIntVal) = 0; ;}
3223 break;
3224
3225 case 90:
3226#line 1074 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3227 {
3228 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3229 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3230 GEN_ERROR("Alignment must be a power of two!");
3231 CHECK_FOR_ERROR
3232;}
3233 break;
3234
3235 case 91:
3236#line 1082 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3237 {
3238 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3239 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
3240 GEN_ERROR("Invalid character in section name!");
3241 (yyval.StrVal) = (yyvsp[0].StrVal);
3242 CHECK_FOR_ERROR
3243;}
3244 break;
3245
3246 case 92:
3247#line 1090 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3248 { (yyval.StrVal) = 0; ;}
3249 break;
3250
3251 case 93:
3252#line 1091 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3253 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3254 break;
3255
3256 case 94:
3257#line 1096 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3258 {;}
3259 break;
3260
Reid Spencera132e042006-12-03 05:46:11 +00003261 case 95:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003262#line 1097 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3263 {;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003264 break;
3265
Reid Spencera132e042006-12-03 05:46:11 +00003266 case 96:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003267#line 1098 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003268 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003269 CurGV->setSection((yyvsp[0].StrVal));
3270 free((yyvsp[0].StrVal));
3271 CHECK_FOR_ERROR
3272 ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003273 break;
3274
Reid Spencera132e042006-12-03 05:46:11 +00003275 case 97:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003276#line 1103 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003277 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003278 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
3279 GEN_ERROR("Alignment must be a power of two!");
3280 CurGV->setAlignment((yyvsp[0].UInt64Val));
3281 CHECK_FOR_ERROR
3282 ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003283 break;
3284
3285 case 99:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003286#line 1117 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3287 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003288 break;
3289
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003290 case 101:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003291#line 1118 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3292 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003293 break;
3294
Reid Spencera132e042006-12-03 05:46:11 +00003295 case 102:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003296#line 1120 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003297 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003298 if (!UpRefs.empty())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003299 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3300 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003301 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003302 ;}
3303 break;
3304
Reid Spencere4d87aa2006-12-23 06:05:41 +00003305 case 116:
3306#line 1132 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003307 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003308 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencera132e042006-12-03 05:46:11 +00003309 CHECK_FOR_ERROR
3310 ;}
3311 break;
3312
Reid Spencere4d87aa2006-12-23 06:05:41 +00003313 case 117:
3314#line 1136 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003315 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003316 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencera132e042006-12-03 05:46:11 +00003317 CHECK_FOR_ERROR
3318 ;}
3319 break;
3320
Reid Spencere4d87aa2006-12-23 06:05:41 +00003321 case 118:
3322#line 1140 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003323 { // Named types are also simple types...
Reid Spencere4d87aa2006-12-23 06:05:41 +00003324 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer3da59db2006-11-27 01:05:10 +00003325 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00003326 (yyval.TypeVal) = new PATypeHolder(tmp);
Reid Spencer3da59db2006-11-27 01:05:10 +00003327;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003328 break;
3329
Reid Spencere4d87aa2006-12-23 06:05:41 +00003330 case 119:
3331#line 1148 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003332 { // Type UpReference
Reid Spencere4d87aa2006-12-23 06:05:41 +00003333 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer3da59db2006-11-27 01:05:10 +00003334 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencere4d87aa2006-12-23 06:05:41 +00003335 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3336 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer3da59db2006-11-27 01:05:10 +00003337 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003338 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003339 ;}
3340 break;
3341
Reid Spencere4d87aa2006-12-23 06:05:41 +00003342 case 120:
3343#line 1156 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003344 { // Function derived type?
3345 std::vector<const Type*> Params;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003346 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3347 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00003348 Params.push_back(*I);
Reid Spencer3da59db2006-11-27 01:05:10 +00003349 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3350 if (isVarArg) Params.pop_back();
3351
Reid Spencere4d87aa2006-12-23 06:05:41 +00003352 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg)));
3353 delete (yyvsp[-1].TypeList); // Delete the argument list
3354 delete (yyvsp[-3].TypeVal); // Delete the return type handle
3355 CHECK_FOR_ERROR
3356 ;}
3357 break;
3358
3359 case 121:
3360#line 1169 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3361 { // Sized array type?
3362 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3363 delete (yyvsp[-1].TypeVal);
3364 CHECK_FOR_ERROR
3365 ;}
3366 break;
3367
3368 case 122:
3369#line 1174 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3370 { // Packed array type?
3371 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3372 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
3373 GEN_ERROR("Unsigned result not equal to signed result");
3374 if (!ElemTy->isPrimitiveType())
3375 GEN_ERROR("Elemental type of a PackedType must be primitive");
3376 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
3377 GEN_ERROR("Vector length should be a power of 2!");
3378 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3379 delete (yyvsp[-1].TypeVal);
3380 CHECK_FOR_ERROR
3381 ;}
3382 break;
3383
3384 case 123:
3385#line 1186 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3386 { // Structure type?
3387 std::vector<const Type*> Elements;
3388 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3389 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
3390 Elements.push_back(*I);
3391
3392 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3393 delete (yyvsp[-1].TypeList);
3394 CHECK_FOR_ERROR
3395 ;}
3396 break;
3397
3398 case 124:
3399#line 1196 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3400 { // Empty structure type?
3401 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
3402 CHECK_FOR_ERROR
3403 ;}
3404 break;
3405
3406 case 125:
3407#line 1200 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3408 {
3409 std::vector<const Type*> Elements;
3410 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3411 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
3412 Elements.push_back(*I);
3413
3414 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3415 delete (yyvsp[-2].TypeList);
3416 CHECK_FOR_ERROR
3417 ;}
3418 break;
3419
3420 case 126:
3421#line 1210 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3422 { // Empty structure type?
3423 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
3424 CHECK_FOR_ERROR
3425 ;}
3426 break;
3427
3428 case 127:
3429#line 1214 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3430 { // Pointer type?
3431 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
3432 GEN_ERROR("Cannot form a pointer to a basic block");
3433 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3434 delete (yyvsp[-1].TypeVal);
3435 CHECK_FOR_ERROR
3436 ;}
3437 break;
3438
3439 case 128:
3440#line 1225 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3441 {
3442 (yyval.TypeList) = new std::list<PATypeHolder>();
3443 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003444 CHECK_FOR_ERROR
3445 ;}
3446 break;
3447
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003448 case 129:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003449#line 1230 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3450 {
3451 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003452 CHECK_FOR_ERROR
3453 ;}
3454 break;
3455
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003456 case 131:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003457#line 1237 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3458 {
3459 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy);
Reid Spencer3da59db2006-11-27 01:05:10 +00003460 CHECK_FOR_ERROR
3461 ;}
3462 break;
3463
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003464 case 132:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003465#line 1241 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3466 {
3467 ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Reid Spencer3da59db2006-11-27 01:05:10 +00003468 CHECK_FOR_ERROR
3469 ;}
3470 break;
3471
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003472 case 133:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003473#line 1245 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003474 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003475 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer3da59db2006-11-27 01:05:10 +00003476 CHECK_FOR_ERROR
3477 ;}
3478 break;
3479
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003480 case 134:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003481#line 1256 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3482 { // Nonempty unsized arr
3483 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
3484 if (ATy == 0)
3485 GEN_ERROR("Cannot make array constant with type: '" +
3486 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
3487 const Type *ETy = ATy->getElementType();
3488 int NumElements = ATy->getNumElements();
3489
3490 // Verify that we have the correct size...
3491 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
3492 GEN_ERROR("Type mismatch: constant sized array initialized with " +
3493 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
3494 itostr(NumElements) + "!");
3495
3496 // Verify all elements are correct type!
3497 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3498 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
3499 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3500 ETy->getDescription() +"' as required!\nIt is of type '"+
3501 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
3502 }
3503
3504 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3505 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer3da59db2006-11-27 01:05:10 +00003506 CHECK_FOR_ERROR
3507 ;}
3508 break;
3509
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003510 case 135:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003511#line 1282 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003512 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003513 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003514 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003515 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003516 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003517
Andrew Lenharth6353e052006-12-08 18:07:09 +00003518 int NumElements = ATy->getNumElements();
3519 if (NumElements != -1 && NumElements != 0)
3520 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
3521 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003522 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3523 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003524 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003525 ;}
3526 break;
3527
Reid Spencere4d87aa2006-12-23 06:05:41 +00003528 case 136:
3529#line 1296 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003530 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003531 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003532 if (ATy == 0)
3533 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003534 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003535
Andrew Lenharth6353e052006-12-08 18:07:09 +00003536 int NumElements = ATy->getNumElements();
3537 const Type *ETy = ATy->getElementType();
Reid Spencere4d87aa2006-12-23 06:05:41 +00003538 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3539 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003540 GEN_ERROR("Can't build string constant of size " +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003541 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Andrew Lenharth6353e052006-12-08 18:07:09 +00003542 " when array has size " + itostr(NumElements) + "!");
3543 std::vector<Constant*> Vals;
3544 if (ETy == Type::SByteTy) {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003545 for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C)
Andrew Lenharth6353e052006-12-08 18:07:09 +00003546 Vals.push_back(ConstantInt::get(ETy, *C));
3547 } else if (ETy == Type::UByteTy) {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003548 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003549 C != (unsigned char*)EndStr; ++C)
3550 Vals.push_back(ConstantInt::get(ETy, *C));
3551 } else {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003552 free((yyvsp[0].StrVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00003553 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
3554 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00003555 free((yyvsp[0].StrVal));
3556 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3557 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003558 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003559 ;}
3560 break;
3561
Reid Spencere4d87aa2006-12-23 06:05:41 +00003562 case 137:
3563#line 1326 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003564 { // Nonempty unsized arr
Reid Spencere4d87aa2006-12-23 06:05:41 +00003565 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003566 if (PTy == 0)
3567 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003568 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003569 const Type *ETy = PTy->getElementType();
3570 int NumElements = PTy->getNumElements();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003571
Andrew Lenharth6353e052006-12-08 18:07:09 +00003572 // Verify that we have the correct size...
Reid Spencere4d87aa2006-12-23 06:05:41 +00003573 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003574 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003575 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Andrew Lenharth6353e052006-12-08 18:07:09 +00003576 itostr(NumElements) + "!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003577
Andrew Lenharth6353e052006-12-08 18:07:09 +00003578 // Verify all elements are correct type!
Reid Spencere4d87aa2006-12-23 06:05:41 +00003579 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3580 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003581 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3582 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencere4d87aa2006-12-23 06:05:41 +00003583 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003584 }
3585
Reid Spencere4d87aa2006-12-23 06:05:41 +00003586 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3587 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003588 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003589 ;}
3590 break;
3591
Reid Spencere4d87aa2006-12-23 06:05:41 +00003592 case 138:
3593#line 1352 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003594 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003595 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003596 if (STy == 0)
3597 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003598 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003599
Reid Spencere4d87aa2006-12-23 06:05:41 +00003600 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003601 GEN_ERROR("Illegal number of initializers for structure type!");
3602
3603 // Check to ensure that constants are compatible with the type initializer!
Reid Spencere4d87aa2006-12-23 06:05:41 +00003604 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3605 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003606 GEN_ERROR("Expected type '" +
3607 STy->getElementType(i)->getDescription() +
3608 "' for element #" + utostr(i) +
3609 " of structure initializer!");
3610
Reid Spencere4d87aa2006-12-23 06:05:41 +00003611 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3612 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003613 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003614 ;}
3615 break;
3616
Reid Spencere4d87aa2006-12-23 06:05:41 +00003617 case 139:
3618#line 1373 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003619 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003620 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003621 if (STy == 0)
3622 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003623 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003624
3625 if (STy->getNumContainedTypes() != 0)
3626 GEN_ERROR("Illegal number of initializers for structure type!");
3627
Reid Spencere4d87aa2006-12-23 06:05:41 +00003628 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3629 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003630 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003631 ;}
3632 break;
3633
Reid Spencere4d87aa2006-12-23 06:05:41 +00003634 case 140:
3635#line 1386 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003636 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003637 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003638 if (PTy == 0)
3639 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003640 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003641
Reid Spencere4d87aa2006-12-23 06:05:41 +00003642 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3643 delete (yyvsp[-1].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003644 CHECK_FOR_ERROR
3645 ;}
3646 break;
3647
Reid Spencere4d87aa2006-12-23 06:05:41 +00003648 case 141:
3649#line 1396 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003650 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003651 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3652 delete (yyvsp[-1].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003653 CHECK_FOR_ERROR
3654 ;}
3655 break;
3656
Reid Spencere4d87aa2006-12-23 06:05:41 +00003657 case 142:
3658#line 1401 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003659 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003660 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003661 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003662 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003663
3664 // ConstExprs can exist in the body of a function, thus creating
3665 // GlobalValues whenever they refer to a variable. Because we are in
3666 // the context of a function, getValNonImprovising will search the functions
3667 // symbol table instead of the module symbol table for the global symbol,
3668 // which throws things all off. To get around this, we just tell
3669 // getValNonImprovising that we are at global scope here.
3670 //
3671 Function *SavedCurFn = CurFun.CurrentFunction;
3672 CurFun.CurrentFunction = 0;
3673
Reid Spencere4d87aa2006-12-23 06:05:41 +00003674 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003675 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003676
3677 CurFun.CurrentFunction = SavedCurFn;
3678
3679 // If this is an initializer for a constant pointer, which is referencing a
3680 // (currently) undefined variable, create a stub now that shall be replaced
3681 // in the future with the right type of variable.
3682 //
3683 if (V == 0) {
3684 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3685 const PointerType *PT = cast<PointerType>(Ty);
3686
3687 // First check to see if the forward references value is already created!
3688 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencere4d87aa2006-12-23 06:05:41 +00003689 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003690
3691 if (I != CurModule.GlobalRefs.end()) {
3692 V = I->second; // Placeholder already exists, use it...
Reid Spencere4d87aa2006-12-23 06:05:41 +00003693 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003694 } else {
3695 std::string Name;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003696 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003697
3698 // Create the forward referenced global.
3699 GlobalValue *GV;
3700 if (const FunctionType *FTy =
3701 dyn_cast<FunctionType>(PT->getElementType())) {
3702 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3703 CurModule.CurrentModule);
3704 } else {
3705 GV = new GlobalVariable(PT->getElementType(), false,
3706 GlobalValue::ExternalLinkage, 0,
3707 Name, CurModule.CurrentModule);
3708 }
3709
3710 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencere4d87aa2006-12-23 06:05:41 +00003711 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003712 V = GV;
3713 }
3714 }
3715
Reid Spencere4d87aa2006-12-23 06:05:41 +00003716 (yyval.ConstVal) = cast<GlobalValue>(V);
3717 delete (yyvsp[-1].TypeVal); // Free the type handle
3718 CHECK_FOR_ERROR
3719 ;}
3720 break;
3721
3722 case 143:
3723#line 1462 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3724 {
3725 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
3726 GEN_ERROR("Mismatched types for constant expression!");
3727 (yyval.ConstVal) = (yyvsp[0].ConstVal);
3728 delete (yyvsp[-1].TypeVal);
3729 CHECK_FOR_ERROR
3730 ;}
3731 break;
3732
3733 case 144:
3734#line 1469 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3735 {
3736 const Type *Ty = (yyvsp[-1].TypeVal)->get();
3737 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3738 GEN_ERROR("Cannot create a null initialized value of this type!");
3739 (yyval.ConstVal) = Constant::getNullValue(Ty);
3740 delete (yyvsp[-1].TypeVal);
3741 CHECK_FOR_ERROR
3742 ;}
3743 break;
3744
3745 case 145:
3746#line 1477 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3747 { // integral constants
3748 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
3749 GEN_ERROR("Constant value doesn't fit in type!");
3750 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
3751 CHECK_FOR_ERROR
3752 ;}
3753 break;
3754
3755 case 146:
3756#line 1483 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3757 { // integral constants
3758 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
3759 GEN_ERROR("Constant value doesn't fit in type!");
3760 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
3761 CHECK_FOR_ERROR
3762 ;}
3763 break;
3764
3765 case 147:
3766#line 1489 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3767 { // integral constants
3768 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
3769 GEN_ERROR("Constant value doesn't fit in type!");
3770 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
3771 CHECK_FOR_ERROR
3772 ;}
3773 break;
3774
3775 case 148:
3776#line 1495 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3777 {
3778 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
3779 GEN_ERROR("Constant value doesn't fit in type!");
3780 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
3781 CHECK_FOR_ERROR
3782 ;}
3783 break;
3784
3785 case 149:
3786#line 1501 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3787 { // Boolean constants
3788 (yyval.ConstVal) = ConstantBool::getTrue();
3789 CHECK_FOR_ERROR
3790 ;}
3791 break;
3792
3793 case 150:
3794#line 1505 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3795 { // Boolean constants
3796 (yyval.ConstVal) = ConstantBool::getFalse();
Reid Spencer61c83e02006-08-18 08:43:06 +00003797 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003798 ;}
3799 break;
3800
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003801 case 151:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003802#line 1509 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3803 { // Float & Double constants
3804 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
3805 GEN_ERROR("Floating point constant invalid for type!!");
3806 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003807 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003808 ;}
3809 break;
3810
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003811 case 152:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003812#line 1517 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003813 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003814 Constant *Val = (yyvsp[-3].ConstVal);
3815 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer3da59db2006-11-27 01:05:10 +00003816 if (!Val->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003817 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003818 Val->getType()->getDescription() + "'!");
3819 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003820 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003821 Ty->getDescription() + "'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003822 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get());
3823 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00003824 ;}
3825 break;
3826
Reid Spencere4d87aa2006-12-23 06:05:41 +00003827 case 153:
3828#line 1529 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003829 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003830 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003831 GEN_ERROR("GetElementPtr requires a pointer operand!");
3832
3833 const Type *IdxTy =
Reid Spencere4d87aa2006-12-23 06:05:41 +00003834 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003835 if (!IdxTy)
3836 GEN_ERROR("Index list invalid for constant getelementptr!");
3837
3838 std::vector<Constant*> IdxVec;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003839 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
3840 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003841 IdxVec.push_back(C);
3842 else
3843 GEN_ERROR("Indices to constant getelementptr must be constants!");
3844
Reid Spencere4d87aa2006-12-23 06:05:41 +00003845 delete (yyvsp[-1].ValueList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003846
Reid Spencere4d87aa2006-12-23 06:05:41 +00003847 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
3848 CHECK_FOR_ERROR
3849 ;}
3850 break;
3851
3852 case 154:
3853#line 1550 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3854 {
3855 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
3856 GEN_ERROR("Select condition must be of boolean type!");
3857 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3858 GEN_ERROR("Select operand types must match!");
3859 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3860 CHECK_FOR_ERROR
3861 ;}
3862 break;
3863
3864 case 155:
3865#line 1558 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3866 {
3867 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3868 GEN_ERROR("Binary operator types must match!");
3869 CHECK_FOR_ERROR;
3870 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3871 ;}
3872 break;
3873
3874 case 156:
3875#line 1564 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3876 {
3877 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3878 GEN_ERROR("Logical operator types must match!");
3879 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
3880 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
3881 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
3882 GEN_ERROR("Logical operator requires integral operands!");
3883 }
3884 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3885 CHECK_FOR_ERROR
3886 ;}
3887 break;
3888
3889 case 157:
3890#line 1575 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3891 {
3892 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3893 GEN_ERROR("icmp operand types must match!");
3894 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3895 ;}
3896 break;
3897
3898 case 158:
3899#line 1580 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3900 {
3901 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3902 GEN_ERROR("fcmp operand types must match!");
3903 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3904 ;}
3905 break;
3906
3907 case 159:
3908#line 1585 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3909 {
3910 if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy)
3911 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
3912 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
3913 GEN_ERROR("Shift constant expression requires integer operand!");
3914 CHECK_FOR_ERROR;
3915 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00003916 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003917 ;}
3918 break;
3919
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003920 case 160:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003921#line 1594 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003922 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003923 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3924 GEN_ERROR("Invalid extractelement operands!");
3925 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003926 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003927 ;}
3928 break;
3929
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003930 case 161:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003931#line 1600 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003932 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003933 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3934 GEN_ERROR("Invalid insertelement operands!");
3935 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3936 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003937 ;}
3938 break;
3939
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003940 case 162:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003941#line 1606 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003942 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003943 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3944 GEN_ERROR("Invalid shufflevector operands!");
3945 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00003946 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00003947 ;}
3948 break;
3949
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003950 case 163:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003951#line 1615 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003952 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003953 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00003954 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00003955 ;}
3956 break;
3957
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003958 case 164:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003959#line 1619 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003960 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003961 (yyval.ConstVector) = new std::vector<Constant*>();
3962 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
3963 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003964 ;}
3965 break;
3966
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003967 case 165:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003968#line 1627 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3969 { (yyval.BoolVal) = false; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003970 break;
3971
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003972 case 166:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003973#line 1627 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
3974 { (yyval.BoolVal) = true; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003975 break;
3976
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003977 case 167:
Reid Spencere4d87aa2006-12-23 06:05:41 +00003978#line 1637 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003979 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003980 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003981 CurModule.ModuleDone();
Reid Spencerf63697d2006-10-09 17:36:59 +00003982 CHECK_FOR_ERROR;
Reid Spencer3822ff52006-11-08 06:47:33 +00003983;}
3984 break;
3985
Reid Spencere4d87aa2006-12-23 06:05:41 +00003986 case 168:
3987#line 1645 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003988 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003989 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003990 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003991 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003992 ;}
3993 break;
3994
Reid Spencere4d87aa2006-12-23 06:05:41 +00003995 case 169:
3996#line 1650 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003997 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003998 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003999 CHECK_FOR_ERROR
4000 ;}
4001 break;
4002
Reid Spencere4d87aa2006-12-23 06:05:41 +00004003 case 170:
4004#line 1654 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004005 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004006 (yyval.ModuleVal) = (yyvsp[-3].ModuleVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004007 CHECK_FOR_ERROR
4008 ;}
4009 break;
4010
Reid Spencere4d87aa2006-12-23 06:05:41 +00004011 case 171:
4012#line 1658 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004013 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004014 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004015 CHECK_FOR_ERROR
4016 ;}
4017 break;
4018
Reid Spencere4d87aa2006-12-23 06:05:41 +00004019 case 172:
4020#line 1662 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004021 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004022 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004023 // Emit an error if there are any unresolved types left.
4024 if (!CurModule.LateResolveTypes.empty()) {
4025 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00004026 if (DID.Type == ValID::NameVal) {
4027 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4028 } else {
4029 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4030 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004031 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004032 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004033 ;}
4034 break;
4035
Reid Spencere4d87aa2006-12-23 06:05:41 +00004036 case 173:
4037#line 1677 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004038 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004039 // Eagerly resolve types. This is not an optimization, this is a
4040 // requirement that is due to the fact that we could have this:
4041 //
4042 // %list = type { %list * }
4043 // %list = type { %list * } ; repeated type decl
4044 //
4045 // If types are not resolved eagerly, then the two types will not be
4046 // determined to be the same type!
4047 //
Reid Spencere4d87aa2006-12-23 06:05:41 +00004048 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004049
Reid Spencere4d87aa2006-12-23 06:05:41 +00004050 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004051 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004052 // If this is a named type that is not a redefinition, add it to the slot
4053 // table.
Reid Spencere4d87aa2006-12-23 06:05:41 +00004054 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004055 }
Reid Spencera132e042006-12-03 05:46:11 +00004056
Reid Spencere4d87aa2006-12-23 06:05:41 +00004057 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004058 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004059 ;}
4060 break;
4061
Reid Spencere4d87aa2006-12-23 06:05:41 +00004062 case 174:
4063#line 1699 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004064 { // Function prototypes can be in const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00004065 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004066 ;}
4067 break;
4068
Reid Spencere4d87aa2006-12-23 06:05:41 +00004069 case 175:
4070#line 1702 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004071 { // Asm blocks can be in the const pool
4072 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004073 ;}
4074 break;
4075
Reid Spencere4d87aa2006-12-23 06:05:41 +00004076 case 176:
4077#line 1705 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004078 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004079 if ((yyvsp[0].ConstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004080 GEN_ERROR("Global value initializer is not a constant!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004081 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
4082 CHECK_FOR_ERROR
4083 ;}
4084 break;
4085
4086 case 177:
4087#line 1710 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4088 {
4089 CurGV = 0;
4090 ;}
4091 break;
4092
4093 case 178:
4094#line 1713 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4095 {
4096 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
4097 CHECK_FOR_ERROR
4098 delete (yyvsp[0].TypeVal);
4099 ;}
4100 break;
4101
4102 case 179:
4103#line 1717 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4104 {
4105 CurGV = 0;
4106 CHECK_FOR_ERROR
4107 ;}
4108 break;
4109
4110 case 180:
4111#line 1721 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4112 {
4113 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
4114 CHECK_FOR_ERROR
4115 delete (yyvsp[0].TypeVal);
4116 ;}
4117 break;
4118
4119 case 181:
4120#line 1725 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4121 {
4122 CurGV = 0;
4123 CHECK_FOR_ERROR
4124 ;}
4125 break;
4126
4127 case 182:
4128#line 1729 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4129 {
4130 CurGV =
4131 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
4132 CHECK_FOR_ERROR
4133 delete (yyvsp[0].TypeVal);
4134 ;}
4135 break;
4136
4137 case 183:
4138#line 1734 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4139 {
4140 CurGV = 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +00004141 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004142 ;}
4143 break;
4144
Reid Spencera132e042006-12-03 05:46:11 +00004145 case 184:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004146#line 1738 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4147 {
4148 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004149 ;}
4150 break;
4151
Reid Spencera132e042006-12-03 05:46:11 +00004152 case 185:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004153#line 1741 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004154 {
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004155 CHECK_FOR_ERROR
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004156 ;}
4157 break;
4158
4159 case 186:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004160#line 1744 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4161 {
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004162 ;}
4163 break;
4164
4165 case 187:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004166#line 1748 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004167 {
Chris Lattner66316012006-01-24 04:14:29 +00004168 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencere4d87aa2006-12-23 06:05:41 +00004169 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4170 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4171 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004172
4173 if (AsmSoFar.empty())
4174 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4175 else
4176 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004177 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004178;}
4179 break;
4180
Reid Spencere4d87aa2006-12-23 06:05:41 +00004181 case 188:
4182#line 1761 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4183 { (yyval.Endianness) = Module::BigEndian; ;}
4184 break;
4185
4186 case 189:
4187#line 1762 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4188 { (yyval.Endianness) = Module::LittleEndian; ;}
4189 break;
4190
4191 case 190:
4192#line 1764 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4193 {
4194 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
4195 CHECK_FOR_ERROR
4196 ;}
4197 break;
4198
4199 case 191:
4200#line 1768 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4201 {
4202 if ((yyvsp[0].UInt64Val) == 32)
4203 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
4204 else if ((yyvsp[0].UInt64Val) == 64)
4205 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4206 else
4207 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
4208 CHECK_FOR_ERROR
4209 ;}
4210 break;
4211
4212 case 192:
4213#line 1777 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4214 {
4215 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4216 free((yyvsp[0].StrVal));
4217 ;}
4218 break;
4219
4220 case 193:
4221#line 1781 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4222 {
4223 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4224 free((yyvsp[0].StrVal));
4225 ;}
4226 break;
4227
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004228 case 195:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004229#line 1788 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4230 {
4231 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4232 free((yyvsp[0].StrVal));
4233 CHECK_FOR_ERROR
4234 ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004235 break;
4236
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004237 case 196:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004238#line 1793 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4239 {
4240 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4241 free((yyvsp[0].StrVal));
4242 CHECK_FOR_ERROR
4243 ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004244 break;
4245
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004246 case 197:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004247#line 1798 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004248 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004249 CHECK_FOR_ERROR
4250 ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004251 break;
4252
Reid Spencere4d87aa2006-12-23 06:05:41 +00004253 case 201:
4254#line 1808 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4255 { (yyval.StrVal) = 0; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004256 break;
4257
4258 case 202:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004259#line 1810 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004260 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004261 if (*(yyvsp[-1].TypeVal) == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004262 GEN_ERROR("void typed arguments are invalid!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004263 (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004264 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004265;}
4266 break;
4267
Reid Spencere4d87aa2006-12-23 06:05:41 +00004268 case 203:
4269#line 1817 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004270 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004271 (yyval.ArgList) = (yyvsp[-2].ArgList);
4272 (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal));
4273 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004274 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004275 ;}
4276 break;
4277
Reid Spencere4d87aa2006-12-23 06:05:41 +00004278 case 204:
4279#line 1823 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004280 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004281 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4282 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4283 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004284 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004285 ;}
4286 break;
4287
Reid Spencere4d87aa2006-12-23 06:05:41 +00004288 case 205:
4289#line 1830 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004290 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004291 (yyval.ArgList) = (yyvsp[0].ArgList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004292 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004293 ;}
4294 break;
4295
Reid Spencere4d87aa2006-12-23 06:05:41 +00004296 case 206:
4297#line 1834 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004298 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004299 (yyval.ArgList) = (yyvsp[-2].ArgList);
4300 (yyval.ArgList)->push_back(std::pair<PATypeHolder*,
Andrew Lenharth6353e052006-12-08 18:07:09 +00004301 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004302 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004303 ;}
4304 break;
4305
Reid Spencere4d87aa2006-12-23 06:05:41 +00004306 case 207:
4307#line 1840 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004308 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004309 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4310 (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004311 CHECK_FOR_ERROR
4312 ;}
4313 break;
4314
Reid Spencere4d87aa2006-12-23 06:05:41 +00004315 case 208:
4316#line 1845 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004317 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004318 (yyval.ArgList) = 0;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004319 CHECK_FOR_ERROR
4320 ;}
4321 break;
4322
Reid Spencere4d87aa2006-12-23 06:05:41 +00004323 case 209:
4324#line 1851 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004325 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004326 UnEscapeLexed((yyvsp[-5].StrVal));
4327 std::string FunctionName((yyvsp[-5].StrVal));
4328 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004329
Reid Spencere4d87aa2006-12-23 06:05:41 +00004330 if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004331 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004332
4333 std::vector<const Type*> ParamTypeList;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004334 if ((yyvsp[-3].ArgList)) { // If there are arguments...
4335 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4336 I != (yyvsp[-3].ArgList)->end(); ++I)
Reid Spencera132e042006-12-03 05:46:11 +00004337 ParamTypeList.push_back(I->first->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004338 }
4339
4340 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4341 if (isVarArg) ParamTypeList.pop_back();
4342
Reid Spencere4d87aa2006-12-23 06:05:41 +00004343 const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004344 const PointerType *PFT = PointerType::get(FT);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004345 delete (yyvsp[-6].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004346
4347 ValID ID;
4348 if (!FunctionName.empty()) {
4349 ID = ValID::create((char*)FunctionName.c_str());
4350 } else {
4351 ID = ValID::create((int)CurModule.Values[PFT].size());
4352 }
4353
4354 Function *Fn = 0;
4355 // See if this function was forward referenced. If so, recycle the object.
4356 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4357 // Move the function to the end of the list, from whereever it was
4358 // previously inserted.
4359 Fn = cast<Function>(FWRef);
4360 CurModule.CurrentModule->getFunctionList().remove(Fn);
4361 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4362 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4363 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4364 // If this is the case, either we need to be a forward decl, or it needs
4365 // to be.
4366 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004367 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004368
4369 // Make sure to strip off any argument names so we can't get conflicts.
4370 if (Fn->isExternal())
4371 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4372 AI != AE; ++AI)
4373 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004374 } else { // Not already defined?
4375 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4376 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004377
Reid Spencer68a24bd2005-08-27 18:50:39 +00004378 InsertValue(Fn, CurModule.Values);
4379 }
4380
4381 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004382
4383 if (CurFun.isDeclare) {
4384 // If we have declaration, always overwrite linkage. This will allow us to
4385 // correctly handle cases, when pointer to function is passed as argument to
4386 // another function.
4387 Fn->setLinkage(CurFun.Linkage);
4388 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00004389 Fn->setCallingConv((yyvsp[-7].UIntVal));
4390 Fn->setAlignment((yyvsp[0].UIntVal));
4391 if ((yyvsp[-1].StrVal)) {
4392 Fn->setSection((yyvsp[-1].StrVal));
4393 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004394 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004395
4396 // Add all of the arguments we parsed to the function...
Reid Spencere4d87aa2006-12-23 06:05:41 +00004397 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004398 if (isVarArg) { // Nuke the last entry
Reid Spencere4d87aa2006-12-23 06:05:41 +00004399 assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&&
Reid Spencera132e042006-12-03 05:46:11 +00004400 "Not a varargs marker!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004401 delete (yyvsp[-3].ArgList)->back().first;
4402 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004403 }
4404 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencere4d87aa2006-12-23 06:05:41 +00004405 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4406 I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencera132e042006-12-03 05:46:11 +00004407 delete I->first; // Delete the typeholder...
4408
Reid Spencer68a24bd2005-08-27 18:50:39 +00004409 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004410 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004411 InsertValue(ArgIt);
4412 }
Reid Spencera132e042006-12-03 05:46:11 +00004413
Reid Spencere4d87aa2006-12-23 06:05:41 +00004414 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004415 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004416 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004417;}
4418 break;
4419
Reid Spencere4d87aa2006-12-23 06:05:41 +00004420 case 212:
4421#line 1947 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004422 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004423 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004424
4425 // Make sure that we keep track of the linkage type even if there was a
4426 // previous "declare".
Reid Spencere4d87aa2006-12-23 06:05:41 +00004427 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
Reid Spencer3822ff52006-11-08 06:47:33 +00004428;}
4429 break;
4430
Reid Spencere4d87aa2006-12-23 06:05:41 +00004431 case 215:
4432#line 1957 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004433 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004434 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004435 CHECK_FOR_ERROR
4436;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004437 break;
4438
Reid Spencere4d87aa2006-12-23 06:05:41 +00004439 case 217:
4440#line 1963 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004441 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004442 break;
4443
Reid Spencere4d87aa2006-12-23 06:05:41 +00004444 case 218:
4445#line 1964 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004446 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
4447 break;
4448
Reid Spencere4d87aa2006-12-23 06:05:41 +00004449 case 219:
4450#line 1966 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004451 { CurFun.isDeclare = true; ;}
4452 break;
4453
Reid Spencere4d87aa2006-12-23 06:05:41 +00004454 case 220:
4455#line 1966 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004456 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004457 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004458 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004459 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004460 ;}
4461 break;
4462
Reid Spencere4d87aa2006-12-23 06:05:41 +00004463 case 221:
4464#line 1976 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004465 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004466 (yyval.BoolVal) = false;
4467 CHECK_FOR_ERROR
4468 ;}
4469 break;
4470
4471 case 222:
4472#line 1980 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4473 {
4474 (yyval.BoolVal) = true;
4475 CHECK_FOR_ERROR
4476 ;}
4477 break;
4478
4479 case 223:
4480#line 1985 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4481 { // A reference to a direct constant
4482 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
4483 CHECK_FOR_ERROR
4484 ;}
4485 break;
4486
4487 case 224:
4488#line 1989 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4489 {
4490 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
4491 CHECK_FOR_ERROR
4492 ;}
4493 break;
4494
4495 case 225:
4496#line 1993 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4497 { // Perhaps it's an FP constant?
4498 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
4499 CHECK_FOR_ERROR
4500 ;}
4501 break;
4502
4503 case 226:
4504#line 1997 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4505 {
4506 (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue());
4507 CHECK_FOR_ERROR
4508 ;}
4509 break;
4510
4511 case 227:
4512#line 2001 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4513 {
4514 (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse());
4515 CHECK_FOR_ERROR
4516 ;}
4517 break;
4518
4519 case 228:
4520#line 2005 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4521 {
4522 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004523 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004524 ;}
4525 break;
4526
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004527 case 229:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004528#line 2009 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004529 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004530 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004531 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004532 ;}
4533 break;
4534
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004535 case 230:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004536#line 2013 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4537 { // A vector zero constant.
4538 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004539 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004540 ;}
4541 break;
4542
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004543 case 231:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004544#line 2017 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004545 { // Nonempty unsized packed vector
Reid Spencere4d87aa2006-12-23 06:05:41 +00004546 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4547 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004548
4549 PackedType* pt = PackedType::get(ETy, NumElements);
4550 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004551 HandleUpRefs(
4552 PackedType::get(
4553 ETy,
4554 NumElements)
4555 )
4556 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004557
4558 // Verify all elements are correct type!
Reid Spencere4d87aa2006-12-23 06:05:41 +00004559 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4560 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004561 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004562 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00004563 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004564 }
4565
Reid Spencere4d87aa2006-12-23 06:05:41 +00004566 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4567 delete PTy; delete (yyvsp[-1].ConstVector);
4568 CHECK_FOR_ERROR
4569 ;}
4570 break;
4571
4572 case 232:
4573#line 2042 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4574 {
4575 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
4576 CHECK_FOR_ERROR
4577 ;}
4578 break;
4579
4580 case 233:
4581#line 2046 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4582 {
4583 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4584 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4585 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4586 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4587 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4588 free((yyvsp[-2].StrVal));
4589 free((yyvsp[0].StrVal));
4590 CHECK_FOR_ERROR
4591 ;}
4592 break;
4593
4594 case 234:
4595#line 2060 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4596 { // Is it an integer reference...?
4597 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4598 CHECK_FOR_ERROR
4599 ;}
4600 break;
4601
4602 case 235:
4603#line 2064 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4604 { // Is it a named reference...?
4605 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4606 CHECK_FOR_ERROR
4607 ;}
4608 break;
4609
4610 case 238:
4611#line 2076 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4612 {
4613 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal);
Reid Spencer21be8652006-10-22 07:03:43 +00004614 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004615 ;}
4616 break;
4617
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004618 case 239:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004619#line 2081 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004620 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004621 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004622 CHECK_FOR_ERROR
4623 ;}
4624 break;
4625
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004626 case 240:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004627#line 2085 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4628 { // Do not allow functions with 0 basic blocks
4629 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004630 CHECK_FOR_ERROR
4631 ;}
4632 break;
4633
4634 case 241:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004635#line 2094 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4636 {
4637 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4638 CHECK_FOR_ERROR
4639 InsertValue((yyvsp[0].TermInstVal));
4640
4641 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4642 InsertValue((yyvsp[-2].BasicBlockVal));
4643 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004644 CHECK_FOR_ERROR
4645 ;}
4646 break;
4647
4648 case 242:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004649#line 2105 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4650 {
4651 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
4652 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4653 if (CI2->getParent() == 0)
4654 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
4655 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4656 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
4657 CHECK_FOR_ERROR
4658 ;}
4659 break;
4660
4661 case 243:
4662#line 2114 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4663 {
4664 (yyval.BasicBlockVal) = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
4665 CHECK_FOR_ERROR
4666
4667 // Make sure to move the basic block to the correct location in the
4668 // function, instead of leaving it inserted wherever it was first
4669 // referenced.
4670 Function::BasicBlockListType &BBL =
4671 CurFun.CurrentFunction->getBasicBlockList();
4672 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
4673 CHECK_FOR_ERROR
4674 ;}
4675 break;
4676
4677 case 244:
4678#line 2126 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4679 {
4680 (yyval.BasicBlockVal) = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
4681 CHECK_FOR_ERROR
4682
4683 // Make sure to move the basic block to the correct location in the
4684 // function, instead of leaving it inserted wherever it was first
4685 // referenced.
4686 Function::BasicBlockListType &BBL =
4687 CurFun.CurrentFunction->getBasicBlockList();
4688 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004689 CHECK_FOR_ERROR
4690 ;}
4691 break;
4692
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004693 case 245:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004694#line 2139 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4695 { // Return with a result...
4696 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004697 CHECK_FOR_ERROR
4698 ;}
4699 break;
4700
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004701 case 246:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004702#line 2143 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4703 { // Return with no result...
4704 (yyval.TermInstVal) = new ReturnInst();
Reid Spencer3822ff52006-11-08 06:47:33 +00004705 CHECK_FOR_ERROR
4706 ;}
4707 break;
4708
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004709 case 247:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004710#line 2147 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4711 { // Unconditional Branch...
4712 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004713 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004714 (yyval.TermInstVal) = new BranchInst(tmpBB);
Reid Spencer3822ff52006-11-08 06:47:33 +00004715 ;}
4716 break;
4717
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004718 case 248:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004719#line 2152 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4720 {
4721 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004722 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004723 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004724 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004725 Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal));
4726 CHECK_FOR_ERROR
4727 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004728 ;}
4729 break;
4730
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004731 case 249:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004732#line 2161 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004733 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004734 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004735 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004736 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
4737 CHECK_FOR_ERROR
4738 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
4739 (yyval.TermInstVal) = S;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004740
Reid Spencere4d87aa2006-12-23 06:05:41 +00004741 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4742 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004743 for (; I != E; ++I) {
4744 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4745 S->addCase(CI, I->second);
4746 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004747 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004748 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00004749 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00004750 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004751 ;}
4752 break;
4753
Reid Spencere4d87aa2006-12-23 06:05:41 +00004754 case 250:
4755#line 2180 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004756 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004757 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004758 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004759 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004760 CHECK_FOR_ERROR
4761 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004762 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004763 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004764 ;}
4765 break;
4766
Reid Spencere4d87aa2006-12-23 06:05:41 +00004767 case 251:
4768#line 2190 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004769 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00004770 const PointerType *PFTy;
4771 const FunctionType *Ty;
Reid Spencer3822ff52006-11-08 06:47:33 +00004772
Reid Spencere4d87aa2006-12-23 06:05:41 +00004773 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004774 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4775 // Pull out the types of all of the arguments...
4776 std::vector<const Type*> ParamTypes;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004777 if ((yyvsp[-7].ValueList)) {
4778 for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004779 I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00004780 ParamTypes.push_back((*I)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004781 }
4782
4783 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4784 if (isVarArg) ParamTypes.pop_back();
4785
Reid Spencere4d87aa2006-12-23 06:05:41 +00004786 Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004787 PFTy = PointerType::get(Ty);
4788 }
4789
Reid Spencere4d87aa2006-12-23 06:05:41 +00004790 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004791 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004792 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004793 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004794 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004795 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004796
4797 // Create the call node...
Reid Spencere4d87aa2006-12-23 06:05:41 +00004798 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
4799 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004800 } else { // Has arguments?
4801 // Loop through FunctionType's arguments and ensure they are specified
4802 // correctly!
4803 //
4804 FunctionType::param_iterator I = Ty->param_begin();
4805 FunctionType::param_iterator E = Ty->param_end();
Reid Spencere4d87aa2006-12-23 06:05:41 +00004806 std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004807
Reid Spencera132e042006-12-03 05:46:11 +00004808 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4809 if ((*ArgI)->getType() != *I)
4810 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
4811 (*I)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004812
4813 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004814 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004815
Reid Spencere4d87aa2006-12-23 06:05:41 +00004816 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004817 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00004818 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004819
Reid Spencere4d87aa2006-12-23 06:05:41 +00004820 delete (yyvsp[-10].TypeVal);
4821 delete (yyvsp[-7].ValueList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004822 CHECK_FOR_ERROR
4823 ;}
4824 break;
4825
Reid Spencere4d87aa2006-12-23 06:05:41 +00004826 case 252:
4827#line 2245 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004828 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004829 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004830 CHECK_FOR_ERROR
4831 ;}
4832 break;
4833
Reid Spencere4d87aa2006-12-23 06:05:41 +00004834 case 253:
4835#line 2249 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004836 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004837 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004838 CHECK_FOR_ERROR
4839 ;}
4840 break;
4841
Reid Spencere4d87aa2006-12-23 06:05:41 +00004842 case 254:
4843#line 2256 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004844 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004845 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
4846 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004847 CHECK_FOR_ERROR
4848 if (V == 0)
4849 GEN_ERROR("May only switch on a constant pool value!");
4850
Reid Spencere4d87aa2006-12-23 06:05:41 +00004851 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004852 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004853 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004854 ;}
4855 break;
4856
Reid Spencere4d87aa2006-12-23 06:05:41 +00004857 case 255:
4858#line 2267 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004859 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004860 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
4861 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004862 CHECK_FOR_ERROR
4863
4864 if (V == 0)
4865 GEN_ERROR("May only switch on a constant pool value!");
4866
Reid Spencere4d87aa2006-12-23 06:05:41 +00004867 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004868 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004869 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004870 ;}
4871 break;
4872
Reid Spencere4d87aa2006-12-23 06:05:41 +00004873 case 256:
4874#line 2280 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004875 {
4876 // Is this definition named?? if so, assign the name...
Reid Spencere4d87aa2006-12-23 06:05:41 +00004877 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004878 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004879 InsertValue((yyvsp[0].InstVal));
4880 (yyval.InstVal) = (yyvsp[0].InstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004881 CHECK_FOR_ERROR
4882;}
4883 break;
4884
Reid Spencere4d87aa2006-12-23 06:05:41 +00004885 case 257:
4886#line 2289 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004887 { // Used for PHI nodes
Reid Spencere4d87aa2006-12-23 06:05:41 +00004888 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
4889 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004890 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004891 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004892 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004893 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4894 delete (yyvsp[-5].TypeVal);
4895 ;}
4896 break;
4897
4898 case 258:
4899#line 2298 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4900 {
4901 (yyval.PHIList) = (yyvsp[-6].PHIList);
4902 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
4903 CHECK_FOR_ERROR
4904 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
4905 CHECK_FOR_ERROR
4906 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4907 ;}
4908 break;
4909
4910 case 259:
4911#line 2308 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4912 { // Used for call statements, and memory insts...
4913 (yyval.ValueList) = new std::vector<Value*>();
4914 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
4915 ;}
4916 break;
4917
4918 case 260:
4919#line 2312 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4920 {
4921 (yyval.ValueList) = (yyvsp[-2].ValueList);
4922 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
4923 CHECK_FOR_ERROR
4924 ;}
4925 break;
4926
4927 case 262:
4928#line 2319 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4929 { (yyval.ValueList) = 0; ;}
4930 break;
4931
4932 case 263:
4933#line 2321 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4934 {
4935 (yyval.BoolVal) = true;
4936 CHECK_FOR_ERROR
4937 ;}
4938 break;
4939
4940 case 264:
4941#line 2325 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4942 {
4943 (yyval.BoolVal) = false;
4944 CHECK_FOR_ERROR
Andrew Lenharth6353e052006-12-08 18:07:09 +00004945 ;}
4946 break;
4947
4948 case 265:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004949#line 2330 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004950 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004951 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
4952 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
4953 GEN_ERROR(
4954 "Arithmetic operator requires integer, FP, or packed operands!");
4955 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) &&
4956 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
4957 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
4958 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
4959 GEN_ERROR("U/S/FRem not supported on packed types!");
4960 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004961 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004962 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004963 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004964 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
4965 if ((yyval.InstVal) == 0)
4966 GEN_ERROR("binary operator returned null!");
4967 delete (yyvsp[-3].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004968 ;}
4969 break;
4970
4971 case 266:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004972#line 2349 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
4973 {
4974 if (!(*(yyvsp[-3].TypeVal))->isIntegral()) {
4975 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
4976 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral())
4977 GEN_ERROR("Logical operator requires integral operands!");
4978 }
4979 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
4980 CHECK_FOR_ERROR
4981 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
4982 CHECK_FOR_ERROR
4983 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
4984 if ((yyval.InstVal) == 0)
4985 GEN_ERROR("binary operator returned null!");
4986 delete (yyvsp[-3].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004987 ;}
4988 break;
4989
4990 case 267:
Reid Spencere4d87aa2006-12-23 06:05:41 +00004991#line 2364 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004992 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004993 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00004994 GEN_ERROR("Packed types not supported by icmp instruction");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004995 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004996 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004997 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004998 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004999 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5000 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005001 GEN_ERROR("icmp operator returned null!");
5002 ;}
5003 break;
5004
Reid Spencere4d87aa2006-12-23 06:05:41 +00005005 case 268:
5006#line 2375 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005007 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005008 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005009 GEN_ERROR("Packed types not supported by fcmp instruction");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005010 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005011 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005012 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005013 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005014 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5015 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005016 GEN_ERROR("fcmp operator returned null!");
5017 ;}
5018 break;
5019
Reid Spencere4d87aa2006-12-23 06:05:41 +00005020 case 269:
5021#line 2386 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005022 {
5023 cerr << "WARNING: Use of eliminated 'not' instruction:"
5024 << " Replacing with 'xor'.\n";
5025
Reid Spencere4d87aa2006-12-23 06:05:41 +00005026 Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Andrew Lenharth6353e052006-12-08 18:07:09 +00005027 if (Ones == 0)
5028 GEN_ERROR("Expected integral type for not instruction!");
5029
Reid Spencere4d87aa2006-12-23 06:05:41 +00005030 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
5031 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005032 GEN_ERROR("Could not create a xor instruction!");
5033 CHECK_FOR_ERROR
5034 ;}
5035 break;
5036
Reid Spencere4d87aa2006-12-23 06:05:41 +00005037 case 270:
5038#line 2399 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005039 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005040 if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005041 GEN_ERROR("Shift amount must be ubyte!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005042 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
Andrew Lenharth6353e052006-12-08 18:07:09 +00005043 GEN_ERROR("Shift constant expression requires integer operand!");
5044 CHECK_FOR_ERROR;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005045 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005046 CHECK_FOR_ERROR
5047 ;}
5048 break;
5049
Reid Spencere4d87aa2006-12-23 06:05:41 +00005050 case 271:
5051#line 2408 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005052 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005053 Value* Val = (yyvsp[-2].ValueVal);
5054 const Type* Ty = (yyvsp[0].TypeVal)->get();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005055 if (!Val->getType()->isFirstClassType())
5056 GEN_ERROR("cast from a non-primitive type: '" +
5057 Val->getType()->getDescription() + "'!");
5058 if (!Ty->isFirstClassType())
5059 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005060 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].TypeVal)->get());
5061 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005062 ;}
5063 break;
5064
Reid Spencere4d87aa2006-12-23 06:05:41 +00005065 case 272:
5066#line 2419 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005067 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005068 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005069 GEN_ERROR("select condition must be boolean!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005070 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Andrew Lenharth6353e052006-12-08 18:07:09 +00005071 GEN_ERROR("select value types should match!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005072 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005073 CHECK_FOR_ERROR
5074 ;}
5075 break;
5076
Reid Spencere4d87aa2006-12-23 06:05:41 +00005077 case 273:
5078#line 2427 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005079 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005080 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5081 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005082 CHECK_FOR_ERROR
5083 ;}
5084 break;
5085
Reid Spencere4d87aa2006-12-23 06:05:41 +00005086 case 274:
5087#line 2432 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005088 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005089 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005090 GEN_ERROR("Invalid extractelement operands!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005091 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005092 CHECK_FOR_ERROR
5093 ;}
5094 break;
5095
Reid Spencere4d87aa2006-12-23 06:05:41 +00005096 case 275:
5097#line 2438 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005098 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005099 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005100 GEN_ERROR("Invalid insertelement operands!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005101 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005102 CHECK_FOR_ERROR
5103 ;}
5104 break;
5105
Reid Spencere4d87aa2006-12-23 06:05:41 +00005106 case 276:
5107#line 2444 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005108 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005109 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005110 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005111 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005112 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005113 ;}
5114 break;
5115
Reid Spencere4d87aa2006-12-23 06:05:41 +00005116 case 277:
5117#line 2450 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005118 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005119 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005120 if (!Ty->isFirstClassType())
5121 GEN_ERROR("PHI node operands must be of first class type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005122 (yyval.InstVal) = new PHINode(Ty);
5123 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5124 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5125 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005126 GEN_ERROR("All elements of a PHI node must be of the same type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005127 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5128 (yyvsp[0].PHIList)->pop_front();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005129 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00005130 delete (yyvsp[0].PHIList); // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005131 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005132 ;}
5133 break;
5134
Reid Spencere4d87aa2006-12-23 06:05:41 +00005135 case 278:
5136#line 2465 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005137 {
5138 const PointerType *PFTy = 0;
5139 const FunctionType *Ty = 0;
5140
Reid Spencere4d87aa2006-12-23 06:05:41 +00005141 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005142 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5143 // Pull out the types of all of the arguments...
5144 std::vector<const Type*> ParamTypes;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005145 if ((yyvsp[-1].ValueList)) {
5146 for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005147 I != E; ++I)
5148 ParamTypes.push_back((*I)->getType());
5149 }
5150
5151 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5152 if (isVarArg) ParamTypes.pop_back();
5153
Reid Spencere4d87aa2006-12-23 06:05:41 +00005154 if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005155 GEN_ERROR("LLVM functions cannot return aggregate types!");
5156
Reid Spencere4d87aa2006-12-23 06:05:41 +00005157 Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005158 PFTy = PointerType::get(Ty);
5159 }
5160
Reid Spencere4d87aa2006-12-23 06:05:41 +00005161 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005162 CHECK_FOR_ERROR
5163
5164 // Create the call node...
Reid Spencere4d87aa2006-12-23 06:05:41 +00005165 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005166 // Make sure no arguments is a good thing!
5167 if (Ty->getNumParams() != 0)
5168 GEN_ERROR("No arguments passed to a function that "
5169 "expects arguments!");
5170
Reid Spencere4d87aa2006-12-23 06:05:41 +00005171 (yyval.InstVal) = new CallInst(V, std::vector<Value*>());
Andrew Lenharth6353e052006-12-08 18:07:09 +00005172 } else { // Has arguments?
5173 // Loop through FunctionType's arguments and ensure they are specified
5174 // correctly!
5175 //
5176 FunctionType::param_iterator I = Ty->param_begin();
5177 FunctionType::param_iterator E = Ty->param_end();
Reid Spencere4d87aa2006-12-23 06:05:41 +00005178 std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005179
5180 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5181 if ((*ArgI)->getType() != *I)
5182 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
5183 (*I)->getDescription() + "'!");
5184
5185 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5186 GEN_ERROR("Invalid number of parameters detected!");
5187
Reid Spencere4d87aa2006-12-23 06:05:41 +00005188 (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005189 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00005190 cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal));
5191 cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal));
5192 delete (yyvsp[-4].TypeVal);
5193 delete (yyvsp[-1].ValueList);
5194 CHECK_FOR_ERROR
5195 ;}
5196 break;
5197
5198 case 279:
5199#line 2524 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
5200 {
5201 (yyval.InstVal) = (yyvsp[0].InstVal);
5202 CHECK_FOR_ERROR
5203 ;}
5204 break;
5205
5206 case 280:
5207#line 2531 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
5208 {
5209 (yyval.ValueList) = (yyvsp[0].ValueList);
5210 CHECK_FOR_ERROR
5211 ;}
5212 break;
5213
5214 case 281:
5215#line 2534 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
5216 {
5217 (yyval.ValueList) = new std::vector<Value*>();
5218 CHECK_FOR_ERROR
5219 ;}
5220 break;
5221
5222 case 282:
5223#line 2539 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
5224 {
5225 (yyval.BoolVal) = true;
5226 CHECK_FOR_ERROR
5227 ;}
5228 break;
5229
5230 case 283:
5231#line 2543 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
5232 {
5233 (yyval.BoolVal) = false;
5234 CHECK_FOR_ERROR
5235 ;}
5236 break;
5237
5238 case 284:
5239#line 2550 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
5240 {
5241 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5242 delete (yyvsp[-1].TypeVal);
5243 CHECK_FOR_ERROR
5244 ;}
5245 break;
5246
5247 case 285:
5248#line 2555 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
5249 {
5250 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
5251 CHECK_FOR_ERROR
5252 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5253 delete (yyvsp[-4].TypeVal);
5254 ;}
5255 break;
5256
5257 case 286:
5258#line 2561 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
5259 {
5260 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5261 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005262 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005263 ;}
5264 break;
5265
Reid Spencercd42c582006-12-05 23:29:42 +00005266 case 287:
Reid Spencere4d87aa2006-12-23 06:05:41 +00005267#line 2566 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005268 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005269 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005270 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005271 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5272 delete (yyvsp[-4].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005273 ;}
5274 break;
5275
Reid Spencercd42c582006-12-05 23:29:42 +00005276 case 288:
Reid Spencere4d87aa2006-12-23 06:05:41 +00005277#line 2572 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
5278 {
5279 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
5280 GEN_ERROR("Trying to free nonpointer type " +
5281 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
5282 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005283 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005284 ;}
5285 break;
5286
Reid Spencercd42c582006-12-05 23:29:42 +00005287 case 289:
Reid Spencere4d87aa2006-12-23 06:05:41 +00005288#line 2580 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
5289 {
5290 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
5291 GEN_ERROR("Can't load from nonpointer type: " +
5292 (*(yyvsp[-1].TypeVal))->getDescription());
5293 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
5294 GEN_ERROR("Can't load from pointer of non-first-class type: " +
5295 (*(yyvsp[-1].TypeVal))->getDescription());
5296 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005297 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005298 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5299 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005300 ;}
5301 break;
5302
Reid Spencercd42c582006-12-05 23:29:42 +00005303 case 290:
Reid Spencere4d87aa2006-12-23 06:05:41 +00005304#line 2592 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005305 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005306 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
5307 if (!PT)
5308 GEN_ERROR("Can't store to a nonpointer type: " +
5309 (*(yyvsp[-1].TypeVal))->getDescription());
5310 const Type *ElTy = PT->getElementType();
5311 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5312 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
5313 "' into space of type '" + ElTy->getDescription() + "'!");
5314
5315 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005316 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005317 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5318 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005319 ;}
5320 break;
5321
Reid Spencercd42c582006-12-05 23:29:42 +00005322 case 291:
Reid Spencere4d87aa2006-12-23 06:05:41 +00005323#line 2607 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005324 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005325 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005326 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005327
Reid Spencere4d87aa2006-12-23 06:05:41 +00005328 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005329 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00005330 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
5331 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005332 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005333 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
5334 delete (yyvsp[-2].TypeVal);
5335 delete (yyvsp[0].ValueList);
Reid Spencer3822ff52006-11-08 06:47:33 +00005336 ;}
5337 break;
5338
5339
Reid Spencere4d87aa2006-12-23 06:05:41 +00005340 default: break;
Reid Spencer3822ff52006-11-08 06:47:33 +00005341 }
5342
Reid Spencere4d87aa2006-12-23 06:05:41 +00005343/* Line 1126 of yacc.c. */
5344#line 5345 "llvmAsmParser.tab.c"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005345
5346 yyvsp -= yylen;
5347 yyssp -= yylen;
5348
5349
Reid Spencer3822ff52006-11-08 06:47:33 +00005350 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005351
5352 *++yyvsp = yyval;
5353
5354
Reid Spencer3822ff52006-11-08 06:47:33 +00005355 /* Now `shift' the result of the reduction. Determine what state
5356 that goes to, based on the state we popped back to and the rule
5357 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005358
5359 yyn = yyr1[yyn];
5360
Reid Spencer3822ff52006-11-08 06:47:33 +00005361 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5362 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005363 yystate = yytable[yystate];
5364 else
Reid Spencer3822ff52006-11-08 06:47:33 +00005365 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005366
5367 goto yynewstate;
5368
5369
Reid Spencer3822ff52006-11-08 06:47:33 +00005370/*------------------------------------.
5371| yyerrlab -- here on detecting error |
5372`------------------------------------*/
5373yyerrlab:
5374 /* If not already recovering from an error, report this error. */
5375 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005376 {
5377 ++yynerrs;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005378#if YYERROR_VERBOSE
5379 yyn = yypact[yystate];
Bill Wendlinge8156192006-12-07 01:30:32 +00005380
Andrew Lenharth6353e052006-12-08 18:07:09 +00005381 if (YYPACT_NINF < yyn && yyn < YYLAST)
5382 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00005383 int yytype = YYTRANSLATE (yychar);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005384 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5385 YYSIZE_T yysize = yysize0;
5386 YYSIZE_T yysize1;
5387 int yysize_overflow = 0;
5388 char *yymsg = 0;
5389# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5390 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
Andrew Lenharth6353e052006-12-08 18:07:09 +00005391 int yyx;
5392
Reid Spencere4d87aa2006-12-23 06:05:41 +00005393#if 0
5394 /* This is so xgettext sees the translatable formats that are
5395 constructed on the fly. */
5396 YY_("syntax error, unexpected %s");
5397 YY_("syntax error, unexpected %s, expecting %s");
5398 YY_("syntax error, unexpected %s, expecting %s or %s");
5399 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5400 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5401#endif
5402 char *yyfmt;
5403 char const *yyf;
5404 static char const yyunexpected[] = "syntax error, unexpected %s";
5405 static char const yyexpecting[] = ", expecting %s";
5406 static char const yyor[] = " or %s";
5407 char yyformat[sizeof yyunexpected
5408 + sizeof yyexpecting - 1
5409 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5410 * (sizeof yyor - 1))];
5411 char const *yyprefix = yyexpecting;
5412
Andrew Lenharth6353e052006-12-08 18:07:09 +00005413 /* Start YYX at -YYN if negative to avoid negative indexes in
5414 YYCHECK. */
5415 int yyxbegin = yyn < 0 ? -yyn : 0;
5416
5417 /* Stay within bounds of both yycheck and yytname. */
5418 int yychecklim = YYLAST - yyn;
5419 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005420 int yycount = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005421
Reid Spencere4d87aa2006-12-23 06:05:41 +00005422 yyarg[0] = yytname[yytype];
5423 yyfmt = yystpcpy (yyformat, yyunexpected);
5424
Andrew Lenharth6353e052006-12-08 18:07:09 +00005425 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5426 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5427 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005428 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005429 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005430 yycount = 1;
5431 yysize = yysize0;
5432 yyformat[sizeof yyunexpected - 1] = '\0';
Andrew Lenharth6353e052006-12-08 18:07:09 +00005433 break;
5434 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00005435 yyarg[yycount++] = yytname[yyx];
5436 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5437 yysize_overflow |= yysize1 < yysize;
5438 yysize = yysize1;
5439 yyfmt = yystpcpy (yyfmt, yyprefix);
5440 yyprefix = yyor;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005441 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005442
Reid Spencere4d87aa2006-12-23 06:05:41 +00005443 yyf = YY_(yyformat);
5444 yysize1 = yysize + yystrlen (yyf);
5445 yysize_overflow |= yysize1 < yysize;
5446 yysize = yysize1;
5447
5448 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5449 yymsg = (char *) YYSTACK_ALLOC (yysize);
5450 if (yymsg)
5451 {
5452 /* Avoid sprintf, as that infringes on the user's name space.
5453 Don't have undefined behavior even if the translation
5454 produced a string with the wrong number of "%s"s. */
5455 char *yyp = yymsg;
5456 int yyi = 0;
5457 while ((*yyp = *yyf))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005458 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005459 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5460 {
5461 yyp += yytnamerr (yyp, yyarg[yyi++]);
5462 yyf += 2;
5463 }
5464 else
5465 {
5466 yyp++;
5467 yyf++;
5468 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005469 }
5470 yyerror (yymsg);
5471 YYSTACK_FREE (yymsg);
5472 }
5473 else
Reid Spencere4d87aa2006-12-23 06:05:41 +00005474 {
5475 yyerror (YY_("syntax error"));
5476 goto yyexhaustedlab;
5477 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005478 }
5479 else
5480#endif /* YYERROR_VERBOSE */
Reid Spencere4d87aa2006-12-23 06:05:41 +00005481 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005482 }
5483
Reid Spencer3822ff52006-11-08 06:47:33 +00005484
Reid Spencer68a24bd2005-08-27 18:50:39 +00005485
5486 if (yyerrstatus == 3)
5487 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005488 /* If just tried and failed to reuse look-ahead token after an
Reid Spencer3822ff52006-11-08 06:47:33 +00005489 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005490
Reid Spencer3822ff52006-11-08 06:47:33 +00005491 if (yychar <= YYEOF)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005492 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005493 /* Return failure if at end of input. */
Reid Spencer3822ff52006-11-08 06:47:33 +00005494 if (yychar == YYEOF)
Reid Spencere4d87aa2006-12-23 06:05:41 +00005495 YYABORT;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005496 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005497 else
5498 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005499 yydestruct ("Error: discarding", yytoken, &yylval);
Reid Spencer3822ff52006-11-08 06:47:33 +00005500 yychar = YYEMPTY;
5501 }
5502 }
5503
Reid Spencere4d87aa2006-12-23 06:05:41 +00005504 /* Else will try to reuse look-ahead token after shifting the error
Reid Spencer3822ff52006-11-08 06:47:33 +00005505 token. */
5506 goto yyerrlab1;
5507
5508
5509/*---------------------------------------------------.
5510| yyerrorlab -- error raised explicitly by YYERROR. |
5511`---------------------------------------------------*/
5512yyerrorlab:
5513
Reid Spencere4d87aa2006-12-23 06:05:41 +00005514 /* Pacify compilers like GCC when the user code never invokes
5515 YYERROR and the label yyerrorlab therefore never appears in user
5516 code. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00005517 if (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00005518 goto yyerrorlab;
5519
Reid Spencere4d87aa2006-12-23 06:05:41 +00005520yyvsp -= yylen;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005521 yyssp -= yylen;
Reid Spencer3822ff52006-11-08 06:47:33 +00005522 yystate = *yyssp;
5523 goto yyerrlab1;
5524
5525
5526/*-------------------------------------------------------------.
5527| yyerrlab1 -- common code for both syntax error and YYERROR. |
5528`-------------------------------------------------------------*/
5529yyerrlab1:
5530 yyerrstatus = 3; /* Each real token shifted decrements this. */
5531
5532 for (;;)
5533 {
5534 yyn = yypact[yystate];
5535 if (yyn != YYPACT_NINF)
5536 {
5537 yyn += YYTERROR;
5538 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5539 {
5540 yyn = yytable[yyn];
5541 if (0 < yyn)
5542 break;
5543 }
5544 }
5545
5546 /* Pop the current state because it cannot handle the error token. */
5547 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005548 YYABORT;
5549
Reid Spencere4d87aa2006-12-23 06:05:41 +00005550
5551 yydestruct ("Error: popping", yystos[yystate], yyvsp);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005552 YYPOPSTACK;
Reid Spencer3822ff52006-11-08 06:47:33 +00005553 yystate = *yyssp;
5554 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005555 }
5556
5557 if (yyn == YYFINAL)
5558 YYACCEPT;
5559
Reid Spencer68a24bd2005-08-27 18:50:39 +00005560 *++yyvsp = yylval;
Reid Spencer3822ff52006-11-08 06:47:33 +00005561
5562
Reid Spencere4d87aa2006-12-23 06:05:41 +00005563 /* Shift the error token. */
5564 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
5565
Reid Spencer68a24bd2005-08-27 18:50:39 +00005566 yystate = yyn;
5567 goto yynewstate;
5568
Chris Lattnerf49c1762006-11-08 05:58:47 +00005569
Reid Spencer3822ff52006-11-08 06:47:33 +00005570/*-------------------------------------.
5571| yyacceptlab -- YYACCEPT comes here. |
5572`-------------------------------------*/
5573yyacceptlab:
5574 yyresult = 0;
5575 goto yyreturn;
5576
5577/*-----------------------------------.
5578| yyabortlab -- YYABORT comes here. |
5579`-----------------------------------*/
5580yyabortlab:
5581 yyresult = 1;
5582 goto yyreturn;
5583
5584#ifndef yyoverflow
Reid Spencere4d87aa2006-12-23 06:05:41 +00005585/*-------------------------------------------------.
5586| yyexhaustedlab -- memory exhaustion comes here. |
5587`-------------------------------------------------*/
5588yyexhaustedlab:
5589 yyerror (YY_("memory exhausted"));
Reid Spencer3822ff52006-11-08 06:47:33 +00005590 yyresult = 2;
5591 /* Fall through. */
Chris Lattnerf49c1762006-11-08 05:58:47 +00005592#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00005593
5594yyreturn:
Reid Spencere4d87aa2006-12-23 06:05:41 +00005595 if (yychar != YYEOF && yychar != YYEMPTY)
5596 yydestruct ("Cleanup: discarding lookahead",
5597 yytoken, &yylval);
5598 while (yyssp != yyss)
5599 {
5600 yydestruct ("Cleanup: popping",
5601 yystos[*yyssp], yyvsp);
5602 YYPOPSTACK;
5603 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005604#ifndef yyoverflow
5605 if (yyss != yyssa)
5606 YYSTACK_FREE (yyss);
5607#endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00005608 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005609}
Reid Spencer3822ff52006-11-08 06:47:33 +00005610
5611
Reid Spencere4d87aa2006-12-23 06:05:41 +00005612#line 2622 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005613
5614
5615void llvm::GenerateError(const std::string &message, int LineNo) {
5616 if (LineNo == -1) LineNo = llvmAsmlineno;
5617 // TODO: column number in exception
5618 if (TheParseError)
5619 TheParseError->setError(CurFilename, message, LineNo);
5620 TriggerError = 1;
5621}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005622
5623int yyerror(const char *ErrorMsg) {
5624 std::string where
5625 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5626 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5627 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5628 if (yychar == YYEMPTY || yychar == 0)
5629 errMsg += "end-of-file.";
5630 else
5631 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005632 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005633 return 0;
5634}
Reid Spencer3822ff52006-11-08 06:47:33 +00005635