blob: d1382fc5c8e8e0e510e736841dc643dc24fb03b8 [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,
Reid Spencer14310612006-12-31 05:40:51 +000074 INT8 = 265,
75 INT16 = 266,
76 INT32 = 267,
77 INT64 = 268,
78 FLOAT = 269,
79 DOUBLE = 270,
80 LABEL = 271,
81 TYPE = 272,
82 VAR_ID = 273,
83 LABELSTR = 274,
84 STRINGCONSTANT = 275,
85 IMPLEMENTATION = 276,
86 ZEROINITIALIZER = 277,
87 TRUETOK = 278,
88 FALSETOK = 279,
89 BEGINTOK = 280,
90 ENDTOK = 281,
91 DECLARE = 282,
92 DEFINE = 283,
93 GLOBAL = 284,
94 CONSTANT = 285,
95 SECTION = 286,
96 VOLATILE = 287,
97 TO = 288,
98 DOTDOTDOT = 289,
99 NULL_TOK = 290,
100 UNDEF = 291,
101 INTERNAL = 292,
102 LINKONCE = 293,
103 WEAK = 294,
104 APPENDING = 295,
105 DLLIMPORT = 296,
106 DLLEXPORT = 297,
107 EXTERN_WEAK = 298,
108 OPAQUE = 299,
109 NOT = 300,
110 EXTERNAL = 301,
111 TARGET = 302,
112 TRIPLE = 303,
113 ENDIAN = 304,
114 POINTERSIZE = 305,
115 LITTLE = 306,
116 BIG = 307,
117 ALIGN = 308,
118 DEPLIBS = 309,
119 CALL = 310,
120 TAIL = 311,
121 ASM_TOK = 312,
122 MODULE = 313,
123 SIDEEFFECT = 314,
124 CC_TOK = 315,
125 CCC_TOK = 316,
126 CSRETCC_TOK = 317,
127 FASTCC_TOK = 318,
128 COLDCC_TOK = 319,
129 X86_STDCALLCC_TOK = 320,
130 X86_FASTCALLCC_TOK = 321,
131 DATALAYOUT = 322,
132 RET = 323,
133 BR = 324,
134 SWITCH = 325,
135 INVOKE = 326,
136 UNWIND = 327,
137 UNREACHABLE = 328,
138 ADD = 329,
139 SUB = 330,
140 MUL = 331,
141 UDIV = 332,
142 SDIV = 333,
143 FDIV = 334,
144 UREM = 335,
145 SREM = 336,
146 FREM = 337,
147 AND = 338,
148 OR = 339,
149 XOR = 340,
150 ICMP = 341,
151 FCMP = 342,
152 EQ = 343,
153 NE = 344,
154 SLT = 345,
155 SGT = 346,
156 SLE = 347,
157 SGE = 348,
158 ULT = 349,
159 UGT = 350,
160 ULE = 351,
161 UGE = 352,
162 OEQ = 353,
163 ONE = 354,
164 OLT = 355,
165 OGT = 356,
166 OLE = 357,
167 OGE = 358,
168 ORD = 359,
169 UNO = 360,
170 UEQ = 361,
171 UNE = 362,
172 MALLOC = 363,
173 ALLOCA = 364,
174 FREE = 365,
175 LOAD = 366,
176 STORE = 367,
177 GETELEMENTPTR = 368,
178 TRUNC = 369,
179 ZEXT = 370,
180 SEXT = 371,
181 FPTRUNC = 372,
182 FPEXT = 373,
183 BITCAST = 374,
184 UITOFP = 375,
185 SITOFP = 376,
186 FPTOUI = 377,
187 FPTOSI = 378,
188 INTTOPTR = 379,
189 PTRTOINT = 380,
190 PHI_TOK = 381,
191 SELECT = 382,
192 SHL = 383,
193 LSHR = 384,
194 ASHR = 385,
195 VAARG = 386,
196 EXTRACTELEMENT = 387,
197 INSERTELEMENT = 388,
Reid Spencer218ded22007-01-05 17:07:23 +0000198 SHUFFLEVECTOR = 389,
199 NORETURN = 390
Reid Spencer3822ff52006-11-08 06:47:33 +0000200 };
201#endif
Reid Spencere4d87aa2006-12-23 06:05:41 +0000202/* Tokens. */
Reid Spencer3822ff52006-11-08 06:47:33 +0000203#define ESINT64VAL 258
204#define EUINT64VAL 259
205#define SINTVAL 260
206#define UINTVAL 261
207#define FPVAL 262
208#define VOID 263
209#define BOOL 264
Reid Spencer14310612006-12-31 05:40:51 +0000210#define INT8 265
211#define INT16 266
212#define INT32 267
213#define INT64 268
214#define FLOAT 269
215#define DOUBLE 270
216#define LABEL 271
217#define TYPE 272
218#define VAR_ID 273
219#define LABELSTR 274
220#define STRINGCONSTANT 275
221#define IMPLEMENTATION 276
222#define ZEROINITIALIZER 277
223#define TRUETOK 278
224#define FALSETOK 279
225#define BEGINTOK 280
226#define ENDTOK 281
227#define DECLARE 282
228#define DEFINE 283
229#define GLOBAL 284
230#define CONSTANT 285
231#define SECTION 286
232#define VOLATILE 287
233#define TO 288
234#define DOTDOTDOT 289
235#define NULL_TOK 290
236#define UNDEF 291
237#define INTERNAL 292
238#define LINKONCE 293
239#define WEAK 294
240#define APPENDING 295
241#define DLLIMPORT 296
242#define DLLEXPORT 297
243#define EXTERN_WEAK 298
244#define OPAQUE 299
245#define NOT 300
246#define EXTERNAL 301
247#define TARGET 302
248#define TRIPLE 303
249#define ENDIAN 304
250#define POINTERSIZE 305
251#define LITTLE 306
252#define BIG 307
253#define ALIGN 308
254#define DEPLIBS 309
255#define CALL 310
256#define TAIL 311
257#define ASM_TOK 312
258#define MODULE 313
259#define SIDEEFFECT 314
260#define CC_TOK 315
261#define CCC_TOK 316
262#define CSRETCC_TOK 317
263#define FASTCC_TOK 318
264#define COLDCC_TOK 319
265#define X86_STDCALLCC_TOK 320
266#define X86_FASTCALLCC_TOK 321
267#define DATALAYOUT 322
268#define RET 323
269#define BR 324
270#define SWITCH 325
271#define INVOKE 326
272#define UNWIND 327
273#define UNREACHABLE 328
274#define ADD 329
275#define SUB 330
276#define MUL 331
277#define UDIV 332
278#define SDIV 333
279#define FDIV 334
280#define UREM 335
281#define SREM 336
282#define FREM 337
283#define AND 338
284#define OR 339
285#define XOR 340
286#define ICMP 341
287#define FCMP 342
288#define EQ 343
289#define NE 344
290#define SLT 345
291#define SGT 346
292#define SLE 347
293#define SGE 348
294#define ULT 349
295#define UGT 350
296#define ULE 351
297#define UGE 352
298#define OEQ 353
299#define ONE 354
300#define OLT 355
301#define OGT 356
302#define OLE 357
303#define OGE 358
304#define ORD 359
305#define UNO 360
306#define UEQ 361
307#define UNE 362
308#define MALLOC 363
309#define ALLOCA 364
310#define FREE 365
311#define LOAD 366
312#define STORE 367
313#define GETELEMENTPTR 368
314#define TRUNC 369
315#define ZEXT 370
316#define SEXT 371
317#define FPTRUNC 372
318#define FPEXT 373
319#define BITCAST 374
320#define UITOFP 375
321#define SITOFP 376
322#define FPTOUI 377
323#define FPTOSI 378
324#define INTTOPTR 379
325#define PTRTOINT 380
326#define PHI_TOK 381
327#define SELECT 382
328#define SHL 383
329#define LSHR 384
330#define ASHR 385
331#define VAARG 386
332#define EXTRACTELEMENT 387
333#define INSERTELEMENT 388
334#define SHUFFLEVECTOR 389
Reid Spencer218ded22007-01-05 17:07:23 +0000335#define NORETURN 390
Reid Spencer3822ff52006-11-08 06:47:33 +0000336
337
338
339
340/* Copy the first part of user declarations. */
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +0000341#line 14 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000342
343#include "ParserInternals.h"
344#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000345#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000346#include "llvm/Instructions.h"
347#include "llvm/Module.h"
348#include "llvm/SymbolTable.h"
349#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000350#include "llvm/Support/CommandLine.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000351#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000352#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000353#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000355#include <list>
356#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000357#ifndef NDEBUG
358#define YYDEBUG 1
359#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000360
Reid Spencere4f47592006-08-18 17:32:55 +0000361// The following is a gross hack. In order to rid the libAsmParser library of
362// exceptions, we have to have a way of getting the yyparse function to go into
363// an error situation. So, whenever we want an error to occur, the GenerateError
364// function (see bottom of file) sets TriggerError. Then, at the end of each
365// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
366// (a goto) to put YACC in error state. Furthermore, several calls to
367// GenerateError are made from inside productions and they must simulate the
368// previous exception behavior by exiting the production immediately. We have
369// replaced these with the GEN_ERROR macro which calls GeneratError and then
370// immediately invokes YYERROR. This would be so much cleaner if it was a
371// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000372static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000373#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000374#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
375
Reid Spencer68a24bd2005-08-27 18:50:39 +0000376int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
377int yylex(); // declaration" of xxx warnings.
378int yyparse();
379
380namespace llvm {
381 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000382#if YYDEBUG
383static cl::opt<bool>
384Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
385 cl::Hidden, cl::init(false));
386#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000387}
388using namespace llvm;
389
390static Module *ParserResult;
391
392// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
393// relating to upreferences in the input stream.
394//
395//#define DEBUG_UPREFS 1
396#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000397#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000398#else
399#define UR_OUT(X)
400#endif
401
402#define YYERROR_VERBOSE 1
403
Chris Lattnerb475c422005-11-12 18:22:38 +0000404static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000405
406
407// This contains info used when building the body of a function. It is
408// destroyed when the function is completed.
409//
410typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000411
Reid Spencer68a24bd2005-08-27 18:50:39 +0000412static void
413ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
414 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
415
416static struct PerModuleInfo {
417 Module *CurrentModule;
418 std::map<const Type *, ValueList> Values; // Module level numbered definitions
419 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000420 std::vector<PATypeHolder> Types;
421 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000422
423 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000424 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000425 /// that we can resolve them later and print error messages as appropriate.
426 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
427
428 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
429 // references to global values. Global values may be referenced before they
430 // are defined, and if so, the temporary object that they represent is held
431 // here. This is used for forward references of GlobalValues.
432 //
433 typedef std::map<std::pair<const PointerType *,
434 ValID>, GlobalValue*> GlobalRefsType;
435 GlobalRefsType GlobalRefs;
436
437 void ModuleDone() {
438 // If we could not resolve some functions at function compilation time
439 // (calls to functions before they are defined), resolve them now... Types
440 // are resolved when the constant pool has been completely parsed.
441 //
442 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000443 if (TriggerError)
444 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000445
446 // Check to make sure that all global value forward references have been
447 // resolved!
448 //
449 if (!GlobalRefs.empty()) {
450 std::string UndefinedReferences = "Unresolved global references exist:\n";
451
452 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
453 I != E; ++I) {
454 UndefinedReferences += " " + I->first.first->getDescription() + " " +
455 I->first.second.getName() + "\n";
456 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000457 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000458 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000459 }
460
461 Values.clear(); // Clear out function local definitions
462 Types.clear();
463 CurrentModule = 0;
464 }
465
Reid Spencer68a24bd2005-08-27 18:50:39 +0000466 // GetForwardRefForGlobal - Check to see if there is a forward reference
467 // for this global. If so, remove it from the GlobalRefs map and return it.
468 // If not, just return null.
469 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
470 // Check to see if there is a forward reference to this global variable...
471 // if there is, eliminate it and patch the reference to use the new def'n.
472 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
473 GlobalValue *Ret = 0;
474 if (I != GlobalRefs.end()) {
475 Ret = I->second;
476 GlobalRefs.erase(I);
477 }
478 return Ret;
479 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000480
481 bool TypeIsUnresolved(PATypeHolder* PATy) {
482 // If it isn't abstract, its resolved
483 const Type* Ty = PATy->get();
484 if (!Ty->isAbstract())
485 return false;
486 // Traverse the type looking for abstract types. If it isn't abstract then
487 // we don't need to traverse that leg of the type.
488 std::vector<const Type*> WorkList, SeenList;
489 WorkList.push_back(Ty);
490 while (!WorkList.empty()) {
491 const Type* Ty = WorkList.back();
492 SeenList.push_back(Ty);
493 WorkList.pop_back();
494 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
495 // Check to see if this is an unresolved type
496 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
497 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
498 for ( ; I != E; ++I) {
499 if (I->second.get() == OpTy)
500 return true;
501 }
502 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
503 const Type* TheTy = SeqTy->getElementType();
504 if (TheTy->isAbstract() && TheTy != Ty) {
505 std::vector<const Type*>::iterator I = SeenList.begin(),
506 E = SeenList.end();
507 for ( ; I != E; ++I)
508 if (*I == TheTy)
509 break;
510 if (I == E)
511 WorkList.push_back(TheTy);
512 }
513 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
514 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
515 const Type* TheTy = StrTy->getElementType(i);
516 if (TheTy->isAbstract() && TheTy != Ty) {
517 std::vector<const Type*>::iterator I = SeenList.begin(),
518 E = SeenList.end();
519 for ( ; I != E; ++I)
520 if (*I == TheTy)
521 break;
522 if (I == E)
523 WorkList.push_back(TheTy);
524 }
525 }
526 }
527 }
528 return false;
529 }
530
531
Reid Spencer68a24bd2005-08-27 18:50:39 +0000532} CurModule;
533
534static struct PerFunctionInfo {
535 Function *CurrentFunction; // Pointer to current function being created
536
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000537 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000538 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000539 bool isDeclare; // Is this function a forward declararation?
540 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000541
542 /// BBForwardRefs - When we see forward references to basic blocks, keep
543 /// track of them here.
544 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
545 std::vector<BasicBlock*> NumberedBlocks;
546 unsigned NextBBNum;
547
548 inline PerFunctionInfo() {
549 CurrentFunction = 0;
550 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000551 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000552 }
553
554 inline void FunctionStart(Function *M) {
555 CurrentFunction = M;
556 NextBBNum = 0;
557 }
558
559 void FunctionDone() {
560 NumberedBlocks.clear();
561
562 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000563 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000564 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000565 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000566 return;
567 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000568
569 // Resolve all forward references now.
570 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
571
572 Values.clear(); // Clear out function local definitions
573 CurrentFunction = 0;
574 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000575 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000576 }
577} CurFun; // Info for the current function...
578
579static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
580
581
582//===----------------------------------------------------------------------===//
583// Code to handle definitions of all the types
584//===----------------------------------------------------------------------===//
585
586static int InsertValue(Value *V,
587 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
588 if (V->hasName()) return -1; // Is this a numbered definition?
589
590 // Yes, insert the value into the value table...
591 ValueList &List = ValueTab[V->getType()];
592 List.push_back(V);
593 return List.size()-1;
594}
595
596static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
597 switch (D.Type) {
598 case ValID::NumberVal: // Is it a numbered definition?
599 // Module constants occupy the lowest numbered slots...
600 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer861d9d62006-11-28 07:29:44 +0000601 return CurModule.Types[(unsigned)D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000602 break;
603 case ValID::NameVal: // Is it a named definition?
604 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
605 D.destroy(); // Free old strdup'd memory...
606 return N;
607 }
608 break;
609 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000610 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000611 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000612 }
613
614 // If we reached here, we referenced either a symbol that we don't know about
615 // or an id number that hasn't been read yet. We may be referencing something
616 // forward, so just create an entry to be resolved later and get to it...
617 //
618 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
619
620
621 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000622 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000623 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000624 return 0;
625 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000626 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000627 return 0;
628 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000629 }
630
Reid Spencer861d9d62006-11-28 07:29:44 +0000631 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000632 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000633 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000634
Reid Spencer861d9d62006-11-28 07:29:44 +0000635 Type *Typ = OpaqueType::get();
636 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
637 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000638 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000639
640static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
641 SymbolTable &SymTab =
Reid Spencer78d033e2007-01-06 07:24:44 +0000642 inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
643 CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000644 return SymTab.lookup(Ty, Name);
645}
646
647// getValNonImprovising - Look up the value specified by the provided type and
648// the provided ValID. If the value exists and has already been defined, return
649// it. Otherwise return null.
650//
651static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000652 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000653 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000654 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000655 return 0;
656 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657
658 switch (D.Type) {
659 case ValID::NumberVal: { // Is it a numbered definition?
660 unsigned Num = (unsigned)D.Num;
661
662 // Module constants occupy the lowest numbered slots...
663 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
664 if (VI != CurModule.Values.end()) {
665 if (Num < VI->second.size())
666 return VI->second[Num];
667 Num -= VI->second.size();
668 }
669
670 // Make sure that our type is within bounds
671 VI = CurFun.Values.find(Ty);
672 if (VI == CurFun.Values.end()) return 0;
673
674 // Check that the number is within bounds...
675 if (VI->second.size() <= Num) return 0;
676
677 return VI->second[Num];
678 }
679
680 case ValID::NameVal: { // Is it a named definition?
681 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
682 if (N == 0) return 0;
683
684 D.destroy(); // Free old strdup'd memory...
685 return N;
686 }
687
688 // Check to make sure that "Ty" is an integral type, and that our
689 // value will fit into the specified type...
690 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000691 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000692 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000693 itostr(D.ConstPool64) + "' is invalid for type '" +
694 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000695 return 0;
696 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000697 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000698
699 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000700 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
701 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000702 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000703 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000704 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000705 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000706 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000707 }
708 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000709 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000710 }
711
712 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000713 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000714 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000715 return 0;
716 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000717 return ConstantFP::get(Ty, D.ConstPoolFP);
718
719 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000720 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000721 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000722 return 0;
723 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000724 return ConstantPointerNull::get(cast<PointerType>(Ty));
725
726 case ValID::ConstUndefVal: // Is it an undef value?
727 return UndefValue::get(Ty);
728
Chris Lattner7aa61892005-12-21 17:53:23 +0000729 case ValID::ConstZeroVal: // Is it a zero value?
730 return Constant::getNullValue(Ty);
731
Reid Spencer68a24bd2005-08-27 18:50:39 +0000732 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000733 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000734 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000735 return 0;
736 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000737 return D.ConstantValue;
738
Chris Lattner0e9c3762006-01-25 22:27:16 +0000739 case ValID::InlineAsmVal: { // Inline asm expression
740 const PointerType *PTy = dyn_cast<PointerType>(Ty);
741 const FunctionType *FTy =
742 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000743 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000744 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000745 return 0;
746 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000747 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
748 D.IAD->HasSideEffects);
749 D.destroy(); // Free InlineAsmDescriptor.
750 return IA;
751 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000752 default:
753 assert(0 && "Unhandled case!");
754 return 0;
755 } // End of switch
756
757 assert(0 && "Unhandled case!");
758 return 0;
759}
760
761// getVal - This function is identical to getValNonImprovising, except that if a
762// value is not already defined, it "improvises" by creating a placeholder var
763// that looks and acts just like the requested variable. When the value is
764// defined later, all uses of the placeholder variable are replaced with the
765// real thing.
766//
767static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000768 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000769 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000770 return 0;
771 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000772
773 // See if the value has already been defined.
774 Value *V = getValNonImprovising(Ty, ID);
775 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000776 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000777
Reid Spencer5b7e7532006-09-28 19:28:24 +0000778 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000779 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000780 return 0;
781 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000782
783 // If we reached here, we referenced either a symbol that we don't know about
784 // or an id number that hasn't been read yet. We may be referencing something
785 // forward, so just create an entry to be resolved later and get to it...
786 //
787 V = new Argument(Ty);
788
789 // Remember where this forward reference came from. FIXME, shouldn't we try
790 // to recycle these things??
791 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
792 llvmAsmlineno)));
793
794 if (inFunctionScope())
795 InsertValue(V, CurFun.LateResolveValues);
796 else
797 InsertValue(V, CurModule.LateResolveValues);
798 return V;
799}
800
801/// getBBVal - This is used for two purposes:
802/// * If isDefinition is true, a new basic block with the specified ID is being
803/// defined.
804/// * If isDefinition is true, this is a reference to a basic block, which may
805/// or may not be a forward reference.
806///
807static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
808 assert(inFunctionScope() && "Can't get basic block at global scope!");
809
810 std::string Name;
811 BasicBlock *BB = 0;
812 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000813 default:
814 GenerateError("Illegal label reference " + ID.getName());
815 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000816 case ValID::NumberVal: // Is it a numbered definition?
817 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
818 CurFun.NumberedBlocks.resize(ID.Num+1);
819 BB = CurFun.NumberedBlocks[ID.Num];
820 break;
821 case ValID::NameVal: // Is it a named definition?
822 Name = ID.Name;
823 if (Value *N = CurFun.CurrentFunction->
Reid Spencer78d033e2007-01-06 07:24:44 +0000824 getValueSymbolTable().lookup(Type::LabelTy, Name))
Reid Spencer68a24bd2005-08-27 18:50:39 +0000825 BB = cast<BasicBlock>(N);
826 break;
827 }
828
829 // See if the block has already been defined.
830 if (BB) {
831 // If this is the definition of the block, make sure the existing value was
832 // just a forward reference. If it was a forward reference, there will be
833 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000834 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000835 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000836 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000837 return 0;
838 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000839
840 ID.destroy(); // Free strdup'd memory.
841 return BB;
842 }
843
844 // Otherwise this block has not been seen before.
845 BB = new BasicBlock("", CurFun.CurrentFunction);
846 if (ID.Type == ValID::NameVal) {
847 BB->setName(ID.Name);
848 } else {
849 CurFun.NumberedBlocks[ID.Num] = BB;
850 }
851
852 // If this is not a definition, keep track of it so we can use it as a forward
853 // reference.
854 if (!isDefinition) {
855 // Remember where this forward reference came from.
856 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
857 } else {
858 // The forward declaration could have been inserted anywhere in the
859 // function: insert it into the correct place now.
860 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
861 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
862 }
863 ID.destroy();
864 return BB;
865}
866
867
868//===----------------------------------------------------------------------===//
869// Code to handle forward references in instructions
870//===----------------------------------------------------------------------===//
871//
872// This code handles the late binding needed with statements that reference
873// values not defined yet... for example, a forward branch, or the PHI node for
874// a loop body.
875//
876// This keeps a table (CurFun.LateResolveValues) of all such forward references
877// and back patchs after we are done.
878//
879
880// ResolveDefinitions - If we could not resolve some defs at parsing
881// time (forward branches, phi functions for loops, etc...) resolve the
882// defs now...
883//
884static void
885ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
886 std::map<const Type*,ValueList> *FutureLateResolvers) {
887 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
888 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
889 E = LateResolvers.end(); LRI != E; ++LRI) {
890 ValueList &List = LRI->second;
891 while (!List.empty()) {
892 Value *V = List.back();
893 List.pop_back();
894
895 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
896 CurModule.PlaceHolderInfo.find(V);
897 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
898
899 ValID &DID = PHI->second.first;
900
901 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000902 if (TriggerError)
903 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000904 if (TheRealValue) {
905 V->replaceAllUsesWith(TheRealValue);
906 delete V;
907 CurModule.PlaceHolderInfo.erase(PHI);
908 } else if (FutureLateResolvers) {
909 // Functions have their unresolved items forwarded to the module late
910 // resolver table
911 InsertValue(V, *FutureLateResolvers);
912 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000913 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000914 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000915 "' of type '" + V->getType()->getDescription() + "'",
916 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000917 return;
918 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000919 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000920 itostr(DID.Num) + " of type '" +
921 V->getType()->getDescription() + "'",
922 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000923 return;
924 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000925 }
926 }
927 }
928
929 LateResolvers.clear();
930}
931
932// ResolveTypeTo - A brand new type was just declared. This means that (if
933// name is not null) things referencing Name can be resolved. Otherwise, things
934// refering to the number can be resolved. Do this now.
935//
936static void ResolveTypeTo(char *Name, const Type *ToTy) {
937 ValID D;
938 if (Name) D = ValID::create(Name);
939 else D = ValID::create((int)CurModule.Types.size());
940
Reid Spencer861d9d62006-11-28 07:29:44 +0000941 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000942 CurModule.LateResolveTypes.find(D);
943 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000944 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000945 CurModule.LateResolveTypes.erase(I);
946 }
947}
948
949// setValueName - Set the specified value to the name given. The name may be
950// null potentially, in which case this is a noop. The string passed in is
951// assumed to be a malloc'd string buffer, and is free'd by this function.
952//
953static void setValueName(Value *V, char *NameStr) {
954 if (NameStr) {
955 std::string Name(NameStr); // Copy string
956 free(NameStr); // Free old string
957
Reid Spencer5b7e7532006-09-28 19:28:24 +0000958 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000959 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000960 return;
961 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000962
963 assert(inFunctionScope() && "Must be in function scope!");
Reid Spencer78d033e2007-01-06 07:24:44 +0000964 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000965 if (ST.lookup(V->getType(), Name)) {
Reid Spencer63c34452007-01-05 21:51:07 +0000966 GenerateError("Redefinition of value '" + Name + "' of type '" +
967 V->getType()->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000968 return;
969 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000970
971 // Set the name.
972 V->setName(Name);
973 }
974}
975
976/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
977/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000978static GlobalVariable *
979ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
980 bool isConstantGlobal, const Type *Ty,
981 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000982 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000983 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000984 return 0;
985 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000986
987 const PointerType *PTy = PointerType::get(Ty);
988
989 std::string Name;
990 if (NameStr) {
991 Name = NameStr; // Copy string
992 free(NameStr); // Free old string
993 }
994
995 // See if this global value was forward referenced. If so, recycle the
996 // object.
997 ValID ID;
998 if (!Name.empty()) {
999 ID = ValID::create((char*)Name.c_str());
1000 } else {
1001 ID = ValID::create((int)CurModule.Values[PTy].size());
1002 }
1003
1004 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1005 // Move the global to the end of the list, from whereever it was
1006 // previously inserted.
1007 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1008 CurModule.CurrentModule->getGlobalList().remove(GV);
1009 CurModule.CurrentModule->getGlobalList().push_back(GV);
1010 GV->setInitializer(Initializer);
1011 GV->setLinkage(Linkage);
1012 GV->setConstant(isConstantGlobal);
1013 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001014 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001015 }
1016
1017 // If this global has a name, check to see if there is already a definition
Reid Spencer63c34452007-01-05 21:51:07 +00001018 // of this global in the module. If so, it is an error.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001019 if (!Name.empty()) {
1020 // We are a simple redefinition of a value, check to see if it is defined
1021 // the same as the old one.
Reid Spencer63c34452007-01-05 21:51:07 +00001022 if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001023 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer63c34452007-01-05 21:51:07 +00001024 "' of type '" + Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001025 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001026 }
1027 }
1028
1029 // Otherwise there is no existing GV to use, create one now.
1030 GlobalVariable *GV =
1031 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1032 CurModule.CurrentModule);
1033 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001034 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001035}
1036
1037// setTypeName - Set the specified type to the name given. The name may be
1038// null potentially, in which case this is a noop. The string passed in is
1039// assumed to be a malloc'd string buffer, and is freed by this function.
1040//
1041// This function returns true if the type has already been defined, but is
1042// allowed to be redefined in the specified context. If the name is a new name
1043// for the type plane, it is inserted and false is returned.
1044static bool setTypeName(const Type *T, char *NameStr) {
1045 assert(!inFunctionScope() && "Can't give types function-local names!");
1046 if (NameStr == 0) return false;
1047
1048 std::string Name(NameStr); // Copy string
1049 free(NameStr); // Free old string
1050
1051 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001052 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001053 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001054 return false;
1055 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001056
1057 // Set the type name, checking for conflicts as we do so.
1058 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1059
1060 if (AlreadyExists) { // Inserting a name that is already defined???
1061 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1062 assert(Existing && "Conflict but no matching type?");
1063
1064 // There is only one case where this is allowed: when we are refining an
1065 // opaque type. In this case, Existing will be an opaque type.
1066 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1067 // We ARE replacing an opaque type!
1068 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1069 return true;
1070 }
1071
1072 // Otherwise, this is an attempt to redefine a type. That's okay if
1073 // the redefinition is identical to the original. This will be so if
1074 // Existing and T point to the same Type object. In this one case we
1075 // allow the equivalent redefinition.
1076 if (Existing == T) return true; // Yes, it's equal.
1077
1078 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001079 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1080 T->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001081 }
1082
1083 return false;
1084}
1085
1086//===----------------------------------------------------------------------===//
1087// Code for handling upreferences in type names...
1088//
1089
1090// TypeContains - Returns true if Ty directly contains E in it.
1091//
1092static bool TypeContains(const Type *Ty, const Type *E) {
1093 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1094 E) != Ty->subtype_end();
1095}
1096
1097namespace {
1098 struct UpRefRecord {
1099 // NestingLevel - The number of nesting levels that need to be popped before
1100 // this type is resolved.
1101 unsigned NestingLevel;
1102
1103 // LastContainedTy - This is the type at the current binding level for the
1104 // type. Every time we reduce the nesting level, this gets updated.
1105 const Type *LastContainedTy;
1106
1107 // UpRefTy - This is the actual opaque type that the upreference is
1108 // represented with.
1109 OpaqueType *UpRefTy;
1110
1111 UpRefRecord(unsigned NL, OpaqueType *URTy)
1112 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1113 };
1114}
1115
1116// UpRefs - A list of the outstanding upreferences that need to be resolved.
1117static std::vector<UpRefRecord> UpRefs;
1118
1119/// HandleUpRefs - Every time we finish a new layer of types, this function is
1120/// called. It loops through the UpRefs vector, which is a list of the
1121/// currently active types. For each type, if the up reference is contained in
1122/// the newly completed type, we decrement the level count. When the level
1123/// count reaches zero, the upreferenced type is the type that is passed in:
1124/// thus we can complete the cycle.
1125///
1126static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001127 // If Ty isn't abstract, or if there are no up-references in it, then there is
1128 // nothing to resolve here.
1129 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1130
Reid Spencer68a24bd2005-08-27 18:50:39 +00001131 PATypeHolder Ty(ty);
1132 UR_OUT("Type '" << Ty->getDescription() <<
1133 "' newly formed. Resolving upreferences.\n" <<
1134 UpRefs.size() << " upreferences active!\n");
1135
1136 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1137 // to zero), we resolve them all together before we resolve them to Ty. At
1138 // the end of the loop, if there is anything to resolve to Ty, it will be in
1139 // this variable.
1140 OpaqueType *TypeToResolve = 0;
1141
1142 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1143 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1144 << UpRefs[i].second->getDescription() << ") = "
1145 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1146 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1147 // Decrement level of upreference
1148 unsigned Level = --UpRefs[i].NestingLevel;
1149 UpRefs[i].LastContainedTy = Ty;
1150 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1151 if (Level == 0) { // Upreference should be resolved!
1152 if (!TypeToResolve) {
1153 TypeToResolve = UpRefs[i].UpRefTy;
1154 } else {
1155 UR_OUT(" * Resolving upreference for "
1156 << UpRefs[i].second->getDescription() << "\n";
1157 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1158 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1159 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1160 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1161 }
1162 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1163 --i; // Do not skip the next element...
1164 }
1165 }
1166 }
1167
1168 if (TypeToResolve) {
1169 UR_OUT(" * Resolving upreference for "
1170 << UpRefs[i].second->getDescription() << "\n";
1171 std::string OldName = TypeToResolve->getDescription());
1172 TypeToResolve->refineAbstractTypeTo(Ty);
1173 }
1174
1175 return Ty;
1176}
1177
Reid Spencer68a24bd2005-08-27 18:50:39 +00001178//===----------------------------------------------------------------------===//
1179// RunVMAsmParser - Define an interface to this parser
1180//===----------------------------------------------------------------------===//
1181//
Reid Spencer14310612006-12-31 05:40:51 +00001182static Module* RunParser(Module * M);
1183
Reid Spencer68a24bd2005-08-27 18:50:39 +00001184Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1185 set_scan_file(F);
1186
1187 CurFilename = Filename;
1188 return RunParser(new Module(CurFilename));
1189}
1190
1191Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1192 set_scan_string(AsmString);
1193
1194 CurFilename = "from_memory";
1195 if (M == NULL) {
1196 return RunParser(new Module (CurFilename));
1197 } else {
1198 return RunParser(M);
1199 }
1200}
1201
1202
Reid Spencer3822ff52006-11-08 06:47:33 +00001203
1204/* Enabling traces. */
1205#ifndef YYDEBUG
1206# define YYDEBUG 0
1207#endif
1208
1209/* Enabling verbose error messages. */
1210#ifdef YYERROR_VERBOSE
1211# undef YYERROR_VERBOSE
1212# define YYERROR_VERBOSE 1
1213#else
1214# define YYERROR_VERBOSE 0
1215#endif
1216
Reid Spencere4d87aa2006-12-23 06:05:41 +00001217/* Enabling the token table. */
1218#ifndef YYTOKEN_TABLE
1219# define YYTOKEN_TABLE 0
1220#endif
1221
Andrew Lenharth6353e052006-12-08 18:07:09 +00001222#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001223#line 876 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00001224typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001225 llvm::Module *ModuleVal;
1226 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001227 llvm::BasicBlock *BasicBlockVal;
1228 llvm::TerminatorInst *TermInstVal;
1229 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001230 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001231
Reid Spencera132e042006-12-03 05:46:11 +00001232 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001233 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001234 llvm::PATypeHolder *TypeVal;
1235 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001236 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001237 llvm::ArgListType *ArgList;
1238 llvm::TypeWithAttrs TypeWithAttrs;
1239 llvm::TypeWithAttrsList *TypeWithAttrsList;
1240 llvm::ValueRefList *ValueRefList;
1241
Reid Spencer68a24bd2005-08-27 18:50:39 +00001242 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001243 std::list<std::pair<llvm::Value*,
1244 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001245 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001246 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001247
1248 llvm::GlobalValue::LinkageTypes Linkage;
Reid Spencer14310612006-12-31 05:40:51 +00001249 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001250 int64_t SInt64Val;
1251 uint64_t UInt64Val;
1252 int SIntVal;
1253 unsigned UIntVal;
1254 double FPVal;
1255 bool BoolVal;
1256
1257 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001258 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001259
Reid Spencera132e042006-12-03 05:46:11 +00001260 llvm::Instruction::BinaryOps BinaryOpVal;
1261 llvm::Instruction::TermOps TermOpVal;
1262 llvm::Instruction::MemoryOps MemOpVal;
1263 llvm::Instruction::CastOps CastOpVal;
1264 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001265 llvm::Module::Endianness Endianness;
Reid Spencera132e042006-12-03 05:46:11 +00001266 llvm::ICmpInst::Predicate IPredicate;
1267 llvm::FCmpInst::Predicate FPredicate;
Andrew Lenharth6353e052006-12-08 18:07:09 +00001268} YYSTYPE;
Reid Spencere4d87aa2006-12-23 06:05:41 +00001269/* Line 196 of yacc.c. */
Reid Spencer63c34452007-01-05 21:51:07 +00001270#line 1271 "llvmAsmParser.tab.c"
Reid Spencer3822ff52006-11-08 06:47:33 +00001271# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1272# define YYSTYPE_IS_DECLARED 1
1273# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001274#endif
1275
1276
1277
Reid Spencer3822ff52006-11-08 06:47:33 +00001278/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001279
1280
Reid Spencere4d87aa2006-12-23 06:05:41 +00001281/* Line 219 of yacc.c. */
Reid Spencer63c34452007-01-05 21:51:07 +00001282#line 1283 "llvmAsmParser.tab.c"
Reid Spencere4d87aa2006-12-23 06:05:41 +00001283
1284#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1285# define YYSIZE_T __SIZE_TYPE__
1286#endif
1287#if ! defined (YYSIZE_T) && defined (size_t)
1288# define YYSIZE_T size_t
1289#endif
1290#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1291# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1292# define YYSIZE_T size_t
1293#endif
1294#if ! defined (YYSIZE_T)
1295# define YYSIZE_T unsigned int
1296#endif
1297
1298#ifndef YY_
1299# if YYENABLE_NLS
1300# if ENABLE_NLS
1301# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1302# define YY_(msgid) dgettext ("bison-runtime", msgid)
1303# endif
1304# endif
1305# ifndef YY_
1306# define YY_(msgid) msgid
1307# endif
1308#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001309
Andrew Lenharth6353e052006-12-08 18:07:09 +00001310#if ! defined (yyoverflow) || YYERROR_VERBOSE
Bill Wendlinge8156192006-12-07 01:30:32 +00001311
Reid Spencer3822ff52006-11-08 06:47:33 +00001312/* The parser invokes alloca or malloc; define the necessary symbols. */
1313
1314# ifdef YYSTACK_USE_ALLOCA
1315# if YYSTACK_USE_ALLOCA
1316# ifdef __GNUC__
1317# define YYSTACK_ALLOC __builtin_alloca
Reid Spencere4d87aa2006-12-23 06:05:41 +00001318# else
1319# define YYSTACK_ALLOC alloca
1320# if defined (__STDC__) || defined (__cplusplus)
1321# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1322# define YYINCLUDED_STDLIB_H
1323# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00001324# endif
1325# endif
1326# endif
1327
1328# ifdef YYSTACK_ALLOC
Andrew Lenharth6353e052006-12-08 18:07:09 +00001329 /* Pacify GCC's `empty if-body' warning. */
1330# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00001331# ifndef YYSTACK_ALLOC_MAXIMUM
1332 /* The OS might guarantee only one guard page at the bottom of the stack,
1333 and a page size can be as small as 4096 bytes. So we cannot safely
1334 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1335 to allow for a few compiler-allocated temporary stack slots. */
1336# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Andrew Lenharth6353e052006-12-08 18:07:09 +00001337# endif
Reid Spencere4d87aa2006-12-23 06:05:41 +00001338# else
Reid Spencer3822ff52006-11-08 06:47:33 +00001339# define YYSTACK_ALLOC YYMALLOC
1340# define YYSTACK_FREE YYFREE
Reid Spencere4d87aa2006-12-23 06:05:41 +00001341# ifndef YYSTACK_ALLOC_MAXIMUM
1342# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1343# endif
1344# ifdef __cplusplus
1345extern "C" {
1346# endif
1347# ifndef YYMALLOC
1348# define YYMALLOC malloc
1349# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1350 && (defined (__STDC__) || defined (__cplusplus)))
1351void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1352# endif
1353# endif
1354# ifndef YYFREE
1355# define YYFREE free
1356# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1357 && (defined (__STDC__) || defined (__cplusplus)))
1358void free (void *); /* INFRINGES ON USER NAME SPACE */
1359# endif
1360# endif
1361# ifdef __cplusplus
1362}
1363# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00001364# endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00001365#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Reid Spencer3822ff52006-11-08 06:47:33 +00001366
1367
Andrew Lenharth6353e052006-12-08 18:07:09 +00001368#if (! defined (yyoverflow) \
1369 && (! defined (__cplusplus) \
1370 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer3822ff52006-11-08 06:47:33 +00001371
1372/* A type that is properly aligned for any stack member. */
1373union yyalloc
1374{
Reid Spencere4d87aa2006-12-23 06:05:41 +00001375 short int yyss;
Reid Spencer3822ff52006-11-08 06:47:33 +00001376 YYSTYPE yyvs;
1377 };
1378
1379/* The size of the maximum gap between one aligned stack and the next. */
1380# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1381
1382/* The size of an array large to enough to hold all stacks, each with
1383 N elements. */
1384# define YYSTACK_BYTES(N) \
Reid Spencere4d87aa2006-12-23 06:05:41 +00001385 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Reid Spencer3822ff52006-11-08 06:47:33 +00001386 + YYSTACK_GAP_MAXIMUM)
1387
1388/* Copy COUNT objects from FROM to TO. The source and destination do
1389 not overlap. */
1390# ifndef YYCOPY
Andrew Lenharth6353e052006-12-08 18:07:09 +00001391# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer3822ff52006-11-08 06:47:33 +00001392# define YYCOPY(To, From, Count) \
1393 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1394# else
1395# define YYCOPY(To, From, Count) \
1396 do \
1397 { \
Reid Spencere4d87aa2006-12-23 06:05:41 +00001398 YYSIZE_T yyi; \
Reid Spencer3822ff52006-11-08 06:47:33 +00001399 for (yyi = 0; yyi < (Count); yyi++) \
1400 (To)[yyi] = (From)[yyi]; \
1401 } \
Andrew Lenharth6353e052006-12-08 18:07:09 +00001402 while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00001403# endif
1404# endif
1405
1406/* Relocate STACK from its old location to the new one. The
1407 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1408 elements in the stack, and YYPTR gives the new location of the
1409 stack. Advance YYPTR to a properly aligned location for the next
1410 stack. */
1411# define YYSTACK_RELOCATE(Stack) \
1412 do \
1413 { \
1414 YYSIZE_T yynewbytes; \
1415 YYCOPY (&yyptr->Stack, Stack, yysize); \
1416 Stack = &yyptr->Stack; \
1417 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1418 yyptr += yynewbytes / sizeof (*yyptr); \
1419 } \
Andrew Lenharth6353e052006-12-08 18:07:09 +00001420 while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001421
1422#endif
1423
Andrew Lenharth6353e052006-12-08 18:07:09 +00001424#if defined (__STDC__) || defined (__cplusplus)
1425 typedef signed char yysigned_char;
1426#else
Reid Spencere4d87aa2006-12-23 06:05:41 +00001427 typedef short int yysigned_char;
Andrew Lenharth6353e052006-12-08 18:07:09 +00001428#endif
1429
1430/* YYFINAL -- State number of the termination state. */
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001431#define YYFINAL 37
Reid Spencer3822ff52006-11-08 06:47:33 +00001432/* YYLAST -- Last index in YYTABLE. */
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001433#define YYLAST 1584
Reid Spencer3822ff52006-11-08 06:47:33 +00001434
Andrew Lenharth6353e052006-12-08 18:07:09 +00001435/* YYNTOKENS -- Number of terminals. */
Reid Spencer14310612006-12-31 05:40:51 +00001436#define YYNTOKENS 150
Andrew Lenharth6353e052006-12-08 18:07:09 +00001437/* YYNNTS -- Number of nonterminals. */
Reid Spencer218ded22007-01-05 17:07:23 +00001438#define YYNNTS 78
Andrew Lenharth6353e052006-12-08 18:07:09 +00001439/* YYNRULES -- Number of rules. */
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001440#define YYNRULES 291
Andrew Lenharth6353e052006-12-08 18:07:09 +00001441/* YYNRULES -- Number of states. */
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001442#define YYNSTATES 576
Reid Spencer3822ff52006-11-08 06:47:33 +00001443
1444/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1445#define YYUNDEFTOK 2
Reid Spencer218ded22007-01-05 17:07:23 +00001446#define YYMAXUTOK 390
Reid Spencer3822ff52006-11-08 06:47:33 +00001447
Reid Spencere4d87aa2006-12-23 06:05:41 +00001448#define YYTRANSLATE(YYX) \
Reid Spencer3822ff52006-11-08 06:47:33 +00001449 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1450
1451/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00001452static const unsigned char yytranslate[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001453{
1454 0, 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,
Reid Spencer218ded22007-01-05 17:07:23 +00001458 140, 141, 138, 2, 137, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001459 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer218ded22007-01-05 17:07:23 +00001460 145, 136, 146, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1462 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer218ded22007-01-05 17:07:23 +00001463 2, 142, 139, 144, 2, 2, 2, 2, 2, 149,
Reid Spencer3822ff52006-11-08 06:47:33 +00001464 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1465 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer14310612006-12-31 05:40:51 +00001466 143, 2, 2, 147, 2, 148, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001467 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1468 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1469 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1471 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1472 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1473 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1474 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1475 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1476 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1477 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1478 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1479 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1480 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1481 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1482 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1483 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1484 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1485 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1486 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1487 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1488 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1489 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
Reid Spencer3da59db2006-11-27 01:05:10 +00001490 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
Reid Spencera132e042006-12-03 05:46:11 +00001491 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
Reid Spencer218ded22007-01-05 17:07:23 +00001492 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1493 135
Reid Spencer3822ff52006-11-08 06:47:33 +00001494};
1495
1496#if YYDEBUG
1497/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1498 YYRHS. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001499static const unsigned short int yyprhs[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001500{
1501 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1502 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1503 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1504 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
Reid Spencer3da59db2006-11-27 01:05:10 +00001505 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
Reid Spencera132e042006-12-03 05:46:11 +00001506 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
Reid Spencer14310612006-12-31 05:40:51 +00001507 119, 121, 123, 125, 128, 129, 131, 133, 135, 137,
1508 139, 141, 143, 145, 146, 148, 150, 151, 153, 155,
1509 157, 159, 160, 162, 164, 166, 168, 170, 172, 175,
Reid Spencer218ded22007-01-05 17:07:23 +00001510 177, 179, 180, 183, 185, 187, 188, 191, 192, 195,
1511 196, 200, 203, 204, 206, 207, 211, 213, 216, 218,
1512 220, 222, 224, 226, 228, 230, 232, 234, 236, 239,
1513 241, 244, 250, 256, 262, 268, 272, 275, 281, 286,
1514 289, 291, 293, 295, 299, 301, 305, 307, 308, 310,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001515 314, 319, 323, 327, 332, 337, 341, 348, 354, 357,
1516 360, 363, 366, 369, 372, 375, 378, 381, 384, 391,
1517 397, 406, 413, 420, 428, 436, 443, 450, 459, 468,
1518 472, 474, 476, 478, 480, 481, 483, 486, 487, 491,
1519 492, 496, 500, 502, 506, 510, 511, 517, 518, 525,
1520 526, 533, 536, 540, 542, 544, 546, 550, 554, 558,
1521 562, 566, 570, 572, 573, 575, 577, 579, 580, 586,
1522 590, 592, 596, 598, 599, 609, 611, 613, 617, 619,
1523 621, 624, 627, 628, 630, 632, 634, 636, 638, 640,
1524 642, 644, 646, 650, 652, 658, 660, 662, 664, 666,
1525 669, 672, 675, 679, 682, 683, 685, 688, 691, 695,
1526 705, 715, 724, 739, 741, 743, 750, 756, 759, 766,
1527 774, 778, 784, 785, 786, 790, 793, 795, 801, 807,
1528 814, 821, 824, 829, 834, 841, 846, 851, 858, 865,
1529 868, 877, 879, 881, 882, 886, 893, 897, 904, 907,
1530 912, 919
Reid Spencer3822ff52006-11-08 06:47:33 +00001531};
1532
Andrew Lenharth6353e052006-12-08 18:07:09 +00001533/* YYRHS -- A `-1'-separated list of the rules' RHS. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001534static const short int yyrhs[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001535{
Reid Spencer218ded22007-01-05 17:07:23 +00001536 187, 0, -1, 5, -1, 6, -1, 74, -1, 75,
Reid Spencer14310612006-12-31 05:40:51 +00001537 -1, 76, -1, 77, -1, 78, -1, 79, -1, 80,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001538 -1, 81, -1, 82, -1, 83, -1, 84, -1, 85,
Reid Spencer14310612006-12-31 05:40:51 +00001539 -1, 114, -1, 115, -1, 116, -1, 117, -1, 118,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001540 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
Reid Spencer14310612006-12-31 05:40:51 +00001541 -1, 124, -1, 125, -1, 128, -1, 129, -1, 130,
1542 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001543 -1, 93, -1, 94, -1, 95, -1, 96, -1, 97,
1544 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
1545 -1, 103, -1, 104, -1, 105, -1, 106, -1, 107,
Reid Spencer14310612006-12-31 05:40:51 +00001546 -1, 94, -1, 95, -1, 96, -1, 97, -1, 23,
1547 -1, 24, -1, 13, -1, 12, -1, 11, -1, 10,
Reid Spencer218ded22007-01-05 17:07:23 +00001548 -1, 14, -1, 15, -1, 200, 136, -1, -1, 37,
Reid Spencer14310612006-12-31 05:40:51 +00001549 -1, 39, -1, 38, -1, 40, -1, 42, -1, 41,
1550 -1, 43, -1, 46, -1, -1, 41, -1, 43, -1,
1551 -1, 37, -1, 38, -1, 39, -1, 42, -1, -1,
1552 61, -1, 62, -1, 63, -1, 64, -1, 65, -1,
Reid Spencer218ded22007-01-05 17:07:23 +00001553 66, -1, 60, 4, -1, 115, -1, 116, -1, -1,
1554 167, 166, -1, 135, -1, 166, -1, -1, 169, 168,
1555 -1, -1, 53, 4, -1, -1, 137, 53, 4, -1,
1556 31, 20, -1, -1, 172, -1, -1, 137, 175, 174,
1557 -1, 172, -1, 53, 4, -1, 9, -1, 10, -1,
1558 11, -1, 12, -1, 13, -1, 14, -1, 15, -1,
1559 16, -1, 44, -1, 176, -1, 177, 138, -1, 212,
1560 -1, 139, 4, -1, 177, 140, 181, 141, 169, -1,
1561 8, 140, 181, 141, 169, -1, 142, 4, 143, 177,
1562 144, -1, 145, 4, 143, 177, 146, -1, 147, 182,
1563 148, -1, 147, 148, -1, 145, 147, 182, 148, 146,
1564 -1, 145, 147, 148, 146, -1, 177, 167, -1, 177,
1565 -1, 8, -1, 178, -1, 180, 137, 178, -1, 180,
1566 -1, 180, 137, 34, -1, 34, -1, -1, 177, -1,
1567 182, 137, 177, -1, 177, 142, 185, 144, -1, 177,
1568 142, 144, -1, 177, 149, 20, -1, 177, 145, 185,
1569 146, -1, 177, 147, 185, 148, -1, 177, 147, 148,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001570 -1, 177, 145, 147, 185, 148, 146, -1, 177, 145,
1571 147, 148, 146, -1, 177, 35, -1, 177, 36, -1,
1572 177, 212, -1, 177, 184, -1, 177, 22, -1, 158,
1573 3, -1, 158, 4, -1, 9, 23, -1, 9, 24,
1574 -1, 159, 7, -1, 154, 140, 183, 33, 177, 141,
1575 -1, 113, 140, 183, 223, 141, -1, 127, 140, 183,
1576 137, 183, 137, 183, 141, -1, 152, 140, 183, 137,
1577 183, 141, -1, 153, 140, 183, 137, 183, 141, -1,
1578 86, 156, 140, 183, 137, 183, 141, -1, 87, 157,
1579 140, 183, 137, 183, 141, -1, 155, 140, 183, 137,
1580 183, 141, -1, 132, 140, 183, 137, 183, 141, -1,
1581 133, 140, 183, 137, 183, 137, 183, 141, -1, 134,
1582 140, 183, 137, 183, 137, 183, 141, -1, 185, 137,
1583 183, -1, 183, -1, 29, -1, 30, -1, 188, -1,
1584 -1, 189, -1, 188, 189, -1, -1, 28, 190, 208,
1585 -1, -1, 27, 191, 209, -1, 58, 57, 195, -1,
1586 21, -1, 160, 17, 177, -1, 160, 17, 8, -1,
1587 -1, 160, 186, 183, 192, 174, -1, -1, 160, 161,
1588 186, 183, 193, 174, -1, -1, 160, 162, 186, 177,
1589 194, 174, -1, 47, 197, -1, 54, 136, 198, -1,
1590 20, -1, 52, -1, 51, -1, 49, 136, 196, -1,
1591 50, 136, 4, -1, 48, 136, 20, -1, 67, 136,
1592 20, -1, 142, 199, 144, -1, 199, 137, 20, -1,
1593 20, -1, -1, 18, -1, 20, -1, 200, -1, -1,
1594 202, 137, 177, 167, 201, -1, 177, 167, 201, -1,
1595 202, -1, 202, 137, 34, -1, 34, -1, -1, 165,
1596 179, 200, 140, 203, 141, 169, 173, 170, -1, 25,
1597 -1, 147, -1, 164, 204, 205, -1, 26, -1, 148,
1598 -1, 215, 207, -1, 163, 204, -1, -1, 59, -1,
1599 3, -1, 4, -1, 7, -1, 23, -1, 24, -1,
1600 35, -1, 36, -1, 22, -1, 145, 185, 146, -1,
1601 184, -1, 57, 210, 20, 137, 20, -1, 151, -1,
1602 200, -1, 212, -1, 211, -1, 177, 213, -1, 215,
1603 216, -1, 206, 216, -1, 217, 160, 218, -1, 217,
1604 220, -1, -1, 19, -1, 68, 214, -1, 68, 8,
1605 -1, 69, 16, 213, -1, 69, 9, 213, 137, 16,
1606 213, 137, 16, 213, -1, 70, 158, 213, 137, 16,
1607 213, 142, 219, 144, -1, 70, 158, 213, 137, 16,
1608 213, 142, 144, -1, 71, 165, 179, 213, 140, 222,
1609 141, 169, 33, 16, 213, 72, 16, 213, -1, 72,
1610 -1, 73, -1, 219, 158, 211, 137, 16, 213, -1,
1611 158, 211, 137, 16, 213, -1, 160, 225, -1, 177,
1612 142, 213, 137, 213, 144, -1, 221, 137, 142, 213,
1613 137, 213, 144, -1, 177, 213, 167, -1, 222, 137,
1614 177, 213, 167, -1, -1, -1, 223, 137, 214, -1,
1615 56, 55, -1, 55, -1, 152, 177, 213, 137, 213,
1616 -1, 153, 177, 213, 137, 213, -1, 86, 156, 177,
1617 213, 137, 213, -1, 87, 157, 177, 213, 137, 213,
1618 -1, 45, 214, -1, 155, 214, 137, 214, -1, 154,
1619 214, 33, 177, -1, 127, 214, 137, 214, 137, 214,
1620 -1, 131, 214, 137, 177, -1, 132, 214, 137, 214,
1621 -1, 133, 214, 137, 214, 137, 214, -1, 134, 214,
1622 137, 214, 137, 214, -1, 126, 221, -1, 224, 165,
1623 179, 213, 140, 222, 141, 169, -1, 227, -1, 32,
1624 -1, -1, 108, 177, 171, -1, 108, 177, 137, 12,
1625 213, 171, -1, 109, 177, 171, -1, 109, 177, 137,
1626 12, 213, 171, -1, 110, 214, -1, 226, 111, 177,
1627 213, -1, 226, 112, 214, 137, 177, 213, -1, 113,
1628 177, 213, 223, -1
Reid Spencer3822ff52006-11-08 06:47:33 +00001629};
1630
1631/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001632static const unsigned short int yyrline[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001633{
Reid Spencer63c34452007-01-05 21:51:07 +00001634 0, 1019, 1019, 1020, 1030, 1030, 1030, 1030, 1030, 1030,
1635 1030, 1030, 1030, 1031, 1031, 1031, 1032, 1032, 1032, 1032,
1636 1032, 1032, 1033, 1033, 1033, 1033, 1033, 1033, 1034, 1034,
1637 1034, 1036, 1036, 1037, 1037, 1038, 1038, 1039, 1039, 1040,
1638 1040, 1044, 1044, 1045, 1045, 1046, 1046, 1047, 1047, 1048,
1639 1048, 1049, 1049, 1050, 1050, 1051, 1052, 1057, 1057, 1057,
1640 1057, 1058, 1058, 1061, 1065, 1071, 1072, 1073, 1074, 1075,
1641 1079, 1080, 1081, 1085, 1086, 1087, 1091, 1092, 1093, 1094,
1642 1095, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1112,
1643 1113, 1116, 1117, 1122, 1123, 1126, 1127, 1134, 1135, 1141,
1644 1142, 1150, 1158, 1159, 1164, 1165, 1166, 1171, 1184, 1184,
1645 1184, 1184, 1184, 1184, 1184, 1184, 1187, 1191, 1195, 1202,
1646 1207, 1215, 1233, 1251, 1256, 1268, 1278, 1282, 1292, 1299,
1647 1306, 1313, 1318, 1323, 1330, 1331, 1338, 1345, 1353, 1358,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001648 1369, 1397, 1413, 1442, 1470, 1495, 1514, 1539, 1558, 1570,
1649 1577, 1640, 1650, 1660, 1666, 1672, 1676, 1680, 1688, 1702,
1650 1723, 1731, 1737, 1748, 1753, 1758, 1767, 1773, 1779, 1788,
1651 1792, 1800, 1800, 1811, 1816, 1824, 1825, 1829, 1829, 1833,
1652 1833, 1836, 1839, 1851, 1875, 1886, 1886, 1895, 1895, 1903,
1653 1903, 1913, 1916, 1922, 1935, 1936, 1938, 1942, 1951, 1955,
1654 1960, 1962, 1967, 1972, 1981, 1981, 1982, 1982, 1984, 1994,
1655 2005, 2009, 2018, 2027, 2032, 2137, 2137, 2139, 2147, 2147,
1656 2149, 2154, 2165, 2169, 2174, 2178, 2182, 2186, 2190, 2194,
1657 2198, 2202, 2206, 2231, 2235, 2249, 2253, 2259, 2259, 2265,
1658 2274, 2278, 2287, 2298, 2307, 2319, 2332, 2336, 2340, 2345,
1659 2354, 2373, 2382, 2449, 2453, 2460, 2471, 2484, 2493, 2504,
1660 2514, 2522, 2530, 2533, 2534, 2541, 2545, 2550, 2571, 2588,
1661 2601, 2614, 2627, 2636, 2649, 2657, 2664, 2670, 2676, 2682,
1662 2697, 2760, 2765, 2769, 2776, 2783, 2791, 2798, 2806, 2814,
1663 2828, 2845
Reid Spencer3822ff52006-11-08 06:47:33 +00001664};
1665#endif
1666
Reid Spencere4d87aa2006-12-23 06:05:41 +00001667#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1668/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Andrew Lenharth6353e052006-12-08 18:07:09 +00001669 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer3822ff52006-11-08 06:47:33 +00001670static const char *const yytname[] =
1671{
1672 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
Reid Spencer14310612006-12-31 05:40:51 +00001673 "UINTVAL", "FPVAL", "VOID", "BOOL", "INT8", "INT16", "INT32", "INT64",
1674 "FLOAT", "DOUBLE", "LABEL", "TYPE", "VAR_ID", "LABELSTR",
1675 "STRINGCONSTANT", "IMPLEMENTATION", "ZEROINITIALIZER", "TRUETOK",
1676 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1677 "CONSTANT", "SECTION", "VOLATILE", "TO", "DOTDOTDOT", "NULL_TOK",
1678 "UNDEF", "INTERNAL", "LINKONCE", "WEAK", "APPENDING", "DLLIMPORT",
1679 "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", "NOT", "EXTERNAL", "TARGET",
1680 "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", "BIG", "ALIGN", "DEPLIBS",
1681 "CALL", "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1682 "CSRETCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK",
1683 "X86_FASTCALLCC_TOK", "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE",
1684 "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV",
1685 "UREM", "SREM", "FREM", "AND", "OR", "XOR", "ICMP", "FCMP", "EQ", "NE",
1686 "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE",
1687 "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC",
1688 "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT",
1689 "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI",
1690 "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK", "SELECT", "SHL", "LSHR",
1691 "ASHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
Reid Spencer218ded22007-01-05 17:07:23 +00001692 "NORETURN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'",
1693 "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "INTVAL",
1694 "ArithmeticOps", "LogicalOps", "CastOps", "ShiftOps", "IPredicates",
1695 "FPredicates", "IntType", "FPType", "OptAssign", "GVInternalLinkage",
Reid Spencer14310612006-12-31 05:40:51 +00001696 "GVExternalLinkage", "FunctionDeclareLinkage", "FunctionDefineLinkage",
Reid Spencer218ded22007-01-05 17:07:23 +00001697 "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr",
1698 "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection",
Reid Spencer14310612006-12-31 05:40:51 +00001699 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
Reid Spencer218ded22007-01-05 17:07:23 +00001700 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
Reid Spencer14310612006-12-31 05:40:51 +00001701 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module",
1702 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1703 "BigOrLittle", "TargetDefinition", "LibrariesDefinition", "LibList",
1704 "Name", "OptName", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
Reid Spencer6fd36ab2006-12-29 20:35:03 +00001705 "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect",
1706 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1707 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
Reid Spencer14310612006-12-31 05:40:51 +00001708 "JumpTable", "Inst", "PHIList", "ValueRefList", "IndexList",
1709 "OptTailCall", "InstVal", "OptVolatile", "MemoryInst", 0
Reid Spencer3822ff52006-11-08 06:47:33 +00001710};
1711#endif
1712
1713# ifdef YYPRINT
1714/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1715 token YYLEX-NUM. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001716static const unsigned short int yytoknum[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001717{
1718 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1719 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1720 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1721 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1722 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1723 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1724 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1725 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1726 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1727 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1728 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
Reid Spencer3da59db2006-11-27 01:05:10 +00001729 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
Reid Spencera132e042006-12-03 05:46:11 +00001730 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
Reid Spencer218ded22007-01-05 17:07:23 +00001731 385, 386, 387, 388, 389, 390, 61, 44, 42, 92,
1732 40, 41, 91, 120, 93, 60, 62, 123, 125, 99
Reid Spencer3822ff52006-11-08 06:47:33 +00001733};
1734# endif
1735
1736/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00001737static const unsigned char yyr1[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001738{
Reid Spencer14310612006-12-31 05:40:51 +00001739 0, 150, 151, 151, 152, 152, 152, 152, 152, 152,
1740 152, 152, 152, 153, 153, 153, 154, 154, 154, 154,
1741 154, 154, 154, 154, 154, 154, 154, 154, 155, 155,
1742 155, 156, 156, 156, 156, 156, 156, 156, 156, 156,
1743 156, 157, 157, 157, 157, 157, 157, 157, 157, 157,
1744 157, 157, 157, 157, 157, 157, 157, 158, 158, 158,
1745 158, 159, 159, 160, 160, 161, 161, 161, 161, 161,
1746 162, 162, 162, 163, 163, 163, 164, 164, 164, 164,
1747 164, 165, 165, 165, 165, 165, 165, 165, 165, 166,
Reid Spencer218ded22007-01-05 17:07:23 +00001748 166, 167, 167, 168, 168, 169, 169, 170, 170, 171,
1749 171, 172, 173, 173, 174, 174, 175, 175, 176, 176,
1750 176, 176, 176, 176, 176, 176, 177, 177, 177, 177,
1751 177, 177, 177, 177, 177, 177, 177, 177, 177, 178,
1752 179, 179, 180, 180, 181, 181, 181, 181, 182, 182,
1753 183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001754 183, 183, 183, 183, 183, 183, 183, 183, 184, 184,
1755 184, 184, 184, 184, 184, 184, 184, 184, 184, 185,
1756 185, 186, 186, 187, 187, 188, 188, 190, 189, 191,
1757 189, 189, 189, 189, 189, 192, 189, 193, 189, 194,
1758 189, 189, 189, 195, 196, 196, 197, 197, 197, 197,
1759 198, 199, 199, 199, 200, 200, 201, 201, 202, 202,
1760 203, 203, 203, 203, 204, 205, 205, 206, 207, 207,
1761 208, 209, 210, 210, 211, 211, 211, 211, 211, 211,
1762 211, 211, 211, 211, 211, 212, 212, 213, 213, 214,
1763 215, 215, 216, 217, 217, 217, 218, 218, 218, 218,
1764 218, 218, 218, 218, 218, 219, 219, 220, 221, 221,
1765 222, 222, 222, 223, 223, 224, 224, 225, 225, 225,
Reid Spencer218ded22007-01-05 17:07:23 +00001766 225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001767 225, 225, 226, 226, 227, 227, 227, 227, 227, 227,
1768 227, 227
Reid Spencer3822ff52006-11-08 06:47:33 +00001769};
1770
1771/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00001772static const unsigned char yyr2[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001773{
1774 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1775 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1776 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3822ff52006-11-08 06:47:33 +00001777 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001778 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001779 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer14310612006-12-31 05:40:51 +00001780 1, 1, 1, 2, 0, 1, 1, 1, 1, 1,
1781 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1782 1, 0, 1, 1, 1, 1, 1, 1, 2, 1,
Reid Spencer218ded22007-01-05 17:07:23 +00001783 1, 0, 2, 1, 1, 0, 2, 0, 2, 0,
1784 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
1785 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
1786 2, 5, 5, 5, 5, 3, 2, 5, 4, 2,
1787 1, 1, 1, 3, 1, 3, 1, 0, 1, 3,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001788 4, 3, 3, 4, 4, 3, 6, 5, 2, 2,
1789 2, 2, 2, 2, 2, 2, 2, 2, 6, 5,
1790 8, 6, 6, 7, 7, 6, 6, 8, 8, 3,
1791 1, 1, 1, 1, 0, 1, 2, 0, 3, 0,
1792 3, 3, 1, 3, 3, 0, 5, 0, 6, 0,
1793 6, 2, 3, 1, 1, 1, 3, 3, 3, 3,
1794 3, 3, 1, 0, 1, 1, 1, 0, 5, 3,
1795 1, 3, 1, 0, 9, 1, 1, 3, 1, 1,
1796 2, 2, 0, 1, 1, 1, 1, 1, 1, 1,
1797 1, 1, 3, 1, 5, 1, 1, 1, 1, 2,
1798 2, 2, 3, 2, 0, 1, 2, 2, 3, 9,
1799 9, 8, 14, 1, 1, 6, 5, 2, 6, 7,
1800 3, 5, 0, 0, 3, 2, 1, 5, 5, 6,
1801 6, 2, 4, 4, 6, 4, 4, 6, 6, 2,
1802 8, 1, 1, 0, 3, 6, 3, 6, 2, 4,
1803 6, 4
Reid Spencer3822ff52006-11-08 06:47:33 +00001804};
1805
1806/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1807 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1808 means the default is an error. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001809static const unsigned short int yydefact[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001810{
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001811 64, 204, 205, 182, 179, 177, 0, 0, 0, 0,
1812 0, 64, 175, 0, 73, 76, 0, 0, 0, 0,
1813 191, 0, 0, 0, 171, 172, 65, 67, 66, 68,
1814 70, 69, 71, 72, 0, 0, 0, 1, 176, 63,
1815 74, 75, 81, 180, 77, 78, 79, 80, 81, 244,
1816 178, 244, 0, 0, 0, 0, 203, 192, 193, 181,
1817 2, 3, 184, 108, 109, 110, 111, 112, 113, 114,
1818 115, 116, 0, 0, 0, 0, 235, 117, 183, 236,
Reid Spencer218ded22007-01-05 17:07:23 +00001819 119, 0, 0, 0, 108, 109, 110, 111, 112, 113,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001820 114, 0, 0, 0, 185, 0, 82, 83, 84, 85,
1821 86, 87, 0, 221, 0, 245, 241, 64, 218, 219,
1822 220, 240, 198, 195, 194, 196, 197, 199, 202, 0,
Reid Spencer218ded22007-01-05 17:07:23 +00001823 137, 120, 0, 0, 0, 126, 138, 0, 118, 137,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001824 187, 189, 155, 156, 153, 154, 157, 152, 148, 149,
Reid Spencer218ded22007-01-05 17:07:23 +00001825 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
1826 14, 15, 0, 0, 0, 16, 17, 18, 19, 20,
1827 21, 22, 23, 24, 25, 26, 27, 0, 28, 29,
1828 30, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001829 0, 0, 151, 150, 104, 88, 131, 130, 0, 215,
1830 216, 217, 283, 243, 0, 200, 136, 91, 132, 134,
Reid Spencer218ded22007-01-05 17:07:23 +00001831 0, 0, 0, 0, 0, 0, 125, 0, 104, 104,
1832 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
1833 0, 55, 56, 51, 52, 53, 54, 41, 42, 43,
1834 44, 45, 46, 47, 48, 49, 50, 0, 0, 0,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001835 0, 0, 0, 141, 170, 0, 0, 0, 145, 0,
1836 142, 0, 0, 0, 0, 0, 186, 0, 282, 0,
1837 266, 0, 0, 0, 0, 81, 253, 254, 0, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00001838 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001839 0, 0, 0, 0, 242, 81, 257, 0, 281, 201,
1840 129, 0, 95, 0, 0, 128, 0, 139, 95, 188,
1841 190, 0, 0, 263, 0, 0, 0, 0, 0, 140,
1842 126, 138, 0, 143, 144, 0, 0, 0, 0, 0,
1843 0, 106, 104, 213, 0, 271, 265, 247, 246, 0,
1844 0, 60, 59, 58, 57, 0, 0, 0, 0, 99,
1845 99, 288, 0, 0, 279, 0, 0, 0, 0, 0,
1846 0, 0, 0, 0, 0, 0, 0, 89, 90, 92,
1847 135, 133, 122, 123, 124, 127, 121, 0, 0, 0,
1848 0, 0, 0, 0, 169, 147, 0, 0, 0, 0,
1849 0, 101, 107, 105, 212, 91, 210, 0, 224, 225,
1850 226, 231, 227, 228, 229, 230, 222, 0, 233, 238,
1851 237, 239, 0, 248, 0, 0, 0, 0, 0, 284,
1852 0, 286, 263, 0, 0, 0, 0, 0, 0, 0,
1853 0, 0, 0, 0, 0, 0, 0, 93, 94, 96,
1854 0, 0, 0, 159, 0, 0, 0, 0, 146, 0,
1855 0, 0, 0, 207, 0, 95, 223, 0, 0, 0,
1856 0, 0, 0, 0, 0, 0, 0, 291, 0, 0,
1857 0, 275, 276, 0, 0, 0, 0, 273, 272, 0,
1858 289, 0, 0, 0, 264, 0, 166, 0, 0, 161,
1859 162, 158, 165, 206, 209, 211, 91, 102, 0, 232,
1860 0, 0, 262, 0, 0, 99, 100, 99, 0, 0,
1861 0, 0, 0, 267, 268, 262, 0, 163, 164, 0,
1862 0, 0, 207, 103, 97, 0, 0, 0, 0, 0,
1863 269, 270, 0, 285, 287, 0, 0, 274, 277, 278,
1864 0, 290, 160, 167, 168, 208, 0, 214, 234, 0,
1865 0, 91, 0, 95, 258, 0, 95, 98, 0, 251,
1866 0, 0, 260, 0, 0, 259, 280, 249, 0, 250,
1867 0, 91, 0, 0, 0, 261, 0, 0, 0, 0,
1868 256, 0, 0, 255, 0, 252
Reid Spencer3822ff52006-11-08 06:47:33 +00001869};
1870
Andrew Lenharth6353e052006-12-08 18:07:09 +00001871/* YYDEFGOTO[NTERM-NUM]. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001872static const short int yydefgoto[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001873{
Reid Spencer218ded22007-01-05 17:07:23 +00001874 -1, 76, 178, 179, 180, 181, 220, 237, 91, 92,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001875 9, 34, 35, 42, 48, 102, 359, 290, 429, 362,
1876 537, 409, 321, 514, 256, 322, 77, 93, 198, 188,
1877 199, 200, 127, 244, 398, 245, 36, 10, 11, 12,
Reid Spencer218ded22007-01-05 17:07:23 +00001878 15, 14, 184, 208, 209, 59, 115, 20, 57, 119,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001879 79, 484, 386, 387, 103, 191, 49, 110, 50, 43,
1880 447, 399, 80, 401, 325, 51, 106, 107, 284, 551,
1881 193, 344, 519, 369, 285, 286, 287, 288
Reid Spencer3822ff52006-11-08 06:47:33 +00001882};
1883
1884/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1885 STATE-NUM. */
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001886#define YYPACT_NINF -457
Reid Spencere4d87aa2006-12-23 06:05:41 +00001887static const short int yypact[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001888{
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001889 49, -457, -457, -457, -457, -457, 8, -107, -9, 255,
1890 61, 188, -457, -7, 113, 165, 33, 38, 51, 69,
1891 -457, 17, 95, 1056, -457, -457, -457, -457, -457, -457,
1892 -457, -457, -457, -457, 91, 91, 1290, -457, -457, -457,
1893 -457, -457, 130, -457, -457, -457, -457, -457, 130, 116,
1894 -457, 25, 192, 98, 265, 198, 201, -457, -457, -457,
1895 -457, -457, 131, -457, -457, -457, -457, -457, -457, -457,
1896 -457, -457, 270, 273, 5, 128, -457, -457, 73, -457,
1897 -457, 1290, 1310, 131, 217, 234, 259, 262, 276, 281,
1898 292, 278, 297, 623, -457, 279, -457, -457, -457, -457,
1899 -457, -457, 1327, -457, -2, -457, -457, 214, -457, -457,
1900 -457, -457, -457, -457, -457, -457, -457, -457, -457, -120,
1901 809, -457, 162, 163, 710, -457, 73, -84, -457, 809,
1902 -457, 73, -457, -457, -457, -457, -457, -457, -457, -457,
1903 -457, -457, -457, -457, -457, -457, -457, -457, -457, -457,
1904 -457, -457, 269, 1007, 167, -457, -457, -457, -457, -457,
1905 -457, -457, -457, -457, -457, -457, -457, 168, -457, -457,
1906 -457, 169, 171, 172, 75, 1347, 768, 296, 177, 178,
1907 179, 180, -457, -457, 184, -457, 131, 73, 214, -457,
1908 -457, -457, 1450, -457, 302, -457, -457, 73, -457, 189,
1909 183, 1310, 1310, 181, -83, 1310, -457, 194, 184, 184,
1910 -457, -457, -457, -457, -457, -457, -457, -457, -457, -457,
1911 185, -457, -457, -457, -457, -457, -457, -457, -457, -457,
1912 -457, -457, -457, -457, -457, -457, -457, 190, 1290, 1290,
1913 1290, 1290, 1290, -457, -457, -27, 784, -32, -457, -77,
1914 -457, 1290, 1290, 1290, 1290, -21, -457, 196, -457, 1310,
1915 -457, 282, 1370, 114, 216, 130, -457, -457, 269, 1007,
1916 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310,
1917 1310, 1310, 1310, 1310, -457, 130, -457, 175, -457, -457,
1918 187, 952, -457, 13, -22, -457, 193, 73, -457, -457,
1919 -457, 1290, 1290, -457, 203, 205, 206, 207, 1290, -457,
1920 199, 623, -75, -457, -457, 209, 210, 305, 211, 331,
1921 348, -457, 184, 1227, 860, -457, -457, 131, -457, 1003,
1922 1003, -457, -457, -457, -457, 1003, 1327, 1310, 1310, 60,
1923 93, -457, 860, -40, 218, 235, 236, 237, 238, 239,
1924 860, 860, 320, 240, 1327, 1310, 1310, -457, -457, -457,
1925 -457, -457, -69, -457, -457, -457, -69, 241, 242, -59,
1926 1290, 1290, 1290, 1290, -457, -457, 208, 1290, 1290, 1310,
1927 1290, -457, -457, -457, -457, 73, 247, 244, -457, -457,
1928 -457, -457, -457, -457, -457, -457, 327, 1290, -457, -457,
1929 -457, -457, 250, -457, 251, 1003, 860, 860, 2, -457,
1930 19, -457, -457, 1003, 248, 1310, 1310, 1310, 1310, 1310,
1931 252, 254, 1310, 1310, 1003, 860, 260, -457, -457, -457,
1932 1290, 1290, 1310, -457, 261, 266, 264, 271, -457, 272,
1933 274, 45, 275, 10, 1273, -457, -457, 382, -24, 387,
1934 394, 277, 283, 285, 1003, 407, 1003, 288, 289, 1003,
1935 290, 73, -457, 291, 295, 1003, 1003, 73, -457, 293,
1936 -457, 1310, 294, 298, -457, 1290, -457, 1290, 1290, -457,
1937 -457, -457, -457, -457, -457, -457, 73, -4, 299, -457,
1938 1003, 1003, 1310, 1003, 1003, 301, -457, 301, 1003, 303,
1939 1310, 1310, 1310, -457, -457, 1310, 860, -457, -457, 300,
1940 304, 306, 10, -457, 361, 398, 309, 287, 860, 39,
1941 -457, -457, 366, -457, -457, 308, 1003, -457, -457, -457,
1942 40, -457, -457, -457, -457, -457, 430, -457, -457, 426,
1943 23, -457, 1310, -457, -457, 310, -457, -457, 1003, -457,
1944 1135, 27, 187, 860, 12, -457, -69, -457, 312, -457,
1945 1135, -457, 427, 441, 322, 187, 1003, 1003, 444, 389,
1946 -457, 1003, 446, -457, 1003, -457
Reid Spencer3822ff52006-11-08 06:47:33 +00001947};
1948
1949/* YYPGOTO[NTERM-NUM]. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00001950static const short int yypgoto[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001951{
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001952 -457, -457, 284, 311, 316, 318, 200, 197, -262, -457,
1953 360, -457, -457, -457, -457, -222, -355, -377, -457, -282,
1954 -457, -327, -17, -457, -167, -457, -457, -23, 182, -286,
1955 -457, 345, 351, 129, -87, -172, 256, -457, -457, 469,
1956 -457, -457, -457, -457, -457, -457, -457, -457, -457, -457,
1957 1, -31, -457, -457, 435, -457, -457, -457, -457, -457,
1958 -457, -456, -1, 121, -257, -457, 433, -457, -457, -457,
1959 -457, -457, -20, 74, -457, -457, -457, -457
Reid Spencer3822ff52006-11-08 06:47:33 +00001960};
1961
1962/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1963 positive, shift that token. If negative, reduce the rule which
1964 number is the opposite. If zero, do what YYDEFACT says.
1965 If YYTABLE_NINF, syntax error. */
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001966#define YYTABLE_NINF -175
Reid Spencere4d87aa2006-12-23 06:05:41 +00001967static const short int yytable[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00001968{
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00001969 78, 13, 335, 247, 249, 328, 182, 428, 443, 123,
1970 319, 428, 13, 411, 454, 341, 366, 194, 345, 346,
1971 347, 348, 349, 189, 195, 352, 353, 319, 1, 21,
1972 2, 456, 320, 331, 332, 333, 334, 331, 332, 333,
1973 334, 299, 300, 336, 105, 562, 357, 358, 22, -174,
1974 405, 108, 126, 205, 205, 455, 16, 17, 18, 131,
1975 308, 37, 308, 354, 206, 296, 427, 1, 424, 2,
1976 3, 314, 455, 376, 312, 19, 4, 5, 432, 187,
1977 60, 61, 433, 83, 84, 85, 86, 87, 88, 89,
1978 90, 70, 183, 1, 558, 2, 6, 197, 128, 426,
1979 129, 126, 413, 7, 564, 308, 197, 8, 13, 512,
1980 308, 357, 358, 308, 313, 58, 128, 309, 129, 71,
1981 24, 25, 489, 329, 364, 357, 358, 357, 358, 39,
1982 330, 427, 428, 60, 61, 105, 83, 63, 64, 65,
1983 66, 67, 68, 69, 70, 190, 1, 427, 2, 113,
1984 114, 128, 124, 129, 40, 383, 41, 363, 460, 56,
1985 462, 463, 464, 487, 552, 94, 468, 549, 523, 52,
1986 524, 559, 71, 109, 53, 474, 542, 542, 293, 294,
1987 543, 546, 297, 128, 565, 129, 481, 54, -173, 257,
1988 95, 96, 97, 98, 99, 100, 101, 408, 128, 428,
1989 129, 428, 44, 45, 46, 55, 1, 47, 2, 3,
1990 130, 128, 112, 129, 72, 4, 5, 73, 117, 243,
1991 74, 118, 75, 311, 182, 448, 331, 332, 333, 334,
1992 410, 128, 1, 129, 2, 6, 324, -60, -60, 324,
1993 132, 133, 7, 527, 528, 529, 8, 339, 340, 324,
1994 342, 343, 324, 324, 324, 324, 324, 350, 351, 324,
1995 324, 554, -59, -59, 556, -58, -58, 72, 197, 116,
1996 73, 120, 23, 74, 121, 75, 125, 122, 550, -57,
1997 -57, 134, 135, 185, 24, 25, 355, 356, -61, 560,
1998 81, 82, 26, 27, 28, 29, 30, 31, 32, -62,
1999 385, 33, 357, 358, 136, 201, 202, 238, 239, 240,
2000 183, 241, 242, 187, 406, 407, 250, 251, 252, 253,
2001 254, 255, 289, 400, 292, 301, 291, 295, 400, 400,
2002 302, 187, 425, 324, 400, 298, 323, 326, 379, 365,
2003 370, 400, 371, 372, 373, 375, 377, 378, 380, 400,
2004 400, 381, 382, 422, 438, 414, 441, 210, 211, 212,
2005 213, 214, 215, 216, 217, 218, 219, 303, 304, 305,
2006 306, 307, 415, 416, 417, 418, 419, 423, 430, 431,
2007 315, 316, 317, 318, 444, 445, 446, 449, 450, 465,
2008 459, 466, 324, 461, 324, 324, 324, 471, 475, 467,
2009 324, 477, 488, 490, 400, 400, 400, 476, 478, 324,
2010 491, 496, 400, 479, 536, 480, 482, 492, 538, 455,
2011 493, 486, 494, 400, 400, 432, 498, 500, 501, 540,
2012 367, 368, 502, 505, 547, 507, 515, 374, 522, 508,
2013 526, 532, 548, 566, 483, 533, 539, 534, 506, 563,
2014 402, 403, 544, 400, 555, 400, 404, 567, 400, 568,
2015 571, 572, 574, 412, 400, 400, 338, 192, 337, 518,
2016 513, 420, 421, 361, 207, 204, 280, 324, 324, 324,
2017 38, 535, 518, 104, 111, 530, 457, 0, 0, 400,
2018 400, 0, 400, 400, 0, 0, 0, 400, 0, 434,
2019 435, 436, 437, 281, 0, 400, 439, 440, 282, 442,
2020 283, 0, 0, 483, 0, 0, 0, 400, 0, 553,
2021 0, 0, 0, 0, 0, 400, 451, 452, 453, 0,
2022 0, 0, 0, 0, 458, 0, 0, 0, 0, 0,
2023 0, 0, 0, 0, 0, 469, 470, 400, 0, 0,
2024 0, 0, 400, 0, 0, 0, 0, 0, 0, 472,
2025 473, 0, 0, 0, 0, 400, 400, 0, 0, 0,
2026 400, 0, 0, 400, 0, 495, 0, 497, 0, 0,
2027 499, 0, 0, 0, 0, 0, 503, 504, 0, 0,
Reid Spencer218ded22007-01-05 17:07:23 +00002028 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002029 0, 0, 0, 0, 509, 0, 510, 511, 0, 0,
2030 0, 516, 517, 0, 520, 521, 0, 0, 0, 525,
2031 0, 0, 0, 0, 0, 0, 0, 531, 60, 61,
2032 0, 0, 0, 0, 0, 0, 0, 0, 0, 541,
2033 0, 1, 0, 2, 0, 137, 0, 545, 0, 0,
2034 0, 0, 0, 0, 0, 0, 0, 0, 138, 139,
2035 0, 0, 0, 0, 0, 0, 0, 0, 0, 557,
2036 0, 0, 0, 0, 561, 0, 0, 0, 0, 0,
2037 0, 0, 0, 0, 0, 0, 0, 569, 570, 0,
2038 0, 0, 573, 0, 0, 575, 0, 140, 141, 142,
2039 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,
2040 153, 0, 0, 0, 0, 60, 61, 0, 83, 63,
2041 64, 65, 66, 67, 68, 69, 70, 0, 1, 0,
2042 2, 0, 0, 0, 0, 0, 154, 155, 156, 157,
2043 158, 159, 160, 161, 162, 163, 164, 165, 166, 0,
2044 167, 168, 169, 170, 71, 171, 172, 173, 0, 0,
2045 0, 128, 0, 129, 0, 174, 0, 0, 175, 0,
2046 176, 0, 177, 60, 61, 0, 83, 84, 85, 86,
2047 87, 88, 89, 90, 70, 0, 1, 0, 2, 60,
2048 61, 0, 83, 84, 85, 86, 87, 88, 89, 90,
2049 70, 0, 1, 0, 2, 0, 0, 0, 0, 0,
2050 0, 0, 71, 0, 60, 61, 0, 83, 63, 64,
2051 65, 66, 67, 68, 69, 70, 0, 1, 71, 2,
2052 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2053 0, 0, 0, 196, 0, 0, 0, 0, 0, 72,
2054 0, 0, 73, 71, 0, 74, 0, 75, 203, 0,
2055 0, 0, 0, 388, 389, 60, 61, 390, 0, 0,
Reid Spencer218ded22007-01-05 17:07:23 +00002056 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002057 2, 0, 391, 392, 393, 0, 0, 0, 0, 0,
2058 0, 0, 0, 0, 0, 394, 395, 0, 0, 0,
2059 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
2060 73, 0, 0, 74, 0, 75, 248, 396, 0, 0,
Reid Spencer218ded22007-01-05 17:07:23 +00002061 0, 0, 0, 72, 0, 0, 73, 0, 0, 74,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002062 0, 75, 310, 0, 140, 141, 142, 143, 144, 145,
2063 146, 147, 148, 149, 150, 151, 152, 153, 72, 0,
2064 0, 73, 0, 0, 74, 0, 75, 60, 61, 0,
2065 83, 63, 64, 65, 66, 67, 68, 69, 70, 0,
2066 1, 0, 2, 154, 155, 156, 157, 158, 159, 160,
2067 161, 162, 163, 164, 165, 166, 360, 167, 168, 169,
2068 170, 0, 171, 172, 173, 0, 71, 0, 128, 0,
2069 129, 0, 0, 0, 0, 397, 388, 389, 60, 61,
2070 390, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2071 0, 1, 0, 2, 0, 391, 392, 393, 0, 0,
2072 221, 222, 0, 0, 0, 0, 0, 0, 394, 395,
2073 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2074 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2075 396, 60, 61, 0, 62, 63, 64, 65, 66, 67,
2076 68, 69, 70, 0, 1, 0, 2, 140, 141, 142,
2077 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,
2078 153, 72, 0, 0, 73, 0, 0, 74, 0, 75,
2079 71, 223, 224, 225, 226, 227, 228, 229, 230, 231,
2080 232, 233, 234, 235, 236, 0, 154, 155, 156, 157,
2081 158, 159, 160, 161, 162, 163, 164, 165, 166, 0,
2082 167, 168, 169, 170, 0, 171, 172, 173, 388, 389,
2083 0, 0, 390, 0, 0, 0, 0, 0, 397, 0,
2084 0, 0, 0, 0, 0, 0, 0, 391, 392, 393,
2085 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2086 394, 395, 0, 0, 0, 0, 0, 0, 0, 0,
2087 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2088 0, 0, 396, 0, 0, 72, 0, 0, 73, 0,
2089 0, 74, 0, 75, 0, 0, 0, 0, 0, 140,
2090 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
2091 151, 152, 153, 0, 0, 0, 0, 0, 0, 0,
2092 0, 0, 60, 61, 0, 83, 63, 64, 65, 66,
2093 67, 68, 69, 70, 0, 1, 0, 2, 154, 155,
2094 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
2095 166, 384, 167, 168, 169, 170, 0, 171, 172, 173,
2096 0, 71, 0, 0, 0, 0, 0, 0, 60, 61,
2097 397, 83, 63, 64, 65, 66, 67, 68, 69, 70,
2098 0, 1, 0, 2, 0, 60, 61, 0, 83, 84,
2099 85, 86, 87, 88, 89, 90, 70, 485, 1, 0,
2100 2, 0, 0, 0, 0, 60, 61, 71, 83, 63,
Reid Spencer218ded22007-01-05 17:07:23 +00002101 64, 65, 66, 67, 68, 69, 70, 0, 1, 0,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002102 2, 0, 60, 61, 71, 186, 63, 64, 65, 66,
2103 67, 68, 69, 70, 0, 1, 0, 2, 0, 0,
2104 0, 0, 60, 61, 71, 83, 84, 85, 86, 87,
2105 88, 89, 90, 70, 0, 1, 72, 2, 0, 73,
2106 0, 71, 74, 0, 75, 60, 61, 0, 327, 63,
2107 64, 65, 66, 67, 68, 69, 70, 0, 1, 0,
2108 2, 71, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002109 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002110 0, 0, 72, 0, 71, 73, 0, 0, 74, 0,
2111 75, 0, 0, 0, 0, 0, 0, 0, 0, 72,
2112 0, 0, 73, 0, 0, 74, 0, 75, 0, 0,
Reid Spencer218ded22007-01-05 17:07:23 +00002113 0, 0, 0, 0, 0, 0, 0, 0, 0, 72,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002114 0, 0, 73, 0, 0, 74, 0, 75, 0, 0,
2115 0, 0, 0, 0, 0, 0, 72, 0, 0, 73,
2116 0, 0, 74, 0, 75, 0, 0, 0, 0, 0,
2117 0, 0, 258, 0, 0, 0, 72, 0, 0, 73,
2118 0, 0, 74, 0, 246, 259, 0, 0, 0, 0,
2119 0, 0, 0, 0, 0, 260, 261, 0, 0, 72,
2120 0, 0, 73, 0, 0, 74, 0, 75, 262, 263,
2121 264, 265, 266, 267, 140, 141, 142, 143, 144, 145,
2122 146, 147, 148, 149, 150, 151, 268, 269, 0, 0,
2123 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2124 0, 0, 0, 0, 0, 0, 0, 0, 270, 271,
2125 272, 0, 0, 273, 155, 156, 157, 158, 159, 160,
2126 161, 162, 163, 164, 165, 166, 274, 275, 168, 169,
2127 170, 276, 277, 278, 279
Reid Spencer3822ff52006-11-08 06:47:33 +00002128};
2129
Reid Spencere4d87aa2006-12-23 06:05:41 +00002130static const short int yycheck[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00002131{
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002132 23, 0, 264, 175, 176, 262, 93, 362, 385, 4,
2133 31, 366, 11, 340, 12, 272, 298, 137, 275, 276,
2134 277, 278, 279, 25, 144, 282, 283, 31, 18, 136,
2135 20, 12, 53, 10, 11, 12, 13, 10, 11, 12,
2136 13, 208, 209, 265, 19, 33, 115, 116, 57, 0,
2137 336, 26, 75, 137, 137, 53, 48, 49, 50, 82,
2138 137, 0, 137, 285, 148, 148, 135, 18, 354, 20,
2139 21, 148, 53, 148, 246, 67, 27, 28, 137, 102,
2140 5, 6, 141, 8, 9, 10, 11, 12, 13, 14,
2141 15, 16, 93, 18, 550, 20, 47, 120, 138, 356,
2142 140, 124, 142, 54, 560, 137, 129, 58, 107, 486,
2143 137, 115, 116, 137, 146, 20, 138, 144, 140, 44,
2144 29, 30, 146, 9, 146, 115, 116, 115, 116, 136,
2145 16, 135, 487, 5, 6, 19, 8, 9, 10, 11,
2146 12, 13, 14, 15, 16, 147, 18, 135, 20, 51,
2147 52, 138, 147, 140, 41, 322, 43, 144, 415, 142,
2148 417, 418, 419, 445, 541, 36, 423, 144, 495, 136,
2149 497, 144, 44, 148, 136, 432, 137, 137, 201, 202,
2150 141, 141, 205, 138, 561, 140, 141, 136, 0, 188,
2151 60, 61, 62, 63, 64, 65, 66, 137, 138, 554,
2152 140, 556, 37, 38, 39, 136, 18, 42, 20, 21,
2153 81, 138, 20, 140, 139, 27, 28, 142, 20, 144,
2154 145, 20, 147, 246, 311, 397, 10, 11, 12, 13,
2155 137, 138, 18, 140, 20, 47, 259, 3, 4, 262,
2156 23, 24, 54, 500, 501, 502, 58, 270, 271, 272,
Reid Spencer14310612006-12-31 05:40:51 +00002157 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002158 283, 543, 3, 4, 546, 3, 4, 139, 291, 4,
2159 142, 140, 17, 145, 4, 147, 148, 4, 540, 3,
2160 4, 3, 4, 4, 29, 30, 111, 112, 7, 551,
2161 34, 35, 37, 38, 39, 40, 41, 42, 43, 7,
2162 323, 46, 115, 116, 7, 143, 143, 140, 140, 140,
2163 311, 140, 140, 336, 337, 338, 20, 140, 140, 140,
2164 140, 137, 20, 324, 141, 140, 137, 146, 329, 330,
2165 140, 354, 355, 356, 335, 141, 140, 55, 33, 146,
2166 137, 342, 137, 137, 137, 146, 137, 137, 137, 350,
2167 351, 20, 4, 33, 146, 137, 379, 88, 89, 90,
2168 91, 92, 93, 94, 95, 96, 97, 238, 239, 240,
2169 241, 242, 137, 137, 137, 137, 137, 137, 137, 137,
2170 251, 252, 253, 254, 137, 141, 59, 137, 137, 137,
2171 142, 137, 415, 416, 417, 418, 419, 137, 137, 422,
2172 423, 137, 20, 16, 405, 406, 407, 141, 137, 432,
2173 16, 4, 413, 141, 53, 141, 141, 140, 20, 53,
2174 137, 444, 137, 424, 425, 137, 137, 137, 137, 142,
2175 301, 302, 137, 140, 4, 141, 137, 308, 137, 141,
2176 137, 141, 16, 16, 443, 141, 137, 141, 471, 137,
2177 329, 330, 144, 454, 144, 456, 335, 16, 459, 137,
2178 16, 72, 16, 342, 465, 466, 269, 107, 268, 492,
2179 487, 350, 351, 291, 129, 124, 192, 500, 501, 502,
2180 11, 512, 505, 48, 51, 505, 412, -1, -1, 490,
2181 491, -1, 493, 494, -1, -1, -1, 498, -1, 370,
2182 371, 372, 373, 192, -1, 506, 377, 378, 192, 380,
2183 192, -1, -1, 512, -1, -1, -1, 518, -1, 542,
2184 -1, -1, -1, -1, -1, 526, 405, 406, 407, -1,
2185 -1, -1, -1, -1, 413, -1, -1, -1, -1, -1,
2186 -1, -1, -1, -1, -1, 424, 425, 548, -1, -1,
2187 -1, -1, 553, -1, -1, -1, -1, -1, -1, 430,
2188 431, -1, -1, -1, -1, 566, 567, -1, -1, -1,
2189 571, -1, -1, 574, -1, 454, -1, 456, -1, -1,
2190 459, -1, -1, -1, -1, -1, 465, 466, -1, -1,
Reid Spencer14310612006-12-31 05:40:51 +00002191 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002192 -1, -1, -1, -1, 475, -1, 477, 478, -1, -1,
2193 -1, 490, 491, -1, 493, 494, -1, -1, -1, 498,
2194 -1, -1, -1, -1, -1, -1, -1, 506, 5, 6,
2195 -1, -1, -1, -1, -1, -1, -1, -1, -1, 518,
2196 -1, 18, -1, 20, -1, 22, -1, 526, -1, -1,
2197 -1, -1, -1, -1, -1, -1, -1, -1, 35, 36,
2198 -1, -1, -1, -1, -1, -1, -1, -1, -1, 548,
2199 -1, -1, -1, -1, 553, -1, -1, -1, -1, -1,
2200 -1, -1, -1, -1, -1, -1, -1, 566, 567, -1,
2201 -1, -1, 571, -1, -1, 574, -1, 74, 75, 76,
2202 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2203 87, -1, -1, -1, -1, 5, 6, -1, 8, 9,
2204 10, 11, 12, 13, 14, 15, 16, -1, 18, -1,
2205 20, -1, -1, -1, -1, -1, 113, 114, 115, 116,
2206 117, 118, 119, 120, 121, 122, 123, 124, 125, -1,
2207 127, 128, 129, 130, 44, 132, 133, 134, -1, -1,
2208 -1, 138, -1, 140, -1, 142, -1, -1, 145, -1,
2209 147, -1, 149, 5, 6, -1, 8, 9, 10, 11,
2210 12, 13, 14, 15, 16, -1, 18, -1, 20, 5,
Reid Spencer218ded22007-01-05 17:07:23 +00002211 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002212 16, -1, 18, -1, 20, -1, -1, -1, -1, -1,
2213 -1, -1, 44, -1, 5, 6, -1, 8, 9, 10,
2214 11, 12, 13, 14, 15, 16, -1, 18, 44, 20,
2215 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2216 -1, -1, -1, 34, -1, -1, -1, -1, -1, 139,
2217 -1, -1, 142, 44, -1, 145, -1, 147, 148, -1,
2218 -1, -1, -1, 3, 4, 5, 6, 7, -1, -1,
2219 -1, -1, -1, -1, -1, -1, -1, -1, 18, -1,
2220 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2221 -1, -1, -1, -1, -1, 35, 36, -1, -1, -1,
2222 -1, -1, -1, -1, -1, -1, -1, 139, -1, -1,
2223 142, -1, -1, 145, -1, 147, 148, 57, -1, -1,
Reid Spencer218ded22007-01-05 17:07:23 +00002224 -1, -1, -1, 139, -1, -1, 142, -1, -1, 145,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002225 -1, 147, 148, -1, 74, 75, 76, 77, 78, 79,
2226 80, 81, 82, 83, 84, 85, 86, 87, 139, -1,
2227 -1, 142, -1, -1, 145, -1, 147, 5, 6, -1,
2228 8, 9, 10, 11, 12, 13, 14, 15, 16, -1,
2229 18, -1, 20, 113, 114, 115, 116, 117, 118, 119,
2230 120, 121, 122, 123, 124, 125, 34, 127, 128, 129,
2231 130, -1, 132, 133, 134, -1, 44, -1, 138, -1,
2232 140, -1, -1, -1, -1, 145, 3, 4, 5, 6,
2233 7, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2234 -1, 18, -1, 20, -1, 22, 23, 24, -1, -1,
2235 23, 24, -1, -1, -1, -1, -1, -1, 35, 36,
2236 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2237 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2238 57, 5, 6, -1, 8, 9, 10, 11, 12, 13,
2239 14, 15, 16, -1, 18, -1, 20, 74, 75, 76,
2240 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2241 87, 139, -1, -1, 142, -1, -1, 145, -1, 147,
2242 44, 94, 95, 96, 97, 98, 99, 100, 101, 102,
2243 103, 104, 105, 106, 107, -1, 113, 114, 115, 116,
2244 117, 118, 119, 120, 121, 122, 123, 124, 125, -1,
2245 127, 128, 129, 130, -1, 132, 133, 134, 3, 4,
2246 -1, -1, 7, -1, -1, -1, -1, -1, 145, -1,
2247 -1, -1, -1, -1, -1, -1, -1, 22, 23, 24,
2248 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2249 35, 36, -1, -1, -1, -1, -1, -1, -1, -1,
2250 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2251 -1, -1, 57, -1, -1, 139, -1, -1, 142, -1,
2252 -1, 145, -1, 147, -1, -1, -1, -1, -1, 74,
2253 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2254 85, 86, 87, -1, -1, -1, -1, -1, -1, -1,
2255 -1, -1, 5, 6, -1, 8, 9, 10, 11, 12,
2256 13, 14, 15, 16, -1, 18, -1, 20, 113, 114,
2257 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2258 125, 34, 127, 128, 129, 130, -1, 132, 133, 134,
2259 -1, 44, -1, -1, -1, -1, -1, -1, 5, 6,
2260 145, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2261 -1, 18, -1, 20, -1, 5, 6, -1, 8, 9,
2262 10, 11, 12, 13, 14, 15, 16, 34, 18, -1,
2263 20, -1, -1, -1, -1, 5, 6, 44, 8, 9,
Reid Spencer218ded22007-01-05 17:07:23 +00002264 10, 11, 12, 13, 14, 15, 16, -1, 18, -1,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002265 20, -1, 5, 6, 44, 8, 9, 10, 11, 12,
2266 13, 14, 15, 16, -1, 18, -1, 20, -1, -1,
2267 -1, -1, 5, 6, 44, 8, 9, 10, 11, 12,
2268 13, 14, 15, 16, -1, 18, 139, 20, -1, 142,
2269 -1, 44, 145, -1, 147, 5, 6, -1, 8, 9,
2270 10, 11, 12, 13, 14, 15, 16, -1, 18, -1,
2271 20, 44, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencere4d87aa2006-12-23 06:05:41 +00002272 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002273 -1, -1, 139, -1, 44, 142, -1, -1, 145, -1,
2274 147, -1, -1, -1, -1, -1, -1, -1, -1, 139,
2275 -1, -1, 142, -1, -1, 145, -1, 147, -1, -1,
Reid Spencer218ded22007-01-05 17:07:23 +00002276 -1, -1, -1, -1, -1, -1, -1, -1, -1, 139,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002277 -1, -1, 142, -1, -1, 145, -1, 147, -1, -1,
2278 -1, -1, -1, -1, -1, -1, 139, -1, -1, 142,
2279 -1, -1, 145, -1, 147, -1, -1, -1, -1, -1,
2280 -1, -1, 32, -1, -1, -1, 139, -1, -1, 142,
2281 -1, -1, 145, -1, 147, 45, -1, -1, -1, -1,
2282 -1, -1, -1, -1, -1, 55, 56, -1, -1, 139,
2283 -1, -1, 142, -1, -1, 145, -1, 147, 68, 69,
2284 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2285 80, 81, 82, 83, 84, 85, 86, 87, -1, -1,
2286 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2287 -1, -1, -1, -1, -1, -1, -1, -1, 108, 109,
2288 110, -1, -1, 113, 114, 115, 116, 117, 118, 119,
2289 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
2290 130, 131, 132, 133, 134
Reid Spencer3822ff52006-11-08 06:47:33 +00002291};
2292
2293/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2294 symbol of state STATE-NUM. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002295static const unsigned char yystos[] =
Reid Spencer3822ff52006-11-08 06:47:33 +00002296{
Reid Spencer14310612006-12-31 05:40:51 +00002297 0, 18, 20, 21, 27, 28, 47, 54, 58, 160,
Reid Spencer218ded22007-01-05 17:07:23 +00002298 187, 188, 189, 200, 191, 190, 48, 49, 50, 67,
2299 197, 136, 57, 17, 29, 30, 37, 38, 39, 40,
2300 41, 42, 43, 46, 161, 162, 186, 0, 189, 136,
2301 41, 43, 163, 209, 37, 38, 39, 42, 164, 206,
2302 208, 215, 136, 136, 136, 136, 142, 198, 20, 195,
Reid Spencer6fd36ab2006-12-29 20:35:03 +00002303 5, 6, 8, 9, 10, 11, 12, 13, 14, 15,
Reid Spencer218ded22007-01-05 17:07:23 +00002304 16, 44, 139, 142, 145, 147, 151, 176, 177, 200,
2305 212, 186, 186, 8, 9, 10, 11, 12, 13, 14,
2306 15, 158, 159, 177, 183, 60, 61, 62, 63, 64,
2307 65, 66, 165, 204, 204, 19, 216, 217, 26, 148,
2308 207, 216, 20, 51, 52, 196, 4, 20, 20, 199,
2309 140, 4, 4, 4, 147, 148, 177, 182, 138, 140,
2310 183, 177, 23, 24, 3, 4, 7, 22, 35, 36,
2311 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2312 84, 85, 86, 87, 113, 114, 115, 116, 117, 118,
2313 119, 120, 121, 122, 123, 124, 125, 127, 128, 129,
2314 130, 132, 133, 134, 142, 145, 147, 149, 152, 153,
2315 154, 155, 184, 212, 192, 4, 8, 177, 179, 25,
2316 147, 205, 160, 220, 137, 144, 34, 177, 178, 180,
2317 181, 143, 143, 148, 182, 137, 148, 181, 193, 194,
2318 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
2319 156, 23, 24, 94, 95, 96, 97, 98, 99, 100,
2320 101, 102, 103, 104, 105, 106, 107, 157, 140, 140,
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002321 140, 140, 140, 144, 183, 185, 147, 185, 148, 185,
2322 20, 140, 140, 140, 140, 137, 174, 200, 32, 45,
2323 55, 56, 68, 69, 70, 71, 72, 73, 86, 87,
2324 108, 109, 110, 113, 126, 127, 131, 132, 133, 134,
2325 152, 153, 154, 155, 218, 224, 225, 226, 227, 20,
2326 167, 137, 141, 177, 177, 146, 148, 177, 141, 174,
2327 174, 140, 140, 183, 183, 183, 183, 183, 137, 144,
2328 148, 177, 185, 146, 148, 183, 183, 183, 183, 31,
2329 53, 172, 175, 140, 177, 214, 55, 8, 214, 9,
2330 16, 10, 11, 12, 13, 158, 165, 156, 157, 177,
2331 177, 214, 177, 177, 221, 214, 214, 214, 214, 214,
2332 177, 177, 214, 214, 165, 111, 112, 115, 116, 166,
2333 34, 178, 169, 144, 146, 146, 169, 183, 183, 223,
2334 137, 137, 137, 137, 183, 146, 148, 137, 137, 33,
2335 137, 20, 4, 174, 34, 177, 202, 203, 3, 4,
2336 7, 22, 23, 24, 35, 36, 57, 145, 184, 211,
2337 212, 213, 213, 213, 213, 179, 177, 177, 137, 171,
2338 137, 171, 213, 142, 137, 137, 137, 137, 137, 137,
2339 213, 213, 33, 137, 179, 177, 214, 135, 166, 168,
2340 137, 137, 137, 141, 183, 183, 183, 183, 146, 183,
2341 183, 177, 183, 167, 137, 141, 59, 210, 185, 137,
2342 137, 213, 213, 213, 12, 53, 12, 223, 213, 142,
2343 214, 177, 214, 214, 214, 137, 137, 177, 214, 213,
2344 213, 137, 183, 183, 214, 137, 141, 137, 137, 141,
2345 141, 141, 141, 200, 201, 34, 177, 169, 20, 146,
2346 16, 16, 140, 137, 137, 213, 4, 213, 137, 213,
2347 137, 137, 137, 213, 213, 140, 177, 141, 141, 183,
2348 183, 183, 167, 172, 173, 137, 213, 213, 177, 222,
2349 213, 213, 137, 171, 171, 213, 137, 214, 214, 214,
2350 222, 213, 141, 141, 141, 201, 53, 170, 20, 137,
2351 142, 213, 137, 141, 144, 213, 141, 4, 16, 144,
2352 158, 219, 167, 177, 169, 144, 169, 213, 211, 144,
2353 158, 213, 33, 137, 211, 167, 16, 16, 137, 213,
2354 213, 16, 72, 213, 16, 213
Reid Spencer3822ff52006-11-08 06:47:33 +00002355};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002356
2357#define yyerrok (yyerrstatus = 0)
2358#define yyclearin (yychar = YYEMPTY)
Reid Spencer3822ff52006-11-08 06:47:33 +00002359#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002360#define YYEOF 0
Reid Spencer3822ff52006-11-08 06:47:33 +00002361
Reid Spencer68a24bd2005-08-27 18:50:39 +00002362#define YYACCEPT goto yyacceptlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002363#define YYABORT goto yyabortlab
2364#define YYERROR goto yyerrorlab
2365
2366
2367/* Like YYERROR except do call yyerror. This remains here temporarily
2368 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002369 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002370
Reid Spencer68a24bd2005-08-27 18:50:39 +00002371#define YYFAIL goto yyerrlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002372
Reid Spencer68a24bd2005-08-27 18:50:39 +00002373#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002374
2375#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002376do \
2377 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3822ff52006-11-08 06:47:33 +00002378 { \
2379 yychar = (Token); \
2380 yylval = (Value); \
2381 yytoken = YYTRANSLATE (yychar); \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002382 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002383 goto yybackup; \
2384 } \
2385 else \
Reid Spencere4d87aa2006-12-23 06:05:41 +00002386 { \
2387 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer3822ff52006-11-08 06:47:33 +00002388 YYERROR; \
2389 } \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002390while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002391
Reid Spencere4d87aa2006-12-23 06:05:41 +00002392
Reid Spencer68a24bd2005-08-27 18:50:39 +00002393#define YYTERROR 1
2394#define YYERRCODE 256
2395
Reid Spencer3822ff52006-11-08 06:47:33 +00002396
Reid Spencere4d87aa2006-12-23 06:05:41 +00002397/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2398 If N is 0, then set CURRENT to the empty location which ends
2399 the previous symbol: RHS[0] (always defined). */
2400
2401#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer3822ff52006-11-08 06:47:33 +00002402#ifndef YYLLOC_DEFAULT
Reid Spencere4d87aa2006-12-23 06:05:41 +00002403# define YYLLOC_DEFAULT(Current, Rhs, N) \
2404 do \
2405 if (N) \
2406 { \
2407 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2408 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2409 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2410 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2411 } \
2412 else \
2413 { \
2414 (Current).first_line = (Current).last_line = \
2415 YYRHSLOC (Rhs, 0).last_line; \
2416 (Current).first_column = (Current).last_column = \
2417 YYRHSLOC (Rhs, 0).last_column; \
2418 } \
2419 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002420#endif
2421
Reid Spencere4d87aa2006-12-23 06:05:41 +00002422
2423/* YY_LOCATION_PRINT -- Print the location on the stream.
2424 This macro was not mandated originally: define only if we know
2425 we won't break user code: when these are the locations we know. */
2426
2427#ifndef YY_LOCATION_PRINT
2428# if YYLTYPE_IS_TRIVIAL
2429# define YY_LOCATION_PRINT(File, Loc) \
2430 fprintf (File, "%d.%d-%d.%d", \
2431 (Loc).first_line, (Loc).first_column, \
2432 (Loc).last_line, (Loc).last_column)
2433# else
2434# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2435# endif
2436#endif
2437
2438
Reid Spencer3822ff52006-11-08 06:47:33 +00002439/* YYLEX -- calling `yylex' with the right arguments. */
2440
Reid Spencer68a24bd2005-08-27 18:50:39 +00002441#ifdef YYLEX_PARAM
Reid Spencer3822ff52006-11-08 06:47:33 +00002442# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002443#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002444# define YYLEX yylex ()
Chris Lattnerf49c1762006-11-08 05:58:47 +00002445#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002446
2447/* Enable debugging if requested. */
2448#if YYDEBUG
2449
2450# ifndef YYFPRINTF
2451# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2452# define YYFPRINTF fprintf
2453# endif
2454
2455# define YYDPRINTF(Args) \
2456do { \
2457 if (yydebug) \
2458 YYFPRINTF Args; \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002459} while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002460
Reid Spencere4d87aa2006-12-23 06:05:41 +00002461# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002462do { \
2463 if (yydebug) \
2464 { \
2465 YYFPRINTF (stderr, "%s ", Title); \
Reid Spencere4d87aa2006-12-23 06:05:41 +00002466 yysymprint (stderr, \
2467 Type, Value); \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002468 YYFPRINTF (stderr, "\n"); \
2469 } \
2470} while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002471
2472/*------------------------------------------------------------------.
2473| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2474| TOP (included). |
2475`------------------------------------------------------------------*/
2476
Andrew Lenharth6353e052006-12-08 18:07:09 +00002477#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002478static void
Reid Spencere4d87aa2006-12-23 06:05:41 +00002479yy_stack_print (short int *bottom, short int *top)
Chris Lattnerf49c1762006-11-08 05:58:47 +00002480#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002481static void
2482yy_stack_print (bottom, top)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002483 short int *bottom;
2484 short int *top;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002485#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002486{
2487 YYFPRINTF (stderr, "Stack now");
Andrew Lenharth6353e052006-12-08 18:07:09 +00002488 for (/* Nothing. */; bottom <= top; ++bottom)
Reid Spencer3822ff52006-11-08 06:47:33 +00002489 YYFPRINTF (stderr, " %d", *bottom);
2490 YYFPRINTF (stderr, "\n");
2491}
2492
2493# define YY_STACK_PRINT(Bottom, Top) \
2494do { \
2495 if (yydebug) \
2496 yy_stack_print ((Bottom), (Top)); \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002497} while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00002498
2499
2500/*------------------------------------------------.
2501| Report that the YYRULE is going to be reduced. |
2502`------------------------------------------------*/
2503
Andrew Lenharth6353e052006-12-08 18:07:09 +00002504#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002505static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002506yy_reduce_print (int yyrule)
Reid Spencer3822ff52006-11-08 06:47:33 +00002507#else
2508static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002509yy_reduce_print (yyrule)
Reid Spencer3822ff52006-11-08 06:47:33 +00002510 int yyrule;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002511#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002512{
2513 int yyi;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002514 unsigned long int yylno = yyrline[yyrule];
2515 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
Andrew Lenharth6353e052006-12-08 18:07:09 +00002516 yyrule - 1, yylno);
2517 /* Print the symbols being reduced, and their result. */
2518 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002519 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2520 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Reid Spencer3822ff52006-11-08 06:47:33 +00002521}
Reid Spencer21be8652006-10-22 07:03:43 +00002522
Reid Spencer3822ff52006-11-08 06:47:33 +00002523# define YY_REDUCE_PRINT(Rule) \
2524do { \
2525 if (yydebug) \
Andrew Lenharth6353e052006-12-08 18:07:09 +00002526 yy_reduce_print (Rule); \
2527} while (0)
Reid Spencer21be8652006-10-22 07:03:43 +00002528
Reid Spencer3822ff52006-11-08 06:47:33 +00002529/* Nonzero means print parse trace. It is left uninitialized so that
2530 multiple parsers can coexist. */
2531int yydebug;
2532#else /* !YYDEBUG */
2533# define YYDPRINTF(Args)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002534# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Reid Spencer3822ff52006-11-08 06:47:33 +00002535# define YY_STACK_PRINT(Bottom, Top)
2536# define YY_REDUCE_PRINT(Rule)
2537#endif /* !YYDEBUG */
Reid Spencer21be8652006-10-22 07:03:43 +00002538
Reid Spencer21be8652006-10-22 07:03:43 +00002539
Reid Spencer3822ff52006-11-08 06:47:33 +00002540/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002541#ifndef YYINITDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002542# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002543#endif
2544
Reid Spencer3822ff52006-11-08 06:47:33 +00002545/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2546 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002547
Reid Spencer3822ff52006-11-08 06:47:33 +00002548 Do not make this value too large; the results are undefined if
Reid Spencere4d87aa2006-12-23 06:05:41 +00002549 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer3822ff52006-11-08 06:47:33 +00002550 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002551
2552#ifndef YYMAXDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002553# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002554#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002555
Reid Spencer68a24bd2005-08-27 18:50:39 +00002556
2557
Reid Spencer3822ff52006-11-08 06:47:33 +00002558#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002559
Reid Spencer3822ff52006-11-08 06:47:33 +00002560# ifndef yystrlen
Andrew Lenharth6353e052006-12-08 18:07:09 +00002561# if defined (__GLIBC__) && defined (_STRING_H)
Reid Spencer3822ff52006-11-08 06:47:33 +00002562# define yystrlen strlen
2563# else
2564/* Return the length of YYSTR. */
2565static YYSIZE_T
Andrew Lenharth6353e052006-12-08 18:07:09 +00002566# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002567yystrlen (const char *yystr)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002568# else
Reid Spencer3822ff52006-11-08 06:47:33 +00002569yystrlen (yystr)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002570 const char *yystr;
2571# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002572{
Reid Spencere4d87aa2006-12-23 06:05:41 +00002573 const char *yys = yystr;
Andrew Lenharth6353e052006-12-08 18:07:09 +00002574
2575 while (*yys++ != '\0')
Reid Spencer3822ff52006-11-08 06:47:33 +00002576 continue;
Andrew Lenharth6353e052006-12-08 18:07:09 +00002577
2578 return yys - yystr - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002579}
Reid Spencer3822ff52006-11-08 06:47:33 +00002580# endif
2581# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002582
Reid Spencer3822ff52006-11-08 06:47:33 +00002583# ifndef yystpcpy
Andrew Lenharth6353e052006-12-08 18:07:09 +00002584# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Reid Spencer3822ff52006-11-08 06:47:33 +00002585# define yystpcpy stpcpy
2586# else
2587/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2588 YYDEST. */
2589static char *
Andrew Lenharth6353e052006-12-08 18:07:09 +00002590# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002591yystpcpy (char *yydest, const char *yysrc)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002592# else
Reid Spencer3822ff52006-11-08 06:47:33 +00002593yystpcpy (yydest, yysrc)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002594 char *yydest;
2595 const char *yysrc;
2596# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002597{
Reid Spencere4d87aa2006-12-23 06:05:41 +00002598 char *yyd = yydest;
2599 const char *yys = yysrc;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002600
Reid Spencer3822ff52006-11-08 06:47:33 +00002601 while ((*yyd++ = *yys++) != '\0')
2602 continue;
2603
2604 return yyd - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002605}
Reid Spencer3822ff52006-11-08 06:47:33 +00002606# endif
2607# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002608
Reid Spencere4d87aa2006-12-23 06:05:41 +00002609# ifndef yytnamerr
2610/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2611 quotes and backslashes, so that it's suitable for yyerror. The
2612 heuristic is that double-quoting is unnecessary unless the string
2613 contains an apostrophe, a comma, or backslash (other than
2614 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2615 null, do not copy; instead, return the length of what the result
2616 would have been. */
2617static YYSIZE_T
2618yytnamerr (char *yyres, const char *yystr)
2619{
2620 if (*yystr == '"')
2621 {
2622 size_t yyn = 0;
2623 char const *yyp = yystr;
2624
2625 for (;;)
2626 switch (*++yyp)
2627 {
2628 case '\'':
2629 case ',':
2630 goto do_not_strip_quotes;
2631
2632 case '\\':
2633 if (*++yyp != '\\')
2634 goto do_not_strip_quotes;
2635 /* Fall through. */
2636 default:
2637 if (yyres)
2638 yyres[yyn] = *yyp;
2639 yyn++;
2640 break;
2641
2642 case '"':
2643 if (yyres)
2644 yyres[yyn] = '\0';
2645 return yyn;
2646 }
2647 do_not_strip_quotes: ;
2648 }
2649
2650 if (! yyres)
2651 return yystrlen (yystr);
2652
2653 return yystpcpy (yyres, yystr) - yyres;
2654}
2655# endif
2656
2657#endif /* YYERROR_VERBOSE */
Reid Spencer3822ff52006-11-08 06:47:33 +00002658
Reid Spencer21be8652006-10-22 07:03:43 +00002659
2660
Andrew Lenharth6353e052006-12-08 18:07:09 +00002661#if YYDEBUG
2662/*--------------------------------.
2663| Print this symbol on YYOUTPUT. |
2664`--------------------------------*/
Reid Spencer3822ff52006-11-08 06:47:33 +00002665
Andrew Lenharth6353e052006-12-08 18:07:09 +00002666#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002667static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002668yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Reid Spencer3822ff52006-11-08 06:47:33 +00002669#else
2670static void
Andrew Lenharth6353e052006-12-08 18:07:09 +00002671yysymprint (yyoutput, yytype, yyvaluep)
2672 FILE *yyoutput;
Reid Spencer3822ff52006-11-08 06:47:33 +00002673 int yytype;
2674 YYSTYPE *yyvaluep;
2675#endif
2676{
Andrew Lenharth6353e052006-12-08 18:07:09 +00002677 /* Pacify ``unused variable'' warnings. */
2678 (void) yyvaluep;
Reid Spencer3822ff52006-11-08 06:47:33 +00002679
Andrew Lenharth6353e052006-12-08 18:07:09 +00002680 if (yytype < YYNTOKENS)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002681 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
Andrew Lenharth6353e052006-12-08 18:07:09 +00002682 else
2683 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2684
Reid Spencere4d87aa2006-12-23 06:05:41 +00002685
2686# ifdef YYPRINT
2687 if (yytype < YYNTOKENS)
2688 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2689# endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00002690 switch (yytype)
2691 {
2692 default:
2693 break;
2694 }
2695 YYFPRINTF (yyoutput, ")");
2696}
2697
2698#endif /* ! YYDEBUG */
2699/*-----------------------------------------------.
2700| Release the memory associated to this symbol. |
2701`-----------------------------------------------*/
2702
2703#if defined (__STDC__) || defined (__cplusplus)
2704static void
Reid Spencere4d87aa2006-12-23 06:05:41 +00002705yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Andrew Lenharth6353e052006-12-08 18:07:09 +00002706#else
2707static void
Reid Spencere4d87aa2006-12-23 06:05:41 +00002708yydestruct (yymsg, yytype, yyvaluep)
2709 const char *yymsg;
Andrew Lenharth6353e052006-12-08 18:07:09 +00002710 int yytype;
2711 YYSTYPE *yyvaluep;
2712#endif
2713{
2714 /* Pacify ``unused variable'' warnings. */
2715 (void) yyvaluep;
Reid Spencer3822ff52006-11-08 06:47:33 +00002716
Reid Spencere4d87aa2006-12-23 06:05:41 +00002717 if (!yymsg)
2718 yymsg = "Deleting";
2719 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2720
Reid Spencer3822ff52006-11-08 06:47:33 +00002721 switch (yytype)
2722 {
2723
2724 default:
Andrew Lenharth6353e052006-12-08 18:07:09 +00002725 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00002726 }
2727}
2728
2729
2730/* Prevent warnings from -Wmissing-prototypes. */
2731
2732#ifdef YYPARSE_PARAM
Andrew Lenharth6353e052006-12-08 18:07:09 +00002733# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002734int yyparse (void *YYPARSE_PARAM);
Andrew Lenharth6353e052006-12-08 18:07:09 +00002735# else
Reid Spencer3822ff52006-11-08 06:47:33 +00002736int yyparse ();
Andrew Lenharth6353e052006-12-08 18:07:09 +00002737# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002738#else /* ! YYPARSE_PARAM */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002739#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002740int yyparse (void);
Chris Lattnerf49c1762006-11-08 05:58:47 +00002741#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002742int yyparse ();
2743#endif
2744#endif /* ! YYPARSE_PARAM */
2745
2746
2747
Reid Spencere4d87aa2006-12-23 06:05:41 +00002748/* The look-ahead symbol. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002749int yychar;
2750
Reid Spencere4d87aa2006-12-23 06:05:41 +00002751/* The semantic value of the look-ahead symbol. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002752YYSTYPE yylval;
2753
2754/* Number of syntax errors so far. */
2755int yynerrs;
2756
2757
2758
2759/*----------.
2760| yyparse. |
2761`----------*/
2762
2763#ifdef YYPARSE_PARAM
Andrew Lenharth6353e052006-12-08 18:07:09 +00002764# if defined (__STDC__) || defined (__cplusplus)
2765int yyparse (void *YYPARSE_PARAM)
2766# else
2767int yyparse (YYPARSE_PARAM)
2768 void *YYPARSE_PARAM;
2769# endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002770#else /* ! YYPARSE_PARAM */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002771#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002772int
2773yyparse (void)
2774#else
2775int
2776yyparse ()
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00002777 ;
Reid Spencer3822ff52006-11-08 06:47:33 +00002778#endif
2779#endif
2780{
2781
Reid Spencere4d87aa2006-12-23 06:05:41 +00002782 int yystate;
2783 int yyn;
Reid Spencer3822ff52006-11-08 06:47:33 +00002784 int yyresult;
2785 /* Number of tokens to shift before error messages enabled. */
2786 int yyerrstatus;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002787 /* Look-ahead token as an internal (translated) token number. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002788 int yytoken = 0;
2789
2790 /* Three stacks and their tools:
2791 `yyss': related to states,
2792 `yyvs': related to semantic values,
2793 `yyls': related to locations.
2794
2795 Refer to the stacks thru separate pointers, to allow yyoverflow
2796 to reallocate them elsewhere. */
2797
2798 /* The state stack. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00002799 short int yyssa[YYINITDEPTH];
2800 short int *yyss = yyssa;
2801 short int *yyssp;
Reid Spencer3822ff52006-11-08 06:47:33 +00002802
2803 /* The semantic value stack. */
2804 YYSTYPE yyvsa[YYINITDEPTH];
2805 YYSTYPE *yyvs = yyvsa;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002806 YYSTYPE *yyvsp;
Reid Spencer3822ff52006-11-08 06:47:33 +00002807
2808
2809
Andrew Lenharth6353e052006-12-08 18:07:09 +00002810#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002811
Reid Spencer3822ff52006-11-08 06:47:33 +00002812 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002813
Reid Spencer3822ff52006-11-08 06:47:33 +00002814 /* The variables used to return semantic value and location from the
2815 action routines. */
2816 YYSTYPE yyval;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002817
2818
Andrew Lenharth6353e052006-12-08 18:07:09 +00002819 /* When reducing, the number of symbols on the RHS of the reduced
2820 rule. */
2821 int yylen;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002822
Reid Spencer3822ff52006-11-08 06:47:33 +00002823 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002824
Reid Spencer68a24bd2005-08-27 18:50:39 +00002825 yystate = 0;
2826 yyerrstatus = 0;
2827 yynerrs = 0;
2828 yychar = YYEMPTY; /* Cause a token to be read. */
2829
2830 /* Initialize stack pointers.
2831 Waste one element of value and location stack
2832 so that they stay on the same level as the state stack.
2833 The wasted elements are never initialized. */
2834
Reid Spencer3822ff52006-11-08 06:47:33 +00002835 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002836 yyvsp = yyvs;
2837
Reid Spencer3822ff52006-11-08 06:47:33 +00002838 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002839
Reid Spencer3822ff52006-11-08 06:47:33 +00002840/*------------------------------------------------------------.
2841| yynewstate -- Push a new state, which is found in yystate. |
2842`------------------------------------------------------------*/
2843 yynewstate:
2844 /* In all cases, when you get here, the value and location stacks
Andrew Lenharth6353e052006-12-08 18:07:09 +00002845 have just been pushed. so pushing a state here evens the stacks.
2846 */
Reid Spencer3822ff52006-11-08 06:47:33 +00002847 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002848
Reid Spencer3822ff52006-11-08 06:47:33 +00002849 yysetstate:
2850 *yyssp = yystate;
2851
2852 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002853 {
2854 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002855 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002856
2857#ifdef yyoverflow
Reid Spencer3822ff52006-11-08 06:47:33 +00002858 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00002859 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer3822ff52006-11-08 06:47:33 +00002860 these so that the &'s don't force the real ones into
2861 memory. */
2862 YYSTYPE *yyvs1 = yyvs;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002863 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002864
Reid Spencer3822ff52006-11-08 06:47:33 +00002865
2866 /* Each stack pointer address is followed by the size of the
2867 data in use in that stack, in bytes. This used to be a
2868 conditional around just the two extra args, but that might
2869 be undefined if yyoverflow is a macro. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00002870 yyoverflow (YY_("memory exhausted"),
Reid Spencer3822ff52006-11-08 06:47:33 +00002871 &yyss1, yysize * sizeof (*yyssp),
2872 &yyvs1, yysize * sizeof (*yyvsp),
2873
2874 &yystacksize);
2875
2876 yyss = yyss1;
2877 yyvs = yyvs1;
2878 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002879#else /* no yyoverflow */
Reid Spencer3822ff52006-11-08 06:47:33 +00002880# ifndef YYSTACK_RELOCATE
Reid Spencere4d87aa2006-12-23 06:05:41 +00002881 goto yyexhaustedlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00002882# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002883 /* Extend the stack our own way. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002884 if (YYMAXDEPTH <= yystacksize)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002885 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002886 yystacksize *= 2;
Reid Spencer3822ff52006-11-08 06:47:33 +00002887 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002888 yystacksize = YYMAXDEPTH;
Reid Spencer3822ff52006-11-08 06:47:33 +00002889
2890 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00002891 short int *yyss1 = yyss;
Reid Spencer3822ff52006-11-08 06:47:33 +00002892 union yyalloc *yyptr =
2893 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2894 if (! yyptr)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002895 goto yyexhaustedlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00002896 YYSTACK_RELOCATE (yyss);
2897 YYSTACK_RELOCATE (yyvs);
2898
2899# undef YYSTACK_RELOCATE
2900 if (yyss1 != yyssa)
2901 YYSTACK_FREE (yyss1);
2902 }
2903# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002904#endif /* no yyoverflow */
2905
Reid Spencer3822ff52006-11-08 06:47:33 +00002906 yyssp = yyss + yysize - 1;
2907 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002908
2909
Reid Spencer3822ff52006-11-08 06:47:33 +00002910 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2911 (unsigned long int) yystacksize));
2912
2913 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002914 YYABORT;
2915 }
2916
Reid Spencer3822ff52006-11-08 06:47:33 +00002917 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002918
2919 goto yybackup;
Reid Spencer3822ff52006-11-08 06:47:33 +00002920
2921/*-----------.
2922| yybackup. |
2923`-----------*/
2924yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002925
Andrew Lenharth6353e052006-12-08 18:07:09 +00002926/* Do appropriate processing given the current state. */
Reid Spencere4d87aa2006-12-23 06:05:41 +00002927/* Read a look-ahead token if we need one and don't already have one. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002928/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002929
Reid Spencere4d87aa2006-12-23 06:05:41 +00002930 /* First try to decide what to do without reference to look-ahead token. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002931
Reid Spencer68a24bd2005-08-27 18:50:39 +00002932 yyn = yypact[yystate];
Reid Spencer3822ff52006-11-08 06:47:33 +00002933 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002934 goto yydefault;
2935
Reid Spencere4d87aa2006-12-23 06:05:41 +00002936 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002937
Reid Spencere4d87aa2006-12-23 06:05:41 +00002938 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002939 if (yychar == YYEMPTY)
2940 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002941 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002942 yychar = YYLEX;
2943 }
2944
Reid Spencer3822ff52006-11-08 06:47:33 +00002945 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002946 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002947 yychar = yytoken = YYEOF;
2948 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002949 }
2950 else
2951 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002952 yytoken = YYTRANSLATE (yychar);
Reid Spencere4d87aa2006-12-23 06:05:41 +00002953 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002954 }
2955
Reid Spencer3822ff52006-11-08 06:47:33 +00002956 /* If the proper action on seeing token YYTOKEN is to reduce or to
2957 detect an error, take that action. */
2958 yyn += yytoken;
2959 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002960 goto yydefault;
2961 yyn = yytable[yyn];
Reid Spencer3822ff52006-11-08 06:47:33 +00002962 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002963 {
Reid Spencer3822ff52006-11-08 06:47:33 +00002964 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002965 goto yyerrlab;
2966 yyn = -yyn;
2967 goto yyreduce;
2968 }
2969
2970 if (yyn == YYFINAL)
2971 YYACCEPT;
2972
Reid Spencere4d87aa2006-12-23 06:05:41 +00002973 /* Shift the look-ahead token. */
2974 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Andrew Lenharth6353e052006-12-08 18:07:09 +00002975
2976 /* Discard the token being shifted unless it is eof. */
2977 if (yychar != YYEOF)
2978 yychar = YYEMPTY;
2979
2980 *++yyvsp = yylval;
2981
2982
Reid Spencer3822ff52006-11-08 06:47:33 +00002983 /* Count tokens shifted since error; after three, turn off error
2984 status. */
2985 if (yyerrstatus)
2986 yyerrstatus--;
Chris Lattner224f84f2006-08-18 17:34:45 +00002987
Reid Spencer68a24bd2005-08-27 18:50:39 +00002988 yystate = yyn;
2989 goto yynewstate;
2990
Chris Lattnerf49c1762006-11-08 05:58:47 +00002991
Reid Spencer3822ff52006-11-08 06:47:33 +00002992/*-----------------------------------------------------------.
2993| yydefault -- do the default action for the current state. |
2994`-----------------------------------------------------------*/
2995yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002996 yyn = yydefact[yystate];
2997 if (yyn == 0)
2998 goto yyerrlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00002999 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003000
Reid Spencer3822ff52006-11-08 06:47:33 +00003001
3002/*-----------------------------.
3003| yyreduce -- Do a reduction. |
3004`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003005yyreduce:
Reid Spencer3822ff52006-11-08 06:47:33 +00003006 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003007 yylen = yyr2[yyn];
3008
Reid Spencer3822ff52006-11-08 06:47:33 +00003009 /* If YYLEN is nonzero, implement the default value of the action:
3010 `$$ = $1'.
3011
3012 Otherwise, the following line sets YYVAL to garbage.
3013 This behavior is undocumented and Bison
3014 users should not rely upon it. Assigning to YYVAL
3015 unconditionally makes the parser a bit smaller, and it avoids a
3016 GCC warning that YYVAL may be used uninitialized. */
3017 yyval = yyvsp[1-yylen];
3018
3019
3020 YY_REDUCE_PRINT (yyn);
3021 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003022 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003023 case 3:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003024#line 1020 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003025 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003026 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003027 GEN_ERROR("Value too large for type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003028 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003029 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003030;}
3031 break;
3032
Reid Spencere4d87aa2006-12-23 06:05:41 +00003033 case 31:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003034#line 1036 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003035 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3036 break;
3037
3038 case 32:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003039#line 1036 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003040 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3041 break;
3042
3043 case 33:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003044#line 1037 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003045 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3046 break;
3047
3048 case 34:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003049#line 1037 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003050 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3051 break;
3052
3053 case 35:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003054#line 1038 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003055 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3056 break;
3057
3058 case 36:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003059#line 1038 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003060 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3061 break;
3062
3063 case 37:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003064#line 1039 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003065 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3066 break;
3067
3068 case 38:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003069#line 1039 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003070 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003071 break;
3072
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003073 case 39:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003074#line 1040 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003075 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003076 break;
3077
3078 case 40:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003079#line 1040 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003080 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003081 break;
3082
3083 case 41:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003084#line 1044 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003085 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003086 break;
3087
3088 case 42:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003089#line 1044 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003090 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003091 break;
3092
3093 case 43:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003094#line 1045 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003095 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003096 break;
3097
3098 case 44:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003099#line 1045 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003100 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003101 break;
3102
3103 case 45:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003104#line 1046 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003105 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003106 break;
3107
3108 case 46:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003109#line 1046 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003110 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003111 break;
3112
3113 case 47:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003114#line 1047 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003115 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003116 break;
3117
3118 case 48:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003119#line 1047 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003120 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003121 break;
3122
3123 case 49:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003124#line 1048 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003125 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003126 break;
3127
3128 case 50:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003129#line 1048 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003130 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003131 break;
3132
3133 case 51:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003134#line 1049 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003135 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003136 break;
3137
3138 case 52:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003139#line 1049 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003140 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003141 break;
3142
3143 case 53:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003144#line 1050 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003145 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003146 break;
3147
3148 case 54:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003149#line 1050 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003150 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003151 break;
3152
3153 case 55:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003154#line 1051 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003155 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003156 break;
3157
3158 case 56:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003159#line 1052 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003160 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003161 break;
3162
Reid Spencer14310612006-12-31 05:40:51 +00003163 case 63:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003164#line 1061 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003165 {
3166 (yyval.StrVal) = (yyvsp[-1].StrVal);
3167 CHECK_FOR_ERROR
3168 ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003169 break;
3170
Reid Spencer14310612006-12-31 05:40:51 +00003171 case 64:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003172#line 1065 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003173 {
3174 (yyval.StrVal) = 0;
3175 CHECK_FOR_ERROR
3176 ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003177 break;
3178
Reid Spencer14310612006-12-31 05:40:51 +00003179 case 65:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003180#line 1071 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003181 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003182 break;
3183
Reid Spencer14310612006-12-31 05:40:51 +00003184 case 66:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003185#line 1072 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003186 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003187 break;
3188
Reid Spencer14310612006-12-31 05:40:51 +00003189 case 67:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003190#line 1073 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003191 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3192 break;
3193
Reid Spencer14310612006-12-31 05:40:51 +00003194 case 68:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003195#line 1074 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003196 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003197 break;
3198
Reid Spencer14310612006-12-31 05:40:51 +00003199 case 69:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003200#line 1075 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003201 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003202 break;
3203
Reid Spencer14310612006-12-31 05:40:51 +00003204 case 70:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003205#line 1079 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003206 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3207 break;
3208
Reid Spencer14310612006-12-31 05:40:51 +00003209 case 71:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003210#line 1080 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003211 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003212 break;
3213
Reid Spencer14310612006-12-31 05:40:51 +00003214 case 72:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003215#line 1081 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003216 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003217 break;
3218
Reid Spencer14310612006-12-31 05:40:51 +00003219 case 73:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003220#line 1085 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003221 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003222 break;
3223
Reid Spencer14310612006-12-31 05:40:51 +00003224 case 74:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003225#line 1086 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003226 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003227 break;
3228
Reid Spencer14310612006-12-31 05:40:51 +00003229 case 75:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003230#line 1087 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003231 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003232 break;
3233
Reid Spencer14310612006-12-31 05:40:51 +00003234 case 76:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003235#line 1091 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003236 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3237 break;
3238
3239 case 77:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003240#line 1092 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003241 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003242 break;
3243
Reid Spencer14310612006-12-31 05:40:51 +00003244 case 78:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003245#line 1093 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003246 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003247 break;
3248
Reid Spencer14310612006-12-31 05:40:51 +00003249 case 79:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003250#line 1094 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003251 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003252 break;
3253
Reid Spencer14310612006-12-31 05:40:51 +00003254 case 80:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003255#line 1095 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003256 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003257 break;
3258
Reid Spencer14310612006-12-31 05:40:51 +00003259 case 81:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003260#line 1098 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003261 { (yyval.UIntVal) = CallingConv::C; ;}
3262 break;
3263
Reid Spencer14310612006-12-31 05:40:51 +00003264 case 82:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003265#line 1099 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003266 { (yyval.UIntVal) = CallingConv::C; ;}
3267 break;
3268
Reid Spencer14310612006-12-31 05:40:51 +00003269 case 83:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003270#line 1100 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003271 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3272 break;
3273
Reid Spencer14310612006-12-31 05:40:51 +00003274 case 84:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003275#line 1101 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003276 { (yyval.UIntVal) = CallingConv::Fast; ;}
3277 break;
3278
Reid Spencer14310612006-12-31 05:40:51 +00003279 case 85:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003280#line 1102 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003281 { (yyval.UIntVal) = CallingConv::Cold; ;}
3282 break;
3283
Reid Spencer14310612006-12-31 05:40:51 +00003284 case 86:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003285#line 1103 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003286 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3287 break;
3288
Reid Spencer14310612006-12-31 05:40:51 +00003289 case 87:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003290#line 1104 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003291 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3292 break;
3293
Reid Spencer14310612006-12-31 05:40:51 +00003294 case 88:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003295#line 1105 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003296 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003297 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003298 GEN_ERROR("Calling conv too large!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003299 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003300 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003301 ;}
3302 break;
3303
Reid Spencer14310612006-12-31 05:40:51 +00003304 case 89:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003305#line 1112 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003306 { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;}
3307 break;
3308
3309 case 90:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003310#line 1113 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003311 { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;}
3312 break;
3313
3314 case 91:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003315#line 1116 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00003316 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
Reid Spencer14310612006-12-31 05:40:51 +00003317 break;
3318
3319 case 92:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003320#line 1117 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003321 {
Reid Spencer218ded22007-01-05 17:07:23 +00003322 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
Reid Spencer14310612006-12-31 05:40:51 +00003323 ;}
3324 break;
3325
3326 case 93:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003327#line 1122 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00003328 { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;}
Reid Spencer14310612006-12-31 05:40:51 +00003329 break;
3330
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003331 case 95:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003332#line 1126 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00003333 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
Reid Spencere4d87aa2006-12-23 06:05:41 +00003334 break;
3335
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003336 case 96:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003337#line 1127 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00003338 {
3339 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3340 ;}
Reid Spencere4d87aa2006-12-23 06:05:41 +00003341 break;
3342
Reid Spencer14310612006-12-31 05:40:51 +00003343 case 97:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003344#line 1134 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003345 { (yyval.UIntVal) = 0; ;}
3346 break;
3347
Reid Spencer218ded22007-01-05 17:07:23 +00003348 case 98:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003349#line 1135 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003350 {
3351 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3352 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3353 GEN_ERROR("Alignment must be a power of two!");
3354 CHECK_FOR_ERROR
3355;}
3356 break;
3357
Reid Spencer218ded22007-01-05 17:07:23 +00003358 case 99:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003359#line 1141 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00003360 { (yyval.UIntVal) = 0; ;}
3361 break;
3362
Reid Spencer14310612006-12-31 05:40:51 +00003363 case 100:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003364#line 1142 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003365 {
Reid Spencer218ded22007-01-05 17:07:23 +00003366 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3367 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3368 GEN_ERROR("Alignment must be a power of two!");
3369 CHECK_FOR_ERROR
3370;}
3371 break;
3372
3373 case 101:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003374#line 1150 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00003375 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003376 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3377 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
3378 GEN_ERROR("Invalid character in section name!");
3379 (yyval.StrVal) = (yyvsp[0].StrVal);
3380 CHECK_FOR_ERROR
3381;}
3382 break;
3383
Reid Spencer218ded22007-01-05 17:07:23 +00003384 case 102:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003385#line 1158 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003386 { (yyval.StrVal) = 0; ;}
3387 break;
3388
Reid Spencer218ded22007-01-05 17:07:23 +00003389 case 103:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003390#line 1159 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003391 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3392 break;
3393
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003394 case 104:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003395#line 1164 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003396 {;}
3397 break;
3398
3399 case 105:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003400#line 1165 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00003401 {;}
3402 break;
3403
3404 case 106:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003405#line 1166 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003406 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003407 CurGV->setSection((yyvsp[0].StrVal));
3408 free((yyvsp[0].StrVal));
3409 CHECK_FOR_ERROR
3410 ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003411 break;
3412
Reid Spencer218ded22007-01-05 17:07:23 +00003413 case 107:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003414#line 1171 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003415 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003416 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
3417 GEN_ERROR("Alignment must be a power of two!");
3418 CurGV->setAlignment((yyvsp[0].UInt64Val));
3419 CHECK_FOR_ERROR
3420 ;}
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003421 break;
3422
Reid Spencer218ded22007-01-05 17:07:23 +00003423 case 116:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003424#line 1187 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003425 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003426 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencera132e042006-12-03 05:46:11 +00003427 CHECK_FOR_ERROR
3428 ;}
3429 break;
3430
Reid Spencer218ded22007-01-05 17:07:23 +00003431 case 117:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003432#line 1191 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003433 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003434 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencera132e042006-12-03 05:46:11 +00003435 CHECK_FOR_ERROR
3436 ;}
3437 break;
3438
Reid Spencer218ded22007-01-05 17:07:23 +00003439 case 118:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003440#line 1195 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003441 { // Pointer type?
3442 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
3443 GEN_ERROR("Cannot form a pointer to a basic block");
3444 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3445 delete (yyvsp[-1].TypeVal);
3446 CHECK_FOR_ERROR
3447 ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003448 break;
3449
Reid Spencer218ded22007-01-05 17:07:23 +00003450 case 119:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003451#line 1202 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003452 { // Named types are also simple types...
3453 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
3454 CHECK_FOR_ERROR
3455 (yyval.TypeVal) = new PATypeHolder(tmp);
3456 ;}
3457 break;
3458
Reid Spencer218ded22007-01-05 17:07:23 +00003459 case 120:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003460#line 1207 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003461 { // Type UpReference
Reid Spencere4d87aa2006-12-23 06:05:41 +00003462 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer3da59db2006-11-27 01:05:10 +00003463 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencere4d87aa2006-12-23 06:05:41 +00003464 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3465 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer3da59db2006-11-27 01:05:10 +00003466 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003467 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003468 ;}
3469 break;
3470
Reid Spencer218ded22007-01-05 17:07:23 +00003471 case 121:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003472#line 1215 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003473 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003474 std::vector<const Type*> Params;
Reid Spencer14310612006-12-31 05:40:51 +00003475 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer218ded22007-01-05 17:07:23 +00003476 Attrs.push_back((yyvsp[0].ParamAttrs));
3477 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00003478 Params.push_back(I->Ty->get());
3479 if (I->Ty->get() != Type::VoidTy)
3480 Attrs.push_back(I->Attrs);
3481 }
Reid Spencer3da59db2006-11-27 01:05:10 +00003482 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3483 if (isVarArg) Params.pop_back();
3484
Reid Spencer14310612006-12-31 05:40:51 +00003485 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs);
Reid Spencer218ded22007-01-05 17:07:23 +00003486 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
Reid Spencer14310612006-12-31 05:40:51 +00003487 delete (yyvsp[-4].TypeVal); // Delete the return type handle
3488 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003489 CHECK_FOR_ERROR
3490 ;}
3491 break;
3492
Reid Spencer218ded22007-01-05 17:07:23 +00003493 case 122:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003494#line 1233 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003495 {
3496 std::vector<const Type*> Params;
3497 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer218ded22007-01-05 17:07:23 +00003498 Attrs.push_back((yyvsp[0].ParamAttrs));
3499 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00003500 Params.push_back(I->Ty->get());
3501 if (I->Ty->get() != Type::VoidTy)
3502 Attrs.push_back(I->Attrs);
3503 }
3504 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3505 if (isVarArg) Params.pop_back();
3506
3507 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs);
Reid Spencer218ded22007-01-05 17:07:23 +00003508 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
Reid Spencer14310612006-12-31 05:40:51 +00003509 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
3510 CHECK_FOR_ERROR
3511 ;}
3512 break;
3513
Reid Spencer218ded22007-01-05 17:07:23 +00003514 case 123:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003515#line 1251 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003516 { // Sized array type?
3517 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3518 delete (yyvsp[-1].TypeVal);
3519 CHECK_FOR_ERROR
3520 ;}
3521 break;
3522
Reid Spencer218ded22007-01-05 17:07:23 +00003523 case 124:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003524#line 1256 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003525 { // Packed array type?
3526 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3527 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
3528 GEN_ERROR("Unsigned result not equal to signed result");
3529 if (!ElemTy->isPrimitiveType())
3530 GEN_ERROR("Elemental type of a PackedType must be primitive");
3531 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
3532 GEN_ERROR("Vector length should be a power of 2!");
3533 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3534 delete (yyvsp[-1].TypeVal);
3535 CHECK_FOR_ERROR
3536 ;}
3537 break;
3538
Reid Spencer218ded22007-01-05 17:07:23 +00003539 case 125:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003540#line 1268 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003541 { // Structure type?
3542 std::vector<const Type*> Elements;
3543 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3544 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
3545 Elements.push_back(*I);
3546
3547 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3548 delete (yyvsp[-1].TypeList);
3549 CHECK_FOR_ERROR
3550 ;}
3551 break;
3552
Reid Spencer218ded22007-01-05 17:07:23 +00003553 case 126:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003554#line 1278 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003555 { // Empty structure type?
3556 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
3557 CHECK_FOR_ERROR
3558 ;}
3559 break;
3560
Reid Spencer218ded22007-01-05 17:07:23 +00003561 case 127:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003562#line 1282 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003563 {
3564 std::vector<const Type*> Elements;
3565 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3566 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
3567 Elements.push_back(*I);
3568
3569 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3570 delete (yyvsp[-2].TypeList);
3571 CHECK_FOR_ERROR
3572 ;}
3573 break;
3574
Reid Spencer218ded22007-01-05 17:07:23 +00003575 case 128:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003576#line 1292 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003577 { // Empty structure type?
3578 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
3579 CHECK_FOR_ERROR
3580 ;}
3581 break;
3582
Reid Spencer218ded22007-01-05 17:07:23 +00003583 case 129:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003584#line 1299 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003585 {
3586 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3587 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
3588 ;}
3589 break;
3590
Reid Spencer14310612006-12-31 05:40:51 +00003591 case 130:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003592#line 1306 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003593 {
Reid Spencer218ded22007-01-05 17:07:23 +00003594 if (!UpRefs.empty())
3595 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3596 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
3597 GEN_ERROR("LLVM functions cannot return aggregate types!");
3598 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer14310612006-12-31 05:40:51 +00003599 ;}
3600 break;
3601
3602 case 131:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003603#line 1313 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00003604 {
3605 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3606 ;}
3607 break;
3608
3609 case 132:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003610#line 1318 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003611 {
3612 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3613 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
3614 CHECK_FOR_ERROR
3615 ;}
3616 break;
3617
Reid Spencer218ded22007-01-05 17:07:23 +00003618 case 133:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003619#line 1323 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003620 {
3621 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
3622 CHECK_FOR_ERROR
3623 ;}
3624 break;
3625
Reid Spencer218ded22007-01-05 17:07:23 +00003626 case 135:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003627#line 1331 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003628 {
3629 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
3630 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3631 TWA.Ty = new PATypeHolder(Type::VoidTy);
3632 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003633 CHECK_FOR_ERROR
3634 ;}
3635 break;
3636
Reid Spencer218ded22007-01-05 17:07:23 +00003637 case 136:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003638#line 1338 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003639 {
3640 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
3641 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3642 TWA.Ty = new PATypeHolder(Type::VoidTy);
3643 (yyval.TypeWithAttrsList)->push_back(TWA);
3644 CHECK_FOR_ERROR
3645 ;}
3646 break;
3647
Reid Spencer218ded22007-01-05 17:07:23 +00003648 case 137:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003649#line 1345 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00003650 {
3651 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3652 CHECK_FOR_ERROR
3653 ;}
3654 break;
3655
Reid Spencer218ded22007-01-05 17:07:23 +00003656 case 138:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003657#line 1353 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003658 {
3659 (yyval.TypeList) = new std::list<PATypeHolder>();
3660 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003661 CHECK_FOR_ERROR
3662 ;}
3663 break;
3664
Reid Spencer218ded22007-01-05 17:07:23 +00003665 case 139:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003666#line 1358 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003667 {
3668 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003669 CHECK_FOR_ERROR
3670 ;}
3671 break;
3672
Reid Spencer218ded22007-01-05 17:07:23 +00003673 case 140:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003674#line 1369 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003675 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003676 if (!UpRefs.empty())
3677 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003678 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
3679 if (ATy == 0)
3680 GEN_ERROR("Cannot make array constant with type: '" +
3681 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
3682 const Type *ETy = ATy->getElementType();
3683 int NumElements = ATy->getNumElements();
3684
3685 // Verify that we have the correct size...
3686 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
3687 GEN_ERROR("Type mismatch: constant sized array initialized with " +
3688 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
3689 itostr(NumElements) + "!");
3690
3691 // Verify all elements are correct type!
3692 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3693 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
3694 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3695 ETy->getDescription() +"' as required!\nIt is of type '"+
3696 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
3697 }
3698
3699 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3700 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer3da59db2006-11-27 01:05:10 +00003701 CHECK_FOR_ERROR
3702 ;}
3703 break;
3704
Reid Spencer218ded22007-01-05 17:07:23 +00003705 case 141:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003706#line 1397 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003707 {
Reid Spencer14310612006-12-31 05:40:51 +00003708 if (!UpRefs.empty())
3709 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003710 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003711 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003712 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003713 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003714
Andrew Lenharth6353e052006-12-08 18:07:09 +00003715 int NumElements = ATy->getNumElements();
3716 if (NumElements != -1 && NumElements != 0)
3717 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
3718 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003719 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3720 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003721 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003722 ;}
3723 break;
3724
Reid Spencer218ded22007-01-05 17:07:23 +00003725 case 142:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003726#line 1413 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003727 {
Reid Spencer14310612006-12-31 05:40:51 +00003728 if (!UpRefs.empty())
3729 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003730 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003731 if (ATy == 0)
3732 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003733 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003734
Andrew Lenharth6353e052006-12-08 18:07:09 +00003735 int NumElements = ATy->getNumElements();
3736 const Type *ETy = ATy->getElementType();
Reid Spencere4d87aa2006-12-23 06:05:41 +00003737 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3738 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003739 GEN_ERROR("Can't build string constant of size " +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003740 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Andrew Lenharth6353e052006-12-08 18:07:09 +00003741 " when array has size " + itostr(NumElements) + "!");
3742 std::vector<Constant*> Vals;
Reid Spencer14310612006-12-31 05:40:51 +00003743 if (ETy == Type::Int8Ty) {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003744 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Reid Spencer14310612006-12-31 05:40:51 +00003745 C != (unsigned char*)EndStr; ++C)
3746 Vals.push_back(ConstantInt::get(ETy, *C));
Andrew Lenharth6353e052006-12-08 18:07:09 +00003747 } else {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003748 free((yyvsp[0].StrVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00003749 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
3750 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00003751 free((yyvsp[0].StrVal));
3752 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3753 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003754 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003755 ;}
3756 break;
3757
Reid Spencer218ded22007-01-05 17:07:23 +00003758 case 143:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003759#line 1442 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003760 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003761 if (!UpRefs.empty())
3762 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003763 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003764 if (PTy == 0)
3765 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003766 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003767 const Type *ETy = PTy->getElementType();
3768 int NumElements = PTy->getNumElements();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003769
Andrew Lenharth6353e052006-12-08 18:07:09 +00003770 // Verify that we have the correct size...
Reid Spencere4d87aa2006-12-23 06:05:41 +00003771 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003772 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003773 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Andrew Lenharth6353e052006-12-08 18:07:09 +00003774 itostr(NumElements) + "!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003775
Andrew Lenharth6353e052006-12-08 18:07:09 +00003776 // Verify all elements are correct type!
Reid Spencere4d87aa2006-12-23 06:05:41 +00003777 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3778 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003779 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3780 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencere4d87aa2006-12-23 06:05:41 +00003781 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003782 }
3783
Reid Spencere4d87aa2006-12-23 06:05:41 +00003784 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3785 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003786 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003787 ;}
3788 break;
3789
Reid Spencer218ded22007-01-05 17:07:23 +00003790 case 144:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003791#line 1470 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003792 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003793 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003794 if (STy == 0)
3795 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003796 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003797
Reid Spencere4d87aa2006-12-23 06:05:41 +00003798 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003799 GEN_ERROR("Illegal number of initializers for structure type!");
3800
3801 // Check to ensure that constants are compatible with the type initializer!
Reid Spencere4d87aa2006-12-23 06:05:41 +00003802 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3803 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003804 GEN_ERROR("Expected type '" +
3805 STy->getElementType(i)->getDescription() +
3806 "' for element #" + utostr(i) +
3807 " of structure initializer!");
3808
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003809 // Check to ensure that Type is not packed
3810 if (STy->isPacked())
3811 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3812
Reid Spencere4d87aa2006-12-23 06:05:41 +00003813 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3814 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003815 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003816 ;}
3817 break;
3818
Reid Spencer218ded22007-01-05 17:07:23 +00003819 case 145:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003820#line 1495 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003821 {
Reid Spencer14310612006-12-31 05:40:51 +00003822 if (!UpRefs.empty())
3823 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003824 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003825 if (STy == 0)
3826 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003827 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003828
3829 if (STy->getNumContainedTypes() != 0)
3830 GEN_ERROR("Illegal number of initializers for structure type!");
3831
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003832 // Check to ensure that Type is not packed
3833 if (STy->isPacked())
3834 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3835
Reid Spencere4d87aa2006-12-23 06:05:41 +00003836 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3837 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003838 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003839 ;}
3840 break;
3841
Reid Spencer218ded22007-01-05 17:07:23 +00003842 case 146:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003843#line 1514 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3844 {
3845 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
3846 if (STy == 0)
3847 GEN_ERROR("Cannot make struct constant with type: '" +
3848 (*(yyvsp[-5].TypeVal))->getDescription() + "'!");
3849
3850 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
3851 GEN_ERROR("Illegal number of initializers for structure type!");
3852
3853 // Check to ensure that constants are compatible with the type initializer!
3854 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
3855 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
3856 GEN_ERROR("Expected type '" +
3857 STy->getElementType(i)->getDescription() +
3858 "' for element #" + utostr(i) +
3859 " of structure initializer!");
3860
3861 // Check to ensure that Type is packed
3862 if (!STy->isPacked())
3863 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3864
3865 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
3866 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
3867 CHECK_FOR_ERROR
3868 ;}
3869 break;
3870
3871 case 147:
3872#line 1539 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3873 {
3874 if (!UpRefs.empty())
3875 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
3876 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
3877 if (STy == 0)
3878 GEN_ERROR("Cannot make struct constant with type: '" +
3879 (*(yyvsp[-4].TypeVal))->getDescription() + "'!");
3880
3881 if (STy->getNumContainedTypes() != 0)
3882 GEN_ERROR("Illegal number of initializers for structure type!");
3883
3884 // Check to ensure that Type is packed
3885 if (!STy->isPacked())
3886 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3887
3888 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3889 delete (yyvsp[-4].TypeVal);
3890 CHECK_FOR_ERROR
3891 ;}
3892 break;
3893
3894 case 148:
3895#line 1558 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003896 {
Reid Spencer14310612006-12-31 05:40:51 +00003897 if (!UpRefs.empty())
3898 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003899 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003900 if (PTy == 0)
3901 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003902 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003903
Reid Spencere4d87aa2006-12-23 06:05:41 +00003904 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3905 delete (yyvsp[-1].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003906 CHECK_FOR_ERROR
3907 ;}
3908 break;
3909
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003910 case 149:
3911#line 1570 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003912 {
Reid Spencer14310612006-12-31 05:40:51 +00003913 if (!UpRefs.empty())
3914 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003915 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3916 delete (yyvsp[-1].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003917 CHECK_FOR_ERROR
3918 ;}
3919 break;
3920
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003921 case 150:
3922#line 1577 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00003923 {
Reid Spencer14310612006-12-31 05:40:51 +00003924 if (!UpRefs.empty())
3925 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003926 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003927 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003928 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003929
3930 // ConstExprs can exist in the body of a function, thus creating
3931 // GlobalValues whenever they refer to a variable. Because we are in
3932 // the context of a function, getValNonImprovising will search the functions
3933 // symbol table instead of the module symbol table for the global symbol,
3934 // which throws things all off. To get around this, we just tell
3935 // getValNonImprovising that we are at global scope here.
3936 //
3937 Function *SavedCurFn = CurFun.CurrentFunction;
3938 CurFun.CurrentFunction = 0;
3939
Reid Spencere4d87aa2006-12-23 06:05:41 +00003940 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003941 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003942
3943 CurFun.CurrentFunction = SavedCurFn;
3944
3945 // If this is an initializer for a constant pointer, which is referencing a
3946 // (currently) undefined variable, create a stub now that shall be replaced
3947 // in the future with the right type of variable.
3948 //
3949 if (V == 0) {
3950 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3951 const PointerType *PT = cast<PointerType>(Ty);
3952
3953 // First check to see if the forward references value is already created!
3954 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencere4d87aa2006-12-23 06:05:41 +00003955 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003956
3957 if (I != CurModule.GlobalRefs.end()) {
3958 V = I->second; // Placeholder already exists, use it...
Reid Spencere4d87aa2006-12-23 06:05:41 +00003959 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003960 } else {
3961 std::string Name;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003962 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003963
3964 // Create the forward referenced global.
3965 GlobalValue *GV;
3966 if (const FunctionType *FTy =
3967 dyn_cast<FunctionType>(PT->getElementType())) {
3968 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3969 CurModule.CurrentModule);
3970 } else {
3971 GV = new GlobalVariable(PT->getElementType(), false,
3972 GlobalValue::ExternalLinkage, 0,
3973 Name, CurModule.CurrentModule);
3974 }
3975
3976 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencere4d87aa2006-12-23 06:05:41 +00003977 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003978 V = GV;
3979 }
3980 }
3981
Reid Spencere4d87aa2006-12-23 06:05:41 +00003982 (yyval.ConstVal) = cast<GlobalValue>(V);
3983 delete (yyvsp[-1].TypeVal); // Free the type handle
3984 CHECK_FOR_ERROR
3985 ;}
3986 break;
3987
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003988 case 151:
3989#line 1640 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00003990 {
Reid Spencer14310612006-12-31 05:40:51 +00003991 if (!UpRefs.empty())
3992 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003993 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Reid Spencere68853b2007-01-04 00:06:14 +00003994 GEN_ERROR("Mismatched types for constant expression: " +
3995 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003996 (yyval.ConstVal) = (yyvsp[0].ConstVal);
3997 delete (yyvsp[-1].TypeVal);
3998 CHECK_FOR_ERROR
3999 ;}
4000 break;
4001
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004002 case 152:
4003#line 1650 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004004 {
Reid Spencer14310612006-12-31 05:40:51 +00004005 if (!UpRefs.empty())
4006 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004007 const Type *Ty = (yyvsp[-1].TypeVal)->get();
4008 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4009 GEN_ERROR("Cannot create a null initialized value of this type!");
4010 (yyval.ConstVal) = Constant::getNullValue(Ty);
4011 delete (yyvsp[-1].TypeVal);
4012 CHECK_FOR_ERROR
4013 ;}
4014 break;
4015
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004016 case 153:
4017#line 1660 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00004018 { // integral constants
4019 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
4020 GEN_ERROR("Constant value doesn't fit in type!");
4021 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
4022 CHECK_FOR_ERROR
4023 ;}
4024 break;
4025
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004026 case 154:
4027#line 1666 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00004028 { // integral constants
4029 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
4030 GEN_ERROR("Constant value doesn't fit in type!");
4031 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
4032 CHECK_FOR_ERROR
4033 ;}
4034 break;
4035
Reid Spencer218ded22007-01-05 17:07:23 +00004036 case 155:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004037#line 1672 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4038 { // Boolean constants
4039 (yyval.ConstVal) = ConstantInt::getTrue();
4040 CHECK_FOR_ERROR
4041 ;}
4042 break;
4043
4044 case 156:
4045#line 1676 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4046 { // Boolean constants
4047 (yyval.ConstVal) = ConstantInt::getFalse();
4048 CHECK_FOR_ERROR
4049 ;}
4050 break;
4051
4052 case 157:
4053#line 1680 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004054 { // Float & Double constants
4055 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
4056 GEN_ERROR("Floating point constant invalid for type!!");
4057 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004058 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004059 ;}
4060 break;
4061
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004062 case 158:
4063#line 1688 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004064 {
Reid Spencer14310612006-12-31 05:40:51 +00004065 if (!UpRefs.empty())
4066 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004067 Constant *Val = (yyvsp[-3].ConstVal);
4068 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer3da59db2006-11-27 01:05:10 +00004069 if (!Val->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004070 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00004071 Val->getType()->getDescription() + "'!");
4072 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004073 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00004074 Ty->getDescription() + "'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004075 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get());
4076 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004077 ;}
4078 break;
4079
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004080 case 159:
4081#line 1702 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004082 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004083 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00004084 GEN_ERROR("GetElementPtr requires a pointer operand!");
4085
4086 const Type *IdxTy =
Reid Spencere4d87aa2006-12-23 06:05:41 +00004087 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004088 if (!IdxTy)
4089 GEN_ERROR("Index list invalid for constant getelementptr!");
4090
4091 std::vector<Constant*> IdxVec;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004092 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4093 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Andrew Lenharth6353e052006-12-08 18:07:09 +00004094 IdxVec.push_back(C);
4095 else
4096 GEN_ERROR("Indices to constant getelementptr must be constants!");
4097
Reid Spencere4d87aa2006-12-23 06:05:41 +00004098 delete (yyvsp[-1].ValueList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004099
Reid Spencere4d87aa2006-12-23 06:05:41 +00004100 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
4101 CHECK_FOR_ERROR
4102 ;}
4103 break;
4104
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004105 case 160:
4106#line 1723 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004107 {
4108 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
4109 GEN_ERROR("Select condition must be of boolean type!");
4110 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
4111 GEN_ERROR("Select operand types must match!");
4112 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4113 CHECK_FOR_ERROR
4114 ;}
4115 break;
4116
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004117 case 161:
4118#line 1731 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004119 {
4120 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
4121 GEN_ERROR("Binary operator types must match!");
4122 CHECK_FOR_ERROR;
4123 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4124 ;}
4125 break;
4126
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004127 case 162:
4128#line 1737 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004129 {
4130 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
4131 GEN_ERROR("Logical operator types must match!");
4132 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
4133 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
4134 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
4135 GEN_ERROR("Logical operator requires integral operands!");
4136 }
4137 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4138 CHECK_FOR_ERROR
4139 ;}
4140 break;
4141
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004142 case 163:
4143#line 1748 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004144 {
4145 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
4146 GEN_ERROR("icmp operand types must match!");
4147 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4148 ;}
4149 break;
4150
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004151 case 164:
4152#line 1753 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004153 {
4154 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
4155 GEN_ERROR("fcmp operand types must match!");
4156 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4157 ;}
4158 break;
4159
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004160 case 165:
4161#line 1758 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004162 {
Reid Spencer14310612006-12-31 05:40:51 +00004163 if ((yyvsp[-1].ConstVal)->getType() != Type::Int8Ty)
4164 GEN_ERROR("Shift count for shift constant must be i8 type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004165 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
4166 GEN_ERROR("Shift constant expression requires integer operand!");
4167 CHECK_FOR_ERROR;
4168 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004169 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004170 ;}
4171 break;
4172
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004173 case 166:
4174#line 1767 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004175 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004176 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
4177 GEN_ERROR("Invalid extractelement operands!");
4178 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004179 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004180 ;}
4181 break;
4182
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004183 case 167:
4184#line 1773 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004185 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004186 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
4187 GEN_ERROR("Invalid insertelement operands!");
4188 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4189 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004190 ;}
4191 break;
4192
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004193 case 168:
4194#line 1779 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004195 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004196 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
4197 GEN_ERROR("Invalid shufflevector operands!");
4198 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004199 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00004200 ;}
4201 break;
4202
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004203 case 169:
4204#line 1788 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00004205 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004206 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004207 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00004208 ;}
4209 break;
4210
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004211 case 170:
4212#line 1792 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00004213 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004214 (yyval.ConstVector) = new std::vector<Constant*>();
4215 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
4216 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004217 ;}
4218 break;
4219
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004220 case 171:
4221#line 1800 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004222 { (yyval.BoolVal) = false; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004223 break;
4224
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004225 case 172:
4226#line 1800 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004227 { (yyval.BoolVal) = true; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004228 break;
4229
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004230 case 173:
4231#line 1811 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00004232 {
4233 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4234 CurModule.ModuleDone();
4235 CHECK_FOR_ERROR;
4236 ;}
4237 break;
4238
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004239 case 174:
4240#line 1816 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00004241 {
4242 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4243 CurModule.ModuleDone();
4244 CHECK_FOR_ERROR;
4245 ;}
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004246 break;
4247
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004248 case 177:
4249#line 1829 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00004250 { CurFun.isDeclare = false ;}
4251 break;
4252
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004253 case 178:
4254#line 1829 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004255 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004256 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004257 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004258 ;}
4259 break;
4260
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004261 case 179:
4262#line 1833 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004263 { CurFun.isDeclare = true; ;}
4264 break;
4265
Reid Spencer218ded22007-01-05 17:07:23 +00004266 case 180:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004267#line 1833 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4268 {
4269 CHECK_FOR_ERROR
4270 ;}
4271 break;
4272
4273 case 181:
4274#line 1836 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4275 {
4276 CHECK_FOR_ERROR
4277 ;}
4278 break;
4279
4280 case 182:
4281#line 1839 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004282 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004283 // Emit an error if there are any unresolved types left.
4284 if (!CurModule.LateResolveTypes.empty()) {
4285 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00004286 if (DID.Type == ValID::NameVal) {
4287 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4288 } else {
4289 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4290 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004291 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004292 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004293 ;}
4294 break;
4295
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004296 case 183:
4297#line 1851 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004298 {
Reid Spencer14310612006-12-31 05:40:51 +00004299 if (!UpRefs.empty())
4300 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004301 // Eagerly resolve types. This is not an optimization, this is a
4302 // requirement that is due to the fact that we could have this:
4303 //
4304 // %list = type { %list * }
4305 // %list = type { %list * } ; repeated type decl
4306 //
4307 // If types are not resolved eagerly, then the two types will not be
4308 // determined to be the same type!
4309 //
Reid Spencere4d87aa2006-12-23 06:05:41 +00004310 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004311
Reid Spencere4d87aa2006-12-23 06:05:41 +00004312 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004313 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004314 // If this is a named type that is not a redefinition, add it to the slot
4315 // table.
Reid Spencere4d87aa2006-12-23 06:05:41 +00004316 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004317 }
Reid Spencera132e042006-12-03 05:46:11 +00004318
Reid Spencere4d87aa2006-12-23 06:05:41 +00004319 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004320 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004321 ;}
4322 break;
4323
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004324 case 184:
4325#line 1875 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00004326 {
4327 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
4328
4329 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
4330 CHECK_FOR_ERROR
4331 // If this is a named type that is not a redefinition, add it to the slot
4332 // table.
4333 CurModule.Types.push_back((yyvsp[0].PrimType));
4334 }
4335 CHECK_FOR_ERROR
4336 ;}
4337 break;
4338
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004339 case 185:
4340#line 1886 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004341 { /* "Externally Visible" Linkage */
4342 if ((yyvsp[0].ConstVal) == 0)
4343 GEN_ERROR("Global value initializer is not a constant!");
4344 CurGV = ParseGlobalVariable((yyvsp[-2].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal),
4345 (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004346 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004347 ;}
4348 break;
4349
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004350 case 186:
4351#line 1892 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004352 {
4353 CurGV = 0;
Reid Spencer3822ff52006-11-08 06:47:33 +00004354 ;}
4355 break;
4356
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004357 case 187:
4358#line 1895 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004359 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004360 if ((yyvsp[0].ConstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004361 GEN_ERROR("Global value initializer is not a constant!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004362 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
4363 CHECK_FOR_ERROR
4364 ;}
4365 break;
4366
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004367 case 188:
4368#line 1900 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004369 {
4370 CurGV = 0;
4371 ;}
4372 break;
4373
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004374 case 189:
4375#line 1903 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004376 {
Reid Spencer14310612006-12-31 05:40:51 +00004377 if (!UpRefs.empty())
4378 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004379 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004380 CHECK_FOR_ERROR
4381 delete (yyvsp[0].TypeVal);
4382 ;}
4383 break;
4384
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004385 case 190:
4386#line 1909 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004387 {
4388 CurGV = 0;
4389 CHECK_FOR_ERROR
4390 ;}
4391 break;
4392
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004393 case 191:
4394#line 1913 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00004395 {
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004396 CHECK_FOR_ERROR
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004397 ;}
4398 break;
4399
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004400 case 192:
4401#line 1916 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004402 {
Reid Spencer218ded22007-01-05 17:07:23 +00004403 CHECK_FOR_ERROR
4404 ;}
4405 break;
4406
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004407 case 193:
4408#line 1922 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer218ded22007-01-05 17:07:23 +00004409 {
Chris Lattner66316012006-01-24 04:14:29 +00004410 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencere4d87aa2006-12-23 06:05:41 +00004411 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4412 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4413 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004414
4415 if (AsmSoFar.empty())
4416 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4417 else
4418 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004419 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004420;}
4421 break;
4422
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004423 case 194:
4424#line 1935 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004425 { (yyval.Endianness) = Module::BigEndian; ;}
4426 break;
4427
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004428 case 195:
4429#line 1936 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004430 { (yyval.Endianness) = Module::LittleEndian; ;}
4431 break;
4432
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004433 case 196:
4434#line 1938 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004435 {
4436 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
4437 CHECK_FOR_ERROR
4438 ;}
4439 break;
4440
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004441 case 197:
4442#line 1942 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004443 {
4444 if ((yyvsp[0].UInt64Val) == 32)
4445 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
4446 else if ((yyvsp[0].UInt64Val) == 64)
4447 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4448 else
4449 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
4450 CHECK_FOR_ERROR
4451 ;}
4452 break;
4453
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004454 case 198:
4455#line 1951 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004456 {
4457 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4458 free((yyvsp[0].StrVal));
4459 ;}
4460 break;
4461
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004462 case 199:
4463#line 1955 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004464 {
4465 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4466 free((yyvsp[0].StrVal));
4467 ;}
4468 break;
4469
Reid Spencer218ded22007-01-05 17:07:23 +00004470 case 201:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004471#line 1962 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4472 {
4473 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4474 free((yyvsp[0].StrVal));
4475 CHECK_FOR_ERROR
4476 ;}
4477 break;
4478
4479 case 202:
4480#line 1967 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4481 {
4482 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4483 free((yyvsp[0].StrVal));
4484 CHECK_FOR_ERROR
4485 ;}
4486 break;
4487
4488 case 203:
4489#line 1972 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004490 {
4491 CHECK_FOR_ERROR
4492 ;}
4493 break;
4494
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004495 case 207:
4496#line 1982 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004497 { (yyval.StrVal) = 0; ;}
4498 break;
4499
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004500 case 208:
4501#line 1984 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004502 {
Reid Spencer14310612006-12-31 05:40:51 +00004503 if (!UpRefs.empty())
4504 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4505 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
4506 GEN_ERROR("void typed arguments are invalid!");
4507 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4508 (yyval.ArgList) = (yyvsp[-4].ArgList);
4509 (yyvsp[-4].ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004510 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004511 ;}
4512 break;
4513
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004514 case 209:
4515#line 1994 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004516 {
Reid Spencer14310612006-12-31 05:40:51 +00004517 if (!UpRefs.empty())
4518 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4519 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
4520 GEN_ERROR("void typed arguments are invalid!");
4521 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4522 (yyval.ArgList) = new ArgListType;
4523 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004524 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004525 ;}
4526 break;
4527
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004528 case 210:
4529#line 2005 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004530 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004531 (yyval.ArgList) = (yyvsp[0].ArgList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004532 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004533 ;}
4534 break;
4535
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004536 case 211:
4537#line 2009 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004538 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004539 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer14310612006-12-31 05:40:51 +00004540 struct ArgListEntry E;
4541 E.Ty = new PATypeHolder(Type::VoidTy);
4542 E.Name = 0;
4543 E.Attrs = FunctionType::NoAttributeSet;
4544 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004545 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004546 ;}
4547 break;
4548
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004549 case 212:
4550#line 2018 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004551 {
Reid Spencer14310612006-12-31 05:40:51 +00004552 (yyval.ArgList) = new ArgListType;
4553 struct ArgListEntry E;
4554 E.Ty = new PATypeHolder(Type::VoidTy);
4555 E.Name = 0;
4556 E.Attrs = FunctionType::NoAttributeSet;
4557 (yyval.ArgList)->push_back(E);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004558 CHECK_FOR_ERROR
4559 ;}
4560 break;
4561
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004562 case 213:
4563#line 2027 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004564 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004565 (yyval.ArgList) = 0;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004566 CHECK_FOR_ERROR
4567 ;}
4568 break;
4569
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004570 case 214:
4571#line 2033 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004572 {
Reid Spencer218ded22007-01-05 17:07:23 +00004573 UnEscapeLexed((yyvsp[-6].StrVal));
4574 std::string FunctionName((yyvsp[-6].StrVal));
4575 free((yyvsp[-6].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004576
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004577 // Check the function result for abstractness if this is a define. We should
4578 // have no abstract types at this point
Reid Spencer218ded22007-01-05 17:07:23 +00004579 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4580 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004581
Reid Spencer68a24bd2005-08-27 18:50:39 +00004582 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00004583 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Reid Spencer218ded22007-01-05 17:07:23 +00004584 ParamAttrs.push_back((yyvsp[-2].ParamAttrs));
4585 if ((yyvsp[-4].ArgList)) { // If there are arguments...
4586 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004587 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004588 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4589 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004590 ParamTypeList.push_back(Ty);
4591 if (Ty != Type::VoidTy)
4592 ParamAttrs.push_back(I->Attrs);
4593 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004594 }
4595
4596 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4597 if (isVarArg) ParamTypeList.pop_back();
4598
Reid Spencer218ded22007-01-05 17:07:23 +00004599 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00004600 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004601 const PointerType *PFT = PointerType::get(FT);
Reid Spencer218ded22007-01-05 17:07:23 +00004602 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004603
4604 ValID ID;
4605 if (!FunctionName.empty()) {
4606 ID = ValID::create((char*)FunctionName.c_str());
4607 } else {
4608 ID = ValID::create((int)CurModule.Values[PFT].size());
4609 }
4610
4611 Function *Fn = 0;
4612 // See if this function was forward referenced. If so, recycle the object.
4613 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4614 // Move the function to the end of the list, from whereever it was
4615 // previously inserted.
4616 Fn = cast<Function>(FWRef);
4617 CurModule.CurrentModule->getFunctionList().remove(Fn);
4618 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4619 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4620 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4621 // If this is the case, either we need to be a forward decl, or it needs
4622 // to be.
4623 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004624 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004625
4626 // Make sure to strip off any argument names so we can't get conflicts.
4627 if (Fn->isExternal())
4628 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4629 AI != AE; ++AI)
4630 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004631 } else { // Not already defined?
4632 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4633 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004634
Reid Spencer68a24bd2005-08-27 18:50:39 +00004635 InsertValue(Fn, CurModule.Values);
4636 }
4637
4638 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004639
4640 if (CurFun.isDeclare) {
4641 // If we have declaration, always overwrite linkage. This will allow us to
4642 // correctly handle cases, when pointer to function is passed as argument to
4643 // another function.
4644 Fn->setLinkage(CurFun.Linkage);
4645 }
Reid Spencer218ded22007-01-05 17:07:23 +00004646 Fn->setCallingConv((yyvsp[-8].UIntVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004647 Fn->setAlignment((yyvsp[0].UIntVal));
4648 if ((yyvsp[-1].StrVal)) {
4649 Fn->setSection((yyvsp[-1].StrVal));
4650 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004651 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004652
4653 // Add all of the arguments we parsed to the function...
Reid Spencer218ded22007-01-05 17:07:23 +00004654 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004655 if (isVarArg) { // Nuke the last entry
Reid Spencer218ded22007-01-05 17:07:23 +00004656 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0&&
Reid Spencera132e042006-12-03 05:46:11 +00004657 "Not a varargs marker!");
Reid Spencer218ded22007-01-05 17:07:23 +00004658 delete (yyvsp[-4].ArgList)->back().Ty;
4659 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004660 }
4661 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer14310612006-12-31 05:40:51 +00004662 unsigned Idx = 1;
Reid Spencer218ded22007-01-05 17:07:23 +00004663 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004664 delete I->Ty; // Delete the typeholder...
4665 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004666 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004667 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004668 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004669 }
Reid Spencera132e042006-12-03 05:46:11 +00004670
Reid Spencer218ded22007-01-05 17:07:23 +00004671 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004672 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004673 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004674;}
4675 break;
4676
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004677 case 217:
4678#line 2139 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004679 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004680 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004681
4682 // Make sure that we keep track of the linkage type even if there was a
4683 // previous "declare".
Reid Spencere4d87aa2006-12-23 06:05:41 +00004684 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
Reid Spencer3822ff52006-11-08 06:47:33 +00004685;}
4686 break;
4687
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004688 case 220:
4689#line 2149 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004690 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004691 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004692 CHECK_FOR_ERROR
4693;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004694 break;
4695
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004696 case 221:
4697#line 2154 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004698 {
Reid Spencer14310612006-12-31 05:40:51 +00004699 CurFun.CurrentFunction->setLinkage((yyvsp[-1].Linkage));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004700 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004701 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004702 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004703 ;}
4704 break;
4705
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004706 case 222:
4707#line 2165 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004708 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004709 (yyval.BoolVal) = false;
4710 CHECK_FOR_ERROR
4711 ;}
4712 break;
4713
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004714 case 223:
4715#line 2169 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004716 {
4717 (yyval.BoolVal) = true;
4718 CHECK_FOR_ERROR
4719 ;}
4720 break;
4721
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004722 case 224:
4723#line 2174 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004724 { // A reference to a direct constant
4725 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
4726 CHECK_FOR_ERROR
4727 ;}
4728 break;
4729
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004730 case 225:
4731#line 2178 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004732 {
4733 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
4734 CHECK_FOR_ERROR
4735 ;}
4736 break;
4737
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004738 case 226:
4739#line 2182 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004740 { // Perhaps it's an FP constant?
4741 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
4742 CHECK_FOR_ERROR
4743 ;}
4744 break;
4745
Reid Spencer218ded22007-01-05 17:07:23 +00004746 case 227:
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004747#line 2186 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4748 {
4749 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
4750 CHECK_FOR_ERROR
4751 ;}
4752 break;
4753
4754 case 228:
4755#line 2190 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4756 {
4757 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
4758 CHECK_FOR_ERROR
4759 ;}
4760 break;
4761
4762 case 229:
4763#line 2194 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004764 {
4765 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004766 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004767 ;}
4768 break;
4769
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004770 case 230:
4771#line 2198 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004772 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004773 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004774 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004775 ;}
4776 break;
4777
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004778 case 231:
4779#line 2202 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004780 { // A vector zero constant.
4781 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004782 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004783 ;}
4784 break;
4785
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004786 case 232:
4787#line 2206 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004788 { // Nonempty unsized packed vector
Reid Spencere4d87aa2006-12-23 06:05:41 +00004789 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4790 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004791
4792 PackedType* pt = PackedType::get(ETy, NumElements);
4793 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004794 HandleUpRefs(
4795 PackedType::get(
4796 ETy,
4797 NumElements)
4798 )
4799 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004800
4801 // Verify all elements are correct type!
Reid Spencere4d87aa2006-12-23 06:05:41 +00004802 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4803 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004804 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004805 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00004806 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004807 }
4808
Reid Spencere4d87aa2006-12-23 06:05:41 +00004809 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4810 delete PTy; delete (yyvsp[-1].ConstVector);
4811 CHECK_FOR_ERROR
4812 ;}
4813 break;
4814
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004815 case 233:
4816#line 2231 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004817 {
4818 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
4819 CHECK_FOR_ERROR
4820 ;}
4821 break;
4822
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004823 case 234:
4824#line 2235 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004825 {
4826 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4827 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4828 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4829 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4830 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4831 free((yyvsp[-2].StrVal));
4832 free((yyvsp[0].StrVal));
4833 CHECK_FOR_ERROR
4834 ;}
4835 break;
4836
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004837 case 235:
4838#line 2249 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004839 { // Is it an integer reference...?
4840 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4841 CHECK_FOR_ERROR
4842 ;}
4843 break;
4844
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004845 case 236:
4846#line 2253 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004847 { // Is it a named reference...?
4848 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4849 CHECK_FOR_ERROR
4850 ;}
4851 break;
4852
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004853 case 239:
4854#line 2265 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004855 {
Reid Spencer14310612006-12-31 05:40:51 +00004856 if (!UpRefs.empty())
4857 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4858 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
4859 delete (yyvsp[-1].TypeVal);
Reid Spencer21be8652006-10-22 07:03:43 +00004860 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004861 ;}
4862 break;
4863
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004864 case 240:
4865#line 2274 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004866 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004867 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004868 CHECK_FOR_ERROR
4869 ;}
4870 break;
4871
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004872 case 241:
4873#line 2278 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004874 { // Do not allow functions with 0 basic blocks
4875 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004876 CHECK_FOR_ERROR
4877 ;}
4878 break;
4879
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004880 case 242:
4881#line 2287 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004882 {
4883 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4884 CHECK_FOR_ERROR
4885 InsertValue((yyvsp[0].TermInstVal));
4886
4887 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4888 InsertValue((yyvsp[-2].BasicBlockVal));
4889 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004890 CHECK_FOR_ERROR
4891 ;}
4892 break;
4893
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004894 case 243:
4895#line 2298 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004896 {
4897 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
4898 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4899 if (CI2->getParent() == 0)
4900 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
4901 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4902 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
4903 CHECK_FOR_ERROR
4904 ;}
4905 break;
4906
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004907 case 244:
4908#line 2307 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004909 {
4910 (yyval.BasicBlockVal) = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
4911 CHECK_FOR_ERROR
4912
4913 // Make sure to move the basic block to the correct location in the
4914 // function, instead of leaving it inserted wherever it was first
4915 // referenced.
4916 Function::BasicBlockListType &BBL =
4917 CurFun.CurrentFunction->getBasicBlockList();
4918 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
4919 CHECK_FOR_ERROR
4920 ;}
4921 break;
4922
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004923 case 245:
4924#line 2319 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004925 {
4926 (yyval.BasicBlockVal) = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
4927 CHECK_FOR_ERROR
4928
4929 // Make sure to move the basic block to the correct location in the
4930 // function, instead of leaving it inserted wherever it was first
4931 // referenced.
4932 Function::BasicBlockListType &BBL =
4933 CurFun.CurrentFunction->getBasicBlockList();
4934 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004935 CHECK_FOR_ERROR
4936 ;}
4937 break;
4938
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004939 case 246:
4940#line 2332 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004941 { // Return with a result...
4942 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004943 CHECK_FOR_ERROR
4944 ;}
4945 break;
4946
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004947 case 247:
4948#line 2336 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004949 { // Return with no result...
4950 (yyval.TermInstVal) = new ReturnInst();
Reid Spencer3822ff52006-11-08 06:47:33 +00004951 CHECK_FOR_ERROR
4952 ;}
4953 break;
4954
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004955 case 248:
4956#line 2340 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004957 { // Unconditional Branch...
4958 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004959 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004960 (yyval.TermInstVal) = new BranchInst(tmpBB);
Reid Spencer3822ff52006-11-08 06:47:33 +00004961 ;}
4962 break;
4963
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004964 case 249:
4965#line 2345 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00004966 {
4967 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004968 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004969 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004970 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004971 Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal));
4972 CHECK_FOR_ERROR
4973 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004974 ;}
4975 break;
4976
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004977 case 250:
4978#line 2354 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004979 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004980 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004981 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00004982 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
4983 CHECK_FOR_ERROR
4984 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
4985 (yyval.TermInstVal) = S;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004986
Reid Spencere4d87aa2006-12-23 06:05:41 +00004987 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4988 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004989 for (; I != E; ++I) {
4990 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4991 S->addCase(CI, I->second);
4992 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004993 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004994 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00004995 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00004996 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004997 ;}
4998 break;
4999
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005000 case 251:
5001#line 2373 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005002 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005003 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005004 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005005 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005006 CHECK_FOR_ERROR
5007 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005008 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005009 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005010 ;}
5011 break;
5012
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005013 case 252:
5014#line 2383 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005015 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005016
Reid Spencer14310612006-12-31 05:40:51 +00005017 // Handle the short syntax
5018 const PointerType *PFTy = 0;
5019 const FunctionType *Ty = 0;
Reid Spencer218ded22007-01-05 17:07:23 +00005020 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005021 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5022 // Pull out the types of all of the arguments...
5023 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005024 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer218ded22007-01-05 17:07:23 +00005025 ParamAttrs.push_back((yyvsp[-6].ParamAttrs));
5026 for (ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005027 const Type *Ty = I->Val->getType();
5028 if (Ty == Type::VoidTy)
5029 GEN_ERROR("Short call syntax cannot be used with varargs");
5030 ParamTypes.push_back(Ty);
5031 ParamAttrs.push_back(I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005032 }
5033
Reid Spencer218ded22007-01-05 17:07:23 +00005034 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005035 PFTy = PointerType::get(Ty);
5036 }
5037
Reid Spencer218ded22007-01-05 17:07:23 +00005038 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005039 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005040 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005041 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005042 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005043 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005044
Reid Spencer14310612006-12-31 05:40:51 +00005045 // Check the arguments
5046 ValueList Args;
Reid Spencer218ded22007-01-05 17:07:23 +00005047 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005048 // Make sure no arguments is a good thing!
5049 if (Ty->getNumParams() != 0)
5050 GEN_ERROR("No arguments passed to a function that "
5051 "expects arguments!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005052 } else { // Has arguments?
5053 // Loop through FunctionType's arguments and ensure they are specified
5054 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005055 FunctionType::param_iterator I = Ty->param_begin();
5056 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer218ded22007-01-05 17:07:23 +00005057 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005058
Reid Spencer14310612006-12-31 05:40:51 +00005059 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5060 if (ArgI->Val->getType() != *I)
5061 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencera132e042006-12-03 05:46:11 +00005062 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00005063 Args.push_back(ArgI->Val);
5064 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005065
Reid Spencer14310612006-12-31 05:40:51 +00005066 if (Ty->isVarArg()) {
5067 if (I == E)
5068 for (; ArgI != ArgE; ++ArgI)
5069 Args.push_back(ArgI->Val); // push the remaining varargs
5070 } else if (I != E || ArgI != ArgE)
Reid Spencer61c83e02006-08-18 08:43:06 +00005071 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005072 }
Reid Spencer14310612006-12-31 05:40:51 +00005073
5074 // Create the InvokeInst
5075 InvokeInst *II = new InvokeInst(V, Normal, Except, Args);
Reid Spencer218ded22007-01-05 17:07:23 +00005076 II->setCallingConv((yyvsp[-12].UIntVal));
Reid Spencer14310612006-12-31 05:40:51 +00005077 (yyval.TermInstVal) = II;
Reid Spencer218ded22007-01-05 17:07:23 +00005078 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005079 CHECK_FOR_ERROR
5080 ;}
5081 break;
5082
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005083 case 253:
5084#line 2449 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005085 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005086 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005087 CHECK_FOR_ERROR
5088 ;}
5089 break;
5090
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005091 case 254:
5092#line 2453 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005093 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005094 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005095 CHECK_FOR_ERROR
5096 ;}
5097 break;
5098
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005099 case 255:
5100#line 2460 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005101 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005102 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5103 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005104 CHECK_FOR_ERROR
5105 if (V == 0)
5106 GEN_ERROR("May only switch on a constant pool value!");
5107
Reid Spencere4d87aa2006-12-23 06:05:41 +00005108 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005109 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005110 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005111 ;}
5112 break;
5113
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005114 case 256:
5115#line 2471 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005116 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005117 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5118 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005119 CHECK_FOR_ERROR
5120
5121 if (V == 0)
5122 GEN_ERROR("May only switch on a constant pool value!");
5123
Reid Spencere4d87aa2006-12-23 06:05:41 +00005124 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005125 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005126 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005127 ;}
5128 break;
5129
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005130 case 257:
5131#line 2484 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005132 {
5133 // Is this definition named?? if so, assign the name...
Reid Spencere4d87aa2006-12-23 06:05:41 +00005134 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005135 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005136 InsertValue((yyvsp[0].InstVal));
5137 (yyval.InstVal) = (yyvsp[0].InstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005138 CHECK_FOR_ERROR
5139;}
5140 break;
5141
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005142 case 258:
5143#line 2493 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005144 { // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00005145 if (!UpRefs.empty())
5146 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005147 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5148 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005149 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005150 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005151 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005152 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5153 delete (yyvsp[-5].TypeVal);
5154 ;}
5155 break;
5156
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005157 case 259:
5158#line 2504 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005159 {
5160 (yyval.PHIList) = (yyvsp[-6].PHIList);
5161 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
5162 CHECK_FOR_ERROR
5163 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5164 CHECK_FOR_ERROR
5165 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5166 ;}
5167 break;
5168
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005169 case 260:
5170#line 2514 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00005171 {
5172 if (!UpRefs.empty())
5173 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5174 // Used for call and invoke instructions
5175 (yyval.ValueRefList) = new ValueRefList();
5176 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5177 (yyval.ValueRefList)->push_back(E);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005178 ;}
5179 break;
5180
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005181 case 261:
5182#line 2522 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005183 {
Reid Spencer14310612006-12-31 05:40:51 +00005184 if (!UpRefs.empty())
5185 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5186 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5187 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5188 (yyval.ValueRefList)->push_back(E);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005189 CHECK_FOR_ERROR
5190 ;}
5191 break;
5192
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005193 case 262:
5194#line 2530 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00005195 { (yyval.ValueRefList) = new ValueRefList(); ;}
Reid Spencere4d87aa2006-12-23 06:05:41 +00005196 break;
5197
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005198 case 263:
5199#line 2533 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00005200 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5201 break;
5202
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005203 case 264:
5204#line 2534 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer14310612006-12-31 05:40:51 +00005205 {
5206 (yyval.ValueList) = (yyvsp[-2].ValueList);
5207 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
5208 CHECK_FOR_ERROR
5209 ;}
5210 break;
5211
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005212 case 265:
5213#line 2541 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005214 {
5215 (yyval.BoolVal) = true;
5216 CHECK_FOR_ERROR
5217 ;}
5218 break;
5219
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005220 case 266:
5221#line 2545 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005222 {
5223 (yyval.BoolVal) = false;
5224 CHECK_FOR_ERROR
Andrew Lenharth6353e052006-12-08 18:07:09 +00005225 ;}
5226 break;
5227
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005228 case 267:
5229#line 2550 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005230 {
Reid Spencer14310612006-12-31 05:40:51 +00005231 if (!UpRefs.empty())
5232 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005233 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5234 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
5235 GEN_ERROR(
5236 "Arithmetic operator requires integer, FP, or packed operands!");
5237 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) &&
5238 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5239 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5240 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
5241 GEN_ERROR("U/S/FRem not supported on packed types!");
5242 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005243 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005244 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005245 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005246 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
5247 if ((yyval.InstVal) == 0)
5248 GEN_ERROR("binary operator returned null!");
5249 delete (yyvsp[-3].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005250 ;}
5251 break;
5252
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005253 case 268:
5254#line 2571 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005255 {
Reid Spencer14310612006-12-31 05:40:51 +00005256 if (!UpRefs.empty())
5257 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005258 if (!(*(yyvsp[-3].TypeVal))->isIntegral()) {
5259 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
5260 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral())
5261 GEN_ERROR("Logical operator requires integral operands!");
5262 }
5263 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
5264 CHECK_FOR_ERROR
5265 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
5266 CHECK_FOR_ERROR
5267 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
5268 if ((yyval.InstVal) == 0)
5269 GEN_ERROR("binary operator returned null!");
5270 delete (yyvsp[-3].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005271 ;}
5272 break;
5273
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005274 case 269:
5275#line 2588 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005276 {
Reid Spencer14310612006-12-31 05:40:51 +00005277 if (!UpRefs.empty())
5278 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
Reid Spencerac4a1dd2007-01-04 02:57:52 +00005279 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
5280 GEN_ERROR("Packed types not supported by icmp instruction");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005281 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005282 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005283 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005284 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005285 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5286 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005287 GEN_ERROR("icmp operator returned null!");
5288 ;}
5289 break;
5290
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005291 case 270:
5292#line 2601 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005293 {
Reid Spencer14310612006-12-31 05:40:51 +00005294 if (!UpRefs.empty())
5295 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
Reid Spencerac4a1dd2007-01-04 02:57:52 +00005296 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
5297 GEN_ERROR("Packed types not supported by fcmp instruction");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005298 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005299 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005300 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005301 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005302 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5303 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005304 GEN_ERROR("fcmp operator returned null!");
5305 ;}
5306 break;
5307
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005308 case 271:
5309#line 2614 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005310 {
5311 cerr << "WARNING: Use of eliminated 'not' instruction:"
5312 << " Replacing with 'xor'.\n";
5313
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005314 Value *Ones = ConstantInt::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Andrew Lenharth6353e052006-12-08 18:07:09 +00005315 if (Ones == 0)
5316 GEN_ERROR("Expected integral type for not instruction!");
5317
Reid Spencere4d87aa2006-12-23 06:05:41 +00005318 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
5319 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005320 GEN_ERROR("Could not create a xor instruction!");
5321 CHECK_FOR_ERROR
5322 ;}
5323 break;
5324
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005325 case 272:
5326#line 2627 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005327 {
Reid Spencer14310612006-12-31 05:40:51 +00005328 if ((yyvsp[0].ValueVal)->getType() != Type::Int8Ty)
5329 GEN_ERROR("Shift amount must be i8 type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005330 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
Andrew Lenharth6353e052006-12-08 18:07:09 +00005331 GEN_ERROR("Shift constant expression requires integer operand!");
5332 CHECK_FOR_ERROR;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005333 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005334 CHECK_FOR_ERROR
5335 ;}
5336 break;
5337
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005338 case 273:
5339#line 2636 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005340 {
Reid Spencer14310612006-12-31 05:40:51 +00005341 if (!UpRefs.empty())
5342 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005343 Value* Val = (yyvsp[-2].ValueVal);
5344 const Type* Ty = (yyvsp[0].TypeVal)->get();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005345 if (!Val->getType()->isFirstClassType())
5346 GEN_ERROR("cast from a non-primitive type: '" +
5347 Val->getType()->getDescription() + "'!");
5348 if (!Ty->isFirstClassType())
5349 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
Reid Spencer14310612006-12-31 05:40:51 +00005350 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, (yyvsp[0].TypeVal)->get());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005351 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005352 ;}
5353 break;
5354
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005355 case 274:
5356#line 2649 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005357 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005358 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005359 GEN_ERROR("select condition must be boolean!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005360 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Andrew Lenharth6353e052006-12-08 18:07:09 +00005361 GEN_ERROR("select value types should match!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005362 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005363 CHECK_FOR_ERROR
5364 ;}
5365 break;
5366
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005367 case 275:
5368#line 2657 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005369 {
Reid Spencer14310612006-12-31 05:40:51 +00005370 if (!UpRefs.empty())
5371 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005372 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5373 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005374 CHECK_FOR_ERROR
5375 ;}
5376 break;
5377
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005378 case 276:
5379#line 2664 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005380 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005381 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005382 GEN_ERROR("Invalid extractelement operands!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005383 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005384 CHECK_FOR_ERROR
5385 ;}
5386 break;
5387
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005388 case 277:
5389#line 2670 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005390 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005391 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005392 GEN_ERROR("Invalid insertelement operands!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005393 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005394 CHECK_FOR_ERROR
5395 ;}
5396 break;
5397
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005398 case 278:
5399#line 2676 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005400 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005401 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005402 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005403 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005404 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005405 ;}
5406 break;
5407
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005408 case 279:
5409#line 2682 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005410 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005411 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005412 if (!Ty->isFirstClassType())
5413 GEN_ERROR("PHI node operands must be of first class type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005414 (yyval.InstVal) = new PHINode(Ty);
5415 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5416 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5417 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005418 GEN_ERROR("All elements of a PHI node must be of the same type!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00005419 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5420 (yyvsp[0].PHIList)->pop_front();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005421 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00005422 delete (yyvsp[0].PHIList); // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005423 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005424 ;}
5425 break;
5426
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005427 case 280:
5428#line 2698 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005429 {
Reid Spencer14310612006-12-31 05:40:51 +00005430
5431 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005432 const PointerType *PFTy = 0;
5433 const FunctionType *Ty = 0;
Reid Spencer218ded22007-01-05 17:07:23 +00005434 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005435 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5436 // Pull out the types of all of the arguments...
5437 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005438 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer218ded22007-01-05 17:07:23 +00005439 ParamAttrs.push_back((yyvsp[0].ParamAttrs));
5440 for (ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005441 const Type *Ty = I->Val->getType();
5442 if (Ty == Type::VoidTy)
5443 GEN_ERROR("Short call syntax cannot be used with varargs");
5444 ParamTypes.push_back(Ty);
5445 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005446 }
5447
Reid Spencer218ded22007-01-05 17:07:23 +00005448 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005449 PFTy = PointerType::get(Ty);
5450 }
5451
Reid Spencer218ded22007-01-05 17:07:23 +00005452 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005453 CHECK_FOR_ERROR
5454
Reid Spencer14310612006-12-31 05:40:51 +00005455 // Check the arguments
5456 ValueList Args;
Reid Spencer218ded22007-01-05 17:07:23 +00005457 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005458 // Make sure no arguments is a good thing!
5459 if (Ty->getNumParams() != 0)
5460 GEN_ERROR("No arguments passed to a function that "
5461 "expects arguments!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005462 } else { // Has arguments?
5463 // Loop through FunctionType's arguments and ensure they are specified
5464 // correctly!
5465 //
5466 FunctionType::param_iterator I = Ty->param_begin();
5467 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer218ded22007-01-05 17:07:23 +00005468 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005469
Reid Spencer14310612006-12-31 05:40:51 +00005470 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5471 if (ArgI->Val->getType() != *I)
5472 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Andrew Lenharth6353e052006-12-08 18:07:09 +00005473 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00005474 Args.push_back(ArgI->Val);
5475 }
5476 if (Ty->isVarArg()) {
5477 if (I == E)
5478 for (; ArgI != ArgE; ++ArgI)
5479 Args.push_back(ArgI->Val); // push the remaining varargs
5480 } else if (I != E || ArgI != ArgE)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005481 GEN_ERROR("Invalid number of parameters detected!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005482 }
Reid Spencer14310612006-12-31 05:40:51 +00005483 // Create the call node
5484 CallInst *CI = new CallInst(V, Args);
Reid Spencer218ded22007-01-05 17:07:23 +00005485 CI->setTailCall((yyvsp[-7].BoolVal));
5486 CI->setCallingConv((yyvsp[-6].UIntVal));
Reid Spencer14310612006-12-31 05:40:51 +00005487 (yyval.InstVal) = CI;
Reid Spencer218ded22007-01-05 17:07:23 +00005488 delete (yyvsp[-2].ValueRefList);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005489 CHECK_FOR_ERROR
5490 ;}
5491 break;
5492
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005493 case 281:
5494#line 2760 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005495 {
5496 (yyval.InstVal) = (yyvsp[0].InstVal);
5497 CHECK_FOR_ERROR
5498 ;}
5499 break;
5500
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005501 case 282:
5502#line 2765 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005503 {
5504 (yyval.BoolVal) = true;
5505 CHECK_FOR_ERROR
5506 ;}
5507 break;
5508
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005509 case 283:
5510#line 2769 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005511 {
5512 (yyval.BoolVal) = false;
5513 CHECK_FOR_ERROR
5514 ;}
5515 break;
5516
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005517 case 284:
5518#line 2776 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005519 {
Reid Spencer14310612006-12-31 05:40:51 +00005520 if (!UpRefs.empty())
5521 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005522 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5523 delete (yyvsp[-1].TypeVal);
5524 CHECK_FOR_ERROR
5525 ;}
5526 break;
5527
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005528 case 285:
5529#line 2783 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005530 {
Reid Spencer14310612006-12-31 05:40:51 +00005531 if (!UpRefs.empty())
5532 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005533 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
5534 CHECK_FOR_ERROR
5535 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5536 delete (yyvsp[-4].TypeVal);
5537 ;}
5538 break;
5539
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005540 case 286:
5541#line 2791 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005542 {
Reid Spencer14310612006-12-31 05:40:51 +00005543 if (!UpRefs.empty())
5544 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005545 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5546 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005547 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005548 ;}
5549 break;
5550
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005551 case 287:
5552#line 2798 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005553 {
Reid Spencer14310612006-12-31 05:40:51 +00005554 if (!UpRefs.empty())
5555 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005556 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005557 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005558 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5559 delete (yyvsp[-4].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005560 ;}
5561 break;
5562
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005563 case 288:
5564#line 2806 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005565 {
5566 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
5567 GEN_ERROR("Trying to free nonpointer type " +
5568 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
5569 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005570 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005571 ;}
5572 break;
5573
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005574 case 289:
5575#line 2814 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencere4d87aa2006-12-23 06:05:41 +00005576 {
Reid Spencer14310612006-12-31 05:40:51 +00005577 if (!UpRefs.empty())
5578 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005579 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
5580 GEN_ERROR("Can't load from nonpointer type: " +
5581 (*(yyvsp[-1].TypeVal))->getDescription());
5582 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
5583 GEN_ERROR("Can't load from pointer of non-first-class type: " +
5584 (*(yyvsp[-1].TypeVal))->getDescription());
5585 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005586 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005587 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5588 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005589 ;}
5590 break;
5591
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005592 case 290:
5593#line 2828 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005594 {
Reid Spencer14310612006-12-31 05:40:51 +00005595 if (!UpRefs.empty())
5596 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005597 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
5598 if (!PT)
5599 GEN_ERROR("Can't store to a nonpointer type: " +
5600 (*(yyvsp[-1].TypeVal))->getDescription());
5601 const Type *ElTy = PT->getElementType();
5602 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5603 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
5604 "' into space of type '" + ElTy->getDescription() + "'!");
5605
5606 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005607 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005608 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5609 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005610 ;}
5611 break;
5612
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005613 case 291:
5614#line 2845 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005615 {
Reid Spencer14310612006-12-31 05:40:51 +00005616 if (!UpRefs.empty())
5617 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005618 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005619 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005620
Reid Spencere4d87aa2006-12-23 06:05:41 +00005621 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005622 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencere4d87aa2006-12-23 06:05:41 +00005623 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
5624 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005625 CHECK_FOR_ERROR
Reid Spencere4d87aa2006-12-23 06:05:41 +00005626 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
5627 delete (yyvsp[-2].TypeVal);
5628 delete (yyvsp[0].ValueList);
Reid Spencer3822ff52006-11-08 06:47:33 +00005629 ;}
5630 break;
5631
5632
Reid Spencere4d87aa2006-12-23 06:05:41 +00005633 default: break;
Reid Spencer3822ff52006-11-08 06:47:33 +00005634 }
5635
Reid Spencere4d87aa2006-12-23 06:05:41 +00005636/* Line 1126 of yacc.c. */
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005637#line 5638 "llvmAsmParser.tab.c"
Andrew Lenharth6353e052006-12-08 18:07:09 +00005638
5639 yyvsp -= yylen;
5640 yyssp -= yylen;
5641
5642
Reid Spencer3822ff52006-11-08 06:47:33 +00005643 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005644
5645 *++yyvsp = yyval;
5646
5647
Reid Spencer3822ff52006-11-08 06:47:33 +00005648 /* Now `shift' the result of the reduction. Determine what state
5649 that goes to, based on the state we popped back to and the rule
5650 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005651
5652 yyn = yyr1[yyn];
5653
Reid Spencer3822ff52006-11-08 06:47:33 +00005654 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5655 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005656 yystate = yytable[yystate];
5657 else
Reid Spencer3822ff52006-11-08 06:47:33 +00005658 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005659
5660 goto yynewstate;
5661
5662
Reid Spencer3822ff52006-11-08 06:47:33 +00005663/*------------------------------------.
5664| yyerrlab -- here on detecting error |
5665`------------------------------------*/
5666yyerrlab:
5667 /* If not already recovering from an error, report this error. */
5668 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005669 {
5670 ++yynerrs;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005671#if YYERROR_VERBOSE
5672 yyn = yypact[yystate];
Bill Wendlinge8156192006-12-07 01:30:32 +00005673
Andrew Lenharth6353e052006-12-08 18:07:09 +00005674 if (YYPACT_NINF < yyn && yyn < YYLAST)
5675 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00005676 int yytype = YYTRANSLATE (yychar);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005677 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5678 YYSIZE_T yysize = yysize0;
5679 YYSIZE_T yysize1;
5680 int yysize_overflow = 0;
5681 char *yymsg = 0;
5682# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5683 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
Andrew Lenharth6353e052006-12-08 18:07:09 +00005684 int yyx;
5685
Reid Spencere4d87aa2006-12-23 06:05:41 +00005686#if 0
5687 /* This is so xgettext sees the translatable formats that are
5688 constructed on the fly. */
5689 YY_("syntax error, unexpected %s");
5690 YY_("syntax error, unexpected %s, expecting %s");
5691 YY_("syntax error, unexpected %s, expecting %s or %s");
5692 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5693 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5694#endif
5695 char *yyfmt;
5696 char const *yyf;
5697 static char const yyunexpected[] = "syntax error, unexpected %s";
5698 static char const yyexpecting[] = ", expecting %s";
5699 static char const yyor[] = " or %s";
5700 char yyformat[sizeof yyunexpected
5701 + sizeof yyexpecting - 1
5702 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5703 * (sizeof yyor - 1))];
5704 char const *yyprefix = yyexpecting;
5705
Andrew Lenharth6353e052006-12-08 18:07:09 +00005706 /* Start YYX at -YYN if negative to avoid negative indexes in
5707 YYCHECK. */
5708 int yyxbegin = yyn < 0 ? -yyn : 0;
5709
5710 /* Stay within bounds of both yycheck and yytname. */
5711 int yychecklim = YYLAST - yyn;
5712 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005713 int yycount = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005714
Reid Spencere4d87aa2006-12-23 06:05:41 +00005715 yyarg[0] = yytname[yytype];
5716 yyfmt = yystpcpy (yyformat, yyunexpected);
5717
Andrew Lenharth6353e052006-12-08 18:07:09 +00005718 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5719 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5720 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005721 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005722 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005723 yycount = 1;
5724 yysize = yysize0;
5725 yyformat[sizeof yyunexpected - 1] = '\0';
Andrew Lenharth6353e052006-12-08 18:07:09 +00005726 break;
5727 }
Reid Spencere4d87aa2006-12-23 06:05:41 +00005728 yyarg[yycount++] = yytname[yyx];
5729 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5730 yysize_overflow |= yysize1 < yysize;
5731 yysize = yysize1;
5732 yyfmt = yystpcpy (yyfmt, yyprefix);
5733 yyprefix = yyor;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005734 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005735
Reid Spencere4d87aa2006-12-23 06:05:41 +00005736 yyf = YY_(yyformat);
5737 yysize1 = yysize + yystrlen (yyf);
5738 yysize_overflow |= yysize1 < yysize;
5739 yysize = yysize1;
5740
5741 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5742 yymsg = (char *) YYSTACK_ALLOC (yysize);
5743 if (yymsg)
5744 {
5745 /* Avoid sprintf, as that infringes on the user's name space.
5746 Don't have undefined behavior even if the translation
5747 produced a string with the wrong number of "%s"s. */
5748 char *yyp = yymsg;
5749 int yyi = 0;
5750 while ((*yyp = *yyf))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005751 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005752 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5753 {
5754 yyp += yytnamerr (yyp, yyarg[yyi++]);
5755 yyf += 2;
5756 }
5757 else
5758 {
5759 yyp++;
5760 yyf++;
5761 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005762 }
5763 yyerror (yymsg);
5764 YYSTACK_FREE (yymsg);
5765 }
5766 else
Reid Spencere4d87aa2006-12-23 06:05:41 +00005767 {
5768 yyerror (YY_("syntax error"));
5769 goto yyexhaustedlab;
5770 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005771 }
5772 else
5773#endif /* YYERROR_VERBOSE */
Reid Spencere4d87aa2006-12-23 06:05:41 +00005774 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005775 }
5776
Reid Spencer3822ff52006-11-08 06:47:33 +00005777
Reid Spencer68a24bd2005-08-27 18:50:39 +00005778
5779 if (yyerrstatus == 3)
5780 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005781 /* If just tried and failed to reuse look-ahead token after an
Reid Spencer3822ff52006-11-08 06:47:33 +00005782 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005783
Reid Spencer3822ff52006-11-08 06:47:33 +00005784 if (yychar <= YYEOF)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005785 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005786 /* Return failure if at end of input. */
Reid Spencer3822ff52006-11-08 06:47:33 +00005787 if (yychar == YYEOF)
Reid Spencere4d87aa2006-12-23 06:05:41 +00005788 YYABORT;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005789 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005790 else
5791 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00005792 yydestruct ("Error: discarding", yytoken, &yylval);
Reid Spencer3822ff52006-11-08 06:47:33 +00005793 yychar = YYEMPTY;
5794 }
5795 }
5796
Reid Spencere4d87aa2006-12-23 06:05:41 +00005797 /* Else will try to reuse look-ahead token after shifting the error
Reid Spencer3822ff52006-11-08 06:47:33 +00005798 token. */
5799 goto yyerrlab1;
5800
5801
5802/*---------------------------------------------------.
5803| yyerrorlab -- error raised explicitly by YYERROR. |
5804`---------------------------------------------------*/
5805yyerrorlab:
5806
Reid Spencere4d87aa2006-12-23 06:05:41 +00005807 /* Pacify compilers like GCC when the user code never invokes
5808 YYERROR and the label yyerrorlab therefore never appears in user
5809 code. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00005810 if (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00005811 goto yyerrorlab;
5812
Reid Spencere4d87aa2006-12-23 06:05:41 +00005813yyvsp -= yylen;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005814 yyssp -= yylen;
Reid Spencer3822ff52006-11-08 06:47:33 +00005815 yystate = *yyssp;
5816 goto yyerrlab1;
5817
5818
5819/*-------------------------------------------------------------.
5820| yyerrlab1 -- common code for both syntax error and YYERROR. |
5821`-------------------------------------------------------------*/
5822yyerrlab1:
5823 yyerrstatus = 3; /* Each real token shifted decrements this. */
5824
5825 for (;;)
5826 {
5827 yyn = yypact[yystate];
5828 if (yyn != YYPACT_NINF)
5829 {
5830 yyn += YYTERROR;
5831 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5832 {
5833 yyn = yytable[yyn];
5834 if (0 < yyn)
5835 break;
5836 }
5837 }
5838
5839 /* Pop the current state because it cannot handle the error token. */
5840 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005841 YYABORT;
5842
Reid Spencere4d87aa2006-12-23 06:05:41 +00005843
5844 yydestruct ("Error: popping", yystos[yystate], yyvsp);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005845 YYPOPSTACK;
Reid Spencer3822ff52006-11-08 06:47:33 +00005846 yystate = *yyssp;
5847 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005848 }
5849
5850 if (yyn == YYFINAL)
5851 YYACCEPT;
5852
Reid Spencer68a24bd2005-08-27 18:50:39 +00005853 *++yyvsp = yylval;
Reid Spencer3822ff52006-11-08 06:47:33 +00005854
5855
Reid Spencere4d87aa2006-12-23 06:05:41 +00005856 /* Shift the error token. */
5857 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
5858
Reid Spencer68a24bd2005-08-27 18:50:39 +00005859 yystate = yyn;
5860 goto yynewstate;
5861
Chris Lattnerf49c1762006-11-08 05:58:47 +00005862
Reid Spencer3822ff52006-11-08 06:47:33 +00005863/*-------------------------------------.
5864| yyacceptlab -- YYACCEPT comes here. |
5865`-------------------------------------*/
5866yyacceptlab:
5867 yyresult = 0;
5868 goto yyreturn;
5869
5870/*-----------------------------------.
5871| yyabortlab -- YYABORT comes here. |
5872`-----------------------------------*/
5873yyabortlab:
5874 yyresult = 1;
5875 goto yyreturn;
5876
5877#ifndef yyoverflow
Reid Spencere4d87aa2006-12-23 06:05:41 +00005878/*-------------------------------------------------.
5879| yyexhaustedlab -- memory exhaustion comes here. |
5880`-------------------------------------------------*/
5881yyexhaustedlab:
5882 yyerror (YY_("memory exhausted"));
Reid Spencer3822ff52006-11-08 06:47:33 +00005883 yyresult = 2;
5884 /* Fall through. */
Chris Lattnerf49c1762006-11-08 05:58:47 +00005885#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00005886
5887yyreturn:
Reid Spencere4d87aa2006-12-23 06:05:41 +00005888 if (yychar != YYEOF && yychar != YYEMPTY)
5889 yydestruct ("Cleanup: discarding lookahead",
5890 yytoken, &yylval);
5891 while (yyssp != yyss)
5892 {
5893 yydestruct ("Cleanup: popping",
5894 yystos[*yyssp], yyvsp);
5895 YYPOPSTACK;
5896 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005897#ifndef yyoverflow
5898 if (yyss != yyssa)
5899 YYSTACK_FREE (yyss);
5900#endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00005901 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005902}
Reid Spencer3822ff52006-11-08 06:47:33 +00005903
5904
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005905#line 2862 "/developer/zsth/llvm-gcc-dev/HEAD/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005906
5907
Reid Spencer14310612006-12-31 05:40:51 +00005908// common code from the two 'RunVMAsmParser' functions
5909static Module* RunParser(Module * M) {
5910
5911 llvmAsmlineno = 1; // Reset the current line number...
5912 CurModule.CurrentModule = M;
5913#if YYDEBUG
5914 yydebug = Debug;
5915#endif
5916
5917 // Check to make sure the parser succeeded
5918 if (yyparse()) {
5919 if (ParserResult)
5920 delete ParserResult;
5921 return 0;
5922 }
5923
5924 // Check to make sure that parsing produced a result
5925 if (!ParserResult)
5926 return 0;
5927
5928 // Reset ParserResult variable while saving its value for the result.
5929 Module *Result = ParserResult;
5930 ParserResult = 0;
5931
5932 return Result;
5933}
5934
Reid Spencer61c83e02006-08-18 08:43:06 +00005935void llvm::GenerateError(const std::string &message, int LineNo) {
5936 if (LineNo == -1) LineNo = llvmAsmlineno;
5937 // TODO: column number in exception
5938 if (TheParseError)
5939 TheParseError->setError(CurFilename, message, LineNo);
5940 TriggerError = 1;
5941}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005942
5943int yyerror(const char *ErrorMsg) {
5944 std::string where
5945 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5946 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5947 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5948 if (yychar == YYEMPTY || yychar == 0)
5949 errMsg += "end-of-file.";
5950 else
5951 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005952 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005953 return 0;
5954}
Reid Spencer3822ff52006-11-08 06:47:33 +00005955