blob: 390592025eaf91a700411fd6d9fa4280e70d21c6 [file] [log] [blame]
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00007
Anton Korobeynikov178a3522007-01-12 19:22:51 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
49/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
61/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000062#define yyparse llvmAsmparse
Anton Korobeynikov178a3522007-01-12 19:22:51 +000063#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000064#define yyerror llvmAsmerror
Anton Korobeynikov178a3522007-01-12 19:22:51 +000065#define yylval llvmAsmlval
66#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000067#define yydebug llvmAsmdebug
68#define yynerrs llvmAsmnerrs
69
Anton Korobeynikov178a3522007-01-12 19:22:51 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 SINTVAL = 260,
80 UINTVAL = 261,
81 FPVAL = 262,
82 VOID = 263,
83 BOOL = 264,
84 INTTYPE = 265,
85 FLOAT = 266,
86 DOUBLE = 267,
87 LABEL = 268,
88 TYPE = 269,
89 VAR_ID = 270,
90 LABELSTR = 271,
91 STRINGCONSTANT = 272,
92 IMPLEMENTATION = 273,
93 ZEROINITIALIZER = 274,
94 TRUETOK = 275,
95 FALSETOK = 276,
96 BEGINTOK = 277,
97 ENDTOK = 278,
98 DECLARE = 279,
99 DEFINE = 280,
100 GLOBAL = 281,
101 CONSTANT = 282,
102 SECTION = 283,
103 VOLATILE = 284,
104 TO = 285,
105 DOTDOTDOT = 286,
106 NULL_TOK = 287,
107 UNDEF = 288,
108 INTERNAL = 289,
109 LINKONCE = 290,
110 WEAK = 291,
111 APPENDING = 292,
112 DLLIMPORT = 293,
113 DLLEXPORT = 294,
114 EXTERN_WEAK = 295,
115 OPAQUE = 296,
116 EXTERNAL = 297,
117 TARGET = 298,
118 TRIPLE = 299,
119 ENDIAN = 300,
120 POINTERSIZE = 301,
121 LITTLE = 302,
122 BIG = 303,
123 ALIGN = 304,
124 DEPLIBS = 305,
125 CALL = 306,
126 TAIL = 307,
127 ASM_TOK = 308,
128 MODULE = 309,
129 SIDEEFFECT = 310,
130 CC_TOK = 311,
131 CCC_TOK = 312,
132 CSRETCC_TOK = 313,
133 FASTCC_TOK = 314,
134 COLDCC_TOK = 315,
135 X86_STDCALLCC_TOK = 316,
136 X86_FASTCALLCC_TOK = 317,
137 DATALAYOUT = 318,
138 RET = 319,
139 BR = 320,
140 SWITCH = 321,
141 INVOKE = 322,
142 UNWIND = 323,
143 UNREACHABLE = 324,
144 ADD = 325,
145 SUB = 326,
146 MUL = 327,
147 UDIV = 328,
148 SDIV = 329,
149 FDIV = 330,
150 UREM = 331,
151 SREM = 332,
152 FREM = 333,
153 AND = 334,
154 OR = 335,
155 XOR = 336,
156 ICMP = 337,
157 FCMP = 338,
158 EQ = 339,
159 NE = 340,
160 SLT = 341,
161 SGT = 342,
162 SLE = 343,
163 SGE = 344,
164 ULT = 345,
165 UGT = 346,
166 ULE = 347,
167 UGE = 348,
168 OEQ = 349,
169 ONE = 350,
170 OLT = 351,
171 OGT = 352,
172 OLE = 353,
173 OGE = 354,
174 ORD = 355,
175 UNO = 356,
176 UEQ = 357,
177 UNE = 358,
178 MALLOC = 359,
179 ALLOCA = 360,
180 FREE = 361,
181 LOAD = 362,
182 STORE = 363,
183 GETELEMENTPTR = 364,
184 TRUNC = 365,
185 ZEXT = 366,
186 SEXT = 367,
187 FPTRUNC = 368,
188 FPEXT = 369,
189 BITCAST = 370,
190 UITOFP = 371,
191 SITOFP = 372,
192 FPTOUI = 373,
193 FPTOSI = 374,
194 INTTOPTR = 375,
195 PTRTOINT = 376,
196 PHI_TOK = 377,
197 SELECT = 378,
198 SHL = 379,
199 LSHR = 380,
200 ASHR = 381,
201 VAARG = 382,
202 EXTRACTELEMENT = 383,
203 INSERTELEMENT = 384,
204 SHUFFLEVECTOR = 385,
205 NORETURN = 386,
206 DEFAULT = 387,
207 HIDDEN = 388
208 };
209#endif
210/* Tokens. */
211#define ESINT64VAL 258
212#define EUINT64VAL 259
213#define SINTVAL 260
214#define UINTVAL 261
215#define FPVAL 262
216#define VOID 263
217#define BOOL 264
218#define INTTYPE 265
219#define FLOAT 266
220#define DOUBLE 267
221#define LABEL 268
222#define TYPE 269
223#define VAR_ID 270
224#define LABELSTR 271
225#define STRINGCONSTANT 272
226#define IMPLEMENTATION 273
227#define ZEROINITIALIZER 274
228#define TRUETOK 275
229#define FALSETOK 276
230#define BEGINTOK 277
231#define ENDTOK 278
232#define DECLARE 279
233#define DEFINE 280
234#define GLOBAL 281
235#define CONSTANT 282
236#define SECTION 283
237#define VOLATILE 284
238#define TO 285
239#define DOTDOTDOT 286
240#define NULL_TOK 287
241#define UNDEF 288
242#define INTERNAL 289
243#define LINKONCE 290
244#define WEAK 291
245#define APPENDING 292
246#define DLLIMPORT 293
247#define DLLEXPORT 294
248#define EXTERN_WEAK 295
249#define OPAQUE 296
250#define EXTERNAL 297
251#define TARGET 298
252#define TRIPLE 299
253#define ENDIAN 300
254#define POINTERSIZE 301
255#define LITTLE 302
256#define BIG 303
257#define ALIGN 304
258#define DEPLIBS 305
259#define CALL 306
260#define TAIL 307
261#define ASM_TOK 308
262#define MODULE 309
263#define SIDEEFFECT 310
264#define CC_TOK 311
265#define CCC_TOK 312
266#define CSRETCC_TOK 313
267#define FASTCC_TOK 314
268#define COLDCC_TOK 315
269#define X86_STDCALLCC_TOK 316
270#define X86_FASTCALLCC_TOK 317
271#define DATALAYOUT 318
272#define RET 319
273#define BR 320
274#define SWITCH 321
275#define INVOKE 322
276#define UNWIND 323
277#define UNREACHABLE 324
278#define ADD 325
279#define SUB 326
280#define MUL 327
281#define UDIV 328
282#define SDIV 329
283#define FDIV 330
284#define UREM 331
285#define SREM 332
286#define FREM 333
287#define AND 334
288#define OR 335
289#define XOR 336
290#define ICMP 337
291#define FCMP 338
292#define EQ 339
293#define NE 340
294#define SLT 341
295#define SGT 342
296#define SLE 343
297#define SGE 344
298#define ULT 345
299#define UGT 346
300#define ULE 347
301#define UGE 348
302#define OEQ 349
303#define ONE 350
304#define OLT 351
305#define OGT 352
306#define OLE 353
307#define OGE 354
308#define ORD 355
309#define UNO 356
310#define UEQ 357
311#define UNE 358
312#define MALLOC 359
313#define ALLOCA 360
314#define FREE 361
315#define LOAD 362
316#define STORE 363
317#define GETELEMENTPTR 364
318#define TRUNC 365
319#define ZEXT 366
320#define SEXT 367
321#define FPTRUNC 368
322#define FPEXT 369
323#define BITCAST 370
324#define UITOFP 371
325#define SITOFP 372
326#define FPTOUI 373
327#define FPTOSI 374
328#define INTTOPTR 375
329#define PTRTOINT 376
330#define PHI_TOK 377
331#define SELECT 378
332#define SHL 379
333#define LSHR 380
334#define ASHR 381
335#define VAARG 382
336#define EXTRACTELEMENT 383
337#define INSERTELEMENT 384
338#define SHUFFLEVECTOR 385
339#define NORETURN 386
340#define DEFAULT 387
341#define HIDDEN 388
342
343
344
345
346/* Copy the first part of user declarations. */
347#line 14 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000348
349#include "ParserInternals.h"
350#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000351#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000352#include "llvm/Instructions.h"
353#include "llvm/Module.h"
354#include "llvm/SymbolTable.h"
355#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000356#include "llvm/Support/CommandLine.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000357#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000358#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000359#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000360#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000361#include <list>
362#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000363#ifndef NDEBUG
364#define YYDEBUG 1
365#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000366
Reid Spencere4f47592006-08-18 17:32:55 +0000367// The following is a gross hack. In order to rid the libAsmParser library of
368// exceptions, we have to have a way of getting the yyparse function to go into
369// an error situation. So, whenever we want an error to occur, the GenerateError
370// function (see bottom of file) sets TriggerError. Then, at the end of each
371// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
372// (a goto) to put YACC in error state. Furthermore, several calls to
373// GenerateError are made from inside productions and they must simulate the
374// previous exception behavior by exiting the production immediately. We have
375// replaced these with the GEN_ERROR macro which calls GeneratError and then
376// immediately invokes YYERROR. This would be so much cleaner if it was a
377// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000378static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000379#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000380#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
381
Reid Spencer68a24bd2005-08-27 18:50:39 +0000382int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
383int yylex(); // declaration" of xxx warnings.
384int yyparse();
385
386namespace llvm {
387 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000388#if YYDEBUG
389static cl::opt<bool>
390Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
391 cl::Hidden, cl::init(false));
392#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000393}
394using namespace llvm;
395
396static Module *ParserResult;
397
398// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
399// relating to upreferences in the input stream.
400//
401//#define DEBUG_UPREFS 1
402#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000403#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000404#else
405#define UR_OUT(X)
406#endif
407
408#define YYERROR_VERBOSE 1
409
Chris Lattnerb475c422005-11-12 18:22:38 +0000410static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000411
412
413// This contains info used when building the body of a function. It is
414// destroyed when the function is completed.
415//
416typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000417
Reid Spencer68a24bd2005-08-27 18:50:39 +0000418static void
419ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
420 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
421
422static struct PerModuleInfo {
423 Module *CurrentModule;
424 std::map<const Type *, ValueList> Values; // Module level numbered definitions
425 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000426 std::vector<PATypeHolder> Types;
427 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000428
429 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000430 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000431 /// that we can resolve them later and print error messages as appropriate.
432 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
433
434 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
435 // references to global values. Global values may be referenced before they
436 // are defined, and if so, the temporary object that they represent is held
437 // here. This is used for forward references of GlobalValues.
438 //
439 typedef std::map<std::pair<const PointerType *,
440 ValID>, GlobalValue*> GlobalRefsType;
441 GlobalRefsType GlobalRefs;
442
443 void ModuleDone() {
444 // If we could not resolve some functions at function compilation time
445 // (calls to functions before they are defined), resolve them now... Types
446 // are resolved when the constant pool has been completely parsed.
447 //
448 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000449 if (TriggerError)
450 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000451
452 // Check to make sure that all global value forward references have been
453 // resolved!
454 //
455 if (!GlobalRefs.empty()) {
456 std::string UndefinedReferences = "Unresolved global references exist:\n";
457
458 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
459 I != E; ++I) {
460 UndefinedReferences += " " + I->first.first->getDescription() + " " +
461 I->first.second.getName() + "\n";
462 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000463 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000464 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000465 }
466
467 Values.clear(); // Clear out function local definitions
468 Types.clear();
469 CurrentModule = 0;
470 }
471
Reid Spencer68a24bd2005-08-27 18:50:39 +0000472 // GetForwardRefForGlobal - Check to see if there is a forward reference
473 // for this global. If so, remove it from the GlobalRefs map and return it.
474 // If not, just return null.
475 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
476 // Check to see if there is a forward reference to this global variable...
477 // if there is, eliminate it and patch the reference to use the new def'n.
478 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
479 GlobalValue *Ret = 0;
480 if (I != GlobalRefs.end()) {
481 Ret = I->second;
482 GlobalRefs.erase(I);
483 }
484 return Ret;
485 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000486
487 bool TypeIsUnresolved(PATypeHolder* PATy) {
488 // If it isn't abstract, its resolved
489 const Type* Ty = PATy->get();
490 if (!Ty->isAbstract())
491 return false;
492 // Traverse the type looking for abstract types. If it isn't abstract then
493 // we don't need to traverse that leg of the type.
494 std::vector<const Type*> WorkList, SeenList;
495 WorkList.push_back(Ty);
496 while (!WorkList.empty()) {
497 const Type* Ty = WorkList.back();
498 SeenList.push_back(Ty);
499 WorkList.pop_back();
500 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
501 // Check to see if this is an unresolved type
502 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
503 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
504 for ( ; I != E; ++I) {
505 if (I->second.get() == OpTy)
506 return true;
507 }
508 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
509 const Type* TheTy = SeqTy->getElementType();
510 if (TheTy->isAbstract() && TheTy != Ty) {
511 std::vector<const Type*>::iterator I = SeenList.begin(),
512 E = SeenList.end();
513 for ( ; I != E; ++I)
514 if (*I == TheTy)
515 break;
516 if (I == E)
517 WorkList.push_back(TheTy);
518 }
519 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
520 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
521 const Type* TheTy = StrTy->getElementType(i);
522 if (TheTy->isAbstract() && TheTy != Ty) {
523 std::vector<const Type*>::iterator I = SeenList.begin(),
524 E = SeenList.end();
525 for ( ; I != E; ++I)
526 if (*I == TheTy)
527 break;
528 if (I == E)
529 WorkList.push_back(TheTy);
530 }
531 }
532 }
533 }
534 return false;
535 }
536
537
Reid Spencer68a24bd2005-08-27 18:50:39 +0000538} CurModule;
539
540static struct PerFunctionInfo {
541 Function *CurrentFunction; // Pointer to current function being created
542
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000543 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000544 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000545 bool isDeclare; // Is this function a forward declararation?
546 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000547 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000548
549 /// BBForwardRefs - When we see forward references to basic blocks, keep
550 /// track of them here.
551 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
552 std::vector<BasicBlock*> NumberedBlocks;
553 unsigned NextBBNum;
554
555 inline PerFunctionInfo() {
556 CurrentFunction = 0;
557 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000558 Linkage = GlobalValue::ExternalLinkage;
559 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000560 }
561
562 inline void FunctionStart(Function *M) {
563 CurrentFunction = M;
564 NextBBNum = 0;
565 }
566
567 void FunctionDone() {
568 NumberedBlocks.clear();
569
570 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000571 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000572 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000573 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000574 return;
575 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000576
577 // Resolve all forward references now.
578 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
579
580 Values.clear(); // Clear out function local definitions
581 CurrentFunction = 0;
582 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000583 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000584 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000585 }
586} CurFun; // Info for the current function...
587
588static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
589
590
591//===----------------------------------------------------------------------===//
592// Code to handle definitions of all the types
593//===----------------------------------------------------------------------===//
594
595static int InsertValue(Value *V,
596 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
597 if (V->hasName()) return -1; // Is this a numbered definition?
598
599 // Yes, insert the value into the value table...
600 ValueList &List = ValueTab[V->getType()];
601 List.push_back(V);
602 return List.size()-1;
603}
604
605static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
606 switch (D.Type) {
607 case ValID::NumberVal: // Is it a numbered definition?
608 // Module constants occupy the lowest numbered slots...
609 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer861d9d62006-11-28 07:29:44 +0000610 return CurModule.Types[(unsigned)D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611 break;
612 case ValID::NameVal: // Is it a named definition?
613 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
614 D.destroy(); // Free old strdup'd memory...
615 return N;
616 }
617 break;
618 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000619 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000620 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621 }
622
623 // If we reached here, we referenced either a symbol that we don't know about
624 // or an id number that hasn't been read yet. We may be referencing something
625 // forward, so just create an entry to be resolved later and get to it...
626 //
627 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
628
629
630 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000631 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000632 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000633 return 0;
634 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000635 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000636 return 0;
637 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000638 }
639
Reid Spencer861d9d62006-11-28 07:29:44 +0000640 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000642 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000643
Reid Spencer861d9d62006-11-28 07:29:44 +0000644 Type *Typ = OpaqueType::get();
645 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
646 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000647 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000648
649static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
650 SymbolTable &SymTab =
Reid Spencer78d033e2007-01-06 07:24:44 +0000651 inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
652 CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000653 return SymTab.lookup(Ty, Name);
654}
655
656// getValNonImprovising - Look up the value specified by the provided type and
657// the provided ValID. If the value exists and has already been defined, return
658// it. Otherwise return null.
659//
660static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000661 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000662 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000663 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000664 return 0;
665 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000666
667 switch (D.Type) {
668 case ValID::NumberVal: { // Is it a numbered definition?
669 unsigned Num = (unsigned)D.Num;
670
671 // Module constants occupy the lowest numbered slots...
672 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
673 if (VI != CurModule.Values.end()) {
674 if (Num < VI->second.size())
675 return VI->second[Num];
676 Num -= VI->second.size();
677 }
678
679 // Make sure that our type is within bounds
680 VI = CurFun.Values.find(Ty);
681 if (VI == CurFun.Values.end()) return 0;
682
683 // Check that the number is within bounds...
684 if (VI->second.size() <= Num) return 0;
685
686 return VI->second[Num];
687 }
688
689 case ValID::NameVal: { // Is it a named definition?
690 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
691 if (N == 0) return 0;
692
693 D.destroy(); // Free old strdup'd memory...
694 return N;
695 }
696
697 // Check to make sure that "Ty" is an integral type, and that our
698 // value will fit into the specified type...
699 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000700 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000701 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000702 itostr(D.ConstPool64) + "' is invalid for type '" +
703 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000704 return 0;
705 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000706 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000707
708 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000709 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
710 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000711 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000712 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000713 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000714 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000715 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000716 }
717 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000718 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000719 }
720
721 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000722 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000723 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000724 return 0;
725 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000726 return ConstantFP::get(Ty, D.ConstPoolFP);
727
728 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000729 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000730 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000731 return 0;
732 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000733 return ConstantPointerNull::get(cast<PointerType>(Ty));
734
735 case ValID::ConstUndefVal: // Is it an undef value?
736 return UndefValue::get(Ty);
737
Chris Lattner7aa61892005-12-21 17:53:23 +0000738 case ValID::ConstZeroVal: // Is it a zero value?
739 return Constant::getNullValue(Ty);
740
Reid Spencer68a24bd2005-08-27 18:50:39 +0000741 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000743 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000744 return 0;
745 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000746 return D.ConstantValue;
747
Chris Lattner0e9c3762006-01-25 22:27:16 +0000748 case ValID::InlineAsmVal: { // Inline asm expression
749 const PointerType *PTy = dyn_cast<PointerType>(Ty);
750 const FunctionType *FTy =
751 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000752 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000753 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000754 return 0;
755 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000756 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
757 D.IAD->HasSideEffects);
758 D.destroy(); // Free InlineAsmDescriptor.
759 return IA;
760 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000761 default:
762 assert(0 && "Unhandled case!");
763 return 0;
764 } // End of switch
765
766 assert(0 && "Unhandled case!");
767 return 0;
768}
769
770// getVal - This function is identical to getValNonImprovising, except that if a
771// value is not already defined, it "improvises" by creating a placeholder var
772// that looks and acts just like the requested variable. When the value is
773// defined later, all uses of the placeholder variable are replaced with the
774// real thing.
775//
776static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000777 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000778 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000779 return 0;
780 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000781
782 // See if the value has already been defined.
783 Value *V = getValNonImprovising(Ty, ID);
784 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000785 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000786
Reid Spencer5b7e7532006-09-28 19:28:24 +0000787 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000788 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000789 return 0;
790 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000791
792 // If we reached here, we referenced either a symbol that we don't know about
793 // or an id number that hasn't been read yet. We may be referencing something
794 // forward, so just create an entry to be resolved later and get to it...
795 //
796 V = new Argument(Ty);
797
798 // Remember where this forward reference came from. FIXME, shouldn't we try
799 // to recycle these things??
800 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
801 llvmAsmlineno)));
802
803 if (inFunctionScope())
804 InsertValue(V, CurFun.LateResolveValues);
805 else
806 InsertValue(V, CurModule.LateResolveValues);
807 return V;
808}
809
810/// getBBVal - This is used for two purposes:
811/// * If isDefinition is true, a new basic block with the specified ID is being
812/// defined.
813/// * If isDefinition is true, this is a reference to a basic block, which may
814/// or may not be a forward reference.
815///
816static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
817 assert(inFunctionScope() && "Can't get basic block at global scope!");
818
819 std::string Name;
820 BasicBlock *BB = 0;
821 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000822 default:
823 GenerateError("Illegal label reference " + ID.getName());
824 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000825 case ValID::NumberVal: // Is it a numbered definition?
826 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
827 CurFun.NumberedBlocks.resize(ID.Num+1);
828 BB = CurFun.NumberedBlocks[ID.Num];
829 break;
830 case ValID::NameVal: // Is it a named definition?
831 Name = ID.Name;
832 if (Value *N = CurFun.CurrentFunction->
Reid Spencer78d033e2007-01-06 07:24:44 +0000833 getValueSymbolTable().lookup(Type::LabelTy, Name))
Reid Spencer68a24bd2005-08-27 18:50:39 +0000834 BB = cast<BasicBlock>(N);
835 break;
836 }
837
838 // See if the block has already been defined.
839 if (BB) {
840 // If this is the definition of the block, make sure the existing value was
841 // just a forward reference. If it was a forward reference, there will be
842 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000843 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000844 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000845 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000846 return 0;
847 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000848
849 ID.destroy(); // Free strdup'd memory.
850 return BB;
851 }
852
853 // Otherwise this block has not been seen before.
854 BB = new BasicBlock("", CurFun.CurrentFunction);
855 if (ID.Type == ValID::NameVal) {
856 BB->setName(ID.Name);
857 } else {
858 CurFun.NumberedBlocks[ID.Num] = BB;
859 }
860
861 // If this is not a definition, keep track of it so we can use it as a forward
862 // reference.
863 if (!isDefinition) {
864 // Remember where this forward reference came from.
865 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
866 } else {
867 // The forward declaration could have been inserted anywhere in the
868 // function: insert it into the correct place now.
869 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
870 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
871 }
872 ID.destroy();
873 return BB;
874}
875
876
877//===----------------------------------------------------------------------===//
878// Code to handle forward references in instructions
879//===----------------------------------------------------------------------===//
880//
881// This code handles the late binding needed with statements that reference
882// values not defined yet... for example, a forward branch, or the PHI node for
883// a loop body.
884//
885// This keeps a table (CurFun.LateResolveValues) of all such forward references
886// and back patchs after we are done.
887//
888
889// ResolveDefinitions - If we could not resolve some defs at parsing
890// time (forward branches, phi functions for loops, etc...) resolve the
891// defs now...
892//
893static void
894ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
895 std::map<const Type*,ValueList> *FutureLateResolvers) {
896 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
897 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
898 E = LateResolvers.end(); LRI != E; ++LRI) {
899 ValueList &List = LRI->second;
900 while (!List.empty()) {
901 Value *V = List.back();
902 List.pop_back();
903
904 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
905 CurModule.PlaceHolderInfo.find(V);
906 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
907
908 ValID &DID = PHI->second.first;
909
910 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000911 if (TriggerError)
912 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000913 if (TheRealValue) {
914 V->replaceAllUsesWith(TheRealValue);
915 delete V;
916 CurModule.PlaceHolderInfo.erase(PHI);
917 } else if (FutureLateResolvers) {
918 // Functions have their unresolved items forwarded to the module late
919 // resolver table
920 InsertValue(V, *FutureLateResolvers);
921 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000922 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000923 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000924 "' of type '" + V->getType()->getDescription() + "'",
925 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000926 return;
927 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000928 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000929 itostr(DID.Num) + " of type '" +
930 V->getType()->getDescription() + "'",
931 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000932 return;
933 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000934 }
935 }
936 }
937
938 LateResolvers.clear();
939}
940
941// ResolveTypeTo - A brand new type was just declared. This means that (if
942// name is not null) things referencing Name can be resolved. Otherwise, things
943// refering to the number can be resolved. Do this now.
944//
945static void ResolveTypeTo(char *Name, const Type *ToTy) {
946 ValID D;
947 if (Name) D = ValID::create(Name);
948 else D = ValID::create((int)CurModule.Types.size());
949
Reid Spencer861d9d62006-11-28 07:29:44 +0000950 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000951 CurModule.LateResolveTypes.find(D);
952 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000953 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000954 CurModule.LateResolveTypes.erase(I);
955 }
956}
957
958// setValueName - Set the specified value to the name given. The name may be
959// null potentially, in which case this is a noop. The string passed in is
960// assumed to be a malloc'd string buffer, and is free'd by this function.
961//
962static void setValueName(Value *V, char *NameStr) {
963 if (NameStr) {
964 std::string Name(NameStr); // Copy string
965 free(NameStr); // Free old string
966
Reid Spencer5b7e7532006-09-28 19:28:24 +0000967 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000968 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000969 return;
970 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000971
972 assert(inFunctionScope() && "Must be in function scope!");
Reid Spencer78d033e2007-01-06 07:24:44 +0000973 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000974 if (ST.lookup(V->getType(), Name)) {
Reid Spencer63c34452007-01-05 21:51:07 +0000975 GenerateError("Redefinition of value '" + Name + "' of type '" +
976 V->getType()->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000977 return;
978 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000979
980 // Set the name.
981 V->setName(Name);
982 }
983}
984
985/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
986/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000987static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000988ParseGlobalVariable(char *NameStr,
989 GlobalValue::LinkageTypes Linkage,
990 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000991 bool isConstantGlobal, const Type *Ty,
992 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000993 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000994 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000995 return 0;
996 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000997
998 const PointerType *PTy = PointerType::get(Ty);
999
1000 std::string Name;
1001 if (NameStr) {
1002 Name = NameStr; // Copy string
1003 free(NameStr); // Free old string
1004 }
1005
1006 // See if this global value was forward referenced. If so, recycle the
1007 // object.
1008 ValID ID;
1009 if (!Name.empty()) {
1010 ID = ValID::create((char*)Name.c_str());
1011 } else {
1012 ID = ValID::create((int)CurModule.Values[PTy].size());
1013 }
1014
1015 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1016 // Move the global to the end of the list, from whereever it was
1017 // previously inserted.
1018 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1019 CurModule.CurrentModule->getGlobalList().remove(GV);
1020 CurModule.CurrentModule->getGlobalList().push_back(GV);
1021 GV->setInitializer(Initializer);
1022 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001023 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001024 GV->setConstant(isConstantGlobal);
1025 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001026 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001027 }
1028
1029 // If this global has a name, check to see if there is already a definition
Reid Spencer63c34452007-01-05 21:51:07 +00001030 // of this global in the module. If so, it is an error.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001031 if (!Name.empty()) {
1032 // We are a simple redefinition of a value, check to see if it is defined
1033 // the same as the old one.
Reid Spencer63c34452007-01-05 21:51:07 +00001034 if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001035 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer63c34452007-01-05 21:51:07 +00001036 "' of type '" + Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001037 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001038 }
1039 }
1040
1041 // Otherwise there is no existing GV to use, create one now.
1042 GlobalVariable *GV =
1043 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1044 CurModule.CurrentModule);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001045 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001046 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001047 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001048}
1049
1050// setTypeName - Set the specified type to the name given. The name may be
1051// null potentially, in which case this is a noop. The string passed in is
1052// assumed to be a malloc'd string buffer, and is freed by this function.
1053//
1054// This function returns true if the type has already been defined, but is
1055// allowed to be redefined in the specified context. If the name is a new name
1056// for the type plane, it is inserted and false is returned.
1057static bool setTypeName(const Type *T, char *NameStr) {
1058 assert(!inFunctionScope() && "Can't give types function-local names!");
1059 if (NameStr == 0) return false;
1060
1061 std::string Name(NameStr); // Copy string
1062 free(NameStr); // Free old string
1063
1064 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001065 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001066 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001067 return false;
1068 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001069
1070 // Set the type name, checking for conflicts as we do so.
1071 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1072
1073 if (AlreadyExists) { // Inserting a name that is already defined???
1074 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1075 assert(Existing && "Conflict but no matching type?");
1076
1077 // There is only one case where this is allowed: when we are refining an
1078 // opaque type. In this case, Existing will be an opaque type.
1079 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1080 // We ARE replacing an opaque type!
1081 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1082 return true;
1083 }
1084
1085 // Otherwise, this is an attempt to redefine a type. That's okay if
1086 // the redefinition is identical to the original. This will be so if
1087 // Existing and T point to the same Type object. In this one case we
1088 // allow the equivalent redefinition.
1089 if (Existing == T) return true; // Yes, it's equal.
1090
1091 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001092 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1093 T->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001094 }
1095
1096 return false;
1097}
1098
1099//===----------------------------------------------------------------------===//
1100// Code for handling upreferences in type names...
1101//
1102
1103// TypeContains - Returns true if Ty directly contains E in it.
1104//
1105static bool TypeContains(const Type *Ty, const Type *E) {
1106 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1107 E) != Ty->subtype_end();
1108}
1109
1110namespace {
1111 struct UpRefRecord {
1112 // NestingLevel - The number of nesting levels that need to be popped before
1113 // this type is resolved.
1114 unsigned NestingLevel;
1115
1116 // LastContainedTy - This is the type at the current binding level for the
1117 // type. Every time we reduce the nesting level, this gets updated.
1118 const Type *LastContainedTy;
1119
1120 // UpRefTy - This is the actual opaque type that the upreference is
1121 // represented with.
1122 OpaqueType *UpRefTy;
1123
1124 UpRefRecord(unsigned NL, OpaqueType *URTy)
1125 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1126 };
1127}
1128
1129// UpRefs - A list of the outstanding upreferences that need to be resolved.
1130static std::vector<UpRefRecord> UpRefs;
1131
1132/// HandleUpRefs - Every time we finish a new layer of types, this function is
1133/// called. It loops through the UpRefs vector, which is a list of the
1134/// currently active types. For each type, if the up reference is contained in
1135/// the newly completed type, we decrement the level count. When the level
1136/// count reaches zero, the upreferenced type is the type that is passed in:
1137/// thus we can complete the cycle.
1138///
1139static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001140 // If Ty isn't abstract, or if there are no up-references in it, then there is
1141 // nothing to resolve here.
1142 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1143
Reid Spencer68a24bd2005-08-27 18:50:39 +00001144 PATypeHolder Ty(ty);
1145 UR_OUT("Type '" << Ty->getDescription() <<
1146 "' newly formed. Resolving upreferences.\n" <<
1147 UpRefs.size() << " upreferences active!\n");
1148
1149 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1150 // to zero), we resolve them all together before we resolve them to Ty. At
1151 // the end of the loop, if there is anything to resolve to Ty, it will be in
1152 // this variable.
1153 OpaqueType *TypeToResolve = 0;
1154
1155 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1156 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1157 << UpRefs[i].second->getDescription() << ") = "
1158 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1159 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1160 // Decrement level of upreference
1161 unsigned Level = --UpRefs[i].NestingLevel;
1162 UpRefs[i].LastContainedTy = Ty;
1163 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1164 if (Level == 0) { // Upreference should be resolved!
1165 if (!TypeToResolve) {
1166 TypeToResolve = UpRefs[i].UpRefTy;
1167 } else {
1168 UR_OUT(" * Resolving upreference for "
1169 << UpRefs[i].second->getDescription() << "\n";
1170 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1171 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1172 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1173 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1174 }
1175 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1176 --i; // Do not skip the next element...
1177 }
1178 }
1179 }
1180
1181 if (TypeToResolve) {
1182 UR_OUT(" * Resolving upreference for "
1183 << UpRefs[i].second->getDescription() << "\n";
1184 std::string OldName = TypeToResolve->getDescription());
1185 TypeToResolve->refineAbstractTypeTo(Ty);
1186 }
1187
1188 return Ty;
1189}
1190
Reid Spencer68a24bd2005-08-27 18:50:39 +00001191//===----------------------------------------------------------------------===//
1192// RunVMAsmParser - Define an interface to this parser
1193//===----------------------------------------------------------------------===//
1194//
Reid Spencer14310612006-12-31 05:40:51 +00001195static Module* RunParser(Module * M);
1196
Reid Spencer68a24bd2005-08-27 18:50:39 +00001197Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1198 set_scan_file(F);
1199
1200 CurFilename = Filename;
1201 return RunParser(new Module(CurFilename));
1202}
1203
1204Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1205 set_scan_string(AsmString);
1206
1207 CurFilename = "from_memory";
1208 if (M == NULL) {
1209 return RunParser(new Module (CurFilename));
1210 } else {
1211 return RunParser(M);
1212 }
1213}
1214
1215
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001216
1217/* Enabling traces. */
1218#ifndef YYDEBUG
1219# define YYDEBUG 0
1220#endif
1221
1222/* Enabling verbose error messages. */
1223#ifdef YYERROR_VERBOSE
1224# undef YYERROR_VERBOSE
1225# define YYERROR_VERBOSE 1
1226#else
1227# define YYERROR_VERBOSE 0
1228#endif
1229
1230/* Enabling the token table. */
1231#ifndef YYTOKEN_TABLE
1232# define YYTOKEN_TABLE 0
1233#endif
1234
1235#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1236typedef union YYSTYPE
1237#line 883 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
1238{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001239 llvm::Module *ModuleVal;
1240 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001241 llvm::BasicBlock *BasicBlockVal;
1242 llvm::TerminatorInst *TermInstVal;
1243 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001244 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001245
Reid Spencera132e042006-12-03 05:46:11 +00001246 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001247 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001248 llvm::PATypeHolder *TypeVal;
1249 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001250 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001251 llvm::ArgListType *ArgList;
1252 llvm::TypeWithAttrs TypeWithAttrs;
1253 llvm::TypeWithAttrsList *TypeWithAttrsList;
1254 llvm::ValueRefList *ValueRefList;
1255
Reid Spencer68a24bd2005-08-27 18:50:39 +00001256 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001257 std::list<std::pair<llvm::Value*,
1258 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001259 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001260 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001261
1262 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001263 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer14310612006-12-31 05:40:51 +00001264 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001265 int64_t SInt64Val;
1266 uint64_t UInt64Val;
1267 int SIntVal;
1268 unsigned UIntVal;
1269 double FPVal;
1270 bool BoolVal;
1271
1272 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001273 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001274
Reid Spencera132e042006-12-03 05:46:11 +00001275 llvm::Instruction::BinaryOps BinaryOpVal;
1276 llvm::Instruction::TermOps TermOpVal;
1277 llvm::Instruction::MemoryOps MemOpVal;
1278 llvm::Instruction::CastOps CastOpVal;
1279 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001280 llvm::Module::Endianness Endianness;
Reid Spencera132e042006-12-03 05:46:11 +00001281 llvm::ICmpInst::Predicate IPredicate;
1282 llvm::FCmpInst::Predicate FPredicate;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001283}
1284/* Line 187 of yacc.c. */
1285#line 1286 "llvmAsmParser.tab.c"
1286 YYSTYPE;
1287# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1288# define YYSTYPE_IS_DECLARED 1
1289# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001290#endif
1291
1292
1293
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001294/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001295
1296
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001297/* Line 216 of yacc.c. */
1298#line 1299 "llvmAsmParser.tab.c"
Reid Spencere4d87aa2006-12-23 06:05:41 +00001299
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001300#ifdef short
1301# undef short
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001302#endif
1303
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001304#ifdef YYTYPE_UINT8
1305typedef YYTYPE_UINT8 yytype_uint8;
Andrew Lenharth6353e052006-12-08 18:07:09 +00001306#else
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001307typedef unsigned char yytype_uint8;
Andrew Lenharth6353e052006-12-08 18:07:09 +00001308#endif
1309
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001310#ifdef YYTYPE_INT8
1311typedef YYTYPE_INT8 yytype_int8;
1312#elif (defined __STDC__ || defined __C99__FUNC__ \
1313 || defined __cplusplus || defined _MSC_VER)
1314typedef signed char yytype_int8;
1315#else
1316typedef short int yytype_int8;
1317#endif
1318
1319#ifdef YYTYPE_UINT16
1320typedef YYTYPE_UINT16 yytype_uint16;
1321#else
1322typedef unsigned short int yytype_uint16;
1323#endif
1324
1325#ifdef YYTYPE_INT16
1326typedef YYTYPE_INT16 yytype_int16;
1327#else
1328typedef short int yytype_int16;
1329#endif
1330
1331#ifndef YYSIZE_T
1332# ifdef __SIZE_TYPE__
1333# define YYSIZE_T __SIZE_TYPE__
1334# elif defined size_t
1335# define YYSIZE_T size_t
1336# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1337 || defined __cplusplus || defined _MSC_VER)
1338# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1339# define YYSIZE_T size_t
1340# else
1341# define YYSIZE_T unsigned int
1342# endif
1343#endif
1344
1345#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1346
1347#ifndef YY_
1348# if YYENABLE_NLS
1349# if ENABLE_NLS
1350# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1351# define YY_(msgid) dgettext ("bison-runtime", msgid)
1352# endif
1353# endif
1354# ifndef YY_
1355# define YY_(msgid) msgid
1356# endif
1357#endif
1358
1359/* Suppress unused-variable warnings by "using" E. */
1360#if ! defined lint || defined __GNUC__
1361# define YYUSE(e) ((void) (e))
1362#else
1363# define YYUSE(e) /* empty */
1364#endif
1365
1366/* Identity function, used to suppress warnings about constant conditions. */
1367#ifndef lint
1368# define YYID(n) (n)
1369#else
1370#if (defined __STDC__ || defined __C99__FUNC__ \
1371 || defined __cplusplus || defined _MSC_VER)
1372static int
1373YYID (int i)
1374#else
1375static int
1376YYID (i)
1377 int i;
1378#endif
1379{
1380 return i;
1381}
1382#endif
1383
1384#if ! defined yyoverflow || YYERROR_VERBOSE
1385
1386/* The parser invokes alloca or malloc; define the necessary symbols. */
1387
1388# ifdef YYSTACK_USE_ALLOCA
1389# if YYSTACK_USE_ALLOCA
1390# ifdef __GNUC__
1391# define YYSTACK_ALLOC __builtin_alloca
1392# elif defined __BUILTIN_VA_ARG_INCR
1393# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1394# elif defined _AIX
1395# define YYSTACK_ALLOC __alloca
1396# elif defined _MSC_VER
1397# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1398# define alloca _alloca
1399# else
1400# define YYSTACK_ALLOC alloca
1401# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1402 || defined __cplusplus || defined _MSC_VER)
1403# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1404# ifndef _STDLIB_H
1405# define _STDLIB_H 1
1406# endif
1407# endif
1408# endif
1409# endif
1410# endif
1411
1412# ifdef YYSTACK_ALLOC
1413 /* Pacify GCC's `empty if-body' warning. */
1414# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1415# ifndef YYSTACK_ALLOC_MAXIMUM
1416 /* The OS might guarantee only one guard page at the bottom of the stack,
1417 and a page size can be as small as 4096 bytes. So we cannot safely
1418 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1419 to allow for a few compiler-allocated temporary stack slots. */
1420# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1421# endif
1422# else
1423# define YYSTACK_ALLOC YYMALLOC
1424# define YYSTACK_FREE YYFREE
1425# ifndef YYSTACK_ALLOC_MAXIMUM
1426# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1427# endif
1428# if (defined __cplusplus && ! defined _STDLIB_H \
1429 && ! ((defined YYMALLOC || defined malloc) \
1430 && (defined YYFREE || defined free)))
1431# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1432# ifndef _STDLIB_H
1433# define _STDLIB_H 1
1434# endif
1435# endif
1436# ifndef YYMALLOC
1437# define YYMALLOC malloc
1438# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1439 || defined __cplusplus || defined _MSC_VER)
1440void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1441# endif
1442# endif
1443# ifndef YYFREE
1444# define YYFREE free
1445# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1446 || defined __cplusplus || defined _MSC_VER)
1447void free (void *); /* INFRINGES ON USER NAME SPACE */
1448# endif
1449# endif
1450# endif
1451#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1452
1453
1454#if (! defined yyoverflow \
1455 && (! defined __cplusplus \
1456 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1457
1458/* A type that is properly aligned for any stack member. */
1459union yyalloc
1460{
1461 yytype_int16 yyss;
1462 YYSTYPE yyvs;
1463 };
1464
1465/* The size of the maximum gap between one aligned stack and the next. */
1466# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1467
1468/* The size of an array large to enough to hold all stacks, each with
1469 N elements. */
1470# define YYSTACK_BYTES(N) \
1471 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1472 + YYSTACK_GAP_MAXIMUM)
1473
1474/* Copy COUNT objects from FROM to TO. The source and destination do
1475 not overlap. */
1476# ifndef YYCOPY
1477# if defined __GNUC__ && 1 < __GNUC__
1478# define YYCOPY(To, From, Count) \
1479 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1480# else
1481# define YYCOPY(To, From, Count) \
1482 do \
1483 { \
1484 YYSIZE_T yyi; \
1485 for (yyi = 0; yyi < (Count); yyi++) \
1486 (To)[yyi] = (From)[yyi]; \
1487 } \
1488 while (YYID (0))
1489# endif
1490# endif
1491
1492/* Relocate STACK from its old location to the new one. The
1493 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1494 elements in the stack, and YYPTR gives the new location of the
1495 stack. Advance YYPTR to a properly aligned location for the next
1496 stack. */
1497# define YYSTACK_RELOCATE(Stack) \
1498 do \
1499 { \
1500 YYSIZE_T yynewbytes; \
1501 YYCOPY (&yyptr->Stack, Stack, yysize); \
1502 Stack = &yyptr->Stack; \
1503 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1504 yyptr += yynewbytes / sizeof (*yyptr); \
1505 } \
1506 while (YYID (0))
1507
1508#endif
1509
1510/* YYFINAL -- State number of the termination state. */
1511#define YYFINAL 36
1512/* YYLAST -- Last index in YYTABLE. */
1513#define YYLAST 1365
1514
1515/* YYNTOKENS -- Number of terminals. */
1516#define YYNTOKENS 148
1517/* YYNNTS -- Number of nonterminals. */
1518#define YYNNTS 79
1519/* YYNRULES -- Number of rules. */
1520#define YYNRULES 286
1521/* YYNRULES -- Number of states. */
1522#define YYNSTATES 571
1523
1524/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1525#define YYUNDEFTOK 2
1526#define YYMAXUTOK 388
1527
1528#define YYTRANSLATE(YYX) \
1529 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1530
1531/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1532static const yytype_uint8 yytranslate[] =
1533{
1534 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1538 138, 139, 136, 2, 135, 2, 2, 2, 2, 2,
1539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1540 143, 134, 144, 2, 2, 2, 2, 2, 2, 2,
1541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1543 2, 140, 137, 142, 2, 2, 2, 2, 2, 147,
1544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1546 141, 2, 2, 145, 2, 146, 2, 2, 2, 2,
1547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1559 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1560 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1561 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1562 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1563 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1564 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1565 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1566 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1567 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1568 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1569 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1570 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1571 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1572 125, 126, 127, 128, 129, 130, 131, 132, 133
1573};
1574
1575#if YYDEBUG
1576/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1577 YYRHS. */
1578static const yytype_uint16 yyprhs[] =
1579{
1580 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1581 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1582 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1583 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1584 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1585 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1586 119, 122, 123, 125, 127, 129, 131, 133, 135, 137,
1587 139, 140, 142, 143, 145, 147, 148, 150, 152, 154,
1588 156, 157, 159, 161, 163, 165, 167, 169, 172, 174,
1589 176, 177, 180, 182, 184, 185, 188, 189, 192, 193,
1590 197, 200, 201, 203, 204, 208, 210, 213, 215, 217,
1591 219, 221, 223, 225, 227, 230, 232, 235, 241, 247,
1592 253, 259, 263, 266, 272, 277, 280, 282, 284, 286,
1593 290, 292, 296, 298, 299, 301, 305, 310, 314, 318,
1594 323, 328, 332, 339, 345, 348, 351, 354, 357, 360,
1595 363, 366, 369, 372, 375, 382, 388, 397, 404, 411,
1596 419, 427, 434, 441, 450, 459, 463, 465, 467, 469,
1597 471, 472, 474, 477, 478, 482, 483, 487, 491, 493,
1598 497, 501, 502, 509, 510, 518, 519, 527, 530, 534,
1599 536, 538, 540, 544, 548, 552, 556, 560, 564, 566,
1600 567, 569, 571, 573, 574, 580, 584, 586, 590, 592,
1601 593, 603, 605, 607, 612, 614, 616, 619, 623, 624,
1602 626, 628, 630, 632, 634, 636, 638, 640, 642, 646,
1603 648, 654, 656, 658, 660, 662, 665, 668, 671, 675,
1604 678, 679, 681, 684, 687, 691, 701, 711, 720, 735,
1605 737, 739, 746, 752, 755, 762, 770, 774, 780, 781,
1606 782, 786, 789, 791, 797, 803, 810, 817, 822, 827,
1607 834, 839, 844, 851, 858, 861, 870, 872, 874, 875,
1608 879, 886, 890, 897, 900, 905, 912
1609};
1610
1611/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1612static const yytype_int16 yyrhs[] =
1613{
1614 186, 0, -1, 5, -1, 6, -1, 70, -1, 71,
1615 -1, 72, -1, 73, -1, 74, -1, 75, -1, 76,
1616 -1, 77, -1, 78, -1, 79, -1, 80, -1, 81,
1617 -1, 110, -1, 111, -1, 112, -1, 113, -1, 114,
1618 -1, 115, -1, 116, -1, 117, -1, 118, -1, 119,
1619 -1, 120, -1, 121, -1, 124, -1, 125, -1, 126,
1620 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
1621 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
1622 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
1623 -1, 99, -1, 100, -1, 101, -1, 102, -1, 103,
1624 -1, 90, -1, 91, -1, 92, -1, 93, -1, 20,
1625 -1, 21, -1, 10, -1, 11, -1, 12, -1, 199,
1626 134, -1, -1, 34, -1, 36, -1, 35, -1, 37,
1627 -1, 39, -1, 38, -1, 40, -1, 42, -1, -1,
1628 133, -1, -1, 38, -1, 40, -1, -1, 34, -1,
1629 35, -1, 36, -1, 39, -1, -1, 57, -1, 58,
1630 -1, 59, -1, 60, -1, 61, -1, 62, -1, 56,
1631 4, -1, 111, -1, 112, -1, -1, 166, 165, -1,
1632 131, -1, 165, -1, -1, 168, 167, -1, -1, 49,
1633 4, -1, -1, 135, 49, 4, -1, 28, 17, -1,
1634 -1, 171, -1, -1, 135, 174, 173, -1, 171, -1,
1635 49, 4, -1, 9, -1, 10, -1, 11, -1, 12,
1636 -1, 13, -1, 41, -1, 175, -1, 176, 136, -1,
1637 211, -1, 137, 4, -1, 176, 138, 180, 139, 168,
1638 -1, 8, 138, 180, 139, 168, -1, 140, 4, 141,
1639 176, 142, -1, 143, 4, 141, 176, 144, -1, 145,
1640 181, 146, -1, 145, 146, -1, 143, 145, 181, 146,
1641 144, -1, 143, 145, 146, 144, -1, 176, 166, -1,
1642 176, -1, 8, -1, 177, -1, 179, 135, 177, -1,
1643 179, -1, 179, 135, 31, -1, 31, -1, -1, 176,
1644 -1, 181, 135, 176, -1, 176, 140, 184, 142, -1,
1645 176, 140, 142, -1, 176, 147, 17, -1, 176, 143,
1646 184, 144, -1, 176, 145, 184, 146, -1, 176, 145,
1647 146, -1, 176, 143, 145, 184, 146, 144, -1, 176,
1648 143, 145, 146, 144, -1, 176, 32, -1, 176, 33,
1649 -1, 176, 211, -1, 176, 183, -1, 176, 19, -1,
1650 156, 3, -1, 156, 4, -1, 9, 20, -1, 9,
1651 21, -1, 157, 7, -1, 152, 138, 182, 30, 176,
1652 139, -1, 109, 138, 182, 222, 139, -1, 123, 138,
1653 182, 135, 182, 135, 182, 139, -1, 150, 138, 182,
1654 135, 182, 139, -1, 151, 138, 182, 135, 182, 139,
1655 -1, 82, 154, 138, 182, 135, 182, 139, -1, 83,
1656 155, 138, 182, 135, 182, 139, -1, 153, 138, 182,
1657 135, 182, 139, -1, 128, 138, 182, 135, 182, 139,
1658 -1, 129, 138, 182, 135, 182, 135, 182, 139, -1,
1659 130, 138, 182, 135, 182, 135, 182, 139, -1, 184,
1660 135, 182, -1, 182, -1, 26, -1, 27, -1, 187,
1661 -1, -1, 188, -1, 187, 188, -1, -1, 25, 189,
1662 207, -1, -1, 24, 190, 208, -1, 54, 53, 194,
1663 -1, 18, -1, 158, 14, 176, -1, 158, 14, 8,
1664 -1, -1, 158, 161, 185, 182, 191, 173, -1, -1,
1665 158, 159, 161, 185, 182, 192, 173, -1, -1, 158,
1666 160, 161, 185, 176, 193, 173, -1, 43, 196, -1,
1667 50, 134, 197, -1, 17, -1, 48, -1, 47, -1,
1668 45, 134, 195, -1, 46, 134, 4, -1, 44, 134,
1669 17, -1, 63, 134, 17, -1, 140, 198, 142, -1,
1670 198, 135, 17, -1, 17, -1, -1, 15, -1, 17,
1671 -1, 199, -1, -1, 201, 135, 176, 166, 200, -1,
1672 176, 166, 200, -1, 201, -1, 201, 135, 31, -1,
1673 31, -1, -1, 164, 178, 199, 138, 202, 139, 168,
1674 172, 169, -1, 22, -1, 145, -1, 163, 161, 203,
1675 204, -1, 23, -1, 146, -1, 214, 206, -1, 162,
1676 161, 203, -1, -1, 55, -1, 3, -1, 4, -1,
1677 7, -1, 20, -1, 21, -1, 32, -1, 33, -1,
1678 19, -1, 143, 184, 144, -1, 183, -1, 53, 209,
1679 17, 135, 17, -1, 149, -1, 199, -1, 211, -1,
1680 210, -1, 176, 212, -1, 214, 215, -1, 205, 215,
1681 -1, 216, 158, 217, -1, 216, 219, -1, -1, 16,
1682 -1, 64, 213, -1, 64, 8, -1, 65, 13, 212,
1683 -1, 65, 9, 212, 135, 13, 212, 135, 13, 212,
1684 -1, 66, 156, 212, 135, 13, 212, 140, 218, 142,
1685 -1, 66, 156, 212, 135, 13, 212, 140, 142, -1,
1686 67, 164, 178, 212, 138, 221, 139, 168, 30, 13,
1687 212, 68, 13, 212, -1, 68, -1, 69, -1, 218,
1688 156, 210, 135, 13, 212, -1, 156, 210, 135, 13,
1689 212, -1, 158, 224, -1, 176, 140, 212, 135, 212,
1690 142, -1, 220, 135, 140, 212, 135, 212, 142, -1,
1691 176, 212, 166, -1, 221, 135, 176, 212, 166, -1,
1692 -1, -1, 222, 135, 213, -1, 52, 51, -1, 51,
1693 -1, 150, 176, 212, 135, 212, -1, 151, 176, 212,
1694 135, 212, -1, 82, 154, 176, 212, 135, 212, -1,
1695 83, 155, 176, 212, 135, 212, -1, 153, 213, 135,
1696 213, -1, 152, 213, 30, 176, -1, 123, 213, 135,
1697 213, 135, 213, -1, 127, 213, 135, 176, -1, 128,
1698 213, 135, 213, -1, 129, 213, 135, 213, 135, 213,
1699 -1, 130, 213, 135, 213, 135, 213, -1, 122, 220,
1700 -1, 223, 164, 178, 212, 138, 221, 139, 168, -1,
1701 226, -1, 29, -1, -1, 104, 176, 170, -1, 104,
1702 176, 135, 10, 212, 170, -1, 105, 176, 170, -1,
1703 105, 176, 135, 10, 212, 170, -1, 106, 213, -1,
1704 225, 107, 176, 212, -1, 225, 108, 213, 135, 176,
1705 212, -1, 109, 176, 212, 222, -1
1706};
1707
1708/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1709static const yytype_uint16 yyrline[] =
1710{
1711 0, 1031, 1031, 1032, 1042, 1042, 1042, 1042, 1042, 1042,
1712 1042, 1042, 1042, 1043, 1043, 1043, 1044, 1044, 1044, 1044,
1713 1044, 1044, 1045, 1045, 1045, 1045, 1045, 1045, 1046, 1046,
1714 1046, 1048, 1048, 1049, 1049, 1050, 1050, 1051, 1051, 1052,
1715 1052, 1056, 1056, 1057, 1057, 1058, 1058, 1059, 1059, 1060,
1716 1060, 1061, 1061, 1062, 1062, 1063, 1064, 1069, 1070, 1070,
1717 1073, 1077, 1083, 1084, 1085, 1086, 1087, 1091, 1092, 1093,
1718 1097, 1098, 1102, 1103, 1104, 1108, 1109, 1110, 1111, 1112,
1719 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1129, 1130,
1720 1133, 1134, 1139, 1140, 1143, 1144, 1151, 1152, 1158, 1159,
1721 1167, 1175, 1176, 1181, 1182, 1183, 1188, 1201, 1201, 1201,
1722 1201, 1201, 1204, 1208, 1212, 1219, 1224, 1232, 1250, 1268,
1723 1273, 1285, 1295, 1299, 1309, 1316, 1323, 1330, 1335, 1340,
1724 1347, 1348, 1355, 1362, 1370, 1375, 1386, 1414, 1430, 1459,
1725 1487, 1512, 1531, 1556, 1575, 1587, 1594, 1657, 1667, 1677,
1726 1683, 1689, 1693, 1697, 1705, 1719, 1740, 1748, 1754, 1765,
1727 1770, 1775, 1784, 1790, 1796, 1805, 1809, 1817, 1817, 1828,
1728 1833, 1841, 1842, 1846, 1846, 1850, 1850, 1853, 1856, 1868,
1729 1892, 1903, 1903, 1912, 1912, 1920, 1920, 1930, 1933, 1939,
1730 1952, 1953, 1955, 1959, 1968, 1972, 1977, 1979, 1984, 1989,
1731 1998, 1998, 1999, 1999, 2001, 2011, 2022, 2026, 2035, 2044,
1732 2049, 2155, 2155, 2157, 2166, 2166, 2168, 2173, 2185, 2189,
1733 2194, 2198, 2202, 2206, 2210, 2214, 2218, 2222, 2226, 2251,
1734 2255, 2269, 2273, 2279, 2279, 2285, 2294, 2298, 2307, 2318,
1735 2327, 2339, 2352, 2356, 2360, 2365, 2374, 2393, 2402, 2469,
1736 2473, 2480, 2491, 2504, 2513, 2524, 2534, 2542, 2550, 2553,
1737 2554, 2561, 2565, 2570, 2591, 2608, 2621, 2634, 2643, 2656,
1738 2664, 2671, 2677, 2683, 2689, 2704, 2767, 2772, 2776, 2783,
1739 2790, 2798, 2805, 2813, 2821, 2835, 2852
1740};
1741#endif
1742
1743#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1744/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1745 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1746static const char *const yytname[] =
1747{
1748 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1749 "UINTVAL", "FPVAL", "VOID", "BOOL", "INTTYPE", "FLOAT", "DOUBLE",
1750 "LABEL", "TYPE", "VAR_ID", "LABELSTR", "STRINGCONSTANT",
1751 "IMPLEMENTATION", "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK",
1752 "ENDTOK", "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION",
1753 "VOLATILE", "TO", "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL",
1754 "LINKONCE", "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK",
1755 "OPAQUE", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE",
1756 "LITTLE", "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1757 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
1758 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1759 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1760 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1761 "XOR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
1762 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
1763 "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE",
1764 "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST",
1765 "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT",
1766 "PHI_TOK", "SELECT", "SHL", "LSHR", "ASHR", "VAARG", "EXTRACTELEMENT",
1767 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "DEFAULT", "HIDDEN", "'='",
1768 "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'",
1769 "'{'", "'}'", "'c'", "$accept", "INTVAL", "ArithmeticOps", "LogicalOps",
1770 "CastOps", "ShiftOps", "IPredicates", "FPredicates", "IntType", "FPType",
1771 "OptAssign", "GVInternalLinkage", "GVExternalLinkage",
1772 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1773 "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr",
1774 "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1775 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1776 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1777 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module",
1778 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1779 "BigOrLittle", "TargetDefinition", "LibrariesDefinition", "LibList",
1780 "Name", "OptName", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1781 "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect",
1782 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1783 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1784 "JumpTable", "Inst", "PHIList", "ValueRefList", "IndexList",
1785 "OptTailCall", "InstVal", "OptVolatile", "MemoryInst", 0
1786};
1787#endif
1788
1789# ifdef YYPRINT
1790/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1791 token YYLEX-NUM. */
1792static const yytype_uint16 yytoknum[] =
1793{
1794 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1795 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1796 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1797 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1798 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1799 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1800 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1801 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1802 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1803 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1804 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1805 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1806 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1807 385, 386, 387, 388, 61, 44, 42, 92, 40, 41,
1808 91, 120, 93, 60, 62, 123, 125, 99
1809};
1810# endif
1811
1812/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1813static const yytype_uint8 yyr1[] =
1814{
1815 0, 148, 149, 149, 150, 150, 150, 150, 150, 150,
1816 150, 150, 150, 151, 151, 151, 152, 152, 152, 152,
1817 152, 152, 152, 152, 152, 152, 152, 152, 153, 153,
1818 153, 154, 154, 154, 154, 154, 154, 154, 154, 154,
1819 154, 155, 155, 155, 155, 155, 155, 155, 155, 155,
1820 155, 155, 155, 155, 155, 155, 155, 156, 157, 157,
1821 158, 158, 159, 159, 159, 159, 159, 160, 160, 160,
1822 161, 161, 162, 162, 162, 163, 163, 163, 163, 163,
1823 164, 164, 164, 164, 164, 164, 164, 164, 165, 165,
1824 166, 166, 167, 167, 168, 168, 169, 169, 170, 170,
1825 171, 172, 172, 173, 173, 174, 174, 175, 175, 175,
1826 175, 175, 176, 176, 176, 176, 176, 176, 176, 176,
1827 176, 176, 176, 176, 176, 177, 178, 178, 179, 179,
1828 180, 180, 180, 180, 181, 181, 182, 182, 182, 182,
1829 182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
1830 182, 182, 182, 182, 183, 183, 183, 183, 183, 183,
1831 183, 183, 183, 183, 183, 184, 184, 185, 185, 186,
1832 186, 187, 187, 189, 188, 190, 188, 188, 188, 188,
1833 188, 191, 188, 192, 188, 193, 188, 188, 188, 194,
1834 195, 195, 196, 196, 196, 196, 197, 198, 198, 198,
1835 199, 199, 200, 200, 201, 201, 202, 202, 202, 202,
1836 203, 204, 204, 205, 206, 206, 207, 208, 209, 209,
1837 210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
1838 210, 211, 211, 212, 212, 213, 214, 214, 215, 216,
1839 216, 216, 217, 217, 217, 217, 217, 217, 217, 217,
1840 217, 218, 218, 219, 220, 220, 221, 221, 221, 222,
1841 222, 223, 223, 224, 224, 224, 224, 224, 224, 224,
1842 224, 224, 224, 224, 224, 224, 224, 225, 225, 226,
1843 226, 226, 226, 226, 226, 226, 226
1844};
1845
1846/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1847static const yytype_uint8 yyr2[] =
1848{
1849 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1850 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1851 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1852 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1853 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1854 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1855 2, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1856 0, 1, 0, 1, 1, 0, 1, 1, 1, 1,
1857 0, 1, 1, 1, 1, 1, 1, 2, 1, 1,
1858 0, 2, 1, 1, 0, 2, 0, 2, 0, 3,
1859 2, 0, 1, 0, 3, 1, 2, 1, 1, 1,
1860 1, 1, 1, 1, 2, 1, 2, 5, 5, 5,
1861 5, 3, 2, 5, 4, 2, 1, 1, 1, 3,
1862 1, 3, 1, 0, 1, 3, 4, 3, 3, 4,
1863 4, 3, 6, 5, 2, 2, 2, 2, 2, 2,
1864 2, 2, 2, 2, 6, 5, 8, 6, 6, 7,
1865 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
1866 0, 1, 2, 0, 3, 0, 3, 3, 1, 3,
1867 3, 0, 6, 0, 7, 0, 7, 2, 3, 1,
1868 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
1869 1, 1, 1, 0, 5, 3, 1, 3, 1, 0,
1870 9, 1, 1, 4, 1, 1, 2, 3, 0, 1,
1871 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
1872 5, 1, 1, 1, 1, 2, 2, 2, 3, 2,
1873 0, 1, 2, 2, 3, 9, 9, 8, 14, 1,
1874 1, 6, 5, 2, 6, 7, 3, 5, 0, 0,
1875 3, 2, 1, 5, 5, 6, 6, 4, 4, 6,
1876 4, 4, 6, 6, 2, 8, 1, 1, 0, 3,
1877 6, 3, 6, 2, 4, 6, 4
1878};
1879
1880/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1881 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1882 means the default is an error. */
1883static const yytype_uint16 yydefact[] =
1884{
1885 61, 200, 201, 178, 175, 173, 0, 0, 0, 70,
1886 0, 61, 171, 0, 72, 75, 0, 0, 0, 0,
1887 187, 0, 0, 0, 62, 64, 63, 65, 67, 66,
1888 68, 69, 71, 70, 70, 0, 1, 172, 60, 73,
1889 74, 70, 176, 76, 77, 78, 79, 70, 240, 174,
1890 240, 0, 0, 0, 0, 199, 188, 189, 177, 2,
1891 3, 180, 107, 108, 109, 110, 111, 112, 0, 0,
1892 0, 0, 231, 113, 179, 232, 115, 0, 0, 167,
1893 168, 0, 80, 80, 241, 237, 61, 214, 215, 216,
1894 236, 194, 191, 190, 192, 193, 195, 198, 0, 133,
1895 116, 0, 0, 0, 0, 122, 134, 0, 114, 133,
1896 0, 0, 107, 108, 109, 110, 0, 0, 0, 181,
1897 0, 81, 82, 83, 84, 85, 86, 0, 217, 0,
1898 278, 239, 0, 196, 132, 90, 128, 130, 0, 0,
1899 0, 0, 0, 0, 121, 0, 183, 185, 151, 152,
1900 149, 150, 153, 148, 144, 145, 4, 5, 6, 7,
1901 8, 9, 10, 11, 12, 13, 14, 15, 0, 0,
1902 0, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1903 25, 26, 27, 0, 28, 29, 30, 0, 0, 0,
1904 0, 0, 0, 0, 0, 0, 0, 0, 147, 146,
1905 103, 87, 127, 126, 0, 211, 212, 213, 277, 262,
1906 0, 0, 0, 0, 80, 249, 250, 0, 0, 0,
1907 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1908 0, 0, 0, 238, 80, 253, 0, 276, 197, 125,
1909 0, 94, 0, 0, 124, 0, 135, 94, 103, 103,
1910 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
1911 0, 55, 56, 51, 52, 53, 54, 41, 42, 43,
1912 44, 45, 46, 47, 48, 49, 50, 0, 0, 0,
1913 0, 0, 0, 137, 166, 0, 0, 0, 141, 0,
1914 138, 0, 0, 0, 0, 0, 182, 0, 261, 243,
1915 0, 242, 0, 0, 57, 0, 0, 0, 0, 98,
1916 98, 283, 0, 0, 274, 0, 0, 0, 0, 0,
1917 0, 0, 0, 0, 0, 0, 0, 88, 89, 91,
1918 131, 129, 118, 119, 120, 123, 117, 184, 186, 0,
1919 0, 259, 0, 0, 0, 0, 0, 136, 122, 134,
1920 0, 139, 140, 0, 0, 0, 0, 0, 0, 105,
1921 103, 209, 220, 221, 222, 227, 223, 224, 225, 226,
1922 218, 0, 229, 234, 233, 235, 0, 244, 0, 0,
1923 0, 0, 0, 279, 0, 281, 259, 0, 0, 0,
1924 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1925 0, 92, 93, 95, 0, 0, 0, 0, 0, 0,
1926 0, 165, 143, 0, 0, 0, 0, 0, 100, 106,
1927 104, 208, 90, 206, 0, 219, 0, 0, 0, 0,
1928 0, 0, 0, 0, 0, 0, 286, 0, 0, 0,
1929 270, 271, 0, 0, 0, 0, 268, 267, 0, 284,
1930 0, 0, 0, 0, 155, 0, 0, 0, 0, 142,
1931 0, 0, 0, 0, 203, 0, 94, 0, 228, 0,
1932 0, 258, 0, 0, 98, 99, 98, 0, 0, 0,
1933 0, 0, 263, 264, 258, 0, 0, 0, 260, 0,
1934 162, 0, 0, 157, 158, 154, 161, 202, 205, 207,
1935 90, 101, 0, 0, 0, 0, 0, 265, 266, 0,
1936 280, 282, 0, 0, 269, 272, 273, 0, 285, 159,
1937 160, 0, 0, 0, 203, 102, 96, 230, 0, 0,
1938 90, 0, 94, 254, 0, 94, 156, 163, 164, 204,
1939 0, 210, 0, 247, 0, 0, 256, 0, 0, 255,
1940 275, 97, 245, 0, 246, 0, 90, 0, 0, 0,
1941 257, 0, 0, 0, 0, 252, 0, 0, 251, 0,
1942 248
1943};
1944
1945/* YYDEFGOTO[NTERM-NUM]. */
1946static const yytype_int16 yydefgoto[] =
1947{
1948 -1, 72, 194, 195, 196, 197, 260, 277, 116, 117,
1949 9, 33, 34, 35, 41, 47, 127, 329, 239, 403,
1950 332, 541, 383, 359, 526, 296, 360, 73, 118, 136,
1951 204, 137, 138, 107, 284, 372, 285, 81, 10, 11,
1952 12, 15, 14, 200, 248, 249, 58, 94, 20, 56,
1953 98, 75, 498, 423, 424, 128, 207, 48, 89, 49,
1954 42, 426, 373, 76, 375, 301, 50, 85, 86, 233,
1955 545, 131, 314, 506, 406, 234, 235, 236, 237
1956};
1957
1958/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1959 STATE-NUM. */
1960#define YYPACT_NINF -425
1961static const yytype_int16 yypact[] =
1962{
1963 320, -425, -425, -425, -425, -425, 19, -109, -23, 37,
1964 53, 392, -425, -78, 163, 228, -47, -44, -41, -38,
1965 -425, -72, 97, 879, -425, -425, -425, -425, -425, -425,
1966 -425, -425, -425, 2, 2, 137, -425, -425, -425, -425,
1967 -425, 2, -425, -425, -425, -425, -425, 2, 159, -425,
1968 16, 102, 218, 198, 208, 211, -425, -425, -425, -425,
1969 -425, 113, -425, -425, -425, -425, -425, -425, 275, 279,
1970 15, 244, -425, -425, 122, -425, -425, 137, 137, -425,
1971 -425, 1099, 419, 419, -425, -425, 274, -425, -425, -425,
1972 -425, -425, -425, -425, -425, -425, -425, -425, -51, 586,
1973 -425, 149, 162, 498, 113, -425, 122, -104, -425, 586,
1974 1099, 1113, 164, 192, 297, 298, 270, 302, 29, -425,
1975 309, -425, -425, -425, -425, -425, -425, 1126, -425, -15,
1976 1235, -425, 299, -425, -425, 122, -425, 180, 179, 1113,
1977 1113, 175, -80, 1113, -425, 182, -425, 122, -425, -425,
1978 -425, -425, -425, -425, -425, -425, -425, -425, -425, -425,
1979 -425, -425, -425, -425, -425, -425, -425, -425, 478, 905,
1980 184, -425, -425, -425, -425, -425, -425, -425, -425, -425,
1981 -425, -425, -425, 185, -425, -425, -425, 186, 189, 190,
1982 734, 1140, 517, 312, 193, 194, 196, 201, -425, -425,
1983 195, -425, 113, 122, 274, -425, -425, -425, -425, -425,
1984 285, 1153, 119, 330, 419, -425, -425, 478, 905, 1113,
1985 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113,
1986 1113, 1113, 1113, -425, 419, -425, 188, -425, -425, 187,
1987 779, -425, 51, 35, -425, 197, 122, -425, 195, 195,
1988 -425, -425, -425, -425, -425, -425, -425, -425, -425, -425,
1989 204, -425, -425, -425, -425, -425, -425, -425, -425, -425,
1990 -425, -425, -425, -425, -425, -425, -425, 205, 1099, 1099,
1991 1099, 1099, 1099, -425, -425, -8, 544, -66, -425, -76,
1992 -425, 1099, 1099, 1099, 1099, 9, -425, 210, -425, 113,
1993 688, -425, 829, 829, -425, 829, 1126, 1113, 1113, 108,
1994 142, -425, 688, 52, 219, 220, 223, 226, 229, 231,
1995 688, 688, 316, 232, 1126, 1113, 1113, -425, -425, -425,
1996 -425, -425, -71, -425, -425, -425, -71, -425, -425, 1099,
1997 1099, -425, 233, 234, 238, 245, 1099, -425, 209, 29,
1998 -13, -425, -425, 250, 251, 358, 256, 378, 394, -425,
1999 195, 1048, -425, -425, -425, -425, -425, -425, -425, -425,
2000 346, 1099, -425, -425, -425, -425, 268, -425, 276, 829,
2001 688, 688, -2, -425, 18, -425, -425, 829, 273, 1113,
2002 1113, 1113, 1113, 1113, 283, 284, 1113, 1113, 829, 688,
2003 286, -425, -425, -425, 287, 290, 59, 1099, 1099, 1099,
2004 1099, -425, -425, 282, 1099, 1099, 1113, 1099, -425, -425,
2005 -425, -425, 122, 292, 281, -425, 397, -52, 415, 416,
2006 300, 295, 306, 829, 433, 829, 308, 310, 829, 313,
2007 122, -425, 314, 315, 829, 829, 122, -425, 317, -425,
2008 1113, 1099, 1099, 1113, -425, 318, 305, 319, 321, -425,
2009 322, 323, 148, 324, 12, 1086, -425, 325, -425, 829,
2010 829, 1113, 829, 829, 333, -425, 333, 829, 336, 1113,
2011 1113, 1113, -425, -425, 1113, 688, 334, 347, -425, 1099,
2012 -425, 1099, 1099, -425, -425, -425, -425, -425, -425, -425,
2013 122, 5, 430, 337, 345, 688, 106, -425, -425, 403,
2014 -425, -425, 349, 829, -425, -425, -425, 136, -425, -425,
2015 -425, 348, 353, 355, 12, -425, 409, -425, 446, -5,
2016 -425, 1113, -425, -425, 356, -425, -425, -425, -425, -425,
2017 491, -425, 829, -425, 957, 14, 187, 688, 88, -425,
2018 -71, -425, -425, 362, -425, 957, -425, 486, 487, 370,
2019 187, 829, 829, 499, 448, -425, 829, 501, -425, 829,
2020 -425
2021};
2022
2023/* YYPGOTO[NTERM-NUM]. */
2024static const yytype_int16 yypgoto[] =
2025{
2026 -425, -425, 388, 389, 390, 391, 326, 327, -212, -425,
2027 445, -425, -425, 47, -425, -425, -196, -310, -379, -425,
2028 -235, -425, -308, 32, -425, -199, -425, -425, -14, 304,
2029 -270, -425, 426, 434, -58, -112, -188, 224, -425, -425,
2030 529, -425, -425, -425, -425, -425, -425, -425, -425, -425,
2031 -425, 0, 22, -425, -425, 459, -425, -425, -425, -425,
2032 -425, -425, -424, -73, 103, -211, -425, 510, -425, -425,
2033 -425, -425, -425, 67, 191, -425, -425, -425, -425
2034};
2035
2036/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2037 positive, shift that token. If negative, reduce the rule which
2038 number is the opposite. If zero, do what YYDEFACT says.
2039 If YYTABLE_NINF, syntax error. */
2040#define YYTABLE_NINF -171
2041static const yytype_int16 yytable[] =
2042{
2043 13, 305, 385, 287, 289, 304, 198, 205, 433, 74,
2044 311, 13, 336, 315, 316, 317, 318, 319, 306, 102,
2045 322, 323, 402, 119, 304, 21, 402, 1, 435, 2,
2046 22, 143, 84, 357, 59, 60, 379, 357, 324, 87,
2047 327, 328, 144, 464, 1, 199, 2, 434, 153, 337,
2048 338, 23, 146, 36, 398, 143, 38, 106, 358, 346,
2049 401, 154, 155, 16, 17, 18, 245, 434, 55, 346,
2050 352, 24, 25, 26, 27, 28, 29, 30, 351, 31,
2051 77, 78, 19, 346, 132, 135, 13, 51, 82, 106,
2052 52, 133, 468, 53, 83, 135, 54, 147, 350, 156,
2053 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
2054 167, 168, 169, 203, 57, 400, 327, 328, 557, 91,
2055 553, 524, 346, 327, 328, 242, 243, 346, 302, 246,
2056 206, 559, 303, 413, 347, 32, 401, 543, 170, 171,
2057 172, 173, 174, 175, 176, 177, 178, 179, 180, 181,
2058 182, 546, 183, 184, 185, 186, 554, 187, 188, 189,
2059 103, 420, 88, 79, 80, 108, 510, 109, 511, 190,
2060 32, 108, 191, 109, 192, 84, 193, 560, 439, 334,
2061 441, 442, 443, 427, 148, 149, 447, 108, 108, 109,
2062 109, 402, 387, 333, 453, -57, -57, 300, 454, 327,
2063 328, 39, 95, 40, 297, 309, 310, 300, 312, 313,
2064 300, 300, 300, 300, 300, 320, 321, 300, 300, 401,
2065 341, 342, 343, 344, 345, 96, 135, 374, 97, 374,
2066 374, 501, 374, 353, 354, 355, 356, 198, 402, 374,
2067 402, 531, 488, 382, 108, 532, 109, 374, 374, 59,
2068 60, 99, 104, 62, 63, 64, 65, 66, 108, 1,
2069 109, 2, 43, 44, 45, 92, 93, 46, 514, 515,
2070 516, 531, 349, 150, 151, 535, 199, 384, 108, 100,
2071 109, 404, 405, 101, 108, 67, 109, 495, 411, 1,
2072 139, 2, 203, 380, 381, 325, 326, 548, 327, 328,
2073 550, 110, 111, 140, -58, -59, 374, 374, 374, 152,
2074 203, 399, 300, 201, 374, 240, 238, 544, 241, 244,
2075 -170, 247, 278, 279, 280, 374, 374, 281, 282, 290,
2076 295, 291, 292, 555, 293, 1, 298, 2, 3, 294,
2077 304, 335, 339, 340, 4, 5, 396, 422, 361, 455,
2078 456, 457, 458, 412, 388, 389, 460, 461, 390, 463,
2079 374, 391, 374, 6, 392, 374, 393, 397, 407, 408,
2080 7, 374, 374, 409, 8, 300, 440, 300, 300, 300,
2081 410, 68, 446, 300, 69, 414, 415, 70, 416, 71,
2082 105, 417, -169, 486, 487, 418, 374, 374, 419, 374,
2083 374, 425, 462, 428, 374, 376, 377, 1, 378, 2,
2084 3, 429, 374, 438, 467, 386, 4, 5, 444, 445,
2085 466, 450, 451, 394, 395, 452, 459, 465, 469, 470,
2086 472, 521, 374, 522, 523, 6, 485, 475, 471, 300,
2087 374, 473, 7, 453, 490, 477, 8, 527, 479, 480,
2088 481, 500, 434, 489, 491, 484, 492, 505, 540, 542,
2089 502, 493, 494, 496, 497, 300, 300, 300, 509, 374,
2090 505, 513, 528, 519, 374, 120, 121, 122, 123, 124,
2091 125, 126, 430, 431, 432, 529, 520, 536, 374, 374,
2092 437, 533, 537, 374, 538, 551, 374, 558, 549, 561,
2093 562, 448, 449, 59, 60, 563, 104, 62, 63, 64,
2094 65, 66, 566, 1, 569, 2, 567, 547, 229, 230,
2095 231, 232, 59, 60, 497, 104, 112, 113, 114, 115,
2096 66, 130, 1, 525, 2, 145, 474, 142, 476, 67,
2097 37, 478, 129, 307, 331, 308, 539, 482, 483, 59,
2098 60, 517, 104, 112, 113, 114, 115, 66, 67, 1,
2099 90, 2, 250, 251, 252, 253, 254, 255, 256, 257,
2100 258, 259, 503, 504, 0, 507, 508, 436, 0, 0,
2101 512, 0, 0, 0, 0, 67, 0, 0, 518, 0,
2102 0, 59, 60, 0, 104, 62, 63, 64, 65, 66,
2103 0, 1, 0, 2, 0, 0, 0, 0, 530, 0,
2104 0, 0, 0, 0, 0, 0, 534, 134, 0, 0,
2105 0, 0, 0, 0, 0, 0, 0, 67, 0, 0,
2106 0, 0, 0, 0, 0, 68, 0, 0, 69, 0,
2107 0, 70, 0, 71, 141, 552, 0, 0, 0, 0,
2108 556, 0, 0, 0, 68, 0, 0, 69, 0, 0,
2109 70, 0, 71, 288, 564, 565, 0, 0, 0, 568,
2110 0, 0, 570, 0, 0, 0, 0, 0, 0, 0,
2111 0, 68, 0, 0, 69, 0, 0, 70, 0, 71,
2112 348, 362, 363, 59, 60, 364, 0, 0, 0, 0,
2113 0, 0, 0, 1, 0, 2, 0, 365, 366, 367,
2114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2115 368, 369, 0, 68, 0, 0, 69, 0, 0, 70,
2116 0, 71, 0, 0, 0, 0, 0, 0, 0, 59,
2117 60, 370, 104, 112, 113, 114, 115, 66, 0, 1,
2118 0, 2, 0, 0, 0, 0, 0, 0, 156, 157,
2119 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
2120 168, 169, 0, 0, 0, 67, 0, 0, 0, 0,
2121 0, 0, 0, 0, 59, 60, 0, 104, 62, 63,
2122 64, 65, 66, 0, 1, 0, 2, 170, 171, 172,
2123 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2124 330, 183, 184, 185, 186, 0, 187, 188, 189, 0,
2125 67, 0, 0, 0, 108, 0, 109, 0, 0, 0,
2126 0, 371, 362, 363, 59, 60, 364, 0, 0, 0,
2127 0, 0, 0, 0, 1, 0, 2, 0, 365, 366,
2128 367, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2129 0, 368, 369, 0, 0, 0, 0, 0, 0, 0,
2130 0, 68, 0, 0, 69, 0, 283, 70, 0, 71,
2131 0, 0, 370, 0, 59, 60, 0, 61, 62, 63,
2132 64, 65, 66, 0, 1, 0, 2, 0, 0, 156,
2133 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
2134 167, 168, 169, 0, 0, 0, 68, 0, 0, 69,
2135 67, 0, 70, 0, 71, 261, 262, 0, 0, 0,
2136 0, 0, 0, 0, 0, 0, 0, 0, 170, 171,
2137 172, 173, 174, 175, 176, 177, 178, 179, 180, 181,
2138 182, 0, 183, 184, 185, 186, 0, 187, 188, 189,
2139 362, 363, 0, 0, 364, 0, 0, 0, 0, 0,
2140 0, 0, 371, 0, 0, 0, 365, 366, 367, 0,
2141 0, 0, 0, 0, 0, 0, 0, 0, 0, 368,
2142 369, 0, 0, 0, 0, 263, 264, 265, 266, 267,
2143 268, 269, 270, 271, 272, 273, 274, 275, 276, 0,
2144 370, 0, 0, 0, 0, 0, 68, 0, 0, 69,
2145 0, 0, 70, 0, 71, 0, 0, 156, 157, 158,
2146 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
2147 169, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2148 0, 0, 0, 59, 60, 0, 104, 62, 63, 64,
2149 65, 66, 0, 1, 0, 2, 170, 171, 172, 173,
2150 174, 175, 176, 177, 178, 179, 180, 181, 182, 421,
2151 183, 184, 185, 186, 0, 187, 188, 189, 0, 67,
2152 0, 59, 60, 0, 104, 62, 63, 64, 65, 66,
2153 371, 1, 0, 2, 59, 60, 0, 104, 112, 113,
2154 114, 115, 66, 0, 1, 0, 2, 499, 59, 60,
2155 0, 104, 62, 63, 64, 65, 66, 67, 1, 0,
2156 2, 59, 60, 0, 202, 62, 63, 64, 65, 66,
2157 67, 1, 0, 2, 0, 59, 60, 0, 104, 112,
2158 113, 114, 115, 66, 67, 1, 0, 2, 59, 60,
2159 0, 299, 62, 63, 64, 65, 66, 67, 1, 0,
2160 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2161 0, 67, 0, 0, 0, 68, 0, 0, 69, 0,
2162 0, 70, 0, 71, 67, 0, 0, 0, 0, 0,
2163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2165 0, 0, 0, 68, 0, 0, 69, 0, 0, 70,
2166 0, 71, 0, 0, 0, 0, 68, 0, 0, 69,
2167 0, 0, 70, 0, 71, 0, 0, 0, 0, 0,
2168 68, 0, 0, 69, 0, 0, 70, 0, 71, 0,
2169 0, 0, 0, 68, 208, 0, 69, 0, 0, 70,
2170 0, 71, 0, 0, 0, 0, 0, 68, 0, 0,
2171 69, 0, 0, 70, 0, 286, 209, 210, 0, 0,
2172 68, 0, 0, 69, 0, 0, 70, 0, 71, 211,
2173 212, 213, 214, 215, 216, 156, 157, 158, 159, 160,
2174 161, 162, 163, 164, 165, 166, 167, 217, 218, 0,
2175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2176 0, 0, 0, 0, 0, 0, 0, 0, 0, 219,
2177 220, 221, 0, 0, 222, 171, 172, 173, 174, 175,
2178 176, 177, 178, 179, 180, 181, 182, 223, 224, 184,
2179 185, 186, 225, 226, 227, 228
2180};
2181
2182static const yytype_int16 yycheck[] =
2183{
2184 0, 213, 310, 191, 192, 10, 118, 22, 10, 23,
2185 221, 11, 247, 224, 225, 226, 227, 228, 214, 4,
2186 231, 232, 332, 81, 10, 134, 336, 15, 10, 17,
2187 53, 135, 16, 28, 5, 6, 306, 28, 234, 23,
2188 111, 112, 146, 422, 15, 118, 17, 49, 19, 248,
2189 249, 14, 110, 0, 324, 135, 134, 71, 49, 135,
2190 131, 32, 33, 44, 45, 46, 146, 49, 140, 135,
2191 146, 34, 35, 36, 37, 38, 39, 40, 144, 42,
2192 33, 34, 63, 135, 135, 99, 86, 134, 41, 103,
2193 134, 142, 144, 134, 47, 109, 134, 111, 286, 70,
2194 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2195 81, 82, 83, 127, 17, 326, 111, 112, 30, 17,
2196 544, 500, 135, 111, 112, 139, 140, 135, 9, 143,
2197 145, 555, 13, 146, 142, 133, 131, 142, 109, 110,
2198 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
2199 121, 530, 123, 124, 125, 126, 142, 128, 129, 130,
2200 145, 360, 146, 26, 27, 136, 474, 138, 476, 140,
2201 133, 136, 143, 138, 145, 16, 147, 556, 389, 144,
2202 391, 392, 393, 371, 20, 21, 397, 136, 136, 138,
2203 138, 501, 140, 142, 135, 3, 4, 211, 139, 111,
2204 112, 38, 4, 40, 204, 219, 220, 221, 222, 223,
2205 224, 225, 226, 227, 228, 229, 230, 231, 232, 131,
2206 278, 279, 280, 281, 282, 17, 240, 300, 17, 302,
2207 303, 466, 305, 291, 292, 293, 294, 349, 548, 312,
2208 550, 135, 453, 135, 136, 139, 138, 320, 321, 5,
2209 6, 138, 8, 9, 10, 11, 12, 13, 136, 15,
2210 138, 17, 34, 35, 36, 47, 48, 39, 479, 480,
2211 481, 135, 286, 3, 4, 139, 349, 135, 136, 4,
2212 138, 339, 340, 4, 136, 41, 138, 139, 346, 15,
2213 141, 17, 306, 307, 308, 107, 108, 532, 111, 112,
2214 535, 77, 78, 141, 7, 7, 379, 380, 381, 7,
2215 324, 325, 326, 4, 387, 135, 17, 529, 139, 144,
2216 0, 139, 138, 138, 138, 398, 399, 138, 138, 17,
2217 135, 138, 138, 545, 138, 15, 51, 17, 18, 138,
2218 10, 144, 138, 138, 24, 25, 30, 361, 138, 407,
2219 408, 409, 410, 144, 135, 135, 414, 415, 135, 417,
2220 433, 135, 435, 43, 135, 438, 135, 135, 135, 135,
2221 50, 444, 445, 135, 54, 389, 390, 391, 392, 393,
2222 135, 137, 396, 397, 140, 135, 135, 143, 30, 145,
2223 146, 135, 0, 451, 452, 17, 469, 470, 4, 472,
2224 473, 55, 416, 135, 477, 302, 303, 15, 305, 17,
2225 18, 135, 485, 140, 17, 312, 24, 25, 135, 135,
2226 139, 135, 135, 320, 321, 135, 144, 135, 13, 13,
2227 135, 489, 505, 491, 492, 43, 450, 4, 138, 453,
2228 513, 135, 50, 135, 139, 135, 54, 17, 135, 135,
2229 135, 465, 49, 135, 135, 138, 135, 471, 49, 13,
2230 135, 139, 139, 139, 464, 479, 480, 481, 135, 542,
2231 484, 135, 135, 139, 547, 56, 57, 58, 59, 60,
2232 61, 62, 379, 380, 381, 140, 139, 139, 561, 562,
2233 387, 142, 139, 566, 139, 4, 569, 135, 142, 13,
2234 13, 398, 399, 5, 6, 135, 8, 9, 10, 11,
2235 12, 13, 13, 15, 13, 17, 68, 531, 130, 130,
2236 130, 130, 5, 6, 524, 8, 9, 10, 11, 12,
2237 13, 86, 15, 501, 17, 109, 433, 103, 435, 41,
2238 11, 438, 83, 217, 240, 218, 524, 444, 445, 5,
2239 6, 484, 8, 9, 10, 11, 12, 13, 41, 15,
2240 50, 17, 84, 85, 86, 87, 88, 89, 90, 91,
2241 92, 93, 469, 470, -1, 472, 473, 386, -1, -1,
2242 477, -1, -1, -1, -1, 41, -1, -1, 485, -1,
2243 -1, 5, 6, -1, 8, 9, 10, 11, 12, 13,
2244 -1, 15, -1, 17, -1, -1, -1, -1, 505, -1,
2245 -1, -1, -1, -1, -1, -1, 513, 31, -1, -1,
2246 -1, -1, -1, -1, -1, -1, -1, 41, -1, -1,
2247 -1, -1, -1, -1, -1, 137, -1, -1, 140, -1,
2248 -1, 143, -1, 145, 146, 542, -1, -1, -1, -1,
2249 547, -1, -1, -1, 137, -1, -1, 140, -1, -1,
2250 143, -1, 145, 146, 561, 562, -1, -1, -1, 566,
2251 -1, -1, 569, -1, -1, -1, -1, -1, -1, -1,
2252 -1, 137, -1, -1, 140, -1, -1, 143, -1, 145,
2253 146, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2254 -1, -1, -1, 15, -1, 17, -1, 19, 20, 21,
2255 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2256 32, 33, -1, 137, -1, -1, 140, -1, -1, 143,
2257 -1, 145, -1, -1, -1, -1, -1, -1, -1, 5,
2258 6, 53, 8, 9, 10, 11, 12, 13, -1, 15,
2259 -1, 17, -1, -1, -1, -1, -1, -1, 70, 71,
2260 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2261 82, 83, -1, -1, -1, 41, -1, -1, -1, -1,
2262 -1, -1, -1, -1, 5, 6, -1, 8, 9, 10,
2263 11, 12, 13, -1, 15, -1, 17, 109, 110, 111,
2264 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2265 31, 123, 124, 125, 126, -1, 128, 129, 130, -1,
2266 41, -1, -1, -1, 136, -1, 138, -1, -1, -1,
2267 -1, 143, 3, 4, 5, 6, 7, -1, -1, -1,
2268 -1, -1, -1, -1, 15, -1, 17, -1, 19, 20,
2269 21, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2270 -1, 32, 33, -1, -1, -1, -1, -1, -1, -1,
2271 -1, 137, -1, -1, 140, -1, 142, 143, -1, 145,
2272 -1, -1, 53, -1, 5, 6, -1, 8, 9, 10,
2273 11, 12, 13, -1, 15, -1, 17, -1, -1, 70,
2274 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2275 81, 82, 83, -1, -1, -1, 137, -1, -1, 140,
2276 41, -1, 143, -1, 145, 20, 21, -1, -1, -1,
2277 -1, -1, -1, -1, -1, -1, -1, -1, 109, 110,
2278 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
2279 121, -1, 123, 124, 125, 126, -1, 128, 129, 130,
2280 3, 4, -1, -1, 7, -1, -1, -1, -1, -1,
2281 -1, -1, 143, -1, -1, -1, 19, 20, 21, -1,
2282 -1, -1, -1, -1, -1, -1, -1, -1, -1, 32,
2283 33, -1, -1, -1, -1, 90, 91, 92, 93, 94,
2284 95, 96, 97, 98, 99, 100, 101, 102, 103, -1,
2285 53, -1, -1, -1, -1, -1, 137, -1, -1, 140,
2286 -1, -1, 143, -1, 145, -1, -1, 70, 71, 72,
2287 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2288 83, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2289 -1, -1, -1, 5, 6, -1, 8, 9, 10, 11,
2290 12, 13, -1, 15, -1, 17, 109, 110, 111, 112,
2291 113, 114, 115, 116, 117, 118, 119, 120, 121, 31,
2292 123, 124, 125, 126, -1, 128, 129, 130, -1, 41,
2293 -1, 5, 6, -1, 8, 9, 10, 11, 12, 13,
2294 143, 15, -1, 17, 5, 6, -1, 8, 9, 10,
2295 11, 12, 13, -1, 15, -1, 17, 31, 5, 6,
2296 -1, 8, 9, 10, 11, 12, 13, 41, 15, -1,
2297 17, 5, 6, -1, 8, 9, 10, 11, 12, 13,
2298 41, 15, -1, 17, -1, 5, 6, -1, 8, 9,
2299 10, 11, 12, 13, 41, 15, -1, 17, 5, 6,
2300 -1, 8, 9, 10, 11, 12, 13, 41, 15, -1,
2301 17, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2302 -1, 41, -1, -1, -1, 137, -1, -1, 140, -1,
2303 -1, 143, -1, 145, 41, -1, -1, -1, -1, -1,
2304 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2305 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2306 -1, -1, -1, 137, -1, -1, 140, -1, -1, 143,
2307 -1, 145, -1, -1, -1, -1, 137, -1, -1, 140,
2308 -1, -1, 143, -1, 145, -1, -1, -1, -1, -1,
2309 137, -1, -1, 140, -1, -1, 143, -1, 145, -1,
2310 -1, -1, -1, 137, 29, -1, 140, -1, -1, 143,
2311 -1, 145, -1, -1, -1, -1, -1, 137, -1, -1,
2312 140, -1, -1, 143, -1, 145, 51, 52, -1, -1,
2313 137, -1, -1, 140, -1, -1, 143, -1, 145, 64,
2314 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2315 75, 76, 77, 78, 79, 80, 81, 82, 83, -1,
2316 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2317 -1, -1, -1, -1, -1, -1, -1, -1, -1, 104,
2318 105, 106, -1, -1, 109, 110, 111, 112, 113, 114,
2319 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2320 125, 126, 127, 128, 129, 130
2321};
2322
2323/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2324 symbol of state STATE-NUM. */
2325static const yytype_uint8 yystos[] =
2326{
2327 0, 15, 17, 18, 24, 25, 43, 50, 54, 158,
2328 186, 187, 188, 199, 190, 189, 44, 45, 46, 63,
2329 196, 134, 53, 14, 34, 35, 36, 37, 38, 39,
2330 40, 42, 133, 159, 160, 161, 0, 188, 134, 38,
2331 40, 162, 208, 34, 35, 36, 39, 163, 205, 207,
2332 214, 134, 134, 134, 134, 140, 197, 17, 194, 5,
2333 6, 8, 9, 10, 11, 12, 13, 41, 137, 140,
2334 143, 145, 149, 175, 176, 199, 211, 161, 161, 26,
2335 27, 185, 161, 161, 16, 215, 216, 23, 146, 206,
2336 215, 17, 47, 48, 195, 4, 17, 17, 198, 138,
2337 4, 4, 4, 145, 8, 146, 176, 181, 136, 138,
2338 185, 185, 9, 10, 11, 12, 156, 157, 176, 182,
2339 56, 57, 58, 59, 60, 61, 62, 164, 203, 203,
2340 158, 219, 135, 142, 31, 176, 177, 179, 180, 141,
2341 141, 146, 181, 135, 146, 180, 182, 176, 20, 21,
2342 3, 4, 7, 19, 32, 33, 70, 71, 72, 73,
2343 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2344 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2345 119, 120, 121, 123, 124, 125, 126, 128, 129, 130,
2346 140, 143, 145, 147, 150, 151, 152, 153, 183, 211,
2347 191, 4, 8, 176, 178, 22, 145, 204, 29, 51,
2348 52, 64, 65, 66, 67, 68, 69, 82, 83, 104,
2349 105, 106, 109, 122, 123, 127, 128, 129, 130, 150,
2350 151, 152, 153, 217, 223, 224, 225, 226, 17, 166,
2351 135, 139, 176, 176, 144, 146, 176, 139, 192, 193,
2352 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2353 154, 20, 21, 90, 91, 92, 93, 94, 95, 96,
2354 97, 98, 99, 100, 101, 102, 103, 155, 138, 138,
2355 138, 138, 138, 142, 182, 184, 145, 184, 146, 184,
2356 17, 138, 138, 138, 138, 135, 173, 199, 51, 8,
2357 176, 213, 9, 13, 10, 156, 164, 154, 155, 176,
2358 176, 213, 176, 176, 220, 213, 213, 213, 213, 213,
2359 176, 176, 213, 213, 164, 107, 108, 111, 112, 165,
2360 31, 177, 168, 142, 144, 144, 168, 173, 173, 138,
2361 138, 182, 182, 182, 182, 182, 135, 142, 146, 176,
2362 184, 144, 146, 182, 182, 182, 182, 28, 49, 171,
2363 174, 138, 3, 4, 7, 19, 20, 21, 32, 33,
2364 53, 143, 183, 210, 211, 212, 212, 212, 212, 178,
2365 176, 176, 135, 170, 135, 170, 212, 140, 135, 135,
2366 135, 135, 135, 135, 212, 212, 30, 135, 178, 176,
2367 213, 131, 165, 167, 182, 182, 222, 135, 135, 135,
2368 135, 182, 144, 146, 135, 135, 30, 135, 17, 4,
2369 173, 31, 176, 201, 202, 55, 209, 184, 135, 135,
2370 212, 212, 212, 10, 49, 10, 222, 212, 140, 213,
2371 176, 213, 213, 213, 135, 135, 176, 213, 212, 212,
2372 135, 135, 135, 135, 139, 182, 182, 182, 182, 144,
2373 182, 182, 176, 182, 166, 135, 139, 17, 144, 13,
2374 13, 138, 135, 135, 212, 4, 212, 135, 212, 135,
2375 135, 135, 212, 212, 138, 176, 182, 182, 213, 135,
2376 139, 135, 135, 139, 139, 139, 139, 199, 200, 31,
2377 176, 168, 135, 212, 212, 176, 221, 212, 212, 135,
2378 170, 170, 212, 135, 213, 213, 213, 221, 212, 139,
2379 139, 182, 182, 182, 166, 171, 172, 17, 135, 140,
2380 212, 135, 139, 142, 212, 139, 139, 139, 139, 200,
2381 49, 169, 13, 142, 156, 218, 166, 176, 168, 142,
2382 168, 4, 212, 210, 142, 156, 212, 30, 135, 210,
2383 166, 13, 13, 135, 212, 212, 13, 68, 212, 13,
2384 212
2385};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002386
2387#define yyerrok (yyerrstatus = 0)
2388#define yyclearin (yychar = YYEMPTY)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002389#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002390#define YYEOF 0
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002391
Reid Spencer68a24bd2005-08-27 18:50:39 +00002392#define YYACCEPT goto yyacceptlab
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002393#define YYABORT goto yyabortlab
2394#define YYERROR goto yyerrorlab
2395
2396
2397/* Like YYERROR except do call yyerror. This remains here temporarily
2398 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002399 Once GCC version 2 has supplanted version 1, this can go. */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002400
Reid Spencer68a24bd2005-08-27 18:50:39 +00002401#define YYFAIL goto yyerrlab
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002402
Reid Spencer68a24bd2005-08-27 18:50:39 +00002403#define YYRECOVERING() (!!yyerrstatus)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002404
2405#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002406do \
2407 if (yychar == YYEMPTY && yylen == 1) \
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002408 { \
2409 yychar = (Token); \
2410 yylval = (Value); \
2411 yytoken = YYTRANSLATE (yychar); \
2412 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002413 goto yybackup; \
2414 } \
2415 else \
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002416 { \
2417 yyerror (YY_("syntax error: cannot back up")); \
2418 YYERROR; \
2419 } \
2420while (YYID (0))
2421
Reid Spencer3822ff52006-11-08 06:47:33 +00002422
Reid Spencer68a24bd2005-08-27 18:50:39 +00002423#define YYTERROR 1
2424#define YYERRCODE 256
2425
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002426
2427/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2428 If N is 0, then set CURRENT to the empty location which ends
2429 the previous symbol: RHS[0] (always defined). */
2430
2431#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2432#ifndef YYLLOC_DEFAULT
2433# define YYLLOC_DEFAULT(Current, Rhs, N) \
2434 do \
2435 if (YYID (N)) \
2436 { \
2437 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2438 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2439 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2440 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2441 } \
2442 else \
2443 { \
2444 (Current).first_line = (Current).last_line = \
2445 YYRHSLOC (Rhs, 0).last_line; \
2446 (Current).first_column = (Current).last_column = \
2447 YYRHSLOC (Rhs, 0).last_column; \
2448 } \
2449 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002450#endif
2451
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002452
2453/* YY_LOCATION_PRINT -- Print the location on the stream.
2454 This macro was not mandated originally: define only if we know
2455 we won't break user code: when these are the locations we know. */
2456
2457#ifndef YY_LOCATION_PRINT
2458# if YYLTYPE_IS_TRIVIAL
2459# define YY_LOCATION_PRINT(File, Loc) \
2460 fprintf (File, "%d.%d-%d.%d", \
2461 (Loc).first_line, (Loc).first_column, \
2462 (Loc).last_line, (Loc).last_column)
2463# else
2464# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2465# endif
2466#endif
2467
2468
2469/* YYLEX -- calling `yylex' with the right arguments. */
2470
Reid Spencer68a24bd2005-08-27 18:50:39 +00002471#ifdef YYLEX_PARAM
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002472# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002473#else
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002474# define YYLEX yylex ()
Chris Lattner0fab59c2007-01-12 18:33:30 +00002475#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002476
2477/* Enable debugging if requested. */
2478#if YYDEBUG
2479
2480# ifndef YYFPRINTF
2481# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2482# define YYFPRINTF fprintf
2483# endif
2484
2485# define YYDPRINTF(Args) \
2486do { \
2487 if (yydebug) \
2488 YYFPRINTF Args; \
2489} while (YYID (0))
2490
2491# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2492do { \
2493 if (yydebug) \
2494 { \
2495 YYFPRINTF (stderr, "%s ", Title); \
2496 yy_symbol_print (stderr, \
2497 Type, Value); \
2498 YYFPRINTF (stderr, "\n"); \
2499 } \
2500} while (YYID (0))
2501
2502
2503/*--------------------------------.
2504| Print this symbol on YYOUTPUT. |
2505`--------------------------------*/
2506
2507/*ARGSUSED*/
2508#if (defined __STDC__ || defined __C99__FUNC__ \
2509 || defined __cplusplus || defined _MSC_VER)
2510static void
2511yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Chris Lattner0fab59c2007-01-12 18:33:30 +00002512#else
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002513static void
2514yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2515 FILE *yyoutput;
2516 int yytype;
2517 YYSTYPE const * const yyvaluep;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002518#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002519{
2520 if (!yyvaluep)
2521 return;
2522# ifdef YYPRINT
2523 if (yytype < YYNTOKENS)
2524 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2525# else
2526 YYUSE (yyoutput);
2527# endif
2528 switch (yytype)
2529 {
2530 default:
2531 break;
2532 }
2533}
2534
2535
2536/*--------------------------------.
2537| Print this symbol on YYOUTPUT. |
2538`--------------------------------*/
2539
2540#if (defined __STDC__ || defined __C99__FUNC__ \
2541 || defined __cplusplus || defined _MSC_VER)
2542static void
2543yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2544#else
2545static void
2546yy_symbol_print (yyoutput, yytype, yyvaluep)
2547 FILE *yyoutput;
2548 int yytype;
2549 YYSTYPE const * const yyvaluep;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002550#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002551{
2552 if (yytype < YYNTOKENS)
2553 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2554 else
2555 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Reid Spencer3822ff52006-11-08 06:47:33 +00002556
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002557 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2558 YYFPRINTF (yyoutput, ")");
2559}
Reid Spencer3822ff52006-11-08 06:47:33 +00002560
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002561/*------------------------------------------------------------------.
2562| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2563| TOP (included). |
2564`------------------------------------------------------------------*/
Reid Spencer3822ff52006-11-08 06:47:33 +00002565
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002566#if (defined __STDC__ || defined __C99__FUNC__ \
2567 || defined __cplusplus || defined _MSC_VER)
2568static void
2569yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2570#else
2571static void
2572yy_stack_print (bottom, top)
2573 yytype_int16 *bottom;
2574 yytype_int16 *top;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002575#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002576{
2577 YYFPRINTF (stderr, "Stack now");
2578 for (; bottom <= top; ++bottom)
2579 YYFPRINTF (stderr, " %d", *bottom);
2580 YYFPRINTF (stderr, "\n");
2581}
Reid Spencer3822ff52006-11-08 06:47:33 +00002582
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002583# define YY_STACK_PRINT(Bottom, Top) \
2584do { \
2585 if (yydebug) \
2586 yy_stack_print ((Bottom), (Top)); \
2587} while (YYID (0))
Reid Spencer3822ff52006-11-08 06:47:33 +00002588
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002589
2590/*------------------------------------------------.
2591| Report that the YYRULE is going to be reduced. |
2592`------------------------------------------------*/
2593
2594#if (defined __STDC__ || defined __C99__FUNC__ \
2595 || defined __cplusplus || defined _MSC_VER)
2596static void
2597yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2598#else
2599static void
2600yy_reduce_print (yyvsp, yyrule)
2601 YYSTYPE *yyvsp;
2602 int yyrule;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002603#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002604{
2605 int yynrhs = yyr2[yyrule];
2606 int yyi;
2607 unsigned long int yylno = yyrline[yyrule];
2608 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2609 yyrule - 1, yylno);
2610 /* The symbols being reduced. */
2611 for (yyi = 0; yyi < yynrhs; yyi++)
2612 {
2613 fprintf (stderr, " $%d = ", yyi + 1);
2614 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2615 &(yyvsp[(yyi + 1) - (yynrhs)])
2616 );
2617 fprintf (stderr, "\n");
2618 }
2619}
Reid Spencer21be8652006-10-22 07:03:43 +00002620
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002621# define YY_REDUCE_PRINT(Rule) \
2622do { \
2623 if (yydebug) \
2624 yy_reduce_print (yyvsp, Rule); \
2625} while (YYID (0))
Reid Spencer21be8652006-10-22 07:03:43 +00002626
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002627/* Nonzero means print parse trace. It is left uninitialized so that
2628 multiple parsers can coexist. */
2629int yydebug;
2630#else /* !YYDEBUG */
2631# define YYDPRINTF(Args)
2632# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2633# define YY_STACK_PRINT(Bottom, Top)
2634# define YY_REDUCE_PRINT(Rule)
2635#endif /* !YYDEBUG */
2636
2637
2638/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002639#ifndef YYINITDEPTH
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002640# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002641#endif
2642
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002643/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2644 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002645
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002646 Do not make this value too large; the results are undefined if
2647 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2648 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002649
2650#ifndef YYMAXDEPTH
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002651# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002652#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002653
Reid Spencer68a24bd2005-08-27 18:50:39 +00002654
2655
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002656#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002657
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002658# ifndef yystrlen
2659# if defined __GLIBC__ && defined _STRING_H
2660# define yystrlen strlen
2661# else
2662/* Return the length of YYSTR. */
2663#if (defined __STDC__ || defined __C99__FUNC__ \
2664 || defined __cplusplus || defined _MSC_VER)
2665static YYSIZE_T
2666yystrlen (const char *yystr)
Chris Lattner0fab59c2007-01-12 18:33:30 +00002667#else
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002668static YYSIZE_T
2669yystrlen (yystr)
2670 const char *yystr;
2671#endif
2672{
2673 YYSIZE_T yylen;
2674 for (yylen = 0; yystr[yylen]; yylen++)
2675 continue;
2676 return yylen;
2677}
2678# endif
2679# endif
2680
2681# ifndef yystpcpy
2682# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2683# define yystpcpy stpcpy
2684# else
2685/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2686 YYDEST. */
2687#if (defined __STDC__ || defined __C99__FUNC__ \
2688 || defined __cplusplus || defined _MSC_VER)
2689static char *
2690yystpcpy (char *yydest, const char *yysrc)
2691#else
2692static char *
2693yystpcpy (yydest, yysrc)
2694 char *yydest;
2695 const char *yysrc;
2696#endif
2697{
2698 char *yyd = yydest;
2699 const char *yys = yysrc;
2700
2701 while ((*yyd++ = *yys++) != '\0')
2702 continue;
2703
2704 return yyd - 1;
2705}
2706# endif
2707# endif
2708
2709# ifndef yytnamerr
2710/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2711 quotes and backslashes, so that it's suitable for yyerror. The
2712 heuristic is that double-quoting is unnecessary unless the string
2713 contains an apostrophe, a comma, or backslash (other than
2714 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2715 null, do not copy; instead, return the length of what the result
2716 would have been. */
2717static YYSIZE_T
2718yytnamerr (char *yyres, const char *yystr)
2719{
2720 if (*yystr == '"')
2721 {
2722 YYSIZE_T yyn = 0;
2723 char const *yyp = yystr;
2724
2725 for (;;)
2726 switch (*++yyp)
2727 {
2728 case '\'':
2729 case ',':
2730 goto do_not_strip_quotes;
2731
2732 case '\\':
2733 if (*++yyp != '\\')
2734 goto do_not_strip_quotes;
2735 /* Fall through. */
2736 default:
2737 if (yyres)
2738 yyres[yyn] = *yyp;
2739 yyn++;
2740 break;
2741
2742 case '"':
2743 if (yyres)
2744 yyres[yyn] = '\0';
2745 return yyn;
2746 }
2747 do_not_strip_quotes: ;
2748 }
2749
2750 if (! yyres)
2751 return yystrlen (yystr);
2752
2753 return yystpcpy (yyres, yystr) - yyres;
2754}
2755# endif
2756
2757/* Copy into YYRESULT an error message about the unexpected token
2758 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2759 including the terminating null byte. If YYRESULT is null, do not
2760 copy anything; just return the number of bytes that would be
2761 copied. As a special case, return 0 if an ordinary "syntax error"
2762 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2763 size calculation. */
2764static YYSIZE_T
2765yysyntax_error (char *yyresult, int yystate, int yychar)
2766{
2767 int yyn = yypact[yystate];
2768
2769 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2770 return 0;
2771 else
2772 {
2773 int yytype = YYTRANSLATE (yychar);
2774 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
2775 YYSIZE_T yysize = yysize0;
2776 YYSIZE_T yysize1;
2777 int yysize_overflow = 0;
2778 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2779 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2780 int yyx;
2781
2782# if 0
2783 /* This is so xgettext sees the translatable formats that are
2784 constructed on the fly. */
2785 YY_("syntax error, unexpected %s");
2786 YY_("syntax error, unexpected %s, expecting %s");
2787 YY_("syntax error, unexpected %s, expecting %s or %s");
2788 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
2789 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
2790# endif
2791 char *yyfmt;
2792 char const *yyf;
2793 static char const yyunexpected[] = "syntax error, unexpected %s";
2794 static char const yyexpecting[] = ", expecting %s";
2795 static char const yyor[] = " or %s";
2796 char yyformat[sizeof yyunexpected
2797 + sizeof yyexpecting - 1
2798 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
2799 * (sizeof yyor - 1))];
2800 char const *yyprefix = yyexpecting;
2801
2802 /* Start YYX at -YYN if negative to avoid negative indexes in
2803 YYCHECK. */
2804 int yyxbegin = yyn < 0 ? -yyn : 0;
2805
2806 /* Stay within bounds of both yycheck and yytname. */
2807 int yychecklim = YYLAST - yyn + 1;
2808 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2809 int yycount = 1;
2810
2811 yyarg[0] = yytname[yytype];
2812 yyfmt = yystpcpy (yyformat, yyunexpected);
2813
2814 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2815 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2816 {
2817 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2818 {
2819 yycount = 1;
2820 yysize = yysize0;
2821 yyformat[sizeof yyunexpected - 1] = '\0';
2822 break;
2823 }
2824 yyarg[yycount++] = yytname[yyx];
2825 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
2826 yysize_overflow |= (yysize1 < yysize);
2827 yysize = yysize1;
2828 yyfmt = yystpcpy (yyfmt, yyprefix);
2829 yyprefix = yyor;
2830 }
2831
2832 yyf = YY_(yyformat);
2833 yysize1 = yysize + yystrlen (yyf);
2834 yysize_overflow |= (yysize1 < yysize);
2835 yysize = yysize1;
2836
2837 if (yysize_overflow)
2838 return YYSIZE_MAXIMUM;
2839
2840 if (yyresult)
2841 {
2842 /* Avoid sprintf, as that infringes on the user's name space.
2843 Don't have undefined behavior even if the translation
2844 produced a string with the wrong number of "%s"s. */
2845 char *yyp = yyresult;
2846 int yyi = 0;
2847 while ((*yyp = *yyf) != '\0')
2848 {
2849 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
2850 {
2851 yyp += yytnamerr (yyp, yyarg[yyi++]);
2852 yyf += 2;
2853 }
2854 else
2855 {
2856 yyp++;
2857 yyf++;
2858 }
2859 }
2860 }
2861 return yysize;
2862 }
2863}
2864#endif /* YYERROR_VERBOSE */
2865
2866
2867/*-----------------------------------------------.
2868| Release the memory associated to this symbol. |
2869`-----------------------------------------------*/
2870
2871/*ARGSUSED*/
2872#if (defined __STDC__ || defined __C99__FUNC__ \
2873 || defined __cplusplus || defined _MSC_VER)
2874static void
2875yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2876#else
2877static void
2878yydestruct (yymsg, yytype, yyvaluep)
2879 const char *yymsg;
2880 int yytype;
2881 YYSTYPE *yyvaluep;
2882#endif
2883{
2884 YYUSE (yyvaluep);
2885
2886 if (!yymsg)
2887 yymsg = "Deleting";
2888 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2889
2890 switch (yytype)
2891 {
2892
2893 default:
2894 break;
2895 }
2896}
2897
2898
2899/* Prevent warnings from -Wmissing-prototypes. */
2900
2901#ifdef YYPARSE_PARAM
2902#if defined __STDC__ || defined __cplusplus
2903int yyparse (void *YYPARSE_PARAM);
2904#else
2905int yyparse ();
2906#endif
2907#else /* ! YYPARSE_PARAM */
2908#if defined __STDC__ || defined __cplusplus
Reid Spencere812fb22006-01-19 01:21:04 +00002909int yyparse (void);
Chris Lattner0fab59c2007-01-12 18:33:30 +00002910#else
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002911int yyparse ();
Chris Lattner0fab59c2007-01-12 18:33:30 +00002912#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002913#endif /* ! YYPARSE_PARAM */
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002914
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002915
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002916
2917/* The look-ahead symbol. */
2918int yychar;
2919
2920/* The semantic value of the look-ahead symbol. */
2921YYSTYPE yylval;
2922
2923/* Number of syntax errors so far. */
2924int yynerrs;
2925
2926
2927
2928/*----------.
2929| yyparse. |
2930`----------*/
2931
2932#ifdef YYPARSE_PARAM
2933#if (defined __STDC__ || defined __C99__FUNC__ \
2934 || defined __cplusplus || defined _MSC_VER)
2935int
2936yyparse (void *YYPARSE_PARAM)
2937#else
2938int
2939yyparse (YYPARSE_PARAM)
2940 void *YYPARSE_PARAM;
2941#endif
2942#else /* ! YYPARSE_PARAM */
2943#if (defined __STDC__ || defined __C99__FUNC__ \
2944 || defined __cplusplus || defined _MSC_VER)
2945int
2946yyparse (void)
2947#else
2948int
2949yyparse ()
2950
Chris Lattner0fab59c2007-01-12 18:33:30 +00002951#endif
2952#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002953{
2954
2955 int yystate;
2956 int yyn;
2957 int yyresult;
2958 /* Number of tokens to shift before error messages enabled. */
2959 int yyerrstatus;
2960 /* Look-ahead token as an internal (translated) token number. */
2961 int yytoken = 0;
2962#if YYERROR_VERBOSE
2963 /* Buffer for error messages, and its allocated size. */
2964 char yymsgbuf[128];
2965 char *yymsg = yymsgbuf;
2966 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002967#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002968
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002969 /* Three stacks and their tools:
2970 `yyss': related to states,
2971 `yyvs': related to semantic values,
2972 `yyls': related to locations.
2973
2974 Refer to the stacks thru separate pointers, to allow yyoverflow
2975 to reallocate them elsewhere. */
2976
2977 /* The state stack. */
2978 yytype_int16 yyssa[YYINITDEPTH];
2979 yytype_int16 *yyss = yyssa;
2980 yytype_int16 *yyssp;
2981
2982 /* The semantic value stack. */
2983 YYSTYPE yyvsa[YYINITDEPTH];
2984 YYSTYPE *yyvs = yyvsa;
2985 YYSTYPE *yyvsp;
2986
2987
2988
2989#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
2990
2991 YYSIZE_T yystacksize = YYINITDEPTH;
2992
2993 /* The variables used to return semantic value and location from the
2994 action routines. */
2995 YYSTYPE yyval;
2996
2997
2998 /* The number of symbols on the RHS of the reduced rule.
2999 Keep to zero when no symbol should be popped. */
3000 int yylen = 0;
3001
3002 YYDPRINTF ((stderr, "Starting parse\n"));
3003
Reid Spencer68a24bd2005-08-27 18:50:39 +00003004 yystate = 0;
3005 yyerrstatus = 0;
3006 yynerrs = 0;
3007 yychar = YYEMPTY; /* Cause a token to be read. */
3008
3009 /* Initialize stack pointers.
3010 Waste one element of value and location stack
3011 so that they stay on the same level as the state stack.
3012 The wasted elements are never initialized. */
3013
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003014 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003015 yyvsp = yyvs;
3016
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003017 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003018
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003019/*------------------------------------------------------------.
3020| yynewstate -- Push a new state, which is found in yystate. |
3021`------------------------------------------------------------*/
3022 yynewstate:
3023 /* In all cases, when you get here, the value and location stacks
3024 have just been pushed. So pushing a state here evens the stacks. */
3025 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003026
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003027 yysetstate:
3028 *yyssp = yystate;
3029
3030 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003031 {
3032 /* Get the current used size of the three stacks, in elements. */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003033 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003034
3035#ifdef yyoverflow
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003036 {
3037 /* Give user a chance to reallocate the stack. Use copies of
3038 these so that the &'s don't force the real ones into
3039 memory. */
3040 YYSTYPE *yyvs1 = yyvs;
3041 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003042
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003043
3044 /* Each stack pointer address is followed by the size of the
3045 data in use in that stack, in bytes. This used to be a
3046 conditional around just the two extra args, but that might
3047 be undefined if yyoverflow is a macro. */
3048 yyoverflow (YY_("memory exhausted"),
3049 &yyss1, yysize * sizeof (*yyssp),
3050 &yyvs1, yysize * sizeof (*yyvsp),
3051
3052 &yystacksize);
3053
3054 yyss = yyss1;
3055 yyvs = yyvs1;
3056 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003057#else /* no yyoverflow */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003058# ifndef YYSTACK_RELOCATE
3059 goto yyexhaustedlab;
3060# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003061 /* Extend the stack our own way. */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003062 if (YYMAXDEPTH <= yystacksize)
3063 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003064 yystacksize *= 2;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003065 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003066 yystacksize = YYMAXDEPTH;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003067
3068 {
3069 yytype_int16 *yyss1 = yyss;
3070 union yyalloc *yyptr =
3071 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3072 if (! yyptr)
3073 goto yyexhaustedlab;
3074 YYSTACK_RELOCATE (yyss);
3075 YYSTACK_RELOCATE (yyvs);
3076
3077# undef YYSTACK_RELOCATE
3078 if (yyss1 != yyssa)
3079 YYSTACK_FREE (yyss1);
3080 }
3081# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003082#endif /* no yyoverflow */
3083
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003084 yyssp = yyss + yysize - 1;
3085 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003086
3087
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003088 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3089 (unsigned long int) yystacksize));
3090
3091 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003092 YYABORT;
3093 }
3094
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003095 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003096
3097 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003098
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003099/*-----------.
3100| yybackup. |
3101`-----------*/
3102yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003103
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003104 /* Do appropriate processing given the current state. Read a
3105 look-ahead token if we need one and don't already have one. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00003106
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003107 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003108 yyn = yypact[yystate];
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003109 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003110 goto yydefault;
3111
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003112 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003113
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003114 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003115 if (yychar == YYEMPTY)
3116 {
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003117 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003118 yychar = YYLEX;
3119 }
3120
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003121 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003122 {
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003123 yychar = yytoken = YYEOF;
3124 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003125 }
3126 else
3127 {
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003128 yytoken = YYTRANSLATE (yychar);
3129 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003130 }
3131
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003132 /* If the proper action on seeing token YYTOKEN is to reduce or to
3133 detect an error, take that action. */
3134 yyn += yytoken;
3135 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003136 goto yydefault;
3137 yyn = yytable[yyn];
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003138 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003139 {
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003140 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003141 goto yyerrlab;
3142 yyn = -yyn;
3143 goto yyreduce;
3144 }
3145
3146 if (yyn == YYFINAL)
3147 YYACCEPT;
3148
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003149 /* Count tokens shifted since error; after three, turn off error
3150 status. */
3151 if (yyerrstatus)
3152 yyerrstatus--;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003153
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003154 /* Shift the look-ahead token. */
3155 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003156
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003157 /* Discard the shifted token unless it is eof. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00003158 if (yychar != YYEOF)
3159 yychar = YYEMPTY;
3160
Reid Spencer68a24bd2005-08-27 18:50:39 +00003161 yystate = yyn;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003162 *++yyvsp = yylval;
3163
Reid Spencer68a24bd2005-08-27 18:50:39 +00003164 goto yynewstate;
3165
Chris Lattner0fab59c2007-01-12 18:33:30 +00003166
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003167/*-----------------------------------------------------------.
3168| yydefault -- do the default action for the current state. |
3169`-----------------------------------------------------------*/
3170yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003171 yyn = yydefact[yystate];
3172 if (yyn == 0)
3173 goto yyerrlab;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003174 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003175
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003176
3177/*-----------------------------.
3178| yyreduce -- Do a reduction. |
3179`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003180yyreduce:
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003181 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003182 yylen = yyr2[yyn];
3183
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003184 /* If YYLEN is nonzero, implement the default value of the action:
3185 `$$ = $1'.
3186
3187 Otherwise, the following line sets YYVAL to garbage.
3188 This behavior is undocumented and Bison
3189 users should not rely upon it. Assigning to YYVAL
3190 unconditionally makes the parser a bit smaller, and it avoids a
3191 GCC warning that YYVAL may be used uninitialized. */
3192 yyval = yyvsp[1-yylen];
3193
3194
3195 YY_REDUCE_PRINT (yyn);
3196 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003197 {
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003198 case 3:
3199#line 1032 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3200 {
3201 if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003202 GEN_ERROR("Value too large for type!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003203 (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003204 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003205;}
3206 break;
3207
3208 case 31:
3209#line 1048 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3210 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3211 break;
3212
3213 case 32:
3214#line 1048 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3215 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3216 break;
3217
3218 case 33:
3219#line 1049 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3220 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3221 break;
3222
3223 case 34:
3224#line 1049 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3225 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3226 break;
3227
3228 case 35:
3229#line 1050 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3230 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3231 break;
3232
3233 case 36:
3234#line 1050 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3235 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3236 break;
3237
3238 case 37:
3239#line 1051 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3240 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3241 break;
3242
3243 case 38:
3244#line 1051 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3245 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3246 break;
3247
3248 case 39:
3249#line 1052 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3250 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3251 break;
3252
3253 case 40:
3254#line 1052 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3255 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3256 break;
3257
3258 case 41:
3259#line 1056 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3260 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3261 break;
3262
3263 case 42:
3264#line 1056 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3265 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3266 break;
3267
3268 case 43:
3269#line 1057 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3270 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3271 break;
3272
3273 case 44:
3274#line 1057 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3275 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3276 break;
3277
3278 case 45:
3279#line 1058 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3280 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3281 break;
3282
3283 case 46:
3284#line 1058 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3285 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3286 break;
3287
3288 case 47:
3289#line 1059 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3290 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3291 break;
3292
3293 case 48:
3294#line 1059 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3295 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3296 break;
3297
3298 case 49:
3299#line 1060 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3300 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3301 break;
3302
3303 case 50:
3304#line 1060 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3305 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3306 break;
3307
3308 case 51:
3309#line 1061 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3310 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3311 break;
3312
3313 case 52:
3314#line 1061 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3315 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3316 break;
3317
3318 case 53:
3319#line 1062 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3320 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3321 break;
3322
3323 case 54:
3324#line 1062 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3325 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3326 break;
3327
3328 case 55:
3329#line 1063 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3330 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3331 break;
3332
3333 case 56:
3334#line 1064 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3335 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3336 break;
3337
3338 case 60:
3339#line 1073 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3340 {
3341 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003342 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003343 ;}
3344 break;
3345
3346 case 61:
3347#line 1077 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3348 {
3349 (yyval.StrVal) = 0;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003350 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003351 ;}
3352 break;
3353
3354 case 62:
3355#line 1083 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3356 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3357 break;
3358
3359 case 63:
3360#line 1084 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3361 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3362 break;
3363
3364 case 64:
3365#line 1085 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3366 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3367 break;
3368
3369 case 65:
3370#line 1086 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3371 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3372 break;
3373
3374 case 66:
3375#line 1087 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3376 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3377 break;
3378
3379 case 67:
3380#line 1091 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3381 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3382 break;
3383
3384 case 68:
3385#line 1092 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3386 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3387 break;
3388
3389 case 69:
3390#line 1093 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3391 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3392 break;
3393
3394 case 70:
3395#line 1097 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3396 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3397 break;
3398
3399 case 71:
3400#line 1098 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3401 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3402 break;
3403
3404 case 72:
3405#line 1102 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3406 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3407 break;
3408
3409 case 73:
3410#line 1103 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3411 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3412 break;
3413
3414 case 74:
3415#line 1104 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3416 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3417 break;
3418
3419 case 75:
3420#line 1108 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3421 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3422 break;
3423
3424 case 76:
3425#line 1109 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3426 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3427 break;
3428
3429 case 77:
3430#line 1110 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3431 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3432 break;
3433
3434 case 78:
3435#line 1111 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3436 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3437 break;
3438
3439 case 79:
3440#line 1112 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3441 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3442 break;
3443
3444 case 80:
3445#line 1115 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3446 { (yyval.UIntVal) = CallingConv::C; ;}
3447 break;
3448
3449 case 81:
3450#line 1116 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3451 { (yyval.UIntVal) = CallingConv::C; ;}
3452 break;
3453
3454 case 82:
3455#line 1117 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3456 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3457 break;
3458
3459 case 83:
3460#line 1118 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3461 { (yyval.UIntVal) = CallingConv::Fast; ;}
3462 break;
3463
3464 case 84:
3465#line 1119 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3466 { (yyval.UIntVal) = CallingConv::Cold; ;}
3467 break;
3468
3469 case 85:
3470#line 1120 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3471 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3472 break;
3473
3474 case 86:
3475#line 1121 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3476 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3477 break;
3478
3479 case 87:
3480#line 1122 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3481 {
3482 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003483 GEN_ERROR("Calling conv too large!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003484 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003485 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003486 ;}
3487 break;
3488
3489 case 88:
3490#line 1129 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3491 { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;}
3492 break;
3493
3494 case 89:
3495#line 1130 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3496 { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;}
3497 break;
3498
3499 case 90:
3500#line 1133 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3501 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3502 break;
3503
3504 case 91:
3505#line 1134 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3506 {
3507 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs));
3508 ;}
3509 break;
3510
3511 case 92:
3512#line 1139 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3513 { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;}
3514 break;
3515
3516 case 94:
3517#line 1143 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3518 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3519 break;
3520
3521 case 95:
3522#line 1144 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3523 {
3524 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs));
3525 ;}
3526 break;
3527
3528 case 96:
3529#line 1151 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3530 { (yyval.UIntVal) = 0; ;}
3531 break;
3532
3533 case 97:
3534#line 1152 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3535 {
3536 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3537 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencera54b7cb2007-01-12 07:05:14 +00003538 GEN_ERROR("Alignment must be a power of two!");
3539 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003540;}
3541 break;
3542
3543 case 98:
3544#line 1158 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3545 { (yyval.UIntVal) = 0; ;}
3546 break;
3547
3548 case 99:
3549#line 1159 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3550 {
3551 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3552 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencera54b7cb2007-01-12 07:05:14 +00003553 GEN_ERROR("Alignment must be a power of two!");
3554 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003555;}
3556 break;
3557
3558 case 100:
3559#line 1167 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3560 {
3561 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
3562 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
Reid Spencere4d87aa2006-12-23 06:05:41 +00003563 GEN_ERROR("Invalid character in section name!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003564 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003565 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003566;}
3567 break;
3568
3569 case 101:
3570#line 1175 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3571 { (yyval.StrVal) = 0; ;}
3572 break;
3573
3574 case 102:
3575#line 1176 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3576 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3577 break;
3578
3579 case 103:
3580#line 1181 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3581 {;}
3582 break;
3583
3584 case 104:
3585#line 1182 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3586 {;}
3587 break;
3588
3589 case 105:
3590#line 1183 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3591 {
3592 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
3593 free((yyvsp[(1) - (1)].StrVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003594 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003595 ;}
3596 break;
3597
3598 case 106:
3599#line 1188 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3600 {
3601 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003602 GEN_ERROR("Alignment must be a power of two!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003603 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003604 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003605 ;}
3606 break;
3607
3608 case 112:
3609#line 1204 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3610 {
3611 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencera132e042006-12-03 05:46:11 +00003612 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003613 ;}
3614 break;
3615
3616 case 113:
3617#line 1208 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3618 {
3619 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Reid Spencera132e042006-12-03 05:46:11 +00003620 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003621 ;}
3622 break;
3623
3624 case 114:
3625#line 1212 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3626 { // Pointer type?
3627 if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy)
Reid Spencer14310612006-12-31 05:40:51 +00003628 GEN_ERROR("Cannot form a pointer to a basic block");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003629 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal))));
3630 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer14310612006-12-31 05:40:51 +00003631 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003632 ;}
3633 break;
3634
3635 case 115:
3636#line 1219 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3637 { // Named types are also simple types...
3638 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Reid Spencer14310612006-12-31 05:40:51 +00003639 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003640 (yyval.TypeVal) = new PATypeHolder(tmp);
3641 ;}
3642 break;
3643
3644 case 116:
3645#line 1224 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3646 { // Type UpReference
3647 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer3da59db2006-11-27 01:05:10 +00003648 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003649 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
3650 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer3da59db2006-11-27 01:05:10 +00003651 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003652 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003653 ;}
3654 break;
3655
3656 case 117:
3657#line 1232 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3658 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003659 std::vector<const Type*> Params;
Reid Spencer14310612006-12-31 05:40:51 +00003660 std::vector<FunctionType::ParameterAttributes> Attrs;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003661 Attrs.push_back((yyvsp[(5) - (5)].ParamAttrs));
3662 for (TypeWithAttrsList::iterator I=(yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E=(yyvsp[(3) - (5)].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00003663 Params.push_back(I->Ty->get());
3664 if (I->Ty->get() != Type::VoidTy)
3665 Attrs.push_back(I->Attrs);
3666 }
Reid Spencer3da59db2006-11-27 01:05:10 +00003667 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3668 if (isVarArg) Params.pop_back();
3669
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003670 FunctionType *FT = FunctionType::get(*(yyvsp[(1) - (5)].TypeVal), Params, isVarArg, Attrs);
3671 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3672 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
3673 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003674 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003675 ;}
3676 break;
3677
3678 case 118:
3679#line 1250 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3680 {
Reid Spencer14310612006-12-31 05:40:51 +00003681 std::vector<const Type*> Params;
3682 std::vector<FunctionType::ParameterAttributes> Attrs;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003683 Attrs.push_back((yyvsp[(5) - (5)].ParamAttrs));
3684 for (TypeWithAttrsList::iterator I=(yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E=(yyvsp[(3) - (5)].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00003685 Params.push_back(I->Ty->get());
3686 if (I->Ty->get() != Type::VoidTy)
3687 Attrs.push_back(I->Attrs);
3688 }
3689 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3690 if (isVarArg) Params.pop_back();
3691
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003692 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg, Attrs);
3693 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3694 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer14310612006-12-31 05:40:51 +00003695 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003696 ;}
3697 break;
3698
3699 case 119:
3700#line 1268 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3701 { // Sized array type?
3702 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
3703 delete (yyvsp[(4) - (5)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003704 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003705 ;}
3706 break;
3707
3708 case 120:
3709#line 1273 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3710 { // Packed array type?
3711 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
3712 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003713 GEN_ERROR("Unsigned result not equal to signed result");
Reid Spencera54b7cb2007-01-12 07:05:14 +00003714 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3715 GEN_ERROR("Element type of a PackedType must be primitive");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003716 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003717 GEN_ERROR("Vector length should be a power of 2!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003718 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
3719 delete (yyvsp[(4) - (5)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003720 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003721 ;}
3722 break;
3723
3724 case 121:
3725#line 1285 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3726 { // Structure type?
Reid Spencere4d87aa2006-12-23 06:05:41 +00003727 std::vector<const Type*> Elements;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003728 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
3729 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Reid Spencere4d87aa2006-12-23 06:05:41 +00003730 Elements.push_back(*I);
3731
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003732 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3733 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003734 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003735 ;}
3736 break;
3737
3738 case 122:
3739#line 1295 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3740 { // Empty structure type?
3741 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003742 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003743 ;}
3744 break;
3745
3746 case 123:
3747#line 1299 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3748 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003749 std::vector<const Type*> Elements;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003750 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
3751 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Reid Spencere4d87aa2006-12-23 06:05:41 +00003752 Elements.push_back(*I);
3753
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003754 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3755 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003756 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003757 ;}
3758 break;
3759
3760 case 124:
3761#line 1309 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3762 { // Empty structure type?
3763 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003764 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003765 ;}
3766 break;
3767
3768 case 125:
3769#line 1316 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3770 {
3771 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
3772 (yyval.TypeWithAttrs).Attrs = (yyvsp[(2) - (2)].ParamAttrs);
3773 ;}
3774 break;
3775
3776 case 126:
3777#line 1323 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3778 {
Reid Spencer218ded22007-01-05 17:07:23 +00003779 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003780 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
3781 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType())
Reid Spencer218ded22007-01-05 17:07:23 +00003782 GEN_ERROR("LLVM functions cannot return aggregate types!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003783 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
3784 ;}
3785 break;
3786
3787 case 127:
3788#line 1330 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3789 {
3790 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3791 ;}
3792 break;
3793
3794 case 128:
3795#line 1335 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3796 {
3797 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3798 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer14310612006-12-31 05:40:51 +00003799 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003800 ;}
3801 break;
3802
3803 case 129:
3804#line 1340 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3805 {
3806 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer14310612006-12-31 05:40:51 +00003807 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003808 ;}
3809 break;
3810
3811 case 131:
3812#line 1348 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3813 {
3814 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Reid Spencer14310612006-12-31 05:40:51 +00003815 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3816 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003817 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003818 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003819 ;}
3820 break;
3821
3822 case 132:
3823#line 1355 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3824 {
3825 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer14310612006-12-31 05:40:51 +00003826 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3827 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003828 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer14310612006-12-31 05:40:51 +00003829 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003830 ;}
3831 break;
3832
3833 case 133:
3834#line 1362 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3835 {
3836 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer14310612006-12-31 05:40:51 +00003837 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003838 ;}
3839 break;
3840
3841 case 134:
3842#line 1370 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3843 {
3844 (yyval.TypeList) = new std::list<PATypeHolder>();
3845 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal)); delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003846 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003847 ;}
3848 break;
3849
3850 case 135:
3851#line 1375 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3852 {
3853 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal)); delete (yyvsp[(3) - (3)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003854 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003855 ;}
3856 break;
3857
3858 case 136:
3859#line 1386 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3860 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003861 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003862 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
3863 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencere4d87aa2006-12-23 06:05:41 +00003864 if (ATy == 0)
3865 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003866 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003867 const Type *ETy = ATy->getElementType();
3868 int NumElements = ATy->getNumElements();
3869
3870 // Verify that we have the correct size...
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003871 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003872 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003873 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencere4d87aa2006-12-23 06:05:41 +00003874 itostr(NumElements) + "!");
3875
3876 // Verify all elements are correct type!
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003877 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
3878 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003879 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3880 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003881 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003882 }
3883
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003884 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
3885 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer3da59db2006-11-27 01:05:10 +00003886 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003887 ;}
3888 break;
3889
3890 case 137:
3891#line 1414 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3892 {
Reid Spencer14310612006-12-31 05:40:51 +00003893 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003894 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
3895 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003896 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003897 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003898 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003899
Andrew Lenharth6353e052006-12-08 18:07:09 +00003900 int NumElements = ATy->getNumElements();
3901 if (NumElements != -1 && NumElements != 0)
3902 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
3903 " arguments, but has size of " + itostr(NumElements) +"!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003904 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3905 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003906 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003907 ;}
3908 break;
3909
3910 case 138:
3911#line 1430 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3912 {
Reid Spencer14310612006-12-31 05:40:51 +00003913 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003914 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
3915 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003916 if (ATy == 0)
3917 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003918 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003919
Andrew Lenharth6353e052006-12-08 18:07:09 +00003920 int NumElements = ATy->getNumElements();
3921 const Type *ETy = ATy->getElementType();
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003922 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
3923 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003924 GEN_ERROR("Can't build string constant of size " +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003925 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) +
Andrew Lenharth6353e052006-12-08 18:07:09 +00003926 " when array has size " + itostr(NumElements) + "!");
3927 std::vector<Constant*> Vals;
Reid Spencer14310612006-12-31 05:40:51 +00003928 if (ETy == Type::Int8Ty) {
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003929 for (unsigned char *C = (unsigned char *)(yyvsp[(3) - (3)].StrVal);
Reid Spencer14310612006-12-31 05:40:51 +00003930 C != (unsigned char*)EndStr; ++C)
3931 Vals.push_back(ConstantInt::get(ETy, *C));
Andrew Lenharth6353e052006-12-08 18:07:09 +00003932 } else {
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003933 free((yyvsp[(3) - (3)].StrVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00003934 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
3935 }
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003936 free((yyvsp[(3) - (3)].StrVal));
3937 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3938 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003939 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003940 ;}
3941 break;
3942
3943 case 139:
3944#line 1459 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3945 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003946 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003947 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
3948 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[(1) - (4)].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003949 if (PTy == 0)
3950 GEN_ERROR("Cannot make packed constant with type: '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003951 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003952 const Type *ETy = PTy->getElementType();
3953 int NumElements = PTy->getNumElements();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003954
Andrew Lenharth6353e052006-12-08 18:07:09 +00003955 // Verify that we have the correct size...
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003956 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003957 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003958 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Andrew Lenharth6353e052006-12-08 18:07:09 +00003959 itostr(NumElements) + "!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003960
Andrew Lenharth6353e052006-12-08 18:07:09 +00003961 // Verify all elements are correct type!
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003962 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
3963 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003964 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3965 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003966 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003967 }
3968
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003969 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
3970 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003971 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003972 ;}
3973 break;
3974
3975 case 140:
3976#line 1487 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3977 {
3978 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003979 if (STy == 0)
3980 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003981 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003982
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003983 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003984 GEN_ERROR("Illegal number of initializers for structure type!");
3985
3986 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003987 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
3988 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003989 GEN_ERROR("Expected type '" +
3990 STy->getElementType(i)->getDescription() +
3991 "' for element #" + utostr(i) +
3992 " of structure initializer!");
3993
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003994 // Check to ensure that Type is not packed
3995 if (STy->isPacked())
3996 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3997
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003998 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
3999 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00004000 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004001 ;}
4002 break;
4003
4004 case 141:
4005#line 1512 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4006 {
Reid Spencer14310612006-12-31 05:40:51 +00004007 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004008 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4009 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004010 if (STy == 0)
4011 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004012 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004013
4014 if (STy->getNumContainedTypes() != 0)
4015 GEN_ERROR("Illegal number of initializers for structure type!");
4016
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004017 // Check to ensure that Type is not packed
4018 if (STy->isPacked())
4019 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
4020
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004021 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4022 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004023 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004024 ;}
4025 break;
4026
4027 case 142:
4028#line 1531 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4029 {
4030 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004031 if (STy == 0)
4032 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004033 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'!");
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004034
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004035 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004036 GEN_ERROR("Illegal number of initializers for structure type!");
4037
4038 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004039 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4040 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004041 GEN_ERROR("Expected type '" +
4042 STy->getElementType(i)->getDescription() +
4043 "' for element #" + utostr(i) +
4044 " of structure initializer!");
4045
4046 // Check to ensure that Type is packed
4047 if (!STy->isPacked())
4048 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
4049
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004050 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4051 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004052 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004053 ;}
4054 break;
4055
4056 case 143:
4057#line 1556 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4058 {
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004059 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004060 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4061 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004062 if (STy == 0)
4063 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004064 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'!");
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004065
4066 if (STy->getNumContainedTypes() != 0)
4067 GEN_ERROR("Illegal number of initializers for structure type!");
4068
4069 // Check to ensure that Type is packed
4070 if (!STy->isPacked())
4071 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
4072
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004073 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4074 delete (yyvsp[(1) - (5)].TypeVal);
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004075 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004076 ;}
4077 break;
4078
4079 case 144:
4080#line 1575 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4081 {
Reid Spencer14310612006-12-31 05:40:51 +00004082 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004083 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4084 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004085 if (PTy == 0)
4086 GEN_ERROR("Cannot make null pointer constant with type: '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004087 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004088
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004089 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4090 delete (yyvsp[(1) - (2)].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004091 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004092 ;}
4093 break;
4094
4095 case 145:
4096#line 1587 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4097 {
Reid Spencer14310612006-12-31 05:40:51 +00004098 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004099 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4100 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4101 delete (yyvsp[(1) - (2)].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004102 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004103 ;}
4104 break;
4105
4106 case 146:
4107#line 1594 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4108 {
Reid Spencer14310612006-12-31 05:40:51 +00004109 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004110 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4111 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004112 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004113 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004114
4115 // ConstExprs can exist in the body of a function, thus creating
4116 // GlobalValues whenever they refer to a variable. Because we are in
4117 // the context of a function, getValNonImprovising will search the functions
4118 // symbol table instead of the module symbol table for the global symbol,
4119 // which throws things all off. To get around this, we just tell
4120 // getValNonImprovising that we are at global scope here.
4121 //
4122 Function *SavedCurFn = CurFun.CurrentFunction;
4123 CurFun.CurrentFunction = 0;
4124
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004125 Value *V = getValNonImprovising(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004126 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004127
4128 CurFun.CurrentFunction = SavedCurFn;
4129
4130 // If this is an initializer for a constant pointer, which is referencing a
4131 // (currently) undefined variable, create a stub now that shall be replaced
4132 // in the future with the right type of variable.
4133 //
4134 if (V == 0) {
4135 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
4136 const PointerType *PT = cast<PointerType>(Ty);
4137
4138 // First check to see if the forward references value is already created!
4139 PerModuleInfo::GlobalRefsType::iterator I =
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004140 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004141
4142 if (I != CurModule.GlobalRefs.end()) {
4143 V = I->second; // Placeholder already exists, use it...
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004144 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004145 } else {
4146 std::string Name;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004147 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004148
4149 // Create the forward referenced global.
4150 GlobalValue *GV;
4151 if (const FunctionType *FTy =
4152 dyn_cast<FunctionType>(PT->getElementType())) {
4153 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4154 CurModule.CurrentModule);
4155 } else {
4156 GV = new GlobalVariable(PT->getElementType(), false,
4157 GlobalValue::ExternalLinkage, 0,
4158 Name, CurModule.CurrentModule);
4159 }
4160
4161 // Keep track of the fact that we have a forward ref to recycle it
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004162 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004163 V = GV;
4164 }
4165 }
4166
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004167 (yyval.ConstVal) = cast<GlobalValue>(V);
4168 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencere4d87aa2006-12-23 06:05:41 +00004169 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004170 ;}
4171 break;
4172
4173 case 147:
4174#line 1657 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4175 {
Reid Spencer14310612006-12-31 05:40:51 +00004176 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004177 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4178 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Reid Spencere68853b2007-01-04 00:06:14 +00004179 GEN_ERROR("Mismatched types for constant expression: " +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004180 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4181 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4182 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004183 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004184 ;}
4185 break;
4186
4187 case 148:
4188#line 1667 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4189 {
Reid Spencer14310612006-12-31 05:40:51 +00004190 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004191 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4192 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Reid Spencere4d87aa2006-12-23 06:05:41 +00004193 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4194 GEN_ERROR("Cannot create a null initialized value of this type!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004195 (yyval.ConstVal) = Constant::getNullValue(Ty);
4196 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004197 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004198 ;}
4199 break;
4200
4201 case 149:
4202#line 1677 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4203 { // integral constants
4204 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Reid Spencer14310612006-12-31 05:40:51 +00004205 GEN_ERROR("Constant value doesn't fit in type!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004206 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val));
Reid Spencer14310612006-12-31 05:40:51 +00004207 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004208 ;}
4209 break;
4210
4211 case 150:
4212#line 1683 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4213 { // integral constants
4214 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Reid Spencer14310612006-12-31 05:40:51 +00004215 GEN_ERROR("Constant value doesn't fit in type!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004216 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val));
Reid Spencer14310612006-12-31 05:40:51 +00004217 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004218 ;}
4219 break;
4220
4221 case 151:
4222#line 1689 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4223 { // Boolean constants
4224 (yyval.ConstVal) = ConstantInt::getTrue();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004225 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004226 ;}
4227 break;
4228
4229 case 152:
4230#line 1693 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4231 { // Boolean constants
4232 (yyval.ConstVal) = ConstantInt::getFalse();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004233 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004234 ;}
4235 break;
4236
4237 case 153:
4238#line 1697 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4239 { // Float & Double constants
4240 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal)))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004241 GEN_ERROR("Floating point constant invalid for type!!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004242 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004243 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004244 ;}
4245 break;
4246
4247 case 154:
4248#line 1705 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4249 {
Reid Spencer14310612006-12-31 05:40:51 +00004250 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004251 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4252 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4253 const Type *Ty = (yyvsp[(5) - (6)].TypeVal)->get();
Reid Spencer3da59db2006-11-27 01:05:10 +00004254 if (!Val->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004255 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00004256 Val->getType()->getDescription() + "'!");
4257 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004258 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00004259 Ty->getDescription() + "'!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004260 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].TypeVal)->get());
4261 delete (yyvsp[(5) - (6)].TypeVal);
4262 ;}
4263 break;
4264
4265 case 155:
4266#line 1719 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4267 {
4268 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00004269 GEN_ERROR("GetElementPtr requires a pointer operand!");
4270
4271 const Type *IdxTy =
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004272 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), *(yyvsp[(4) - (5)].ValueList), true);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004273 if (!IdxTy)
4274 GEN_ERROR("Index list invalid for constant getelementptr!");
4275
4276 std::vector<Constant*> IdxVec;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004277 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4278 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Andrew Lenharth6353e052006-12-08 18:07:09 +00004279 IdxVec.push_back(C);
4280 else
4281 GEN_ERROR("Indices to constant getelementptr must be constants!");
4282
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004283 delete (yyvsp[(4) - (5)].ValueList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004284
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004285 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), IdxVec);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004286 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004287 ;}
4288 break;
4289
4290 case 156:
4291#line 1740 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4292 {
4293 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Reid Spencere4d87aa2006-12-23 06:05:41 +00004294 GEN_ERROR("Select condition must be of boolean type!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004295 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004296 GEN_ERROR("Select operand types must match!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004297 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004298 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004299 ;}
4300 break;
4301
4302 case 157:
4303#line 1748 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4304 {
4305 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004306 GEN_ERROR("Binary operator types must match!");
4307 CHECK_FOR_ERROR;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004308 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4309 ;}
4310 break;
4311
4312 case 158:
4313#line 1754 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4314 {
4315 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004316 GEN_ERROR("Logical operator types must match!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004317 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isIntegral()) {
4318 if (!isa<PackedType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4319 !cast<PackedType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isIntegral())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004320 GEN_ERROR("Logical operator requires integral operands!");
4321 }
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004322 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004323 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004324 ;}
4325 break;
4326
4327 case 159:
4328#line 1765 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4329 {
4330 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004331 GEN_ERROR("icmp operand types must match!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004332 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4333 ;}
4334 break;
4335
4336 case 160:
4337#line 1770 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4338 {
4339 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004340 GEN_ERROR("fcmp operand types must match!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004341 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4342 ;}
4343 break;
4344
4345 case 161:
4346#line 1775 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4347 {
4348 if ((yyvsp[(5) - (6)].ConstVal)->getType() != Type::Int8Ty)
Reid Spencer14310612006-12-31 05:40:51 +00004349 GEN_ERROR("Shift count for shift constant must be i8 type!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004350 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004351 GEN_ERROR("Shift constant expression requires integer operand!");
4352 CHECK_FOR_ERROR;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004353 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004354 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004355 ;}
4356 break;
4357
4358 case 162:
4359#line 1784 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4360 {
4361 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004362 GEN_ERROR("Invalid extractelement operands!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004363 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004364 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004365 ;}
4366 break;
4367
4368 case 163:
4369#line 1790 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4370 {
4371 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004372 GEN_ERROR("Invalid insertelement operands!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004373 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004374 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004375 ;}
4376 break;
4377
4378 case 164:
4379#line 1796 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4380 {
4381 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004382 GEN_ERROR("Invalid shufflevector operands!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004383 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004384 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004385 ;}
4386 break;
4387
4388 case 165:
4389#line 1805 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4390 {
4391 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004392 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004393 ;}
4394 break;
4395
4396 case 166:
4397#line 1809 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4398 {
4399 (yyval.ConstVector) = new std::vector<Constant*>();
4400 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004401 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004402 ;}
4403 break;
4404
4405 case 167:
4406#line 1817 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4407 { (yyval.BoolVal) = false; ;}
4408 break;
4409
4410 case 168:
4411#line 1817 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4412 { (yyval.BoolVal) = true; ;}
4413 break;
4414
4415 case 169:
4416#line 1828 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4417 {
4418 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer14310612006-12-31 05:40:51 +00004419 CurModule.ModuleDone();
4420 CHECK_FOR_ERROR;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004421 ;}
4422 break;
4423
4424 case 170:
4425#line 1833 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4426 {
4427 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer218ded22007-01-05 17:07:23 +00004428 CurModule.ModuleDone();
4429 CHECK_FOR_ERROR;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004430 ;}
4431 break;
4432
4433 case 173:
4434#line 1846 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4435 { CurFun.isDeclare = false ;}
4436 break;
4437
4438 case 174:
4439#line 1846 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4440 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004441 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004442 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004443 ;}
4444 break;
4445
4446 case 175:
4447#line 1850 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4448 { CurFun.isDeclare = true; ;}
4449 break;
4450
4451 case 176:
4452#line 1850 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4453 {
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004454 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004455 ;}
4456 break;
4457
4458 case 177:
4459#line 1853 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4460 {
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004461 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004462 ;}
4463 break;
4464
4465 case 178:
4466#line 1856 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4467 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004468 // Emit an error if there are any unresolved types left.
4469 if (!CurModule.LateResolveTypes.empty()) {
4470 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00004471 if (DID.Type == ValID::NameVal) {
4472 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4473 } else {
4474 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4475 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004476 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004477 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004478 ;}
4479 break;
4480
4481 case 179:
4482#line 1868 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4483 {
Reid Spencer14310612006-12-31 05:40:51 +00004484 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004485 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004486 // Eagerly resolve types. This is not an optimization, this is a
4487 // requirement that is due to the fact that we could have this:
4488 //
4489 // %list = type { %list * }
4490 // %list = type { %list * } ; repeated type decl
4491 //
4492 // If types are not resolved eagerly, then the two types will not be
4493 // determined to be the same type!
4494 //
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004495 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004496
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004497 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004498 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004499 // If this is a named type that is not a redefinition, add it to the slot
4500 // table.
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004501 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004502 }
Reid Spencera132e042006-12-03 05:46:11 +00004503
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004504 delete (yyvsp[(3) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004505 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004506 ;}
4507 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00004508
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004509 case 180:
4510#line 1892 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4511 {
4512 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4513
4514 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer14310612006-12-31 05:40:51 +00004515 CHECK_FOR_ERROR
4516 // If this is a named type that is not a redefinition, add it to the slot
4517 // table.
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004518 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Reid Spencer14310612006-12-31 05:40:51 +00004519 }
4520 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004521 ;}
4522 break;
4523
4524 case 181:
4525#line 1903 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4526 { /* "Externally Visible" Linkage */
4527 if ((yyvsp[(4) - (4)].ConstVal) == 0)
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004528 GEN_ERROR("Global value initializer is not a constant!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004529 CurGV = ParseGlobalVariable((yyvsp[(1) - (4)].StrVal), GlobalValue::ExternalLinkage,
4530 (yyvsp[(2) - (4)].Visibility), (yyvsp[(3) - (4)].BoolVal), (yyvsp[(4) - (4)].ConstVal)->getType(), (yyvsp[(4) - (4)].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004531 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004532 ;}
4533 break;
4534
4535 case 182:
4536#line 1909 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4537 {
Reid Spencer6fd36ab2006-12-29 20:35:03 +00004538 CurGV = 0;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004539 ;}
4540 break;
4541
4542 case 183:
4543#line 1912 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4544 {
4545 if ((yyvsp[(5) - (5)].ConstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004546 GEN_ERROR("Global value initializer is not a constant!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004547 CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), (yyvsp[(2) - (5)].Linkage), (yyvsp[(3) - (5)].Visibility), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal)->getType(), (yyvsp[(5) - (5)].ConstVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004548 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004549 ;}
4550 break;
4551
4552 case 184:
4553#line 1917 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4554 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004555 CurGV = 0;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004556 ;}
4557 break;
4558
4559 case 185:
4560#line 1920 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4561 {
Reid Spencer14310612006-12-31 05:40:51 +00004562 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004563 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (5)].TypeVal))->getDescription());
4564 CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), (yyvsp[(2) - (5)].Linkage), (yyvsp[(3) - (5)].Visibility), (yyvsp[(4) - (5)].BoolVal), *(yyvsp[(5) - (5)].TypeVal), 0);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004565 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004566 delete (yyvsp[(5) - (5)].TypeVal);
4567 ;}
4568 break;
4569
4570 case 186:
4571#line 1926 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4572 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004573 CurGV = 0;
4574 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004575 ;}
4576 break;
4577
4578 case 187:
4579#line 1930 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4580 {
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004581 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004582 ;}
4583 break;
4584
4585 case 188:
4586#line 1933 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4587 {
Reid Spencer218ded22007-01-05 17:07:23 +00004588 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004589 ;}
4590 break;
4591
4592 case 189:
4593#line 1939 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4594 {
Chris Lattner66316012006-01-24 04:14:29 +00004595 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004596 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
4597 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
4598 free((yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004599
4600 if (AsmSoFar.empty())
4601 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4602 else
4603 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004604 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004605;}
4606 break;
4607
4608 case 190:
4609#line 1952 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4610 { (yyval.Endianness) = Module::BigEndian; ;}
4611 break;
4612
4613 case 191:
4614#line 1953 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4615 { (yyval.Endianness) = Module::LittleEndian; ;}
4616 break;
4617
4618 case 192:
4619#line 1955 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4620 {
4621 CurModule.CurrentModule->setEndianness((yyvsp[(3) - (3)].Endianness));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004622 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004623 ;}
4624 break;
4625
4626 case 193:
4627#line 1959 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4628 {
4629 if ((yyvsp[(3) - (3)].UInt64Val) == 32)
Reid Spencere4d87aa2006-12-23 06:05:41 +00004630 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004631 else if ((yyvsp[(3) - (3)].UInt64Val) == 64)
Reid Spencere4d87aa2006-12-23 06:05:41 +00004632 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4633 else
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004634 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004635 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004636 ;}
4637 break;
4638
4639 case 194:
4640#line 1968 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4641 {
4642 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
4643 free((yyvsp[(3) - (3)].StrVal));
4644 ;}
4645 break;
4646
4647 case 195:
4648#line 1972 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4649 {
4650 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
4651 free((yyvsp[(3) - (3)].StrVal));
4652 ;}
4653 break;
4654
4655 case 197:
4656#line 1979 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4657 {
4658 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
4659 free((yyvsp[(3) - (3)].StrVal));
Reid Spencera54b7cb2007-01-12 07:05:14 +00004660 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004661 ;}
4662 break;
4663
4664 case 198:
4665#line 1984 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4666 {
4667 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
4668 free((yyvsp[(1) - (1)].StrVal));
Reid Spencera54b7cb2007-01-12 07:05:14 +00004669 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004670 ;}
4671 break;
4672
4673 case 199:
4674#line 1989 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4675 {
Reid Spencera54b7cb2007-01-12 07:05:14 +00004676 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004677 ;}
4678 break;
4679
4680 case 203:
4681#line 1999 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4682 { (yyval.StrVal) = 0; ;}
4683 break;
4684
4685 case 204:
4686#line 2001 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4687 {
Reid Spencer14310612006-12-31 05:40:51 +00004688 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004689 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
4690 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Reid Spencer14310612006-12-31 05:40:51 +00004691 GEN_ERROR("void typed arguments are invalid!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004692 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
4693 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
4694 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004695 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004696 ;}
4697 break;
4698
4699 case 205:
4700#line 2011 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4701 {
Reid Spencer14310612006-12-31 05:40:51 +00004702 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004703 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4704 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Reid Spencer14310612006-12-31 05:40:51 +00004705 GEN_ERROR("void typed arguments are invalid!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004706 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
4707 (yyval.ArgList) = new ArgListType;
4708 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004709 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004710 ;}
4711 break;
4712
4713 case 206:
4714#line 2022 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4715 {
4716 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004717 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004718 ;}
4719 break;
4720
4721 case 207:
4722#line 2026 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4723 {
4724 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Reid Spencer14310612006-12-31 05:40:51 +00004725 struct ArgListEntry E;
4726 E.Ty = new PATypeHolder(Type::VoidTy);
4727 E.Name = 0;
4728 E.Attrs = FunctionType::NoAttributeSet;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004729 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004730 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004731 ;}
4732 break;
4733
4734 case 208:
4735#line 2035 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4736 {
4737 (yyval.ArgList) = new ArgListType;
Reid Spencer14310612006-12-31 05:40:51 +00004738 struct ArgListEntry E;
4739 E.Ty = new PATypeHolder(Type::VoidTy);
4740 E.Name = 0;
4741 E.Attrs = FunctionType::NoAttributeSet;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004742 (yyval.ArgList)->push_back(E);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004743 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004744 ;}
4745 break;
4746
4747 case 209:
4748#line 2044 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4749 {
4750 (yyval.ArgList) = 0;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004751 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004752 ;}
4753 break;
4754
4755 case 210:
4756#line 2050 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4757 {
4758 UnEscapeLexed((yyvsp[(3) - (9)].StrVal));
4759 std::string FunctionName((yyvsp[(3) - (9)].StrVal));
4760 free((yyvsp[(3) - (9)].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004761
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004762 // Check the function result for abstractness if this is a define. We should
4763 // have no abstract types at this point
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004764 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (9)].TypeVal)))
4765 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (9)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004766
Reid Spencer68a24bd2005-08-27 18:50:39 +00004767 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00004768 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004769 ParamAttrs.push_back((yyvsp[(7) - (9)].ParamAttrs));
4770 if ((yyvsp[(5) - (9)].ArgList)) { // If there are arguments...
4771 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004772 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004773 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4774 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004775 ParamTypeList.push_back(Ty);
4776 if (Ty != Type::VoidTy)
4777 ParamAttrs.push_back(I->Attrs);
4778 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004779 }
4780
4781 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4782 if (isVarArg) ParamTypeList.pop_back();
4783
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004784 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (9)].TypeVal), ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00004785 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004786 const PointerType *PFT = PointerType::get(FT);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004787 delete (yyvsp[(2) - (9)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004788
4789 ValID ID;
4790 if (!FunctionName.empty()) {
4791 ID = ValID::create((char*)FunctionName.c_str());
4792 } else {
4793 ID = ValID::create((int)CurModule.Values[PFT].size());
4794 }
4795
4796 Function *Fn = 0;
4797 // See if this function was forward referenced. If so, recycle the object.
4798 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4799 // Move the function to the end of the list, from whereever it was
4800 // previously inserted.
4801 Fn = cast<Function>(FWRef);
4802 CurModule.CurrentModule->getFunctionList().remove(Fn);
4803 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4804 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4805 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4806 // If this is the case, either we need to be a forward decl, or it needs
4807 // to be.
4808 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004809 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004810
4811 // Make sure to strip off any argument names so we can't get conflicts.
4812 if (Fn->isExternal())
4813 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4814 AI != AE; ++AI)
4815 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004816 } else { // Not already defined?
4817 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4818 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004819
Reid Spencer68a24bd2005-08-27 18:50:39 +00004820 InsertValue(Fn, CurModule.Values);
4821 }
4822
4823 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004824
4825 if (CurFun.isDeclare) {
4826 // If we have declaration, always overwrite linkage. This will allow us to
4827 // correctly handle cases, when pointer to function is passed as argument to
4828 // another function.
4829 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004830 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004831 }
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004832 Fn->setCallingConv((yyvsp[(1) - (9)].UIntVal));
4833 Fn->setAlignment((yyvsp[(9) - (9)].UIntVal));
4834 if ((yyvsp[(8) - (9)].StrVal)) {
4835 Fn->setSection((yyvsp[(8) - (9)].StrVal));
4836 free((yyvsp[(8) - (9)].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004837 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004838
4839 // Add all of the arguments we parsed to the function...
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004840 if ((yyvsp[(5) - (9)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004841 if (isVarArg) { // Nuke the last entry
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004842 assert((yyvsp[(5) - (9)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (9)].ArgList)->back().Name == 0&&
Reid Spencera132e042006-12-03 05:46:11 +00004843 "Not a varargs marker!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004844 delete (yyvsp[(5) - (9)].ArgList)->back().Ty;
4845 (yyvsp[(5) - (9)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004846 }
4847 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer14310612006-12-31 05:40:51 +00004848 unsigned Idx = 1;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004849 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004850 delete I->Ty; // Delete the typeholder...
4851 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004852 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004853 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004854 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004855 }
Reid Spencera132e042006-12-03 05:46:11 +00004856
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004857 delete (yyvsp[(5) - (9)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004858 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004859 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004860;}
4861 break;
4862
4863 case 213:
4864#line 2157 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4865 {
4866 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004867
4868 // Make sure that we keep track of the linkage type even if there was a
4869 // previous "declare".
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004870 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
4871 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
4872;}
4873 break;
4874
4875 case 216:
4876#line 2168 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4877 {
4878 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004879 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004880;}
4881 break;
4882
4883 case 217:
4884#line 2173 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4885 {
4886 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
4887 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
4888 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004889 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004890 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004891 ;}
4892 break;
4893
4894 case 218:
4895#line 2185 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4896 {
4897 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004898 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004899 ;}
4900 break;
4901
4902 case 219:
4903#line 2189 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4904 {
4905 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004906 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004907 ;}
4908 break;
4909
4910 case 220:
4911#line 2194 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4912 { // A reference to a direct constant
4913 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004914 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004915 ;}
4916 break;
4917
4918 case 221:
4919#line 2198 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4920 {
4921 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004922 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004923 ;}
4924 break;
4925
4926 case 222:
4927#line 2202 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4928 { // Perhaps it's an FP constant?
4929 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004930 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004931 ;}
4932 break;
4933
4934 case 223:
4935#line 2206 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4936 {
4937 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004938 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004939 ;}
4940 break;
4941
4942 case 224:
4943#line 2210 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4944 {
4945 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004946 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004947 ;}
4948 break;
4949
4950 case 225:
4951#line 2214 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4952 {
4953 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004954 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004955 ;}
4956 break;
4957
4958 case 226:
4959#line 2218 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4960 {
4961 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004962 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004963 ;}
4964 break;
4965
4966 case 227:
4967#line 2222 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4968 { // A vector zero constant.
4969 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004970 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004971 ;}
4972 break;
4973
4974 case 228:
4975#line 2226 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4976 { // Nonempty unsized packed vector
4977 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
4978 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004979
4980 PackedType* pt = PackedType::get(ETy, NumElements);
4981 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004982 HandleUpRefs(
4983 PackedType::get(
4984 ETy,
4985 NumElements)
4986 )
4987 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004988
4989 // Verify all elements are correct type!
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004990 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
4991 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004992 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004993 ETy->getDescription() +"' as required!\nIt is of type '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004994 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004995 }
4996
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004997 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
4998 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004999 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005000 ;}
5001 break;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005002
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005003 case 229:
5004#line 2251 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5005 {
5006 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005007 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005008 ;}
5009 break;
5010
5011 case 230:
5012#line 2255 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5013 {
5014 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5015 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5016 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5017 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5018 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5019 free((yyvsp[(3) - (5)].StrVal));
5020 free((yyvsp[(5) - (5)].StrVal));
5021 CHECK_FOR_ERROR
5022 ;}
5023 break;
5024
5025 case 231:
5026#line 2269 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5027 { // Is it an integer reference...?
5028 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal));
5029 CHECK_FOR_ERROR
5030 ;}
5031 break;
5032
5033 case 232:
5034#line 2273 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5035 { // Is it a named reference...?
5036 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal));
5037 CHECK_FOR_ERROR
5038 ;}
5039 break;
5040
5041 case 235:
5042#line 2285 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5043 {
5044 if (!UpRefs.empty())
5045 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5046 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5047 delete (yyvsp[(1) - (2)].TypeVal);
5048 CHECK_FOR_ERROR
5049 ;}
5050 break;
5051
5052 case 236:
5053#line 2294 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5054 {
5055 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5056 CHECK_FOR_ERROR
5057 ;}
5058 break;
5059
5060 case 237:
5061#line 2298 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5062 { // Do not allow functions with 0 basic blocks
5063 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5064 CHECK_FOR_ERROR
5065 ;}
5066 break;
5067
5068 case 238:
5069#line 2307 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5070 {
5071 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
5072 CHECK_FOR_ERROR
5073 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5074
5075 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5076 InsertValue((yyvsp[(1) - (3)].BasicBlockVal));
5077 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
5078 CHECK_FOR_ERROR
5079 ;}
5080 break;
5081
5082 case 239:
5083#line 2318 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5084 {
5085 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005086 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5087 if (CI2->getParent() == 0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005088 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5089 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5090 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005091 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005092 ;}
5093 break;
5094
5095 case 240:
5096#line 2327 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5097 {
5098 (yyval.BasicBlockVal) = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005099 CHECK_FOR_ERROR
5100
5101 // Make sure to move the basic block to the correct location in the
5102 // function, instead of leaving it inserted wherever it was first
5103 // referenced.
5104 Function::BasicBlockListType &BBL =
5105 CurFun.CurrentFunction->getBasicBlockList();
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005106 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005107 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005108 ;}
5109 break;
5110
5111 case 241:
5112#line 2339 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5113 {
5114 (yyval.BasicBlockVal) = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005115 CHECK_FOR_ERROR
5116
5117 // Make sure to move the basic block to the correct location in the
5118 // function, instead of leaving it inserted wherever it was first
5119 // referenced.
5120 Function::BasicBlockListType &BBL =
5121 CurFun.CurrentFunction->getBasicBlockList();
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005122 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00005123 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005124 ;}
5125 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00005126
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005127 case 242:
5128#line 2352 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5129 { // Return with a result...
5130 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal));
5131 CHECK_FOR_ERROR
5132 ;}
5133 break;
5134
5135 case 243:
5136#line 2356 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5137 { // Return with no result...
5138 (yyval.TermInstVal) = new ReturnInst();
5139 CHECK_FOR_ERROR
5140 ;}
5141 break;
5142
5143 case 244:
5144#line 2360 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5145 { // Unconditional Branch...
5146 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5147 CHECK_FOR_ERROR
5148 (yyval.TermInstVal) = new BranchInst(tmpBB);
5149 ;}
5150 break;
5151
5152 case 245:
5153#line 2365 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5154 {
5155 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5156 CHECK_FOR_ERROR
5157 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5158 CHECK_FOR_ERROR
5159 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5160 CHECK_FOR_ERROR
5161 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5162 ;}
5163 break;
5164
5165 case 246:
5166#line 2374 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5167 {
5168 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5169 CHECK_FOR_ERROR
5170 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5171 CHECK_FOR_ERROR
5172 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5173 (yyval.TermInstVal) = S;
5174
5175 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5176 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005177 for (; I != E; ++I) {
5178 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5179 S->addCase(CI, I->second);
5180 else
Reid Spencer61c83e02006-08-18 08:43:06 +00005181 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005182 }
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005183 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005184 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005185 ;}
5186 break;
5187
5188 case 247:
5189#line 2393 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5190 {
5191 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005192 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005193 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005194 CHECK_FOR_ERROR
5195 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005196 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005197 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005198 ;}
5199 break;
5200
5201 case 248:
5202#line 2403 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5203 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005204
Reid Spencer14310612006-12-31 05:40:51 +00005205 // Handle the short syntax
5206 const PointerType *PFTy = 0;
5207 const FunctionType *Ty = 0;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005208 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005209 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5210 // Pull out the types of all of the arguments...
5211 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005212 FunctionType::ParamAttrsList ParamAttrs;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005213 ParamAttrs.push_back((yyvsp[(8) - (14)].ParamAttrs));
5214 for (ValueRefList::iterator I = (yyvsp[(6) - (14)].ValueRefList)->begin(), E = (yyvsp[(6) - (14)].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005215 const Type *Ty = I->Val->getType();
5216 if (Ty == Type::VoidTy)
5217 GEN_ERROR("Short call syntax cannot be used with varargs");
5218 ParamTypes.push_back(Ty);
5219 ParamAttrs.push_back(I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005220 }
5221
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005222 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005223 PFTy = PointerType::get(Ty);
5224 }
5225
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005226 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005227 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005228 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005229 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005230 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005231 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005232
Reid Spencer14310612006-12-31 05:40:51 +00005233 // Check the arguments
5234 ValueList Args;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005235 if ((yyvsp[(6) - (14)].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005236 // Make sure no arguments is a good thing!
5237 if (Ty->getNumParams() != 0)
5238 GEN_ERROR("No arguments passed to a function that "
5239 "expects arguments!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005240 } else { // Has arguments?
5241 // Loop through FunctionType's arguments and ensure they are specified
5242 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005243 FunctionType::param_iterator I = Ty->param_begin();
5244 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005245 ValueRefList::iterator ArgI = (yyvsp[(6) - (14)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (14)].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005246
Reid Spencer14310612006-12-31 05:40:51 +00005247 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5248 if (ArgI->Val->getType() != *I)
5249 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencera132e042006-12-03 05:46:11 +00005250 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00005251 Args.push_back(ArgI->Val);
5252 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005253
Reid Spencer14310612006-12-31 05:40:51 +00005254 if (Ty->isVarArg()) {
5255 if (I == E)
5256 for (; ArgI != ArgE; ++ArgI)
5257 Args.push_back(ArgI->Val); // push the remaining varargs
5258 } else if (I != E || ArgI != ArgE)
Reid Spencer61c83e02006-08-18 08:43:06 +00005259 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005260 }
Reid Spencer14310612006-12-31 05:40:51 +00005261
5262 // Create the InvokeInst
5263 InvokeInst *II = new InvokeInst(V, Normal, Except, Args);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005264 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
5265 (yyval.TermInstVal) = II;
5266 delete (yyvsp[(6) - (14)].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005267 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005268 ;}
5269 break;
5270
5271 case 249:
5272#line 2469 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5273 {
5274 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005275 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005276 ;}
5277 break;
5278
5279 case 250:
5280#line 2473 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5281 {
5282 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005283 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005284 ;}
5285 break;
5286
5287 case 251:
5288#line 2480 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5289 {
5290 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5291 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005292 CHECK_FOR_ERROR
5293 if (V == 0)
5294 GEN_ERROR("May only switch on a constant pool value!");
5295
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005296 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005297 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005298 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5299 ;}
5300 break;
5301
5302 case 252:
5303#line 2491 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5304 {
5305 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5306 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005307 CHECK_FOR_ERROR
5308
5309 if (V == 0)
5310 GEN_ERROR("May only switch on a constant pool value!");
5311
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005312 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005313 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005314 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5315 ;}
5316 break;
5317
5318 case 253:
5319#line 2504 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5320 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00005321 // Is this definition named?? if so, assign the name...
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005322 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005323 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005324 InsertValue((yyvsp[(2) - (2)].InstVal));
5325 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005326 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005327;}
5328 break;
5329
5330 case 254:
5331#line 2513 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5332 { // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00005333 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005334 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5335 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5336 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005337 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005338 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005339 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005340 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5341 delete (yyvsp[(1) - (6)].TypeVal);
5342 ;}
5343 break;
5344
5345 case 255:
5346#line 2524 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5347 {
5348 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5349 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005350 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005351 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005352 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005353 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5354 ;}
5355 break;
5356
5357 case 256:
5358#line 2534 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5359 {
Reid Spencer14310612006-12-31 05:40:51 +00005360 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005361 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005362 // Used for call and invoke instructions
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005363 (yyval.ValueRefList) = new ValueRefList();
5364 ValueRefListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (3)].TypeVal)->get(), (yyvsp[(2) - (3)].ValIDVal));
5365 (yyval.ValueRefList)->push_back(E);
5366 ;}
5367 break;
5368
5369 case 257:
5370#line 2542 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5371 {
Reid Spencer14310612006-12-31 05:40:51 +00005372 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005373 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5374 (yyval.ValueRefList) = (yyvsp[(1) - (5)].ValueRefList);
5375 ValueRefListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (5)].TypeVal)->get(), (yyvsp[(4) - (5)].ValIDVal));
5376 (yyval.ValueRefList)->push_back(E);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005377 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005378 ;}
5379 break;
5380
5381 case 258:
5382#line 2550 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5383 { (yyval.ValueRefList) = new ValueRefList(); ;}
5384 break;
5385
5386 case 259:
5387#line 2553 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5388 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5389 break;
5390
5391 case 260:
5392#line 2554 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5393 {
5394 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5395 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencer14310612006-12-31 05:40:51 +00005396 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005397 ;}
5398 break;
5399
5400 case 261:
5401#line 2561 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5402 {
5403 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005404 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005405 ;}
5406 break;
5407
5408 case 262:
5409#line 2565 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5410 {
5411 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005412 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005413 ;}
5414 break;
5415
5416 case 263:
5417#line 2570 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5418 {
Reid Spencer14310612006-12-31 05:40:51 +00005419 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005420 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5421 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5422 !isa<PackedType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005423 GEN_ERROR(
5424 "Arithmetic operator requires integer, FP, or packed operands!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005425 if (isa<PackedType>((*(yyvsp[(2) - (5)].TypeVal)).get()) &&
5426 ((yyvsp[(1) - (5)].BinaryOpVal) == Instruction::URem ||
5427 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::SRem ||
5428 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::FRem))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005429 GEN_ERROR("U/S/FRem not supported on packed types!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005430 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005431 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005432 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005433 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005434 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
5435 if ((yyval.InstVal) == 0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00005436 GEN_ERROR("binary operator returned null!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005437 delete (yyvsp[(2) - (5)].TypeVal);
5438 ;}
5439 break;
5440
5441 case 264:
5442#line 2591 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5443 {
Reid Spencer14310612006-12-31 05:40:51 +00005444 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005445 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5446 if (!(*(yyvsp[(2) - (5)].TypeVal))->isIntegral()) {
5447 if (!isa<PackedType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
5448 !cast<PackedType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isIntegral())
Reid Spencere4d87aa2006-12-23 06:05:41 +00005449 GEN_ERROR("Logical operator requires integral operands!");
5450 }
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005451 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005452 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005453 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005454 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005455 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
5456 if ((yyval.InstVal) == 0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00005457 GEN_ERROR("binary operator returned null!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005458 delete (yyvsp[(2) - (5)].TypeVal);
5459 ;}
5460 break;
5461
5462 case 265:
5463#line 2608 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5464 {
Reid Spencer14310612006-12-31 05:40:51 +00005465 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005466 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5467 if (isa<PackedType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Reid Spencerac4a1dd2007-01-04 02:57:52 +00005468 GEN_ERROR("Packed types not supported by icmp instruction");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005469 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005470 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005471 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005472 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005473 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
5474 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005475 GEN_ERROR("icmp operator returned null!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005476 ;}
5477 break;
5478
5479 case 266:
5480#line 2621 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5481 {
Reid Spencer14310612006-12-31 05:40:51 +00005482 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005483 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5484 if (isa<PackedType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Reid Spencerac4a1dd2007-01-04 02:57:52 +00005485 GEN_ERROR("Packed types not supported by fcmp instruction");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005486 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005487 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005488 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005489 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005490 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
5491 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005492 GEN_ERROR("fcmp operator returned null!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005493 ;}
5494 break;
5495
5496 case 267:
5497#line 2634 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5498 {
5499 if ((yyvsp[(4) - (4)].ValueVal)->getType() != Type::Int8Ty)
Reid Spencer14310612006-12-31 05:40:51 +00005500 GEN_ERROR("Shift amount must be i8 type!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005501 if (!(yyvsp[(2) - (4)].ValueVal)->getType()->isInteger())
Andrew Lenharth6353e052006-12-08 18:07:09 +00005502 GEN_ERROR("Shift constant expression requires integer operand!");
5503 CHECK_FOR_ERROR;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005504 (yyval.InstVal) = new ShiftInst((yyvsp[(1) - (4)].OtherOpVal), (yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005505 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005506 ;}
5507 break;
5508
5509 case 268:
5510#line 2643 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5511 {
Reid Spencer14310612006-12-31 05:40:51 +00005512 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005513 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5514 Value* Val = (yyvsp[(2) - (4)].ValueVal);
5515 const Type* Ty = (yyvsp[(4) - (4)].TypeVal)->get();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005516 if (!Val->getType()->isFirstClassType())
5517 GEN_ERROR("cast from a non-primitive type: '" +
5518 Val->getType()->getDescription() + "'!");
5519 if (!Ty->isFirstClassType())
5520 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005521 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, (yyvsp[(4) - (4)].TypeVal)->get());
5522 delete (yyvsp[(4) - (4)].TypeVal);
5523 ;}
5524 break;
5525
5526 case 269:
5527#line 2656 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5528 {
5529 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005530 GEN_ERROR("select condition must be boolean!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005531 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Andrew Lenharth6353e052006-12-08 18:07:09 +00005532 GEN_ERROR("select value types should match!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005533 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005534 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005535 ;}
5536 break;
5537
5538 case 270:
5539#line 2664 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5540 {
Reid Spencer14310612006-12-31 05:40:51 +00005541 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005542 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5543 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
5544 delete (yyvsp[(4) - (4)].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005545 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005546 ;}
5547 break;
5548
5549 case 271:
5550#line 2671 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5551 {
5552 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005553 GEN_ERROR("Invalid extractelement operands!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005554 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005555 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005556 ;}
5557 break;
5558
5559 case 272:
5560#line 2677 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5561 {
5562 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005563 GEN_ERROR("Invalid insertelement operands!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005564 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005565 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005566 ;}
5567 break;
5568
5569 case 273:
5570#line 2683 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5571 {
5572 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Andrew Lenharth6353e052006-12-08 18:07:09 +00005573 GEN_ERROR("Invalid shufflevector operands!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005574 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005575 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005576 ;}
5577 break;
5578
5579 case 274:
5580#line 2689 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5581 {
5582 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005583 if (!Ty->isFirstClassType())
5584 GEN_ERROR("PHI node operands must be of first class type!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005585 (yyval.InstVal) = new PHINode(Ty);
5586 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
5587 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
5588 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005589 GEN_ERROR("All elements of a PHI node must be of the same type!");
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005590 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
5591 (yyvsp[(2) - (2)].PHIList)->pop_front();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005592 }
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005593 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005594 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005595 ;}
5596 break;
5597
5598 case 275:
5599#line 2705 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5600 {
Reid Spencer14310612006-12-31 05:40:51 +00005601
5602 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005603 const PointerType *PFTy = 0;
5604 const FunctionType *Ty = 0;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005605 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005606 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5607 // Pull out the types of all of the arguments...
5608 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005609 FunctionType::ParamAttrsList ParamAttrs;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005610 ParamAttrs.push_back((yyvsp[(8) - (8)].ParamAttrs));
5611 for (ValueRefList::iterator I = (yyvsp[(6) - (8)].ValueRefList)->begin(), E = (yyvsp[(6) - (8)].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005612 const Type *Ty = I->Val->getType();
5613 if (Ty == Type::VoidTy)
5614 GEN_ERROR("Short call syntax cannot be used with varargs");
5615 ParamTypes.push_back(Ty);
5616 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005617 }
5618
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005619 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005620 PFTy = PointerType::get(Ty);
5621 }
5622
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005623 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005624 CHECK_FOR_ERROR
5625
Reid Spencer14310612006-12-31 05:40:51 +00005626 // Check the arguments
5627 ValueList Args;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005628 if ((yyvsp[(6) - (8)].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005629 // Make sure no arguments is a good thing!
5630 if (Ty->getNumParams() != 0)
5631 GEN_ERROR("No arguments passed to a function that "
5632 "expects arguments!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005633 } else { // Has arguments?
5634 // Loop through FunctionType's arguments and ensure they are specified
5635 // correctly!
5636 //
5637 FunctionType::param_iterator I = Ty->param_begin();
5638 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005639 ValueRefList::iterator ArgI = (yyvsp[(6) - (8)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (8)].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005640
Reid Spencer14310612006-12-31 05:40:51 +00005641 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5642 if (ArgI->Val->getType() != *I)
5643 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Andrew Lenharth6353e052006-12-08 18:07:09 +00005644 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00005645 Args.push_back(ArgI->Val);
5646 }
5647 if (Ty->isVarArg()) {
5648 if (I == E)
5649 for (; ArgI != ArgE; ++ArgI)
5650 Args.push_back(ArgI->Val); // push the remaining varargs
5651 } else if (I != E || ArgI != ArgE)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005652 GEN_ERROR("Invalid number of parameters detected!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005653 }
Reid Spencer14310612006-12-31 05:40:51 +00005654 // Create the call node
5655 CallInst *CI = new CallInst(V, Args);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005656 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
5657 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
5658 (yyval.InstVal) = CI;
5659 delete (yyvsp[(6) - (8)].ValueRefList);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005660 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005661 ;}
5662 break;
5663
5664 case 276:
5665#line 2767 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5666 {
5667 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005668 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005669 ;}
5670 break;
5671
5672 case 277:
5673#line 2772 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5674 {
5675 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005676 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005677 ;}
5678 break;
5679
5680 case 278:
5681#line 2776 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5682 {
5683 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005684 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005685 ;}
5686 break;
5687
5688 case 279:
5689#line 2783 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5690 {
Reid Spencer14310612006-12-31 05:40:51 +00005691 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005692 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
5693 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
5694 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005695 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005696 ;}
5697 break;
5698
5699 case 280:
5700#line 2790 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5701 {
Reid Spencer14310612006-12-31 05:40:51 +00005702 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005703 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
5704 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005705 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005706 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
5707 delete (yyvsp[(2) - (6)].TypeVal);
5708 ;}
5709 break;
5710
5711 case 281:
5712#line 2798 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5713 {
Reid Spencer14310612006-12-31 05:40:51 +00005714 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005715 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
5716 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
5717 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005718 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005719 ;}
5720 break;
5721
5722 case 282:
5723#line 2805 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5724 {
Reid Spencer14310612006-12-31 05:40:51 +00005725 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005726 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
5727 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005728 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005729 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
5730 delete (yyvsp[(2) - (6)].TypeVal);
5731 ;}
5732 break;
5733
5734 case 283:
5735#line 2813 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5736 {
5737 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005738 GEN_ERROR("Trying to free nonpointer type " +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005739 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "!");
5740 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005741 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005742 ;}
5743 break;
5744
5745 case 284:
5746#line 2821 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5747 {
Reid Spencer14310612006-12-31 05:40:51 +00005748 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005749 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (4)].TypeVal))->getDescription());
5750 if (!isa<PointerType>((yyvsp[(3) - (4)].TypeVal)->get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005751 GEN_ERROR("Can't load from nonpointer type: " +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005752 (*(yyvsp[(3) - (4)].TypeVal))->getDescription());
5753 if (!cast<PointerType>((yyvsp[(3) - (4)].TypeVal)->get())->getElementType()->isFirstClassType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00005754 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005755 (*(yyvsp[(3) - (4)].TypeVal))->getDescription());
5756 Value* tmpVal = getVal(*(yyvsp[(3) - (4)].TypeVal), (yyvsp[(4) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005757 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005758 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
5759 delete (yyvsp[(3) - (4)].TypeVal);
5760 ;}
5761 break;
5762
5763 case 285:
5764#line 2835 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5765 {
Reid Spencer14310612006-12-31 05:40:51 +00005766 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005767 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
5768 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal)->get());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005769 if (!PT)
5770 GEN_ERROR("Can't store to a nonpointer type: " +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005771 (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005772 const Type *ElTy = PT->getElementType();
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005773 if (ElTy != (yyvsp[(3) - (6)].ValueVal)->getType())
5774 GEN_ERROR("Can't store '" + (yyvsp[(3) - (6)].ValueVal)->getType()->getDescription() +
Reid Spencere4d87aa2006-12-23 06:05:41 +00005775 "' into space of type '" + ElTy->getDescription() + "'!");
5776
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005777 Value* tmpVal = getVal(*(yyvsp[(5) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005778 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005779 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (6)].ValueVal), tmpVal, (yyvsp[(1) - (6)].BoolVal));
5780 delete (yyvsp[(5) - (6)].TypeVal);
5781 ;}
5782 break;
5783
5784 case 286:
5785#line 2852 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5786 {
Reid Spencer14310612006-12-31 05:40:51 +00005787 if (!UpRefs.empty())
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005788 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
5789 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005790 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005791
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005792 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), *(yyvsp[(4) - (4)].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005793 GEN_ERROR("Invalid getelementptr indices for type '" +
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005794 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'!");
5795 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005796 CHECK_FOR_ERROR
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005797 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[(4) - (4)].ValueList));
5798 delete (yyvsp[(2) - (4)].TypeVal);
5799 delete (yyvsp[(4) - (4)].ValueList);
5800 ;}
5801 break;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005802
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005803
5804/* Line 1267 of yacc.c. */
5805#line 5806 "llvmAsmParser.tab.c"
5806 default: break;
Chris Lattner0fab59c2007-01-12 18:33:30 +00005807 }
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005808 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
5809
5810 YYPOPSTACK (yylen);
5811 yylen = 0;
5812 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005813
5814 *++yyvsp = yyval;
5815
5816
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005817 /* Now `shift' the result of the reduction. Determine what state
5818 that goes to, based on the state we popped back to and the rule
5819 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005820
5821 yyn = yyr1[yyn];
5822
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005823 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5824 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005825 yystate = yytable[yystate];
5826 else
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005827 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005828
5829 goto yynewstate;
5830
5831
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005832/*------------------------------------.
5833| yyerrlab -- here on detecting error |
5834`------------------------------------*/
5835yyerrlab:
5836 /* If not already recovering from an error, report this error. */
5837 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005838 {
5839 ++yynerrs;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005840#if ! YYERROR_VERBOSE
5841 yyerror (YY_("syntax error"));
5842#else
5843 {
5844 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
5845 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
5846 {
5847 YYSIZE_T yyalloc = 2 * yysize;
5848 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
5849 yyalloc = YYSTACK_ALLOC_MAXIMUM;
5850 if (yymsg != yymsgbuf)
5851 YYSTACK_FREE (yymsg);
5852 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
5853 if (yymsg)
5854 yymsg_alloc = yyalloc;
5855 else
5856 {
5857 yymsg = yymsgbuf;
5858 yymsg_alloc = sizeof yymsgbuf;
5859 }
5860 }
Chris Lattner0fab59c2007-01-12 18:33:30 +00005861
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005862 if (0 < yysize && yysize <= yymsg_alloc)
5863 {
5864 (void) yysyntax_error (yymsg, yystate, yychar);
5865 yyerror (yymsg);
5866 }
5867 else
5868 {
5869 yyerror (YY_("syntax error"));
5870 if (yysize != 0)
5871 goto yyexhaustedlab;
5872 }
5873 }
5874#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005875 }
5876
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005877
Reid Spencer68a24bd2005-08-27 18:50:39 +00005878
5879 if (yyerrstatus == 3)
5880 {
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005881 /* If just tried and failed to reuse look-ahead token after an
5882 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005883
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005884 if (yychar <= YYEOF)
5885 {
5886 /* Return failure if at end of input. */
5887 if (yychar == YYEOF)
5888 YYABORT;
5889 }
5890 else
5891 {
5892 yydestruct ("Error: discarding",
5893 yytoken, &yylval);
5894 yychar = YYEMPTY;
5895 }
5896 }
5897
5898 /* Else will try to reuse look-ahead token after shifting the error
5899 token. */
5900 goto yyerrlab1;
5901
5902
5903/*---------------------------------------------------.
5904| yyerrorlab -- error raised explicitly by YYERROR. |
5905`---------------------------------------------------*/
5906yyerrorlab:
5907
5908 /* Pacify compilers like GCC when the user code never invokes
5909 YYERROR and the label yyerrorlab therefore never appears in user
5910 code. */
5911 if (/*CONSTCOND*/ 0)
5912 goto yyerrorlab;
5913
5914 /* Do not reclaim the symbols of the rule which action triggered
5915 this YYERROR. */
5916 YYPOPSTACK (yylen);
5917 yylen = 0;
5918 YY_STACK_PRINT (yyss, yyssp);
5919 yystate = *yyssp;
5920 goto yyerrlab1;
5921
5922
5923/*-------------------------------------------------------------.
5924| yyerrlab1 -- common code for both syntax error and YYERROR. |
5925`-------------------------------------------------------------*/
5926yyerrlab1:
5927 yyerrstatus = 3; /* Each real token shifted decrements this. */
5928
5929 for (;;)
5930 {
5931 yyn = yypact[yystate];
5932 if (yyn != YYPACT_NINF)
5933 {
5934 yyn += YYTERROR;
5935 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5936 {
5937 yyn = yytable[yyn];
5938 if (0 < yyn)
5939 break;
5940 }
5941 }
5942
5943 /* Pop the current state because it cannot handle the error token. */
5944 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005945 YYABORT;
5946
Reid Spencere4d87aa2006-12-23 06:05:41 +00005947
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005948 yydestruct ("Error: popping",
5949 yystos[yystate], yyvsp);
5950 YYPOPSTACK (1);
5951 yystate = *yyssp;
5952 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005953 }
5954
5955 if (yyn == YYFINAL)
5956 YYACCEPT;
5957
Reid Spencer68a24bd2005-08-27 18:50:39 +00005958 *++yyvsp = yylval;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005959
5960
5961 /* Shift the error token. */
5962 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005963
Reid Spencer68a24bd2005-08-27 18:50:39 +00005964 yystate = yyn;
5965 goto yynewstate;
5966
Chris Lattner0fab59c2007-01-12 18:33:30 +00005967
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005968/*-------------------------------------.
5969| yyacceptlab -- YYACCEPT comes here. |
5970`-------------------------------------*/
5971yyacceptlab:
5972 yyresult = 0;
5973 goto yyreturn;
5974
5975/*-----------------------------------.
5976| yyabortlab -- YYABORT comes here. |
5977`-----------------------------------*/
5978yyabortlab:
5979 yyresult = 1;
5980 goto yyreturn;
5981
5982#ifndef yyoverflow
5983/*-------------------------------------------------.
5984| yyexhaustedlab -- memory exhaustion comes here. |
5985`-------------------------------------------------*/
5986yyexhaustedlab:
5987 yyerror (YY_("memory exhausted"));
5988 yyresult = 2;
5989 /* Fall through. */
Chris Lattner0fab59c2007-01-12 18:33:30 +00005990#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005991
5992yyreturn:
5993 if (yychar != YYEOF && yychar != YYEMPTY)
5994 yydestruct ("Cleanup: discarding lookahead",
5995 yytoken, &yylval);
5996 /* Do not reclaim the symbols of the rule which action triggered
5997 this YYABORT or YYACCEPT. */
5998 YYPOPSTACK (yylen);
5999 YY_STACK_PRINT (yyss, yyssp);
6000 while (yyssp != yyss)
6001 {
6002 yydestruct ("Cleanup: popping",
6003 yystos[*yyssp], yyvsp);
6004 YYPOPSTACK (1);
Chris Lattner0fab59c2007-01-12 18:33:30 +00006005 }
Anton Korobeynikov178a3522007-01-12 19:22:51 +00006006#ifndef yyoverflow
6007 if (yyss != yyssa)
6008 YYSTACK_FREE (yyss);
6009#endif
6010#if YYERROR_VERBOSE
6011 if (yymsg != yymsgbuf)
6012 YYSTACK_FREE (yymsg);
6013#endif
6014 /* Make sure YYID is used. */
6015 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006016}
Anton Korobeynikov178a3522007-01-12 19:22:51 +00006017
6018
6019#line 2869 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006020
6021
Reid Spencer14310612006-12-31 05:40:51 +00006022// common code from the two 'RunVMAsmParser' functions
6023static Module* RunParser(Module * M) {
6024
6025 llvmAsmlineno = 1; // Reset the current line number...
6026 CurModule.CurrentModule = M;
6027#if YYDEBUG
6028 yydebug = Debug;
6029#endif
6030
6031 // Check to make sure the parser succeeded
6032 if (yyparse()) {
6033 if (ParserResult)
6034 delete ParserResult;
6035 return 0;
6036 }
6037
6038 // Check to make sure that parsing produced a result
6039 if (!ParserResult)
6040 return 0;
6041
6042 // Reset ParserResult variable while saving its value for the result.
6043 Module *Result = ParserResult;
6044 ParserResult = 0;
6045
6046 return Result;
6047}
6048
Reid Spencer61c83e02006-08-18 08:43:06 +00006049void llvm::GenerateError(const std::string &message, int LineNo) {
6050 if (LineNo == -1) LineNo = llvmAsmlineno;
6051 // TODO: column number in exception
6052 if (TheParseError)
6053 TheParseError->setError(CurFilename, message, LineNo);
6054 TriggerError = 1;
6055}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006056
6057int yyerror(const char *ErrorMsg) {
6058 std::string where
6059 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6060 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
6061 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
6062 if (yychar == YYEMPTY || yychar == 0)
6063 errMsg += "end-of-file.";
6064 else
6065 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006066 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006067 return 0;
6068}
Anton Korobeynikov178a3522007-01-12 19:22:51 +00006069