blob: 1719f0650ee3af16869858d47f6f1b10d95da3bf [file] [log] [blame]
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00005
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Anton Korobeynikov178a3522007-01-12 19:22:51 +000010
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
44
45/* Pure parsers. */
46#define YYPURE 0
47
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
51/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000052#define yyparse llvmAsmparse
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000055#define yylval llvmAsmlval
56#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000057#define yydebug llvmAsmdebug
58#define yynerrs llvmAsmnerrs
59
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000060
61/* Tokens. */
62#ifndef YYTOKENTYPE
63# define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
67 ESINT64VAL = 258,
68 EUINT64VAL = 259,
69 SINTVAL = 260,
70 UINTVAL = 261,
71 FPVAL = 262,
72 VOID = 263,
73 INTTYPE = 264,
74 FLOAT = 265,
75 DOUBLE = 266,
76 LABEL = 267,
77 TYPE = 268,
78 VAR_ID = 269,
79 LABELSTR = 270,
80 STRINGCONSTANT = 271,
81 IMPLEMENTATION = 272,
82 ZEROINITIALIZER = 273,
83 TRUETOK = 274,
84 FALSETOK = 275,
85 BEGINTOK = 276,
86 ENDTOK = 277,
87 DECLARE = 278,
88 DEFINE = 279,
89 GLOBAL = 280,
90 CONSTANT = 281,
91 SECTION = 282,
92 VOLATILE = 283,
93 TO = 284,
94 DOTDOTDOT = 285,
95 NULL_TOK = 286,
96 UNDEF = 287,
97 INTERNAL = 288,
98 LINKONCE = 289,
99 WEAK = 290,
100 APPENDING = 291,
101 DLLIMPORT = 292,
102 DLLEXPORT = 293,
103 EXTERN_WEAK = 294,
104 OPAQUE = 295,
105 EXTERNAL = 296,
106 TARGET = 297,
107 TRIPLE = 298,
108 ENDIAN = 299,
109 POINTERSIZE = 300,
110 LITTLE = 301,
111 BIG = 302,
112 ALIGN = 303,
113 DEPLIBS = 304,
114 CALL = 305,
115 TAIL = 306,
116 ASM_TOK = 307,
117 MODULE = 308,
118 SIDEEFFECT = 309,
119 CC_TOK = 310,
120 CCC_TOK = 311,
121 CSRETCC_TOK = 312,
122 FASTCC_TOK = 313,
123 COLDCC_TOK = 314,
124 X86_STDCALLCC_TOK = 315,
125 X86_FASTCALLCC_TOK = 316,
126 DATALAYOUT = 317,
127 RET = 318,
128 BR = 319,
129 SWITCH = 320,
130 INVOKE = 321,
131 UNWIND = 322,
132 UNREACHABLE = 323,
133 ADD = 324,
134 SUB = 325,
135 MUL = 326,
136 UDIV = 327,
137 SDIV = 328,
138 FDIV = 329,
139 UREM = 330,
140 SREM = 331,
141 FREM = 332,
142 AND = 333,
143 OR = 334,
144 XOR = 335,
145 ICMP = 336,
146 FCMP = 337,
147 EQ = 338,
148 NE = 339,
149 SLT = 340,
150 SGT = 341,
151 SLE = 342,
152 SGE = 343,
153 ULT = 344,
154 UGT = 345,
155 ULE = 346,
156 UGE = 347,
157 OEQ = 348,
158 ONE = 349,
159 OLT = 350,
160 OGT = 351,
161 OLE = 352,
162 OGE = 353,
163 ORD = 354,
164 UNO = 355,
165 UEQ = 356,
166 UNE = 357,
167 MALLOC = 358,
168 ALLOCA = 359,
169 FREE = 360,
170 LOAD = 361,
171 STORE = 362,
172 GETELEMENTPTR = 363,
173 TRUNC = 364,
174 ZEXT = 365,
175 SEXT = 366,
176 FPTRUNC = 367,
177 FPEXT = 368,
178 BITCAST = 369,
179 UITOFP = 370,
180 SITOFP = 371,
181 FPTOUI = 372,
182 FPTOSI = 373,
183 INTTOPTR = 374,
184 PTRTOINT = 375,
185 PHI_TOK = 376,
186 SELECT = 377,
187 SHL = 378,
188 LSHR = 379,
189 ASHR = 380,
190 VAARG = 381,
191 EXTRACTELEMENT = 382,
192 INSERTELEMENT = 383,
193 SHUFFLEVECTOR = 384,
194 NORETURN = 385,
195 DEFAULT = 386,
196 HIDDEN = 387
197 };
198#endif
199/* Tokens. */
200#define ESINT64VAL 258
201#define EUINT64VAL 259
202#define SINTVAL 260
203#define UINTVAL 261
204#define FPVAL 262
205#define VOID 263
206#define INTTYPE 264
207#define FLOAT 265
208#define DOUBLE 266
209#define LABEL 267
210#define TYPE 268
211#define VAR_ID 269
212#define LABELSTR 270
213#define STRINGCONSTANT 271
214#define IMPLEMENTATION 272
215#define ZEROINITIALIZER 273
216#define TRUETOK 274
217#define FALSETOK 275
218#define BEGINTOK 276
219#define ENDTOK 277
220#define DECLARE 278
221#define DEFINE 279
222#define GLOBAL 280
223#define CONSTANT 281
224#define SECTION 282
225#define VOLATILE 283
226#define TO 284
227#define DOTDOTDOT 285
228#define NULL_TOK 286
229#define UNDEF 287
230#define INTERNAL 288
231#define LINKONCE 289
232#define WEAK 290
233#define APPENDING 291
234#define DLLIMPORT 292
235#define DLLEXPORT 293
236#define EXTERN_WEAK 294
237#define OPAQUE 295
238#define EXTERNAL 296
239#define TARGET 297
240#define TRIPLE 298
241#define ENDIAN 299
242#define POINTERSIZE 300
243#define LITTLE 301
244#define BIG 302
245#define ALIGN 303
246#define DEPLIBS 304
247#define CALL 305
248#define TAIL 306
249#define ASM_TOK 307
250#define MODULE 308
251#define SIDEEFFECT 309
252#define CC_TOK 310
253#define CCC_TOK 311
254#define CSRETCC_TOK 312
255#define FASTCC_TOK 313
256#define COLDCC_TOK 314
257#define X86_STDCALLCC_TOK 315
258#define X86_FASTCALLCC_TOK 316
259#define DATALAYOUT 317
260#define RET 318
261#define BR 319
262#define SWITCH 320
263#define INVOKE 321
264#define UNWIND 322
265#define UNREACHABLE 323
266#define ADD 324
267#define SUB 325
268#define MUL 326
269#define UDIV 327
270#define SDIV 328
271#define FDIV 329
272#define UREM 330
273#define SREM 331
274#define FREM 332
275#define AND 333
276#define OR 334
277#define XOR 335
278#define ICMP 336
279#define FCMP 337
280#define EQ 338
281#define NE 339
282#define SLT 340
283#define SGT 341
284#define SLE 342
285#define SGE 343
286#define ULT 344
287#define UGT 345
288#define ULE 346
289#define UGE 347
290#define OEQ 348
291#define ONE 349
292#define OLT 350
293#define OGT 351
294#define OLE 352
295#define OGE 353
296#define ORD 354
297#define UNO 355
298#define UEQ 356
299#define UNE 357
300#define MALLOC 358
301#define ALLOCA 359
302#define FREE 360
303#define LOAD 361
304#define STORE 362
305#define GETELEMENTPTR 363
306#define TRUNC 364
307#define ZEXT 365
308#define SEXT 366
309#define FPTRUNC 367
310#define FPEXT 368
311#define BITCAST 369
312#define UITOFP 370
313#define SITOFP 371
314#define FPTOUI 372
315#define FPTOSI 373
316#define INTTOPTR 374
317#define PTRTOINT 375
318#define PHI_TOK 376
319#define SELECT 377
320#define SHL 378
321#define LSHR 379
322#define ASHR 380
323#define VAARG 381
324#define EXTRACTELEMENT 382
325#define INSERTELEMENT 383
326#define SHUFFLEVECTOR 384
327#define NORETURN 385
328#define DEFAULT 386
329#define HIDDEN 387
330
331
332
333
334/* Copy the first part of user declarations. */
335#line 14 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000336
337#include "ParserInternals.h"
338#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000339#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000340#include "llvm/Instructions.h"
341#include "llvm/Module.h"
342#include "llvm/SymbolTable.h"
343#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000344#include "llvm/Support/CommandLine.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000345#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000346#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000347#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000348#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000349#include <list>
350#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000351#ifndef NDEBUG
352#define YYDEBUG 1
353#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354
Reid Spencere4f47592006-08-18 17:32:55 +0000355// The following is a gross hack. In order to rid the libAsmParser library of
356// exceptions, we have to have a way of getting the yyparse function to go into
357// an error situation. So, whenever we want an error to occur, the GenerateError
358// function (see bottom of file) sets TriggerError. Then, at the end of each
359// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
360// (a goto) to put YACC in error state. Furthermore, several calls to
361// GenerateError are made from inside productions and they must simulate the
362// previous exception behavior by exiting the production immediately. We have
363// replaced these with the GEN_ERROR macro which calls GeneratError and then
364// immediately invokes YYERROR. This would be so much cleaner if it was a
365// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000366static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000367#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000368#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
369
Reid Spencer68a24bd2005-08-27 18:50:39 +0000370int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
371int yylex(); // declaration" of xxx warnings.
372int yyparse();
373
374namespace llvm {
375 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000376#if YYDEBUG
377static cl::opt<bool>
378Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
379 cl::Hidden, cl::init(false));
380#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000381}
382using namespace llvm;
383
384static Module *ParserResult;
385
386// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
387// relating to upreferences in the input stream.
388//
389//#define DEBUG_UPREFS 1
390#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000391#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000392#else
393#define UR_OUT(X)
394#endif
395
396#define YYERROR_VERBOSE 1
397
Chris Lattnerb475c422005-11-12 18:22:38 +0000398static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000399
400
401// This contains info used when building the body of a function. It is
402// destroyed when the function is completed.
403//
404typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000405
Reid Spencer68a24bd2005-08-27 18:50:39 +0000406static void
407ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
408 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
409
410static struct PerModuleInfo {
411 Module *CurrentModule;
412 std::map<const Type *, ValueList> Values; // Module level numbered definitions
413 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000414 std::vector<PATypeHolder> Types;
415 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000416
417 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000418 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000419 /// that we can resolve them later and print error messages as appropriate.
420 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
421
422 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
423 // references to global values. Global values may be referenced before they
424 // are defined, and if so, the temporary object that they represent is held
425 // here. This is used for forward references of GlobalValues.
426 //
427 typedef std::map<std::pair<const PointerType *,
428 ValID>, GlobalValue*> GlobalRefsType;
429 GlobalRefsType GlobalRefs;
430
431 void ModuleDone() {
432 // If we could not resolve some functions at function compilation time
433 // (calls to functions before they are defined), resolve them now... Types
434 // are resolved when the constant pool has been completely parsed.
435 //
436 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000437 if (TriggerError)
438 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000439
440 // Check to make sure that all global value forward references have been
441 // resolved!
442 //
443 if (!GlobalRefs.empty()) {
444 std::string UndefinedReferences = "Unresolved global references exist:\n";
445
446 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
447 I != E; ++I) {
448 UndefinedReferences += " " + I->first.first->getDescription() + " " +
449 I->first.second.getName() + "\n";
450 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000451 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000452 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000453 }
454
455 Values.clear(); // Clear out function local definitions
456 Types.clear();
457 CurrentModule = 0;
458 }
459
Reid Spencer68a24bd2005-08-27 18:50:39 +0000460 // GetForwardRefForGlobal - Check to see if there is a forward reference
461 // for this global. If so, remove it from the GlobalRefs map and return it.
462 // If not, just return null.
463 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
464 // Check to see if there is a forward reference to this global variable...
465 // if there is, eliminate it and patch the reference to use the new def'n.
466 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
467 GlobalValue *Ret = 0;
468 if (I != GlobalRefs.end()) {
469 Ret = I->second;
470 GlobalRefs.erase(I);
471 }
472 return Ret;
473 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000474
475 bool TypeIsUnresolved(PATypeHolder* PATy) {
476 // If it isn't abstract, its resolved
477 const Type* Ty = PATy->get();
478 if (!Ty->isAbstract())
479 return false;
480 // Traverse the type looking for abstract types. If it isn't abstract then
481 // we don't need to traverse that leg of the type.
482 std::vector<const Type*> WorkList, SeenList;
483 WorkList.push_back(Ty);
484 while (!WorkList.empty()) {
485 const Type* Ty = WorkList.back();
486 SeenList.push_back(Ty);
487 WorkList.pop_back();
488 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
489 // Check to see if this is an unresolved type
490 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
491 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
492 for ( ; I != E; ++I) {
493 if (I->second.get() == OpTy)
494 return true;
495 }
496 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
497 const Type* TheTy = SeqTy->getElementType();
498 if (TheTy->isAbstract() && TheTy != Ty) {
499 std::vector<const Type*>::iterator I = SeenList.begin(),
500 E = SeenList.end();
501 for ( ; I != E; ++I)
502 if (*I == TheTy)
503 break;
504 if (I == E)
505 WorkList.push_back(TheTy);
506 }
507 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
508 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
509 const Type* TheTy = StrTy->getElementType(i);
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 }
520 }
521 }
522 return false;
523 }
524
525
Reid Spencer68a24bd2005-08-27 18:50:39 +0000526} CurModule;
527
528static struct PerFunctionInfo {
529 Function *CurrentFunction; // Pointer to current function being created
530
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000531 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000532 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000533 bool isDeclare; // Is this function a forward declararation?
534 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000535 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000536
537 /// BBForwardRefs - When we see forward references to basic blocks, keep
538 /// track of them here.
539 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
540 std::vector<BasicBlock*> NumberedBlocks;
541 unsigned NextBBNum;
542
543 inline PerFunctionInfo() {
544 CurrentFunction = 0;
545 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000546 Linkage = GlobalValue::ExternalLinkage;
547 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000548 }
549
550 inline void FunctionStart(Function *M) {
551 CurrentFunction = M;
552 NextBBNum = 0;
553 }
554
555 void FunctionDone() {
556 NumberedBlocks.clear();
557
558 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000559 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000560 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000561 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000562 return;
563 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000564
565 // Resolve all forward references now.
566 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
567
568 Values.clear(); // Clear out function local definitions
569 CurrentFunction = 0;
570 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000571 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000572 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000573 }
574} CurFun; // Info for the current function...
575
576static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
577
578
579//===----------------------------------------------------------------------===//
580// Code to handle definitions of all the types
581//===----------------------------------------------------------------------===//
582
583static int InsertValue(Value *V,
584 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
585 if (V->hasName()) return -1; // Is this a numbered definition?
586
587 // Yes, insert the value into the value table...
588 ValueList &List = ValueTab[V->getType()];
589 List.push_back(V);
590 return List.size()-1;
591}
592
593static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
594 switch (D.Type) {
595 case ValID::NumberVal: // Is it a numbered definition?
596 // Module constants occupy the lowest numbered slots...
597 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer861d9d62006-11-28 07:29:44 +0000598 return CurModule.Types[(unsigned)D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000599 break;
600 case ValID::NameVal: // Is it a named definition?
601 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
602 D.destroy(); // Free old strdup'd memory...
603 return N;
604 }
605 break;
606 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000607 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000608 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000609 }
610
611 // If we reached here, we referenced either a symbol that we don't know about
612 // or an id number that hasn't been read yet. We may be referencing something
613 // forward, so just create an entry to be resolved later and get to it...
614 //
615 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
616
617
618 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000619 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000620 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000621 return 0;
622 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000623 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000624 return 0;
625 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626 }
627
Reid Spencer861d9d62006-11-28 07:29:44 +0000628 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000629 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000630 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000631
Reid Spencer861d9d62006-11-28 07:29:44 +0000632 Type *Typ = OpaqueType::get();
633 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
634 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000635 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000636
637static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
638 SymbolTable &SymTab =
Reid Spencer78d033e2007-01-06 07:24:44 +0000639 inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
640 CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641 return SymTab.lookup(Ty, Name);
642}
643
644// getValNonImprovising - Look up the value specified by the provided type and
645// the provided ValID. If the value exists and has already been defined, return
646// it. Otherwise return null.
647//
648static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000649 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000650 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000651 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000652 return 0;
653 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000654
655 switch (D.Type) {
656 case ValID::NumberVal: { // Is it a numbered definition?
657 unsigned Num = (unsigned)D.Num;
658
659 // Module constants occupy the lowest numbered slots...
660 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
661 if (VI != CurModule.Values.end()) {
662 if (Num < VI->second.size())
663 return VI->second[Num];
664 Num -= VI->second.size();
665 }
666
667 // Make sure that our type is within bounds
668 VI = CurFun.Values.find(Ty);
669 if (VI == CurFun.Values.end()) return 0;
670
671 // Check that the number is within bounds...
672 if (VI->second.size() <= Num) return 0;
673
674 return VI->second[Num];
675 }
676
677 case ValID::NameVal: { // Is it a named definition?
678 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
679 if (N == 0) return 0;
680
681 D.destroy(); // Free old strdup'd memory...
682 return N;
683 }
684
685 // Check to make sure that "Ty" is an integral type, and that our
686 // value will fit into the specified type...
687 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000688 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000689 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000690 itostr(D.ConstPool64) + "' is invalid for type '" +
691 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000692 return 0;
693 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000694 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000695
696 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000697 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
698 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000699 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000700 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000701 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000702 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000703 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000704 }
705 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000706 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000707 }
708
709 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000710 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000711 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000712 return 0;
713 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000714 return ConstantFP::get(Ty, D.ConstPoolFP);
715
716 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000717 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000718 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000719 return 0;
720 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000721 return ConstantPointerNull::get(cast<PointerType>(Ty));
722
723 case ValID::ConstUndefVal: // Is it an undef value?
724 return UndefValue::get(Ty);
725
Chris Lattner7aa61892005-12-21 17:53:23 +0000726 case ValID::ConstZeroVal: // Is it a zero value?
727 return Constant::getNullValue(Ty);
728
Reid Spencer68a24bd2005-08-27 18:50:39 +0000729 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000730 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000731 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000732 return 0;
733 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000734 return D.ConstantValue;
735
Chris Lattner0e9c3762006-01-25 22:27:16 +0000736 case ValID::InlineAsmVal: { // Inline asm expression
737 const PointerType *PTy = dyn_cast<PointerType>(Ty);
738 const FunctionType *FTy =
739 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000740 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000741 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 return 0;
743 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000744 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
745 D.IAD->HasSideEffects);
746 D.destroy(); // Free InlineAsmDescriptor.
747 return IA;
748 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000749 default:
750 assert(0 && "Unhandled case!");
751 return 0;
752 } // End of switch
753
754 assert(0 && "Unhandled case!");
755 return 0;
756}
757
758// getVal - This function is identical to getValNonImprovising, except that if a
759// value is not already defined, it "improvises" by creating a placeholder var
760// that looks and acts just like the requested variable. When the value is
761// defined later, all uses of the placeholder variable are replaced with the
762// real thing.
763//
764static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000765 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000766 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 return 0;
768 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000769
770 // See if the value has already been defined.
771 Value *V = getValNonImprovising(Ty, ID);
772 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000773 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000774
Reid Spencer5b7e7532006-09-28 19:28:24 +0000775 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000776 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000777 return 0;
778 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000779
780 // If we reached here, we referenced either a symbol that we don't know about
781 // or an id number that hasn't been read yet. We may be referencing something
782 // forward, so just create an entry to be resolved later and get to it...
783 //
784 V = new Argument(Ty);
785
786 // Remember where this forward reference came from. FIXME, shouldn't we try
787 // to recycle these things??
788 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
789 llvmAsmlineno)));
790
791 if (inFunctionScope())
792 InsertValue(V, CurFun.LateResolveValues);
793 else
794 InsertValue(V, CurModule.LateResolveValues);
795 return V;
796}
797
798/// getBBVal - This is used for two purposes:
799/// * If isDefinition is true, a new basic block with the specified ID is being
800/// defined.
801/// * If isDefinition is true, this is a reference to a basic block, which may
802/// or may not be a forward reference.
803///
804static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
805 assert(inFunctionScope() && "Can't get basic block at global scope!");
806
807 std::string Name;
808 BasicBlock *BB = 0;
809 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000810 default:
811 GenerateError("Illegal label reference " + ID.getName());
812 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000813 case ValID::NumberVal: // Is it a numbered definition?
814 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
815 CurFun.NumberedBlocks.resize(ID.Num+1);
816 BB = CurFun.NumberedBlocks[ID.Num];
817 break;
818 case ValID::NameVal: // Is it a named definition?
819 Name = ID.Name;
820 if (Value *N = CurFun.CurrentFunction->
Reid Spencer78d033e2007-01-06 07:24:44 +0000821 getValueSymbolTable().lookup(Type::LabelTy, Name))
Reid Spencer68a24bd2005-08-27 18:50:39 +0000822 BB = cast<BasicBlock>(N);
823 break;
824 }
825
826 // See if the block has already been defined.
827 if (BB) {
828 // If this is the definition of the block, make sure the existing value was
829 // just a forward reference. If it was a forward reference, there will be
830 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000831 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000832 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000833 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000834 return 0;
835 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000836
837 ID.destroy(); // Free strdup'd memory.
838 return BB;
839 }
840
841 // Otherwise this block has not been seen before.
842 BB = new BasicBlock("", CurFun.CurrentFunction);
843 if (ID.Type == ValID::NameVal) {
844 BB->setName(ID.Name);
845 } else {
846 CurFun.NumberedBlocks[ID.Num] = BB;
847 }
848
849 // If this is not a definition, keep track of it so we can use it as a forward
850 // reference.
851 if (!isDefinition) {
852 // Remember where this forward reference came from.
853 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
854 } else {
855 // The forward declaration could have been inserted anywhere in the
856 // function: insert it into the correct place now.
857 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
858 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
859 }
860 ID.destroy();
861 return BB;
862}
863
864
865//===----------------------------------------------------------------------===//
866// Code to handle forward references in instructions
867//===----------------------------------------------------------------------===//
868//
869// This code handles the late binding needed with statements that reference
870// values not defined yet... for example, a forward branch, or the PHI node for
871// a loop body.
872//
873// This keeps a table (CurFun.LateResolveValues) of all such forward references
874// and back patchs after we are done.
875//
876
877// ResolveDefinitions - If we could not resolve some defs at parsing
878// time (forward branches, phi functions for loops, etc...) resolve the
879// defs now...
880//
881static void
882ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
883 std::map<const Type*,ValueList> *FutureLateResolvers) {
884 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
885 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
886 E = LateResolvers.end(); LRI != E; ++LRI) {
887 ValueList &List = LRI->second;
888 while (!List.empty()) {
889 Value *V = List.back();
890 List.pop_back();
891
892 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
893 CurModule.PlaceHolderInfo.find(V);
894 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
895
896 ValID &DID = PHI->second.first;
897
898 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000899 if (TriggerError)
900 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000901 if (TheRealValue) {
902 V->replaceAllUsesWith(TheRealValue);
903 delete V;
904 CurModule.PlaceHolderInfo.erase(PHI);
905 } else if (FutureLateResolvers) {
906 // Functions have their unresolved items forwarded to the module late
907 // resolver table
908 InsertValue(V, *FutureLateResolvers);
909 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000910 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000911 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000912 "' of type '" + V->getType()->getDescription() + "'",
913 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000914 return;
915 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000916 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000917 itostr(DID.Num) + " of type '" +
918 V->getType()->getDescription() + "'",
919 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000920 return;
921 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000922 }
923 }
924 }
925
926 LateResolvers.clear();
927}
928
929// ResolveTypeTo - A brand new type was just declared. This means that (if
930// name is not null) things referencing Name can be resolved. Otherwise, things
931// refering to the number can be resolved. Do this now.
932//
933static void ResolveTypeTo(char *Name, const Type *ToTy) {
934 ValID D;
935 if (Name) D = ValID::create(Name);
936 else D = ValID::create((int)CurModule.Types.size());
937
Reid Spencer861d9d62006-11-28 07:29:44 +0000938 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000939 CurModule.LateResolveTypes.find(D);
940 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000941 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000942 CurModule.LateResolveTypes.erase(I);
943 }
944}
945
946// setValueName - Set the specified value to the name given. The name may be
947// null potentially, in which case this is a noop. The string passed in is
948// assumed to be a malloc'd string buffer, and is free'd by this function.
949//
950static void setValueName(Value *V, char *NameStr) {
951 if (NameStr) {
952 std::string Name(NameStr); // Copy string
953 free(NameStr); // Free old string
954
Reid Spencer5b7e7532006-09-28 19:28:24 +0000955 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000956 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000957 return;
958 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000959
960 assert(inFunctionScope() && "Must be in function scope!");
Reid Spencer78d033e2007-01-06 07:24:44 +0000961 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000962 if (ST.lookup(V->getType(), Name)) {
Reid Spencer63c34452007-01-05 21:51:07 +0000963 GenerateError("Redefinition of value '" + Name + "' of type '" +
964 V->getType()->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000965 return;
966 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000967
968 // Set the name.
969 V->setName(Name);
970 }
971}
972
973/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
974/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000975static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000976ParseGlobalVariable(char *NameStr,
977 GlobalValue::LinkageTypes Linkage,
978 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000979 bool isConstantGlobal, const Type *Ty,
980 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000981 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000982 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000983 return 0;
984 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000985
986 const PointerType *PTy = PointerType::get(Ty);
987
988 std::string Name;
989 if (NameStr) {
990 Name = NameStr; // Copy string
991 free(NameStr); // Free old string
992 }
993
994 // See if this global value was forward referenced. If so, recycle the
995 // object.
996 ValID ID;
997 if (!Name.empty()) {
998 ID = ValID::create((char*)Name.c_str());
999 } else {
1000 ID = ValID::create((int)CurModule.Values[PTy].size());
1001 }
1002
1003 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1004 // Move the global to the end of the list, from whereever it was
1005 // previously inserted.
1006 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1007 CurModule.CurrentModule->getGlobalList().remove(GV);
1008 CurModule.CurrentModule->getGlobalList().push_back(GV);
1009 GV->setInitializer(Initializer);
1010 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001011 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001012 GV->setConstant(isConstantGlobal);
1013 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001014 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001015 }
1016
1017 // If this global has a name, check to see if there is already a definition
Reid Spencer63c34452007-01-05 21:51:07 +00001018 // of this global in the module. If so, it is an error.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001019 if (!Name.empty()) {
1020 // We are a simple redefinition of a value, check to see if it is defined
1021 // the same as the old one.
Reid Spencer63c34452007-01-05 21:51:07 +00001022 if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001023 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer63c34452007-01-05 21:51:07 +00001024 "' of type '" + Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001025 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001026 }
1027 }
1028
1029 // Otherwise there is no existing GV to use, create one now.
1030 GlobalVariable *GV =
1031 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1032 CurModule.CurrentModule);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001033 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001034 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001035 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001036}
1037
1038// setTypeName - Set the specified type to the name given. The name may be
1039// null potentially, in which case this is a noop. The string passed in is
1040// assumed to be a malloc'd string buffer, and is freed by this function.
1041//
1042// This function returns true if the type has already been defined, but is
1043// allowed to be redefined in the specified context. If the name is a new name
1044// for the type plane, it is inserted and false is returned.
1045static bool setTypeName(const Type *T, char *NameStr) {
1046 assert(!inFunctionScope() && "Can't give types function-local names!");
1047 if (NameStr == 0) return false;
1048
1049 std::string Name(NameStr); // Copy string
1050 free(NameStr); // Free old string
1051
1052 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001053 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001054 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001055 return false;
1056 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001057
1058 // Set the type name, checking for conflicts as we do so.
1059 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1060
1061 if (AlreadyExists) { // Inserting a name that is already defined???
1062 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1063 assert(Existing && "Conflict but no matching type?");
1064
1065 // There is only one case where this is allowed: when we are refining an
1066 // opaque type. In this case, Existing will be an opaque type.
1067 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1068 // We ARE replacing an opaque type!
1069 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1070 return true;
1071 }
1072
1073 // Otherwise, this is an attempt to redefine a type. That's okay if
1074 // the redefinition is identical to the original. This will be so if
1075 // Existing and T point to the same Type object. In this one case we
1076 // allow the equivalent redefinition.
1077 if (Existing == T) return true; // Yes, it's equal.
1078
1079 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001080 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1081 T->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001082 }
1083
1084 return false;
1085}
1086
1087//===----------------------------------------------------------------------===//
1088// Code for handling upreferences in type names...
1089//
1090
1091// TypeContains - Returns true if Ty directly contains E in it.
1092//
1093static bool TypeContains(const Type *Ty, const Type *E) {
1094 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1095 E) != Ty->subtype_end();
1096}
1097
1098namespace {
1099 struct UpRefRecord {
1100 // NestingLevel - The number of nesting levels that need to be popped before
1101 // this type is resolved.
1102 unsigned NestingLevel;
1103
1104 // LastContainedTy - This is the type at the current binding level for the
1105 // type. Every time we reduce the nesting level, this gets updated.
1106 const Type *LastContainedTy;
1107
1108 // UpRefTy - This is the actual opaque type that the upreference is
1109 // represented with.
1110 OpaqueType *UpRefTy;
1111
1112 UpRefRecord(unsigned NL, OpaqueType *URTy)
1113 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1114 };
1115}
1116
1117// UpRefs - A list of the outstanding upreferences that need to be resolved.
1118static std::vector<UpRefRecord> UpRefs;
1119
1120/// HandleUpRefs - Every time we finish a new layer of types, this function is
1121/// called. It loops through the UpRefs vector, which is a list of the
1122/// currently active types. For each type, if the up reference is contained in
1123/// the newly completed type, we decrement the level count. When the level
1124/// count reaches zero, the upreferenced type is the type that is passed in:
1125/// thus we can complete the cycle.
1126///
1127static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001128 // If Ty isn't abstract, or if there are no up-references in it, then there is
1129 // nothing to resolve here.
1130 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1131
Reid Spencer68a24bd2005-08-27 18:50:39 +00001132 PATypeHolder Ty(ty);
1133 UR_OUT("Type '" << Ty->getDescription() <<
1134 "' newly formed. Resolving upreferences.\n" <<
1135 UpRefs.size() << " upreferences active!\n");
1136
1137 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1138 // to zero), we resolve them all together before we resolve them to Ty. At
1139 // the end of the loop, if there is anything to resolve to Ty, it will be in
1140 // this variable.
1141 OpaqueType *TypeToResolve = 0;
1142
1143 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1144 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1145 << UpRefs[i].second->getDescription() << ") = "
1146 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1147 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1148 // Decrement level of upreference
1149 unsigned Level = --UpRefs[i].NestingLevel;
1150 UpRefs[i].LastContainedTy = Ty;
1151 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1152 if (Level == 0) { // Upreference should be resolved!
1153 if (!TypeToResolve) {
1154 TypeToResolve = UpRefs[i].UpRefTy;
1155 } else {
1156 UR_OUT(" * Resolving upreference for "
1157 << UpRefs[i].second->getDescription() << "\n";
1158 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1159 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1160 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1161 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1162 }
1163 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1164 --i; // Do not skip the next element...
1165 }
1166 }
1167 }
1168
1169 if (TypeToResolve) {
1170 UR_OUT(" * Resolving upreference for "
1171 << UpRefs[i].second->getDescription() << "\n";
1172 std::string OldName = TypeToResolve->getDescription());
1173 TypeToResolve->refineAbstractTypeTo(Ty);
1174 }
1175
1176 return Ty;
1177}
1178
Reid Spencer68a24bd2005-08-27 18:50:39 +00001179//===----------------------------------------------------------------------===//
1180// RunVMAsmParser - Define an interface to this parser
1181//===----------------------------------------------------------------------===//
1182//
Reid Spencer14310612006-12-31 05:40:51 +00001183static Module* RunParser(Module * M);
1184
Reid Spencer68a24bd2005-08-27 18:50:39 +00001185Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1186 set_scan_file(F);
1187
1188 CurFilename = Filename;
1189 return RunParser(new Module(CurFilename));
1190}
1191
1192Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1193 set_scan_string(AsmString);
1194
1195 CurFilename = "from_memory";
1196 if (M == NULL) {
1197 return RunParser(new Module (CurFilename));
1198 } else {
1199 return RunParser(M);
1200 }
1201}
1202
1203
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001204
1205/* Enabling traces. */
1206#ifndef YYDEBUG
1207# define YYDEBUG 0
1208#endif
1209
1210/* Enabling verbose error messages. */
1211#ifdef YYERROR_VERBOSE
1212# undef YYERROR_VERBOSE
1213# define YYERROR_VERBOSE 1
1214#else
1215# define YYERROR_VERBOSE 0
1216#endif
1217
1218/* Enabling the token table. */
1219#ifndef YYTOKEN_TABLE
1220# define YYTOKEN_TABLE 0
1221#endif
1222
1223#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1224#line 883 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
1225typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001226 llvm::Module *ModuleVal;
1227 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001228 llvm::BasicBlock *BasicBlockVal;
1229 llvm::TerminatorInst *TermInstVal;
1230 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001231 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001232
Reid Spencera132e042006-12-03 05:46:11 +00001233 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001234 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001235 llvm::PATypeHolder *TypeVal;
1236 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001237 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001238 llvm::ArgListType *ArgList;
1239 llvm::TypeWithAttrs TypeWithAttrs;
1240 llvm::TypeWithAttrsList *TypeWithAttrsList;
1241 llvm::ValueRefList *ValueRefList;
1242
Reid Spencer68a24bd2005-08-27 18:50:39 +00001243 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001244 std::list<std::pair<llvm::Value*,
1245 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001246 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001247 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001248
1249 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001250 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer14310612006-12-31 05:40:51 +00001251 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001252 int64_t SInt64Val;
1253 uint64_t UInt64Val;
1254 int SIntVal;
1255 unsigned UIntVal;
1256 double FPVal;
1257 bool BoolVal;
1258
1259 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001260 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001261
Reid Spencera132e042006-12-03 05:46:11 +00001262 llvm::Instruction::BinaryOps BinaryOpVal;
1263 llvm::Instruction::TermOps TermOpVal;
1264 llvm::Instruction::MemoryOps MemOpVal;
1265 llvm::Instruction::CastOps CastOpVal;
1266 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001267 llvm::Module::Endianness Endianness;
Reid Spencera132e042006-12-03 05:46:11 +00001268 llvm::ICmpInst::Predicate IPredicate;
1269 llvm::FCmpInst::Predicate FPredicate;
Reid Spencer6f407902007-01-13 05:00:46 +00001270} YYSTYPE;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001271/* Line 196 of yacc.c. */
1272#line 1273 "llvmAsmParser.tab.c"
1273# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1274# define YYSTYPE_IS_DECLARED 1
1275# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001276#endif
1277
1278
1279
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001280/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001281
1282
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001283/* Line 219 of yacc.c. */
1284#line 1285 "llvmAsmParser.tab.c"
Reid Spencere4d87aa2006-12-23 06:05:41 +00001285
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001286#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1287# define YYSIZE_T __SIZE_TYPE__
1288#endif
1289#if ! defined (YYSIZE_T) && defined (size_t)
1290# define YYSIZE_T size_t
1291#endif
1292#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1293# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1294# define YYSIZE_T size_t
1295#endif
1296#if ! defined (YYSIZE_T)
1297# define YYSIZE_T unsigned int
1298#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001299
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001300#ifndef YY_
1301# if YYENABLE_NLS
1302# if ENABLE_NLS
1303# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1304# define YY_(msgid) dgettext ("bison-runtime", msgid)
1305# endif
1306# endif
1307# ifndef YY_
1308# define YY_(msgid) msgid
1309# endif
1310#endif
1311
1312#if ! defined (yyoverflow) || YYERROR_VERBOSE
1313
1314/* The parser invokes alloca or malloc; define the necessary symbols. */
1315
1316# ifdef YYSTACK_USE_ALLOCA
1317# if YYSTACK_USE_ALLOCA
1318# ifdef __GNUC__
1319# define YYSTACK_ALLOC __builtin_alloca
1320# else
1321# define YYSTACK_ALLOC alloca
1322# if defined (__STDC__) || defined (__cplusplus)
1323# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1324# define YYINCLUDED_STDLIB_H
1325# endif
1326# endif
1327# endif
1328# endif
1329
1330# ifdef YYSTACK_ALLOC
1331 /* Pacify GCC's `empty if-body' warning. */
1332# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1333# ifndef YYSTACK_ALLOC_MAXIMUM
1334 /* The OS might guarantee only one guard page at the bottom of the stack,
1335 and a page size can be as small as 4096 bytes. So we cannot safely
1336 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1337 to allow for a few compiler-allocated temporary stack slots. */
1338# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1339# endif
1340# else
1341# define YYSTACK_ALLOC YYMALLOC
1342# define YYSTACK_FREE YYFREE
1343# ifndef YYSTACK_ALLOC_MAXIMUM
1344# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1345# endif
1346# ifdef __cplusplus
1347extern "C" {
1348# endif
1349# ifndef YYMALLOC
1350# define YYMALLOC malloc
1351# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1352 && (defined (__STDC__) || defined (__cplusplus)))
1353void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1354# endif
1355# endif
1356# ifndef YYFREE
1357# define YYFREE free
1358# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1359 && (defined (__STDC__) || defined (__cplusplus)))
1360void free (void *); /* INFRINGES ON USER NAME SPACE */
1361# endif
1362# endif
1363# ifdef __cplusplus
1364}
1365# endif
1366# endif
1367#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1368
1369
1370#if (! defined (yyoverflow) \
1371 && (! defined (__cplusplus) \
1372 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1373
1374/* A type that is properly aligned for any stack member. */
1375union yyalloc
1376{
1377 short int yyss;
1378 YYSTYPE yyvs;
1379 };
1380
1381/* The size of the maximum gap between one aligned stack and the next. */
1382# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1383
1384/* The size of an array large to enough to hold all stacks, each with
1385 N elements. */
1386# define YYSTACK_BYTES(N) \
1387 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1388 + YYSTACK_GAP_MAXIMUM)
1389
1390/* Copy COUNT objects from FROM to TO. The source and destination do
1391 not overlap. */
1392# ifndef YYCOPY
1393# if defined (__GNUC__) && 1 < __GNUC__
1394# define YYCOPY(To, From, Count) \
1395 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1396# else
1397# define YYCOPY(To, From, Count) \
1398 do \
1399 { \
1400 YYSIZE_T yyi; \
1401 for (yyi = 0; yyi < (Count); yyi++) \
1402 (To)[yyi] = (From)[yyi]; \
1403 } \
1404 while (0)
1405# endif
1406# endif
1407
1408/* Relocate STACK from its old location to the new one. The
1409 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1410 elements in the stack, and YYPTR gives the new location of the
1411 stack. Advance YYPTR to a properly aligned location for the next
1412 stack. */
1413# define YYSTACK_RELOCATE(Stack) \
1414 do \
1415 { \
1416 YYSIZE_T yynewbytes; \
1417 YYCOPY (&yyptr->Stack, Stack, yysize); \
1418 Stack = &yyptr->Stack; \
1419 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1420 yyptr += yynewbytes / sizeof (*yyptr); \
1421 } \
1422 while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001423
1424#endif
1425
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001426#if defined (__STDC__) || defined (__cplusplus)
1427 typedef signed char yysigned_char;
Reid Spencer6f407902007-01-13 05:00:46 +00001428#else
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001429 typedef short int yysigned_char;
Reid Spencer6f407902007-01-13 05:00:46 +00001430#endif
1431
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001432/* YYFINAL -- State number of the termination state. */
1433#define YYFINAL 36
1434/* YYLAST -- Last index in YYTABLE. */
1435#define YYLAST 1357
1436
1437/* YYNTOKENS -- Number of terminals. */
1438#define YYNTOKENS 147
1439/* YYNNTS -- Number of nonterminals. */
1440#define YYNNTS 79
1441/* YYNRULES -- Number of rules. */
1442#define YYNRULES 285
1443/* YYNRULES -- Number of states. */
1444#define YYNSTATES 569
1445
1446/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1447#define YYUNDEFTOK 2
1448#define YYMAXUTOK 387
1449
1450#define YYTRANSLATE(YYX) \
1451 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1452
1453/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1454static const unsigned char yytranslate[] =
1455{
1456 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1457 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1458 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1459 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1460 137, 138, 135, 2, 134, 2, 2, 2, 2, 2,
1461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1462 142, 133, 143, 2, 2, 2, 2, 2, 2, 2,
1463 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1464 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1465 2, 139, 136, 141, 2, 2, 2, 2, 2, 146,
1466 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1467 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1468 140, 2, 2, 144, 2, 145, 2, 2, 2, 2,
1469 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1471 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1472 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1473 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1474 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1475 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1476 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1477 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1478 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1479 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1480 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1481 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1482 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1483 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1484 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1485 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1486 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1487 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1488 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1489 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1490 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1491 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1492 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1493 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1494 125, 126, 127, 128, 129, 130, 131, 132
1495};
1496
1497#if YYDEBUG
1498/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1499 YYRHS. */
1500static const unsigned short int yyprhs[] =
1501{
1502 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1503 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1504 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1505 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1506 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1507 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1508 119, 122, 123, 125, 127, 129, 131, 133, 135, 137,
1509 139, 140, 142, 143, 145, 147, 148, 150, 152, 154,
1510 156, 157, 159, 161, 163, 165, 167, 169, 172, 174,
1511 176, 177, 180, 182, 184, 185, 188, 189, 192, 193,
1512 197, 200, 201, 203, 204, 208, 210, 213, 215, 217,
1513 219, 221, 223, 225, 228, 230, 233, 239, 245, 251,
1514 257, 261, 264, 270, 275, 278, 280, 282, 284, 288,
1515 290, 294, 296, 297, 299, 303, 308, 312, 316, 321,
1516 326, 330, 337, 343, 346, 349, 352, 355, 358, 361,
1517 364, 367, 370, 373, 380, 386, 395, 402, 409, 417,
1518 425, 432, 439, 448, 457, 461, 463, 465, 467, 469,
1519 470, 472, 475, 476, 480, 481, 485, 489, 491, 495,
1520 499, 500, 507, 508, 516, 517, 525, 528, 532, 534,
1521 536, 538, 542, 546, 550, 554, 558, 562, 564, 565,
1522 567, 569, 571, 572, 578, 582, 584, 588, 590, 591,
1523 601, 603, 605, 610, 612, 614, 617, 621, 622, 624,
1524 626, 628, 630, 632, 634, 636, 638, 640, 644, 646,
1525 652, 654, 656, 658, 660, 663, 666, 669, 673, 676,
1526 677, 679, 682, 685, 689, 699, 709, 718, 733, 735,
1527 737, 744, 750, 753, 760, 768, 772, 778, 779, 780,
1528 784, 787, 789, 795, 801, 808, 815, 820, 825, 832,
1529 837, 842, 849, 856, 859, 868, 870, 872, 873, 877,
1530 884, 888, 895, 898, 903, 910
1531};
1532
1533/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1534static const short int yyrhs[] =
1535{
1536 185, 0, -1, 5, -1, 6, -1, 69, -1, 70,
1537 -1, 71, -1, 72, -1, 73, -1, 74, -1, 75,
1538 -1, 76, -1, 77, -1, 78, -1, 79, -1, 80,
1539 -1, 109, -1, 110, -1, 111, -1, 112, -1, 113,
1540 -1, 114, -1, 115, -1, 116, -1, 117, -1, 118,
1541 -1, 119, -1, 120, -1, 123, -1, 124, -1, 125,
1542 -1, 83, -1, 84, -1, 85, -1, 86, -1, 87,
1543 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
1544 -1, 93, -1, 94, -1, 95, -1, 96, -1, 97,
1545 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
1546 -1, 89, -1, 90, -1, 91, -1, 92, -1, 19,
1547 -1, 20, -1, 9, -1, 10, -1, 11, -1, 198,
1548 133, -1, -1, 33, -1, 35, -1, 34, -1, 36,
1549 -1, 38, -1, 37, -1, 39, -1, 41, -1, -1,
1550 132, -1, -1, 37, -1, 39, -1, -1, 33, -1,
1551 34, -1, 35, -1, 38, -1, -1, 56, -1, 57,
1552 -1, 58, -1, 59, -1, 60, -1, 61, -1, 55,
1553 4, -1, 110, -1, 111, -1, -1, 165, 164, -1,
1554 130, -1, 164, -1, -1, 167, 166, -1, -1, 48,
1555 4, -1, -1, 134, 48, 4, -1, 27, 16, -1,
1556 -1, 170, -1, -1, 134, 173, 172, -1, 170, -1,
1557 48, 4, -1, 9, -1, 10, -1, 11, -1, 12,
1558 -1, 40, -1, 174, -1, 175, 135, -1, 210, -1,
1559 136, 4, -1, 175, 137, 179, 138, 167, -1, 8,
1560 137, 179, 138, 167, -1, 139, 4, 140, 175, 141,
1561 -1, 142, 4, 140, 175, 143, -1, 144, 180, 145,
1562 -1, 144, 145, -1, 142, 144, 180, 145, 143, -1,
1563 142, 144, 145, 143, -1, 175, 165, -1, 175, -1,
1564 8, -1, 176, -1, 178, 134, 176, -1, 178, -1,
1565 178, 134, 30, -1, 30, -1, -1, 175, -1, 180,
1566 134, 175, -1, 175, 139, 183, 141, -1, 175, 139,
1567 141, -1, 175, 146, 16, -1, 175, 142, 183, 143,
1568 -1, 175, 144, 183, 145, -1, 175, 144, 145, -1,
1569 175, 142, 144, 183, 145, 143, -1, 175, 142, 144,
1570 145, 143, -1, 175, 31, -1, 175, 32, -1, 175,
1571 210, -1, 175, 182, -1, 175, 18, -1, 155, 3,
1572 -1, 155, 4, -1, 9, 19, -1, 9, 20, -1,
1573 156, 7, -1, 151, 137, 181, 29, 175, 138, -1,
1574 108, 137, 181, 221, 138, -1, 122, 137, 181, 134,
1575 181, 134, 181, 138, -1, 149, 137, 181, 134, 181,
1576 138, -1, 150, 137, 181, 134, 181, 138, -1, 81,
1577 153, 137, 181, 134, 181, 138, -1, 82, 154, 137,
1578 181, 134, 181, 138, -1, 152, 137, 181, 134, 181,
1579 138, -1, 127, 137, 181, 134, 181, 138, -1, 128,
1580 137, 181, 134, 181, 134, 181, 138, -1, 129, 137,
1581 181, 134, 181, 134, 181, 138, -1, 183, 134, 181,
1582 -1, 181, -1, 25, -1, 26, -1, 186, -1, -1,
1583 187, -1, 186, 187, -1, -1, 24, 188, 206, -1,
1584 -1, 23, 189, 207, -1, 53, 52, 193, -1, 17,
1585 -1, 157, 13, 175, -1, 157, 13, 8, -1, -1,
1586 157, 160, 184, 181, 190, 172, -1, -1, 157, 158,
1587 160, 184, 181, 191, 172, -1, -1, 157, 159, 160,
1588 184, 175, 192, 172, -1, 42, 195, -1, 49, 133,
1589 196, -1, 16, -1, 47, -1, 46, -1, 44, 133,
1590 194, -1, 45, 133, 4, -1, 43, 133, 16, -1,
1591 62, 133, 16, -1, 139, 197, 141, -1, 197, 134,
1592 16, -1, 16, -1, -1, 14, -1, 16, -1, 198,
1593 -1, -1, 200, 134, 175, 165, 199, -1, 175, 165,
1594 199, -1, 200, -1, 200, 134, 30, -1, 30, -1,
1595 -1, 163, 177, 198, 137, 201, 138, 167, 171, 168,
1596 -1, 21, -1, 144, -1, 162, 160, 202, 203, -1,
1597 22, -1, 145, -1, 213, 205, -1, 161, 160, 202,
1598 -1, -1, 54, -1, 3, -1, 4, -1, 7, -1,
1599 19, -1, 20, -1, 31, -1, 32, -1, 18, -1,
1600 142, 183, 143, -1, 182, -1, 52, 208, 16, 134,
1601 16, -1, 148, -1, 198, -1, 210, -1, 209, -1,
1602 175, 211, -1, 213, 214, -1, 204, 214, -1, 215,
1603 157, 216, -1, 215, 218, -1, -1, 15, -1, 63,
1604 212, -1, 63, 8, -1, 64, 12, 211, -1, 64,
1605 9, 211, 134, 12, 211, 134, 12, 211, -1, 65,
1606 155, 211, 134, 12, 211, 139, 217, 141, -1, 65,
1607 155, 211, 134, 12, 211, 139, 141, -1, 66, 163,
1608 177, 211, 137, 220, 138, 167, 29, 12, 211, 67,
1609 12, 211, -1, 67, -1, 68, -1, 217, 155, 209,
1610 134, 12, 211, -1, 155, 209, 134, 12, 211, -1,
1611 157, 223, -1, 175, 139, 211, 134, 211, 141, -1,
1612 219, 134, 139, 211, 134, 211, 141, -1, 175, 211,
1613 165, -1, 220, 134, 175, 211, 165, -1, -1, -1,
1614 221, 134, 212, -1, 51, 50, -1, 50, -1, 149,
1615 175, 211, 134, 211, -1, 150, 175, 211, 134, 211,
1616 -1, 81, 153, 175, 211, 134, 211, -1, 82, 154,
1617 175, 211, 134, 211, -1, 152, 212, 134, 212, -1,
1618 151, 212, 29, 175, -1, 122, 212, 134, 212, 134,
1619 212, -1, 126, 212, 134, 175, -1, 127, 212, 134,
1620 212, -1, 128, 212, 134, 212, 134, 212, -1, 129,
1621 212, 134, 212, 134, 212, -1, 121, 219, -1, 222,
1622 163, 177, 211, 137, 220, 138, 167, -1, 225, -1,
1623 28, -1, -1, 103, 175, 169, -1, 103, 175, 134,
1624 9, 211, 169, -1, 104, 175, 169, -1, 104, 175,
1625 134, 9, 211, 169, -1, 105, 212, -1, 224, 106,
1626 175, 211, -1, 224, 107, 212, 134, 175, 211, -1,
1627 108, 175, 211, 221, -1
1628};
1629
1630/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1631static const unsigned short int yyrline[] =
1632{
1633 0, 1031, 1031, 1032, 1042, 1042, 1042, 1042, 1042, 1042,
1634 1042, 1042, 1042, 1043, 1043, 1043, 1044, 1044, 1044, 1044,
1635 1044, 1044, 1045, 1045, 1045, 1045, 1045, 1045, 1046, 1046,
1636 1046, 1048, 1048, 1049, 1049, 1050, 1050, 1051, 1051, 1052,
1637 1052, 1056, 1056, 1057, 1057, 1058, 1058, 1059, 1059, 1060,
1638 1060, 1061, 1061, 1062, 1062, 1063, 1064, 1069, 1070, 1070,
1639 1073, 1077, 1083, 1084, 1085, 1086, 1087, 1091, 1092, 1093,
1640 1097, 1098, 1102, 1103, 1104, 1108, 1109, 1110, 1111, 1112,
1641 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1129, 1130,
1642 1133, 1134, 1139, 1140, 1143, 1144, 1151, 1152, 1158, 1159,
1643 1167, 1175, 1176, 1181, 1182, 1183, 1188, 1201, 1201, 1201,
1644 1201, 1204, 1208, 1212, 1219, 1224, 1232, 1250, 1268, 1273,
1645 1285, 1295, 1299, 1309, 1316, 1323, 1330, 1335, 1340, 1347,
1646 1348, 1355, 1362, 1370, 1375, 1386, 1414, 1430, 1459, 1487,
1647 1512, 1531, 1556, 1575, 1587, 1594, 1657, 1667, 1677, 1683,
1648 1689, 1694, 1699, 1707, 1719, 1740, 1748, 1754, 1765, 1770,
1649 1775, 1784, 1790, 1796, 1805, 1809, 1817, 1817, 1828, 1833,
1650 1841, 1842, 1846, 1846, 1850, 1850, 1853, 1856, 1868, 1892,
1651 1903, 1903, 1912, 1912, 1920, 1920, 1930, 1933, 1939, 1952,
1652 1953, 1955, 1959, 1968, 1972, 1977, 1979, 1984, 1989, 1998,
1653 1998, 1999, 1999, 2001, 2011, 2022, 2026, 2035, 2044, 2049,
1654 2155, 2155, 2157, 2166, 2166, 2168, 2173, 2185, 2189, 2194,
1655 2198, 2202, 2206, 2210, 2214, 2218, 2222, 2226, 2251, 2255,
1656 2269, 2273, 2279, 2279, 2285, 2294, 2298, 2307, 2318, 2327,
1657 2339, 2352, 2356, 2360, 2365, 2375, 2394, 2403, 2470, 2474,
1658 2481, 2492, 2505, 2514, 2525, 2535, 2543, 2551, 2554, 2555,
1659 2562, 2566, 2571, 2592, 2609, 2622, 2635, 2644, 2656, 2664,
1660 2671, 2677, 2683, 2689, 2704, 2767, 2772, 2776, 2783, 2790,
1661 2798, 2805, 2813, 2821, 2835, 2852
1662};
1663#endif
1664
1665#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1666/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1667 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1668static const char *const yytname[] =
1669{
1670 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1671 "UINTVAL", "FPVAL", "VOID", "INTTYPE", "FLOAT", "DOUBLE", "LABEL",
1672 "TYPE", "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1673 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1674 "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1675 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1676 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1677 "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", "BIG",
1678 "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT",
1679 "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", "COLDCC_TOK",
1680 "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", "RET", "BR",
1681 "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV",
1682 "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", "XOR", "ICMP",
1683 "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1684 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1685 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1686 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1687 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1688 "SELECT", "SHL", "LSHR", "ASHR", "VAARG", "EXTRACTELEMENT",
1689 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "DEFAULT", "HIDDEN", "'='",
1690 "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'",
1691 "'{'", "'}'", "'c'", "$accept", "INTVAL", "ArithmeticOps", "LogicalOps",
1692 "CastOps", "ShiftOps", "IPredicates", "FPredicates", "IntType", "FPType",
1693 "OptAssign", "GVInternalLinkage", "GVExternalLinkage",
1694 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1695 "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr",
1696 "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1697 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1698 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1699 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module",
1700 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1701 "BigOrLittle", "TargetDefinition", "LibrariesDefinition", "LibList",
1702 "Name", "OptName", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1703 "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect",
1704 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1705 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1706 "JumpTable", "Inst", "PHIList", "ValueRefList", "IndexList",
1707 "OptTailCall", "InstVal", "OptVolatile", "MemoryInst", 0
1708};
1709#endif
1710
1711# ifdef YYPRINT
1712/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1713 token YYLEX-NUM. */
1714static const unsigned short int yytoknum[] =
1715{
1716 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1717 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1718 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1719 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1720 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1721 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1722 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1723 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1724 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1725 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1726 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1727 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1728 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1729 385, 386, 387, 61, 44, 42, 92, 40, 41, 91,
1730 120, 93, 60, 62, 123, 125, 99
1731};
1732# endif
1733
1734/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1735static const unsigned char yyr1[] =
1736{
1737 0, 147, 148, 148, 149, 149, 149, 149, 149, 149,
1738 149, 149, 149, 150, 150, 150, 151, 151, 151, 151,
1739 151, 151, 151, 151, 151, 151, 151, 151, 152, 152,
1740 152, 153, 153, 153, 153, 153, 153, 153, 153, 153,
1741 153, 154, 154, 154, 154, 154, 154, 154, 154, 154,
1742 154, 154, 154, 154, 154, 154, 154, 155, 156, 156,
1743 157, 157, 158, 158, 158, 158, 158, 159, 159, 159,
1744 160, 160, 161, 161, 161, 162, 162, 162, 162, 162,
1745 163, 163, 163, 163, 163, 163, 163, 163, 164, 164,
1746 165, 165, 166, 166, 167, 167, 168, 168, 169, 169,
1747 170, 171, 171, 172, 172, 173, 173, 174, 174, 174,
1748 174, 175, 175, 175, 175, 175, 175, 175, 175, 175,
1749 175, 175, 175, 175, 176, 177, 177, 178, 178, 179,
1750 179, 179, 179, 180, 180, 181, 181, 181, 181, 181,
1751 181, 181, 181, 181, 181, 181, 181, 181, 181, 181,
1752 181, 181, 181, 182, 182, 182, 182, 182, 182, 182,
1753 182, 182, 182, 182, 183, 183, 184, 184, 185, 185,
1754 186, 186, 188, 187, 189, 187, 187, 187, 187, 187,
1755 190, 187, 191, 187, 192, 187, 187, 187, 193, 194,
1756 194, 195, 195, 195, 195, 196, 197, 197, 197, 198,
1757 198, 199, 199, 200, 200, 201, 201, 201, 201, 202,
1758 203, 203, 204, 205, 205, 206, 207, 208, 208, 209,
1759 209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
1760 210, 210, 211, 211, 212, 213, 213, 214, 215, 215,
1761 215, 216, 216, 216, 216, 216, 216, 216, 216, 216,
1762 217, 217, 218, 219, 219, 220, 220, 220, 221, 221,
1763 222, 222, 223, 223, 223, 223, 223, 223, 223, 223,
1764 223, 223, 223, 223, 223, 223, 224, 224, 225, 225,
1765 225, 225, 225, 225, 225, 225
1766};
1767
1768/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1769static const unsigned char yyr2[] =
1770{
1771 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1772 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1773 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1774 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1775 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1776 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1777 2, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1778 0, 1, 0, 1, 1, 0, 1, 1, 1, 1,
1779 0, 1, 1, 1, 1, 1, 1, 2, 1, 1,
1780 0, 2, 1, 1, 0, 2, 0, 2, 0, 3,
1781 2, 0, 1, 0, 3, 1, 2, 1, 1, 1,
1782 1, 1, 1, 2, 1, 2, 5, 5, 5, 5,
1783 3, 2, 5, 4, 2, 1, 1, 1, 3, 1,
1784 3, 1, 0, 1, 3, 4, 3, 3, 4, 4,
1785 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
1786 2, 2, 2, 6, 5, 8, 6, 6, 7, 7,
1787 6, 6, 8, 8, 3, 1, 1, 1, 1, 0,
1788 1, 2, 0, 3, 0, 3, 3, 1, 3, 3,
1789 0, 6, 0, 7, 0, 7, 2, 3, 1, 1,
1790 1, 3, 3, 3, 3, 3, 3, 1, 0, 1,
1791 1, 1, 0, 5, 3, 1, 3, 1, 0, 9,
1792 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
1793 1, 1, 1, 1, 1, 1, 1, 3, 1, 5,
1794 1, 1, 1, 1, 2, 2, 2, 3, 2, 0,
1795 1, 2, 2, 3, 9, 9, 8, 14, 1, 1,
1796 6, 5, 2, 6, 7, 3, 5, 0, 0, 3,
1797 2, 1, 5, 5, 6, 6, 4, 4, 6, 4,
1798 4, 6, 6, 2, 8, 1, 1, 0, 3, 6,
1799 3, 6, 2, 4, 6, 4
1800};
1801
1802/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1803 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1804 means the default is an error. */
1805static const unsigned short int yydefact[] =
1806{
1807 61, 199, 200, 177, 174, 172, 0, 0, 0, 70,
1808 0, 61, 170, 0, 72, 75, 0, 0, 0, 0,
1809 186, 0, 0, 0, 62, 64, 63, 65, 67, 66,
1810 68, 69, 71, 70, 70, 0, 1, 171, 60, 73,
1811 74, 70, 175, 76, 77, 78, 79, 70, 239, 173,
1812 239, 0, 0, 0, 0, 198, 187, 188, 176, 2,
1813 3, 179, 107, 108, 109, 110, 111, 0, 0, 0,
1814 0, 230, 112, 178, 231, 114, 0, 0, 166, 167,
1815 0, 80, 80, 240, 236, 61, 213, 214, 215, 235,
1816 193, 190, 189, 191, 192, 194, 197, 0, 132, 115,
1817 0, 0, 0, 0, 121, 133, 0, 113, 132, 0,
1818 0, 107, 108, 109, 0, 0, 0, 180, 0, 81,
1819 82, 83, 84, 85, 86, 0, 216, 0, 277, 238,
1820 0, 195, 131, 90, 127, 129, 0, 0, 0, 0,
1821 0, 0, 120, 0, 182, 184, 150, 151, 148, 149,
1822 152, 147, 143, 144, 4, 5, 6, 7, 8, 9,
1823 10, 11, 12, 13, 14, 15, 0, 0, 0, 16,
1824 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1825 27, 0, 28, 29, 30, 0, 0, 0, 0, 0,
1826 0, 0, 0, 0, 0, 0, 146, 145, 103, 87,
1827 126, 125, 0, 210, 211, 212, 276, 261, 0, 0,
1828 0, 0, 80, 248, 249, 0, 0, 0, 0, 0,
1829 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1830 0, 237, 80, 252, 0, 275, 196, 124, 0, 94,
1831 0, 0, 123, 0, 134, 94, 103, 103, 31, 32,
1832 33, 34, 35, 36, 37, 38, 39, 40, 0, 55,
1833 56, 51, 52, 53, 54, 41, 42, 43, 44, 45,
1834 46, 47, 48, 49, 50, 0, 0, 0, 0, 0,
1835 0, 136, 165, 0, 0, 0, 140, 0, 137, 0,
1836 0, 0, 0, 0, 181, 0, 260, 242, 0, 241,
1837 0, 0, 57, 0, 0, 0, 0, 98, 98, 282,
1838 0, 0, 273, 0, 0, 0, 0, 0, 0, 0,
1839 0, 0, 0, 0, 0, 88, 89, 91, 130, 128,
1840 117, 118, 119, 122, 116, 183, 185, 0, 0, 258,
1841 0, 0, 0, 0, 0, 135, 121, 133, 0, 138,
1842 139, 0, 0, 0, 0, 0, 0, 105, 103, 208,
1843 219, 220, 221, 226, 222, 223, 224, 225, 217, 0,
1844 228, 233, 232, 234, 0, 243, 0, 0, 0, 0,
1845 0, 278, 0, 280, 258, 0, 0, 0, 0, 0,
1846 0, 0, 0, 0, 0, 0, 0, 0, 0, 92,
1847 93, 95, 0, 0, 0, 0, 0, 0, 0, 164,
1848 142, 0, 0, 0, 0, 0, 100, 106, 104, 207,
1849 90, 205, 0, 218, 0, 0, 0, 0, 0, 0,
1850 0, 0, 0, 0, 285, 0, 0, 0, 269, 270,
1851 0, 0, 0, 0, 267, 266, 0, 283, 0, 0,
1852 0, 0, 154, 0, 0, 0, 0, 141, 0, 0,
1853 0, 0, 202, 0, 94, 0, 227, 0, 0, 257,
1854 0, 0, 98, 99, 98, 0, 0, 0, 0, 0,
1855 262, 263, 257, 0, 0, 0, 259, 0, 161, 0,
1856 0, 156, 157, 153, 160, 201, 204, 206, 90, 101,
1857 0, 0, 0, 0, 0, 264, 265, 0, 279, 281,
1858 0, 0, 268, 271, 272, 0, 284, 158, 159, 0,
1859 0, 0, 202, 102, 96, 229, 0, 0, 90, 0,
1860 94, 253, 0, 94, 155, 162, 163, 203, 0, 209,
1861 0, 246, 0, 0, 255, 0, 0, 254, 274, 97,
1862 244, 0, 245, 0, 90, 0, 0, 0, 256, 0,
1863 0, 0, 0, 251, 0, 0, 250, 0, 247
1864};
1865
1866/* YYDEFGOTO[NTERM-NUM]. */
1867static const short int yydefgoto[] =
1868{
1869 -1, 71, 192, 193, 194, 195, 258, 275, 114, 115,
1870 9, 33, 34, 35, 41, 47, 125, 327, 237, 401,
1871 330, 539, 381, 357, 524, 294, 358, 72, 116, 134,
1872 202, 135, 136, 106, 282, 370, 283, 80, 10, 11,
1873 12, 15, 14, 198, 246, 247, 58, 93, 20, 56,
1874 97, 74, 496, 421, 422, 126, 205, 48, 88, 49,
1875 42, 424, 371, 75, 373, 299, 50, 84, 85, 231,
1876 543, 129, 312, 504, 404, 232, 233, 234, 235
1877};
1878
1879/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1880 STATE-NUM. */
1881#define YYPACT_NINF -413
1882static const short int yypact[] =
1883{
1884 401, -413, -413, -413, -413, -413, 110, -107, 30, 67,
1885 77, 527, -413, -43, 2, 238, -16, 8, 47, 84,
1886 -413, -4, 132, 791, -413, -413, -413, -413, -413, -413,
1887 -413, -413, -413, 91, 91, 149, -413, -413, -413, -413,
1888 -413, 91, -413, -413, -413, -413, -413, 91, 147, -413,
1889 20, 210, 208, 280, 226, 273, -413, -413, -413, -413,
1890 -413, 160, -413, -413, -413, -413, -413, 295, 299, 3,
1891 7, -413, -413, 140, -413, -413, 149, 149, -413, -413,
1892 954, 192, 192, -413, -413, 184, -413, -413, -413, -413,
1893 -413, -413, -413, -413, -413, -413, -413, -65, 549, -413,
1894 167, 171, 22, 160, -413, 140, -81, -413, 549, 954,
1895 1045, 95, 311, 312, 284, 313, 602, -413, 317, -413,
1896 -413, -413, -413, -413, -413, 1125, -413, -7, 1228, -413,
1897 306, -413, -413, 140, -413, 191, 193, 1045, 1045, 186,
1898 -64, 1045, -413, 194, -413, 140, -413, -413, -413, -413,
1899 -413, -413, -413, -413, -413, -413, -413, -413, -413, -413,
1900 -413, -413, -413, -413, -413, -413, 251, 501, 207, -413,
1901 -413, -413, -413, -413, -413, -413, -413, -413, -413, -413,
1902 -413, 209, -413, -413, -413, 214, 215, 216, 49, 1138,
1903 120, 314, 219, 222, 224, 225, -413, -413, 230, -413,
1904 160, 140, 184, -413, -413, -413, -413, -413, 315, 1185,
1905 175, 357, 192, -413, -413, 251, 501, 1045, 1045, 1045,
1906 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045,
1907 1045, -413, 192, -413, 195, -413, -413, 203, 693, -413,
1908 126, 46, -413, 228, 140, -413, 230, 230, -413, -413,
1909 -413, -413, -413, -413, -413, -413, -413, -413, 231, -413,
1910 -413, -413, -413, -413, -413, -413, -413, -413, -413, -413,
1911 -413, -413, -413, -413, -413, 235, 954, 954, 954, 954,
1912 954, -413, -413, 29, 500, -24, -413, -27, -413, 954,
1913 954, 954, 954, 39, -413, 241, -413, 160, 746, -413,
1914 873, 873, -413, 873, 1125, 1045, 1045, 123, 159, -413,
1915 746, 146, 233, 245, 248, 249, 250, 252, 746, 746,
1916 356, 253, 1125, 1045, 1045, -413, -413, -413, -413, -413,
1917 -18, -413, -413, -413, -18, -413, -413, 954, 954, -413,
1918 254, 255, 256, 259, 954, -413, 262, 602, -12, -413,
1919 -413, 265, 274, 367, 275, 391, 407, -413, 230, 774,
1920 -413, -413, -413, -413, -413, -413, -413, -413, 358, 954,
1921 -413, -413, -413, -413, 282, -413, 285, 873, 746, 746,
1922 35, -413, 43, -413, -413, 873, 281, 1045, 1045, 1045,
1923 1045, 1045, 289, 292, 1045, 1045, 873, 746, 293, -413,
1924 -413, -413, 294, 301, -25, 954, 954, 954, 954, -413,
1925 -413, 271, 954, 954, 1045, 954, -413, -413, -413, -413,
1926 140, 302, 303, -413, 417, 25, 427, 428, 305, 310,
1927 318, 873, 441, 873, 319, 322, 873, 323, 140, -413,
1928 324, 325, 873, 873, 140, -413, 309, -413, 1045, 954,
1929 954, 1045, -413, 326, 328, 327, 335, -413, 332, 333,
1930 131, 336, 34, 1028, -413, 339, -413, 873, 873, 1045,
1931 873, 873, 341, -413, 341, 873, 342, 1045, 1045, 1045,
1932 -413, -413, 1045, 746, 340, 345, -413, 954, -413, 954,
1933 954, -413, -413, -413, -413, -413, -413, -413, 140, 10,
1934 431, 343, 346, 746, 63, -413, -413, 400, -413, -413,
1935 338, 873, -413, -413, -413, 144, -413, -413, -413, 351,
1936 352, 354, 34, -413, 403, -413, 472, -3, -413, 1045,
1937 -413, -413, 355, -413, -413, -413, -413, -413, 489, -413,
1938 873, -413, 1000, 15, 203, 746, 66, -413, -18, -413,
1939 -413, 361, -413, 1000, -413, 485, 486, 368, 203, 873,
1940 873, 491, 434, -413, 873, 492, -413, 873, -413
1941};
1942
1943/* YYPGOTO[NTERM-NUM]. */
1944static const short int yypgoto[] =
1945{
1946 -413, -413, 379, 385, 389, 390, 304, 307, -210, -413,
1947 439, -413, -413, 145, -413, -413, -192, -305, -412, -413,
1948 -235, -413, -303, 26, -413, -201, -413, -413, -14, 288,
1949 -255, -413, 420, 429, -58, -112, -187, 239, -413, -413,
1950 518, -413, -413, -413, -413, -413, -413, -413, -413, -413,
1951 -413, 0, 11, -413, -413, 448, -413, -413, -413, -413,
1952 -413, -413, -403, -73, 103, -151, -413, 482, -413, -413,
1953 -413, -413, -413, 53, 153, -413, -413, -413, -413
1954};
1955
1956/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1957 positive, shift that token. If negative, reduce the rule which
1958 number is the opposite. If zero, do what YYDEFACT says.
1959 If YYTABLE_NINF, syntax error. */
1960#define YYTABLE_NINF -170
1961static const short int yytable[] =
1962{
1963 13, 303, 285, 287, 196, 383, 302, 101, 462, 73,
1964 334, 13, 59, 60, 203, 103, 62, 63, 64, 65,
1965 304, 1, 117, 2, 302, 400, 21, 59, 60, 400,
1966 103, 62, 63, 64, 65, 83, 1, 355, 2, 39,
1967 322, 40, 86, 197, 431, 335, 336, 66, 1, 377,
1968 2, 144, 433, 141, 59, 60, 105, 103, 111, 112,
1969 113, 65, 66, 1, 142, 2, 355, 396, 309, 130,
1970 141, 313, 314, 315, 316, 317, 131, 36, 320, 321,
1971 23, 243, 22, 432, 133, 13, 522, 356, 105, 66,
1972 38, 432, 325, 326, 133, 555, 145, 348, -57, -57,
1973 24, 25, 26, 27, 28, 29, 30, 344, 31, 451,
1974 344, 201, 399, 452, 146, 147, 544, 51, 350, 349,
1975 325, 326, 344, 240, 241, 59, 60, 244, 103, 111,
1976 112, 113, 65, 411, 1, 55, 2, 204, 541, 551,
1977 399, 52, 558, 67, 325, 326, 68, 102, 57, 69,
1978 557, 70, 104, 16, 17, 18, 552, 418, 67, 344,
1979 66, 68, 83, 344, 69, 87, 70, 139, 466, 508,
1980 345, 509, 19, 398, 78, 79, 325, 326, 76, 77,
1981 53, 107, 425, 108, 300, 67, 81, 301, 68, 332,
1982 281, 69, 82, 70, 400, 298, 399, 529, 1, 32,
1983 2, 530, 295, 307, 308, 298, 310, 311, 298, 298,
1984 298, 298, 298, 318, 319, 298, 298, 54, 339, 340,
1985 341, 342, 343, 32, 133, 372, 90, 372, 372, 499,
1986 372, 351, 352, 353, 354, 196, 437, 372, 439, 440,
1987 441, 400, 95, 400, 445, 372, 372, 118, 119, 120,
1988 121, 122, 123, 124, 91, 92, 67, 380, 107, 68,
1989 108, 107, 69, 108, 70, 286, 107, 331, 108, 493,
1990 347, 43, 44, 45, 197, 107, 46, 108, 529, 402,
1991 403, 107, 533, 108, 94, 385, 409, 148, 149, 96,
1992 201, 378, 379, 382, 107, 546, 108, 98, 548, 99,
1993 486, 323, 324, 100, 372, 372, 372, 137, 201, 397,
1994 298, 138, 372, 325, 326, 109, 110, 542, -58, -59,
1995 150, 199, 236, 372, 372, 238, 512, 513, 514, 242,
1996 288, 239, 245, 553, 248, 249, 250, 251, 252, 253,
1997 254, 255, 256, 257, 276, 420, 277, 453, 454, 455,
1998 456, 278, 279, 280, 458, 459, 289, 461, 372, 290,
1999 372, 291, 292, 372, 293, 296, 302, 386, 337, 372,
2000 372, 333, 338, 298, 438, 298, 298, 298, 359, 387,
2001 444, 298, 388, 389, 390, 394, 391, 395, 405, 406,
2002 407, 484, 485, 408, 372, 372, 414, 372, 372, 412,
2003 460, -169, 372, 374, 375, 410, 376, 416, 413, 415,
2004 372, 417, 423, 384, 457, 1, 426, 2, 3, 427,
2005 436, 392, 393, 442, 4, 5, 443, 448, 449, 519,
2006 372, 520, 521, 465, 483, 450, 463, 298, 372, 467,
2007 468, 464, 469, 6, 470, 473, 482, 525, 432, 498,
2008 7, 538, 471, 451, 8, 503, 475, 477, 478, 479,
2009 487, 489, 495, 298, 298, 298, 488, 372, 503, 490,
2010 491, 492, 372, 500, 494, 507, 511, 526, 517, 531,
2011 428, 429, 430, 518, 540, 527, 372, 372, 435, 534,
2012 535, 372, 536, 549, 372, 556, 547, 559, 560, 446,
2013 447, 565, 561, 564, 567, 59, 60, 227, 103, 111,
2014 112, 113, 65, 228, 1, 545, 2, 229, 230, 305,
2015 259, 260, 495, 306, 128, 523, 329, -168, 143, 37,
2016 127, 140, 89, 537, 472, 515, 474, 434, 0, 476,
2017 66, 1, 0, 2, 3, 480, 481, 0, 0, 0,
2018 4, 5, 0, 0, 59, 60, 0, 103, 62, 63,
2019 64, 65, 0, 1, 0, 2, 0, 0, 0, 6,
2020 501, 502, 0, 505, 506, 0, 7, 0, 510, 132,
2021 8, 0, 0, 0, 0, 0, 516, 0, 0, 66,
2022 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
2023 271, 272, 273, 274, 0, 0, 528, 59, 60, 0,
2024 0, 0, 0, 0, 532, 0, 1, 0, 2, 0,
2025 151, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2026 0, 0, 0, 152, 153, 0, 67, 0, 0, 68,
2027 0, 0, 69, 550, 70, 346, 0, 0, 554, 0,
2028 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2029 0, 0, 562, 563, 0, 0, 0, 566, 0, 0,
2030 568, 154, 155, 156, 157, 158, 159, 160, 161, 162,
2031 163, 164, 165, 166, 167, 67, 0, 0, 68, 0,
2032 0, 69, 0, 70, 0, 0, 0, 0, 59, 60,
2033 0, 103, 62, 63, 64, 65, 0, 1, 0, 2,
2034 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
2035 178, 179, 180, 328, 181, 182, 183, 184, 0, 185,
2036 186, 187, 0, 66, 0, 0, 0, 107, 0, 108,
2037 0, 188, 0, 0, 189, 0, 190, 0, 191, 360,
2038 361, 59, 60, 362, 0, 0, 0, 0, 0, 0,
2039 1, 0, 2, 0, 363, 364, 365, 0, 0, 0,
2040 0, 0, 0, 0, 0, 0, 0, 366, 367, 59,
2041 60, 0, 103, 62, 63, 64, 65, 0, 1, 0,
2042 2, 0, 0, 0, 0, 0, 59, 60, 368, 61,
2043 62, 63, 64, 65, 419, 1, 0, 2, 0, 0,
2044 0, 0, 0, 0, 66, 154, 155, 156, 157, 158,
2045 159, 160, 161, 162, 163, 164, 165, 166, 167, 67,
2046 0, 66, 68, 0, 0, 69, 0, 70, 0, 0,
2047 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2048 0, 0, 0, 0, 168, 169, 170, 171, 172, 173,
2049 174, 175, 176, 177, 178, 179, 180, 0, 181, 182,
2050 183, 184, 0, 185, 186, 187, 360, 361, 59, 60,
2051 362, 107, 0, 108, 0, 0, 0, 1, 369, 2,
2052 0, 363, 364, 365, 0, 0, 0, 0, 0, 0,
2053 0, 0, 0, 0, 366, 367, 0, 0, 0, 0,
2054 67, 0, 0, 68, 0, 0, 69, 0, 70, 0,
2055 0, 0, 0, 0, 0, 368, 0, 67, 0, 0,
2056 68, 0, 0, 69, 0, 70, 0, 0, 0, 0,
2057 0, 0, 154, 155, 156, 157, 158, 159, 160, 161,
2058 162, 163, 164, 165, 166, 167, 0, 0, 0, 59,
2059 60, 0, 103, 111, 112, 113, 65, 0, 1, 0,
2060 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2061 0, 168, 169, 170, 171, 172, 173, 174, 175, 176,
2062 177, 178, 179, 180, 66, 181, 182, 183, 184, 0,
2063 185, 186, 187, 360, 361, 0, 0, 362, 0, 0,
2064 0, 0, 0, 0, 0, 369, 0, 0, 363, 364,
2065 365, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2066 0, 366, 367, 59, 60, 0, 103, 62, 63, 64,
2067 65, 0, 1, 0, 2, 0, 0, 0, 0, 0,
2068 59, 60, 368, 103, 62, 63, 64, 65, 497, 1,
2069 0, 2, 0, 0, 0, 0, 0, 0, 66, 154,
2070 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
2071 165, 166, 167, 0, 0, 66, 0, 0, 0, 0,
2072 67, 0, 0, 68, 0, 0, 69, 0, 70, 0,
2073 0, 0, 0, 0, 0, 0, 0, 0, 168, 169,
2074 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
2075 180, 0, 181, 182, 183, 184, 0, 185, 186, 187,
2076 59, 60, 0, 200, 62, 63, 64, 65, 0, 1,
2077 0, 2, 369, 59, 60, 0, 103, 111, 112, 113,
2078 65, 0, 1, 0, 2, 0, 0, 0, 0, 0,
2079 0, 0, 0, 0, 67, 66, 0, 68, 0, 0,
2080 69, 0, 70, 0, 0, 0, 0, 0, 66, 0,
2081 0, 67, 0, 0, 68, 0, 0, 69, 0, 70,
2082 59, 60, 0, 297, 62, 63, 64, 65, 0, 1,
2083 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
2084 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2085 0, 0, 0, 0, 0, 66, 0, 0, 0, 0,
2086 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2087 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2088 0, 0, 0, 0, 0, 0, 206, 0, 0, 0,
2089 0, 67, 0, 0, 68, 0, 0, 69, 0, 70,
2090 0, 0, 0, 0, 67, 0, 0, 68, 207, 208,
2091 69, 0, 284, 0, 0, 0, 0, 0, 0, 0,
2092 0, 209, 210, 211, 212, 213, 214, 154, 155, 156,
2093 157, 158, 159, 160, 161, 162, 163, 164, 165, 215,
2094 216, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2095 0, 67, 0, 0, 68, 0, 0, 69, 0, 70,
2096 0, 217, 218, 219, 0, 0, 220, 169, 170, 171,
2097 172, 173, 174, 175, 176, 177, 178, 179, 180, 221,
2098 222, 182, 183, 184, 223, 224, 225, 226
2099};
2100
2101static const short int yycheck[] =
2102{
2103 0, 211, 189, 190, 116, 308, 9, 4, 420, 23,
2104 245, 11, 5, 6, 21, 8, 9, 10, 11, 12,
2105 212, 14, 80, 16, 9, 330, 133, 5, 6, 334,
2106 8, 9, 10, 11, 12, 15, 14, 27, 16, 37,
2107 232, 39, 22, 116, 9, 246, 247, 40, 14, 304,
2108 16, 109, 9, 134, 5, 6, 70, 8, 9, 10,
2109 11, 12, 40, 14, 145, 16, 27, 322, 219, 134,
2110 134, 222, 223, 224, 225, 226, 141, 0, 229, 230,
2111 13, 145, 52, 48, 98, 85, 498, 48, 102, 40,
2112 133, 48, 110, 111, 108, 29, 110, 284, 3, 4,
2113 33, 34, 35, 36, 37, 38, 39, 134, 41, 134,
2114 134, 125, 130, 138, 19, 20, 528, 133, 145, 143,
2115 110, 111, 134, 137, 138, 5, 6, 141, 8, 9,
2116 10, 11, 12, 145, 14, 139, 16, 144, 141, 542,
2117 130, 133, 554, 136, 110, 111, 139, 144, 16, 142,
2118 553, 144, 145, 43, 44, 45, 141, 358, 136, 134,
2119 40, 139, 15, 134, 142, 145, 144, 145, 143, 472,
2120 141, 474, 62, 324, 25, 26, 110, 111, 33, 34,
2121 133, 135, 369, 137, 9, 136, 41, 12, 139, 143,
2122 141, 142, 47, 144, 499, 209, 130, 134, 14, 132,
2123 16, 138, 202, 217, 218, 219, 220, 221, 222, 223,
2124 224, 225, 226, 227, 228, 229, 230, 133, 276, 277,
2125 278, 279, 280, 132, 238, 298, 16, 300, 301, 464,
2126 303, 289, 290, 291, 292, 347, 387, 310, 389, 390,
2127 391, 546, 16, 548, 395, 318, 319, 55, 56, 57,
2128 58, 59, 60, 61, 46, 47, 136, 134, 135, 139,
2129 137, 135, 142, 137, 144, 145, 135, 141, 137, 138,
2130 284, 33, 34, 35, 347, 135, 38, 137, 134, 337,
2131 338, 135, 138, 137, 4, 139, 344, 3, 4, 16,
2132 304, 305, 306, 134, 135, 530, 137, 137, 533, 4,
2133 451, 106, 107, 4, 377, 378, 379, 140, 322, 323,
2134 324, 140, 385, 110, 111, 76, 77, 527, 7, 7,
2135 7, 4, 16, 396, 397, 134, 477, 478, 479, 143,
2136 16, 138, 138, 543, 83, 84, 85, 86, 87, 88,
2137 89, 90, 91, 92, 137, 359, 137, 405, 406, 407,
2138 408, 137, 137, 137, 412, 413, 137, 415, 431, 137,
2139 433, 137, 137, 436, 134, 50, 9, 134, 137, 442,
2140 443, 143, 137, 387, 388, 389, 390, 391, 137, 134,
2141 394, 395, 134, 134, 134, 29, 134, 134, 134, 134,
2142 134, 449, 450, 134, 467, 468, 29, 470, 471, 134,
2143 414, 0, 475, 300, 301, 143, 303, 16, 134, 134,
2144 483, 4, 54, 310, 143, 14, 134, 16, 17, 134,
2145 139, 318, 319, 134, 23, 24, 134, 134, 134, 487,
2146 503, 489, 490, 16, 448, 134, 134, 451, 511, 12,
2147 12, 138, 137, 42, 134, 4, 137, 16, 48, 463,
2148 49, 48, 134, 134, 53, 469, 134, 134, 134, 134,
2149 134, 134, 462, 477, 478, 479, 138, 540, 482, 134,
2150 138, 138, 545, 134, 138, 134, 134, 134, 138, 141,
2151 377, 378, 379, 138, 12, 139, 559, 560, 385, 138,
2152 138, 564, 138, 4, 567, 134, 141, 12, 12, 396,
2153 397, 67, 134, 12, 12, 5, 6, 128, 8, 9,
2154 10, 11, 12, 128, 14, 529, 16, 128, 128, 215,
2155 19, 20, 522, 216, 85, 499, 238, 0, 108, 11,
2156 82, 102, 50, 522, 431, 482, 433, 384, -1, 436,
2157 40, 14, -1, 16, 17, 442, 443, -1, -1, -1,
2158 23, 24, -1, -1, 5, 6, -1, 8, 9, 10,
2159 11, 12, -1, 14, -1, 16, -1, -1, -1, 42,
2160 467, 468, -1, 470, 471, -1, 49, -1, 475, 30,
2161 53, -1, -1, -1, -1, -1, 483, -1, -1, 40,
2162 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2163 99, 100, 101, 102, -1, -1, 503, 5, 6, -1,
2164 -1, -1, -1, -1, 511, -1, 14, -1, 16, -1,
2165 18, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2166 -1, -1, -1, 31, 32, -1, 136, -1, -1, 139,
2167 -1, -1, 142, 540, 144, 145, -1, -1, 545, -1,
2168 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2169 -1, -1, 559, 560, -1, -1, -1, 564, -1, -1,
2170 567, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2171 78, 79, 80, 81, 82, 136, -1, -1, 139, -1,
2172 -1, 142, -1, 144, -1, -1, -1, -1, 5, 6,
2173 -1, 8, 9, 10, 11, 12, -1, 14, -1, 16,
2174 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2175 118, 119, 120, 30, 122, 123, 124, 125, -1, 127,
2176 128, 129, -1, 40, -1, -1, -1, 135, -1, 137,
2177 -1, 139, -1, -1, 142, -1, 144, -1, 146, 3,
2178 4, 5, 6, 7, -1, -1, -1, -1, -1, -1,
2179 14, -1, 16, -1, 18, 19, 20, -1, -1, -1,
2180 -1, -1, -1, -1, -1, -1, -1, 31, 32, 5,
2181 6, -1, 8, 9, 10, 11, 12, -1, 14, -1,
2182 16, -1, -1, -1, -1, -1, 5, 6, 52, 8,
2183 9, 10, 11, 12, 30, 14, -1, 16, -1, -1,
2184 -1, -1, -1, -1, 40, 69, 70, 71, 72, 73,
2185 74, 75, 76, 77, 78, 79, 80, 81, 82, 136,
2186 -1, 40, 139, -1, -1, 142, -1, 144, -1, -1,
2187 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2188 -1, -1, -1, -1, 108, 109, 110, 111, 112, 113,
2189 114, 115, 116, 117, 118, 119, 120, -1, 122, 123,
2190 124, 125, -1, 127, 128, 129, 3, 4, 5, 6,
2191 7, 135, -1, 137, -1, -1, -1, 14, 142, 16,
2192 -1, 18, 19, 20, -1, -1, -1, -1, -1, -1,
2193 -1, -1, -1, -1, 31, 32, -1, -1, -1, -1,
2194 136, -1, -1, 139, -1, -1, 142, -1, 144, -1,
2195 -1, -1, -1, -1, -1, 52, -1, 136, -1, -1,
2196 139, -1, -1, 142, -1, 144, -1, -1, -1, -1,
2197 -1, -1, 69, 70, 71, 72, 73, 74, 75, 76,
2198 77, 78, 79, 80, 81, 82, -1, -1, -1, 5,
2199 6, -1, 8, 9, 10, 11, 12, -1, 14, -1,
2200 16, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2201 -1, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2202 117, 118, 119, 120, 40, 122, 123, 124, 125, -1,
2203 127, 128, 129, 3, 4, -1, -1, 7, -1, -1,
2204 -1, -1, -1, -1, -1, 142, -1, -1, 18, 19,
2205 20, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2206 -1, 31, 32, 5, 6, -1, 8, 9, 10, 11,
2207 12, -1, 14, -1, 16, -1, -1, -1, -1, -1,
2208 5, 6, 52, 8, 9, 10, 11, 12, 30, 14,
2209 -1, 16, -1, -1, -1, -1, -1, -1, 40, 69,
2210 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2211 80, 81, 82, -1, -1, 40, -1, -1, -1, -1,
2212 136, -1, -1, 139, -1, -1, 142, -1, 144, -1,
2213 -1, -1, -1, -1, -1, -1, -1, -1, 108, 109,
2214 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
2215 120, -1, 122, 123, 124, 125, -1, 127, 128, 129,
2216 5, 6, -1, 8, 9, 10, 11, 12, -1, 14,
2217 -1, 16, 142, 5, 6, -1, 8, 9, 10, 11,
2218 12, -1, 14, -1, 16, -1, -1, -1, -1, -1,
2219 -1, -1, -1, -1, 136, 40, -1, 139, -1, -1,
2220 142, -1, 144, -1, -1, -1, -1, -1, 40, -1,
2221 -1, 136, -1, -1, 139, -1, -1, 142, -1, 144,
2222 5, 6, -1, 8, 9, 10, 11, 12, -1, 14,
2223 -1, 16, -1, -1, -1, -1, -1, -1, -1, -1,
2224 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2225 -1, -1, -1, -1, -1, 40, -1, -1, -1, -1,
2226 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2227 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2228 -1, -1, -1, -1, -1, -1, 28, -1, -1, -1,
2229 -1, 136, -1, -1, 139, -1, -1, 142, -1, 144,
2230 -1, -1, -1, -1, 136, -1, -1, 139, 50, 51,
2231 142, -1, 144, -1, -1, -1, -1, -1, -1, -1,
2232 -1, 63, 64, 65, 66, 67, 68, 69, 70, 71,
2233 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2234 82, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2235 -1, 136, -1, -1, 139, -1, -1, 142, -1, 144,
2236 -1, 103, 104, 105, -1, -1, 108, 109, 110, 111,
2237 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2238 122, 123, 124, 125, 126, 127, 128, 129
2239};
2240
2241/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2242 symbol of state STATE-NUM. */
2243static const unsigned char yystos[] =
2244{
2245 0, 14, 16, 17, 23, 24, 42, 49, 53, 157,
2246 185, 186, 187, 198, 189, 188, 43, 44, 45, 62,
2247 195, 133, 52, 13, 33, 34, 35, 36, 37, 38,
2248 39, 41, 132, 158, 159, 160, 0, 187, 133, 37,
2249 39, 161, 207, 33, 34, 35, 38, 162, 204, 206,
2250 213, 133, 133, 133, 133, 139, 196, 16, 193, 5,
2251 6, 8, 9, 10, 11, 12, 40, 136, 139, 142,
2252 144, 148, 174, 175, 198, 210, 160, 160, 25, 26,
2253 184, 160, 160, 15, 214, 215, 22, 145, 205, 214,
2254 16, 46, 47, 194, 4, 16, 16, 197, 137, 4,
2255 4, 4, 144, 8, 145, 175, 180, 135, 137, 184,
2256 184, 9, 10, 11, 155, 156, 175, 181, 55, 56,
2257 57, 58, 59, 60, 61, 163, 202, 202, 157, 218,
2258 134, 141, 30, 175, 176, 178, 179, 140, 140, 145,
2259 180, 134, 145, 179, 181, 175, 19, 20, 3, 4,
2260 7, 18, 31, 32, 69, 70, 71, 72, 73, 74,
2261 75, 76, 77, 78, 79, 80, 81, 82, 108, 109,
2262 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
2263 120, 122, 123, 124, 125, 127, 128, 129, 139, 142,
2264 144, 146, 149, 150, 151, 152, 182, 210, 190, 4,
2265 8, 175, 177, 21, 144, 203, 28, 50, 51, 63,
2266 64, 65, 66, 67, 68, 81, 82, 103, 104, 105,
2267 108, 121, 122, 126, 127, 128, 129, 149, 150, 151,
2268 152, 216, 222, 223, 224, 225, 16, 165, 134, 138,
2269 175, 175, 143, 145, 175, 138, 191, 192, 83, 84,
2270 85, 86, 87, 88, 89, 90, 91, 92, 153, 19,
2271 20, 89, 90, 91, 92, 93, 94, 95, 96, 97,
2272 98, 99, 100, 101, 102, 154, 137, 137, 137, 137,
2273 137, 141, 181, 183, 144, 183, 145, 183, 16, 137,
2274 137, 137, 137, 134, 172, 198, 50, 8, 175, 212,
2275 9, 12, 9, 155, 163, 153, 154, 175, 175, 212,
2276 175, 175, 219, 212, 212, 212, 212, 212, 175, 175,
2277 212, 212, 163, 106, 107, 110, 111, 164, 30, 176,
2278 167, 141, 143, 143, 167, 172, 172, 137, 137, 181,
2279 181, 181, 181, 181, 134, 141, 145, 175, 183, 143,
2280 145, 181, 181, 181, 181, 27, 48, 170, 173, 137,
2281 3, 4, 7, 18, 19, 20, 31, 32, 52, 142,
2282 182, 209, 210, 211, 211, 211, 211, 177, 175, 175,
2283 134, 169, 134, 169, 211, 139, 134, 134, 134, 134,
2284 134, 134, 211, 211, 29, 134, 177, 175, 212, 130,
2285 164, 166, 181, 181, 221, 134, 134, 134, 134, 181,
2286 143, 145, 134, 134, 29, 134, 16, 4, 172, 30,
2287 175, 200, 201, 54, 208, 183, 134, 134, 211, 211,
2288 211, 9, 48, 9, 221, 211, 139, 212, 175, 212,
2289 212, 212, 134, 134, 175, 212, 211, 211, 134, 134,
2290 134, 134, 138, 181, 181, 181, 181, 143, 181, 181,
2291 175, 181, 165, 134, 138, 16, 143, 12, 12, 137,
2292 134, 134, 211, 4, 211, 134, 211, 134, 134, 134,
2293 211, 211, 137, 175, 181, 181, 212, 134, 138, 134,
2294 134, 138, 138, 138, 138, 198, 199, 30, 175, 167,
2295 134, 211, 211, 175, 220, 211, 211, 134, 169, 169,
2296 211, 134, 212, 212, 212, 220, 211, 138, 138, 181,
2297 181, 181, 165, 170, 171, 16, 134, 139, 211, 134,
2298 138, 141, 211, 138, 138, 138, 138, 199, 48, 168,
2299 12, 141, 155, 217, 165, 175, 167, 141, 167, 4,
2300 211, 209, 141, 155, 211, 29, 134, 209, 165, 12,
2301 12, 134, 211, 211, 12, 67, 211, 12, 211
2302};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002303
2304#define yyerrok (yyerrstatus = 0)
2305#define yyclearin (yychar = YYEMPTY)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002306#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002307#define YYEOF 0
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002308
Reid Spencer68a24bd2005-08-27 18:50:39 +00002309#define YYACCEPT goto yyacceptlab
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002310#define YYABORT goto yyabortlab
2311#define YYERROR goto yyerrorlab
2312
2313
2314/* Like YYERROR except do call yyerror. This remains here temporarily
2315 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002316 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002317
Reid Spencer68a24bd2005-08-27 18:50:39 +00002318#define YYFAIL goto yyerrlab
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002319
Reid Spencer68a24bd2005-08-27 18:50:39 +00002320#define YYRECOVERING() (!!yyerrstatus)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002321
2322#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002323do \
2324 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002325 { \
2326 yychar = (Token); \
2327 yylval = (Value); \
2328 yytoken = YYTRANSLATE (yychar); \
Reid Spencer6f407902007-01-13 05:00:46 +00002329 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002330 goto yybackup; \
2331 } \
2332 else \
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002333 { \
2334 yyerror (YY_("syntax error: cannot back up")); \
2335 YYERROR; \
2336 } \
Reid Spencer6f407902007-01-13 05:00:46 +00002337while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002338
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002339
Reid Spencer68a24bd2005-08-27 18:50:39 +00002340#define YYTERROR 1
2341#define YYERRCODE 256
2342
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002343
2344/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2345 If N is 0, then set CURRENT to the empty location which ends
2346 the previous symbol: RHS[0] (always defined). */
2347
2348#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2349#ifndef YYLLOC_DEFAULT
2350# define YYLLOC_DEFAULT(Current, Rhs, N) \
2351 do \
2352 if (N) \
2353 { \
2354 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2355 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2356 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2357 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2358 } \
2359 else \
2360 { \
2361 (Current).first_line = (Current).last_line = \
2362 YYRHSLOC (Rhs, 0).last_line; \
2363 (Current).first_column = (Current).last_column = \
2364 YYRHSLOC (Rhs, 0).last_column; \
2365 } \
2366 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002367#endif
2368
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002369
2370/* YY_LOCATION_PRINT -- Print the location on the stream.
2371 This macro was not mandated originally: define only if we know
2372 we won't break user code: when these are the locations we know. */
2373
2374#ifndef YY_LOCATION_PRINT
2375# if YYLTYPE_IS_TRIVIAL
2376# define YY_LOCATION_PRINT(File, Loc) \
2377 fprintf (File, "%d.%d-%d.%d", \
2378 (Loc).first_line, (Loc).first_column, \
2379 (Loc).last_line, (Loc).last_column)
2380# else
2381# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2382# endif
2383#endif
2384
2385
2386/* YYLEX -- calling `yylex' with the right arguments. */
2387
Reid Spencer68a24bd2005-08-27 18:50:39 +00002388#ifdef YYLEX_PARAM
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002389# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002390#else
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002391# define YYLEX yylex ()
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002392#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002393
2394/* Enable debugging if requested. */
2395#if YYDEBUG
2396
2397# ifndef YYFPRINTF
2398# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2399# define YYFPRINTF fprintf
2400# endif
2401
2402# define YYDPRINTF(Args) \
2403do { \
2404 if (yydebug) \
2405 YYFPRINTF Args; \
2406} while (0)
2407
2408# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2409do { \
2410 if (yydebug) \
2411 { \
2412 YYFPRINTF (stderr, "%s ", Title); \
2413 yysymprint (stderr, \
2414 Type, Value); \
2415 YYFPRINTF (stderr, "\n"); \
2416 } \
2417} while (0)
2418
2419/*------------------------------------------------------------------.
2420| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2421| TOP (included). |
2422`------------------------------------------------------------------*/
2423
2424#if defined (__STDC__) || defined (__cplusplus)
2425static void
2426yy_stack_print (short int *bottom, short int *top)
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002427#else
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002428static void
2429yy_stack_print (bottom, top)
2430 short int *bottom;
2431 short int *top;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002432#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002433{
2434 YYFPRINTF (stderr, "Stack now");
2435 for (/* Nothing. */; bottom <= top; ++bottom)
2436 YYFPRINTF (stderr, " %d", *bottom);
2437 YYFPRINTF (stderr, "\n");
2438}
2439
2440# define YY_STACK_PRINT(Bottom, Top) \
2441do { \
2442 if (yydebug) \
2443 yy_stack_print ((Bottom), (Top)); \
2444} while (0)
2445
2446
2447/*------------------------------------------------.
2448| Report that the YYRULE is going to be reduced. |
2449`------------------------------------------------*/
2450
2451#if defined (__STDC__) || defined (__cplusplus)
2452static void
2453yy_reduce_print (int yyrule)
2454#else
2455static void
2456yy_reduce_print (yyrule)
2457 int yyrule;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002458#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002459{
2460 int yyi;
2461 unsigned long int yylno = yyrline[yyrule];
2462 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2463 yyrule - 1, yylno);
2464 /* Print the symbols being reduced, and their result. */
2465 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2466 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2467 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2468}
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002469
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002470# define YY_REDUCE_PRINT(Rule) \
2471do { \
2472 if (yydebug) \
2473 yy_reduce_print (Rule); \
2474} while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002475
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002476/* Nonzero means print parse trace. It is left uninitialized so that
2477 multiple parsers can coexist. */
2478int yydebug;
2479#else /* !YYDEBUG */
2480# define YYDPRINTF(Args)
2481# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2482# define YY_STACK_PRINT(Bottom, Top)
2483# define YY_REDUCE_PRINT(Rule)
2484#endif /* !YYDEBUG */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002485
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002486
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002487/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002488#ifndef YYINITDEPTH
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002489# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002490#endif
2491
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002492/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2493 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002494
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002495 Do not make this value too large; the results are undefined if
2496 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2497 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002498
2499#ifndef YYMAXDEPTH
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002500# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002501#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002502
Reid Spencer68a24bd2005-08-27 18:50:39 +00002503
2504
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002505#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002506
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002507# ifndef yystrlen
2508# if defined (__GLIBC__) && defined (_STRING_H)
2509# define yystrlen strlen
2510# else
2511/* Return the length of YYSTR. */
2512static YYSIZE_T
2513# if defined (__STDC__) || defined (__cplusplus)
2514yystrlen (const char *yystr)
2515# else
2516yystrlen (yystr)
2517 const char *yystr;
2518# endif
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002519{
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002520 const char *yys = yystr;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002521
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002522 while (*yys++ != '\0')
2523 continue;
2524
2525 return yys - yystr - 1;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002526}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002527# endif
2528# endif
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002529
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002530# ifndef yystpcpy
2531# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2532# define yystpcpy stpcpy
2533# else
2534/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2535 YYDEST. */
2536static char *
2537# if defined (__STDC__) || defined (__cplusplus)
2538yystpcpy (char *yydest, const char *yysrc)
2539# else
2540yystpcpy (yydest, yysrc)
2541 char *yydest;
2542 const char *yysrc;
2543# endif
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002544{
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002545 char *yyd = yydest;
2546 const char *yys = yysrc;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002547
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002548 while ((*yyd++ = *yys++) != '\0')
2549 continue;
2550
2551 return yyd - 1;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002552}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002553# endif
2554# endif
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002555
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002556# ifndef yytnamerr
2557/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2558 quotes and backslashes, so that it's suitable for yyerror. The
2559 heuristic is that double-quoting is unnecessary unless the string
2560 contains an apostrophe, a comma, or backslash (other than
2561 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2562 null, do not copy; instead, return the length of what the result
2563 would have been. */
2564static YYSIZE_T
2565yytnamerr (char *yyres, const char *yystr)
2566{
2567 if (*yystr == '"')
2568 {
2569 size_t yyn = 0;
2570 char const *yyp = yystr;
2571
2572 for (;;)
2573 switch (*++yyp)
2574 {
2575 case '\'':
2576 case ',':
2577 goto do_not_strip_quotes;
2578
2579 case '\\':
2580 if (*++yyp != '\\')
2581 goto do_not_strip_quotes;
2582 /* Fall through. */
2583 default:
2584 if (yyres)
2585 yyres[yyn] = *yyp;
2586 yyn++;
2587 break;
2588
2589 case '"':
2590 if (yyres)
2591 yyres[yyn] = '\0';
2592 return yyn;
2593 }
2594 do_not_strip_quotes: ;
2595 }
2596
2597 if (! yyres)
2598 return yystrlen (yystr);
2599
2600 return yystpcpy (yyres, yystr) - yyres;
2601}
2602# endif
2603
2604#endif /* YYERROR_VERBOSE */
2605
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002606
2607
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002608#if YYDEBUG
2609/*--------------------------------.
2610| Print this symbol on YYOUTPUT. |
2611`--------------------------------*/
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002612
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002613#if defined (__STDC__) || defined (__cplusplus)
2614static void
2615yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002616#else
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002617static void
2618yysymprint (yyoutput, yytype, yyvaluep)
2619 FILE *yyoutput;
2620 int yytype;
2621 YYSTYPE *yyvaluep;
2622#endif
2623{
2624 /* Pacify ``unused variable'' warnings. */
2625 (void) yyvaluep;
2626
2627 if (yytype < YYNTOKENS)
2628 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2629 else
2630 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2631
2632
2633# ifdef YYPRINT
2634 if (yytype < YYNTOKENS)
2635 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2636# endif
2637 switch (yytype)
2638 {
2639 default:
2640 break;
2641 }
2642 YYFPRINTF (yyoutput, ")");
2643}
2644
2645#endif /* ! YYDEBUG */
2646/*-----------------------------------------------.
2647| Release the memory associated to this symbol. |
2648`-----------------------------------------------*/
2649
2650#if defined (__STDC__) || defined (__cplusplus)
2651static void
2652yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2653#else
2654static void
2655yydestruct (yymsg, yytype, yyvaluep)
2656 const char *yymsg;
2657 int yytype;
2658 YYSTYPE *yyvaluep;
2659#endif
2660{
2661 /* Pacify ``unused variable'' warnings. */
2662 (void) yyvaluep;
2663
2664 if (!yymsg)
2665 yymsg = "Deleting";
2666 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2667
2668 switch (yytype)
2669 {
2670
2671 default:
2672 break;
2673 }
2674}
2675
2676
2677/* Prevent warnings from -Wmissing-prototypes. */
2678
2679#ifdef YYPARSE_PARAM
2680# if defined (__STDC__) || defined (__cplusplus)
2681int yyparse (void *YYPARSE_PARAM);
2682# else
2683int yyparse ();
2684# endif
2685#else /* ! YYPARSE_PARAM */
2686#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002687int yyparse (void);
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002688#else
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002689int yyparse ();
2690#endif
2691#endif /* ! YYPARSE_PARAM */
2692
2693
2694
2695/* The look-ahead symbol. */
2696int yychar;
2697
2698/* The semantic value of the look-ahead symbol. */
2699YYSTYPE yylval;
2700
2701/* Number of syntax errors so far. */
2702int yynerrs;
2703
2704
2705
2706/*----------.
2707| yyparse. |
2708`----------*/
2709
2710#ifdef YYPARSE_PARAM
2711# if defined (__STDC__) || defined (__cplusplus)
2712int yyparse (void *YYPARSE_PARAM)
2713# else
2714int yyparse (YYPARSE_PARAM)
2715 void *YYPARSE_PARAM;
2716# endif
2717#else /* ! YYPARSE_PARAM */
2718#if defined (__STDC__) || defined (__cplusplus)
2719int
2720yyparse (void)
2721#else
2722int
2723yyparse ()
2724
2725#endif
2726#endif
2727{
2728
2729 int yystate;
2730 int yyn;
2731 int yyresult;
2732 /* Number of tokens to shift before error messages enabled. */
2733 int yyerrstatus;
2734 /* Look-ahead token as an internal (translated) token number. */
2735 int yytoken = 0;
2736
2737 /* Three stacks and their tools:
2738 `yyss': related to states,
2739 `yyvs': related to semantic values,
2740 `yyls': related to locations.
2741
2742 Refer to the stacks thru separate pointers, to allow yyoverflow
2743 to reallocate them elsewhere. */
2744
2745 /* The state stack. */
2746 short int yyssa[YYINITDEPTH];
2747 short int *yyss = yyssa;
2748 short int *yyssp;
2749
2750 /* The semantic value stack. */
2751 YYSTYPE yyvsa[YYINITDEPTH];
2752 YYSTYPE *yyvs = yyvsa;
2753 YYSTYPE *yyvsp;
2754
2755
2756
Reid Spencer6f407902007-01-13 05:00:46 +00002757#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002758
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002759 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002760
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002761 /* The variables used to return semantic value and location from the
2762 action routines. */
2763 YYSTYPE yyval;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002764
2765
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002766 /* When reducing, the number of symbols on the RHS of the reduced
2767 rule. */
Reid Spencer6f407902007-01-13 05:00:46 +00002768 int yylen;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002769
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002770 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002771
Reid Spencer68a24bd2005-08-27 18:50:39 +00002772 yystate = 0;
2773 yyerrstatus = 0;
2774 yynerrs = 0;
2775 yychar = YYEMPTY; /* Cause a token to be read. */
2776
2777 /* Initialize stack pointers.
2778 Waste one element of value and location stack
2779 so that they stay on the same level as the state stack.
2780 The wasted elements are never initialized. */
2781
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002782 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002783 yyvsp = yyvs;
2784
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002785 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002786
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002787/*------------------------------------------------------------.
2788| yynewstate -- Push a new state, which is found in yystate. |
2789`------------------------------------------------------------*/
2790 yynewstate:
2791 /* In all cases, when you get here, the value and location stacks
2792 have just been pushed. so pushing a state here evens the stacks.
2793 */
2794 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002795
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002796 yysetstate:
2797 *yyssp = yystate;
2798
2799 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002800 {
2801 /* Get the current used size of the three stacks, in elements. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002802 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002803
2804#ifdef yyoverflow
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002805 {
2806 /* Give user a chance to reallocate the stack. Use copies of
2807 these so that the &'s don't force the real ones into
2808 memory. */
2809 YYSTYPE *yyvs1 = yyvs;
2810 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002811
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002812
2813 /* Each stack pointer address is followed by the size of the
2814 data in use in that stack, in bytes. This used to be a
2815 conditional around just the two extra args, but that might
2816 be undefined if yyoverflow is a macro. */
2817 yyoverflow (YY_("memory exhausted"),
2818 &yyss1, yysize * sizeof (*yyssp),
2819 &yyvs1, yysize * sizeof (*yyvsp),
2820
2821 &yystacksize);
2822
2823 yyss = yyss1;
2824 yyvs = yyvs1;
2825 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002826#else /* no yyoverflow */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002827# ifndef YYSTACK_RELOCATE
2828 goto yyexhaustedlab;
2829# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002830 /* Extend the stack our own way. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002831 if (YYMAXDEPTH <= yystacksize)
2832 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002833 yystacksize *= 2;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002834 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002835 yystacksize = YYMAXDEPTH;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002836
2837 {
2838 short int *yyss1 = yyss;
2839 union yyalloc *yyptr =
2840 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2841 if (! yyptr)
2842 goto yyexhaustedlab;
2843 YYSTACK_RELOCATE (yyss);
2844 YYSTACK_RELOCATE (yyvs);
2845
2846# undef YYSTACK_RELOCATE
2847 if (yyss1 != yyssa)
2848 YYSTACK_FREE (yyss1);
2849 }
2850# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002851#endif /* no yyoverflow */
2852
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002853 yyssp = yyss + yysize - 1;
2854 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002855
2856
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002857 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2858 (unsigned long int) yystacksize));
2859
2860 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002861 YYABORT;
2862 }
2863
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002864 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002865
2866 goto yybackup;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002867
2868/*-----------.
2869| yybackup. |
2870`-----------*/
2871yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002872
Reid Spencer6f407902007-01-13 05:00:46 +00002873/* Do appropriate processing given the current state. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002874/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencer6f407902007-01-13 05:00:46 +00002875/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002876
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002877 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer6f407902007-01-13 05:00:46 +00002878
Reid Spencer68a24bd2005-08-27 18:50:39 +00002879 yyn = yypact[yystate];
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002880 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002881 goto yydefault;
2882
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002883 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002884
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002885 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002886 if (yychar == YYEMPTY)
2887 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002888 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002889 yychar = YYLEX;
2890 }
2891
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002892 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002893 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002894 yychar = yytoken = YYEOF;
2895 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002896 }
2897 else
2898 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002899 yytoken = YYTRANSLATE (yychar);
2900 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002901 }
2902
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002903 /* If the proper action on seeing token YYTOKEN is to reduce or to
2904 detect an error, take that action. */
2905 yyn += yytoken;
2906 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002907 goto yydefault;
2908 yyn = yytable[yyn];
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002909 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002910 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002911 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002912 goto yyerrlab;
2913 yyn = -yyn;
2914 goto yyreduce;
2915 }
2916
2917 if (yyn == YYFINAL)
2918 YYACCEPT;
2919
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002920 /* Shift the look-ahead token. */
2921 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer6f407902007-01-13 05:00:46 +00002922
2923 /* Discard the token being shifted unless it is eof. */
2924 if (yychar != YYEOF)
2925 yychar = YYEMPTY;
2926
2927 *++yyvsp = yylval;
2928
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002929
2930 /* Count tokens shifted since error; after three, turn off error
2931 status. */
2932 if (yyerrstatus)
2933 yyerrstatus--;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002934
Reid Spencer68a24bd2005-08-27 18:50:39 +00002935 yystate = yyn;
2936 goto yynewstate;
2937
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002938
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002939/*-----------------------------------------------------------.
2940| yydefault -- do the default action for the current state. |
2941`-----------------------------------------------------------*/
2942yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002943 yyn = yydefact[yystate];
2944 if (yyn == 0)
2945 goto yyerrlab;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002946 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002947
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002948
2949/*-----------------------------.
2950| yyreduce -- Do a reduction. |
2951`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002952yyreduce:
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002953 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002954 yylen = yyr2[yyn];
2955
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002956 /* If YYLEN is nonzero, implement the default value of the action:
2957 `$$ = $1'.
2958
2959 Otherwise, the following line sets YYVAL to garbage.
2960 This behavior is undocumented and Bison
2961 users should not rely upon it. Assigning to YYVAL
2962 unconditionally makes the parser a bit smaller, and it avoids a
2963 GCC warning that YYVAL may be used uninitialized. */
2964 yyval = yyvsp[1-yylen];
2965
2966
2967 YY_REDUCE_PRINT (yyn);
2968 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002969 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002970 case 3:
2971#line 1032 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
2972 {
2973 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00002974 GEN_ERROR("Value too large for type!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002975 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00002976 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002977;}
2978 break;
2979
2980 case 31:
2981#line 1048 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
2982 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
2983 break;
2984
2985 case 32:
2986#line 1048 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
2987 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
2988 break;
2989
2990 case 33:
2991#line 1049 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
2992 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
2993 break;
2994
2995 case 34:
2996#line 1049 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
2997 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
2998 break;
2999
3000 case 35:
3001#line 1050 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3002 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3003 break;
3004
3005 case 36:
3006#line 1050 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3007 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3008 break;
3009
3010 case 37:
3011#line 1051 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3012 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3013 break;
3014
3015 case 38:
3016#line 1051 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3017 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3018 break;
3019
3020 case 39:
3021#line 1052 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3022 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3023 break;
3024
3025 case 40:
3026#line 1052 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3027 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3028 break;
3029
3030 case 41:
3031#line 1056 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3032 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3033 break;
3034
3035 case 42:
3036#line 1056 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3037 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3038 break;
3039
3040 case 43:
3041#line 1057 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3042 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3043 break;
3044
3045 case 44:
3046#line 1057 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3047 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3048 break;
3049
3050 case 45:
3051#line 1058 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3052 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3053 break;
3054
3055 case 46:
3056#line 1058 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3057 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3058 break;
3059
3060 case 47:
3061#line 1059 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3062 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3063 break;
3064
3065 case 48:
3066#line 1059 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3067 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3068 break;
3069
3070 case 49:
3071#line 1060 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3072 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3073 break;
3074
3075 case 50:
3076#line 1060 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3077 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3078 break;
3079
3080 case 51:
3081#line 1061 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3082 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3083 break;
3084
3085 case 52:
3086#line 1061 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3087 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3088 break;
3089
3090 case 53:
3091#line 1062 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3092 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3093 break;
3094
3095 case 54:
3096#line 1062 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3097 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3098 break;
3099
3100 case 55:
3101#line 1063 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3102 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3103 break;
3104
3105 case 56:
3106#line 1064 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3107 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3108 break;
3109
3110 case 60:
3111#line 1073 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3112 {
3113 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003114 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003115 ;}
3116 break;
3117
3118 case 61:
3119#line 1077 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3120 {
3121 (yyval.StrVal) = 0;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003122 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003123 ;}
3124 break;
3125
3126 case 62:
3127#line 1083 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3128 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3129 break;
3130
3131 case 63:
3132#line 1084 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3133 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3134 break;
3135
3136 case 64:
3137#line 1085 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3138 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3139 break;
3140
3141 case 65:
3142#line 1086 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3143 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3144 break;
3145
3146 case 66:
3147#line 1087 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3148 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3149 break;
3150
3151 case 67:
3152#line 1091 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3153 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3154 break;
3155
3156 case 68:
3157#line 1092 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3158 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3159 break;
3160
3161 case 69:
3162#line 1093 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3163 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3164 break;
3165
3166 case 70:
3167#line 1097 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3168 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3169 break;
3170
3171 case 71:
3172#line 1098 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3173 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3174 break;
3175
3176 case 72:
3177#line 1102 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3178 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3179 break;
3180
3181 case 73:
3182#line 1103 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3183 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3184 break;
3185
3186 case 74:
3187#line 1104 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3188 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3189 break;
3190
3191 case 75:
3192#line 1108 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3193 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3194 break;
3195
3196 case 76:
3197#line 1109 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3198 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3199 break;
3200
3201 case 77:
3202#line 1110 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3203 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3204 break;
3205
3206 case 78:
3207#line 1111 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3208 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3209 break;
3210
3211 case 79:
3212#line 1112 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3213 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3214 break;
3215
3216 case 80:
3217#line 1115 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3218 { (yyval.UIntVal) = CallingConv::C; ;}
3219 break;
3220
3221 case 81:
3222#line 1116 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3223 { (yyval.UIntVal) = CallingConv::C; ;}
3224 break;
3225
3226 case 82:
3227#line 1117 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3228 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3229 break;
3230
3231 case 83:
3232#line 1118 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3233 { (yyval.UIntVal) = CallingConv::Fast; ;}
3234 break;
3235
3236 case 84:
3237#line 1119 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3238 { (yyval.UIntVal) = CallingConv::Cold; ;}
3239 break;
3240
3241 case 85:
3242#line 1120 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3243 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3244 break;
3245
3246 case 86:
3247#line 1121 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3248 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3249 break;
3250
3251 case 87:
3252#line 1122 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3253 {
3254 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003255 GEN_ERROR("Calling conv too large!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003256 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003257 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003258 ;}
3259 break;
3260
3261 case 88:
3262#line 1129 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3263 { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;}
3264 break;
3265
3266 case 89:
3267#line 1130 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3268 { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;}
3269 break;
3270
3271 case 90:
3272#line 1133 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3273 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3274 break;
3275
3276 case 91:
3277#line 1134 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3278 {
3279 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3280 ;}
3281 break;
3282
3283 case 92:
3284#line 1139 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3285 { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;}
3286 break;
3287
3288 case 94:
3289#line 1143 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3290 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3291 break;
3292
3293 case 95:
3294#line 1144 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3295 {
3296 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3297 ;}
3298 break;
3299
3300 case 96:
3301#line 1151 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3302 { (yyval.UIntVal) = 0; ;}
3303 break;
3304
3305 case 97:
3306#line 1152 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3307 {
3308 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3309 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencera54b7cb2007-01-12 07:05:14 +00003310 GEN_ERROR("Alignment must be a power of two!");
3311 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003312;}
3313 break;
3314
3315 case 98:
3316#line 1158 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3317 { (yyval.UIntVal) = 0; ;}
3318 break;
3319
3320 case 99:
3321#line 1159 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3322 {
3323 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3324 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencera54b7cb2007-01-12 07:05:14 +00003325 GEN_ERROR("Alignment must be a power of two!");
3326 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003327;}
3328 break;
3329
3330 case 100:
3331#line 1167 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3332 {
3333 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3334 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencere4d87aa2006-12-23 06:05:41 +00003335 GEN_ERROR("Invalid character in section name!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003336 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003337 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003338;}
3339 break;
3340
3341 case 101:
3342#line 1175 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3343 { (yyval.StrVal) = 0; ;}
3344 break;
3345
3346 case 102:
3347#line 1176 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3348 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3349 break;
3350
3351 case 103:
3352#line 1181 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3353 {;}
3354 break;
3355
3356 case 104:
3357#line 1182 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3358 {;}
3359 break;
3360
3361 case 105:
3362#line 1183 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3363 {
3364 CurGV->setSection((yyvsp[0].StrVal));
3365 free((yyvsp[0].StrVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003366 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003367 ;}
3368 break;
3369
3370 case 106:
3371#line 1188 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3372 {
3373 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003374 GEN_ERROR("Alignment must be a power of two!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003375 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003376 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003377 ;}
3378 break;
3379
3380 case 111:
3381#line 1204 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3382 {
3383 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencera132e042006-12-03 05:46:11 +00003384 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003385 ;}
3386 break;
3387
3388 case 112:
3389#line 1208 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3390 {
3391 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer6f407902007-01-13 05:00:46 +00003392 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003393 ;}
3394 break;
3395
3396 case 113:
3397#line 1212 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3398 { // Pointer type?
3399 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Reid Spencer6f407902007-01-13 05:00:46 +00003400 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003401 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3402 delete (yyvsp[-1].TypeVal);
Reid Spencera132e042006-12-03 05:46:11 +00003403 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003404 ;}
3405 break;
3406
3407 case 114:
3408#line 1219 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3409 { // Named types are also simple types...
3410 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer14310612006-12-31 05:40:51 +00003411 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003412 (yyval.TypeVal) = new PATypeHolder(tmp);
3413 ;}
3414 break;
3415
3416 case 115:
3417#line 1224 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3418 { // Type UpReference
3419 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer3da59db2006-11-27 01:05:10 +00003420 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003421 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3422 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer3da59db2006-11-27 01:05:10 +00003423 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003424 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003425 ;}
3426 break;
3427
3428 case 116:
3429#line 1232 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3430 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003431 std::vector<const Type*> Params;
Reid Spencer14310612006-12-31 05:40:51 +00003432 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003433 Attrs.push_back((yyvsp[0].ParamAttrs));
3434 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00003435 Params.push_back(I->Ty->get());
3436 if (I->Ty->get() != Type::VoidTy)
3437 Attrs.push_back(I->Attrs);
3438 }
Reid Spencer3da59db2006-11-27 01:05:10 +00003439 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3440 if (isVarArg) Params.pop_back();
3441
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003442 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs);
3443 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3444 delete (yyvsp[-4].TypeVal); // Delete the return type handle
3445 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer6f407902007-01-13 05:00:46 +00003446 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003447 ;}
3448 break;
3449
3450 case 117:
3451#line 1250 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3452 {
Reid Spencer6f407902007-01-13 05:00:46 +00003453 std::vector<const Type*> Params;
3454 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003455 Attrs.push_back((yyvsp[0].ParamAttrs));
3456 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer6f407902007-01-13 05:00:46 +00003457 Params.push_back(I->Ty->get());
3458 if (I->Ty->get() != Type::VoidTy)
3459 Attrs.push_back(I->Attrs);
3460 }
3461 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3462 if (isVarArg) Params.pop_back();
3463
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003464 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs);
3465 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3466 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003467 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003468 ;}
3469 break;
3470
3471 case 118:
3472#line 1268 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3473 { // Sized array type?
3474 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3475 delete (yyvsp[-1].TypeVal);
Reid Spencer14310612006-12-31 05:40:51 +00003476 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003477 ;}
3478 break;
3479
3480 case 119:
3481#line 1273 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3482 { // Packed array type?
3483 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3484 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003485 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner42a75512007-01-15 02:27:26 +00003486 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencera54b7cb2007-01-12 07:05:14 +00003487 GEN_ERROR("Element type of a PackedType must be primitive");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003488 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003489 GEN_ERROR("Vector length should be a power of 2!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003490 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3491 delete (yyvsp[-1].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003492 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003493 ;}
3494 break;
3495
3496 case 120:
3497#line 1285 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3498 { // Structure type?
Reid Spencere4d87aa2006-12-23 06:05:41 +00003499 std::vector<const Type*> Elements;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003500 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3501 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencere4d87aa2006-12-23 06:05:41 +00003502 Elements.push_back(*I);
3503
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003504 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3505 delete (yyvsp[-1].TypeList);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003506 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003507 ;}
3508 break;
3509
3510 case 121:
3511#line 1295 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3512 { // Empty structure type?
3513 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003514 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003515 ;}
3516 break;
3517
3518 case 122:
3519#line 1299 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3520 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003521 std::vector<const Type*> Elements;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003522 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3523 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Reid Spencere4d87aa2006-12-23 06:05:41 +00003524 Elements.push_back(*I);
3525
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003526 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3527 delete (yyvsp[-2].TypeList);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003528 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003529 ;}
3530 break;
3531
3532 case 123:
3533#line 1309 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3534 { // Empty structure type?
3535 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003536 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003537 ;}
3538 break;
3539
3540 case 124:
3541#line 1316 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3542 {
3543 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3544 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
3545 ;}
3546 break;
3547
3548 case 125:
3549#line 1323 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3550 {
Reid Spencer6f407902007-01-13 05:00:46 +00003551 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003552 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3553 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Reid Spencer6f407902007-01-13 05:00:46 +00003554 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003555 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3556 ;}
3557 break;
3558
3559 case 126:
3560#line 1330 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3561 {
3562 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3563 ;}
3564 break;
3565
3566 case 127:
3567#line 1335 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3568 {
3569 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3570 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer14310612006-12-31 05:40:51 +00003571 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003572 ;}
3573 break;
3574
3575 case 128:
3576#line 1340 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3577 {
3578 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer14310612006-12-31 05:40:51 +00003579 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003580 ;}
3581 break;
3582
3583 case 130:
3584#line 1348 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3585 {
3586 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer14310612006-12-31 05:40:51 +00003587 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3588 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003589 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003590 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003591 ;}
3592 break;
3593
3594 case 131:
3595#line 1355 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3596 {
3597 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer14310612006-12-31 05:40:51 +00003598 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3599 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003600 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer14310612006-12-31 05:40:51 +00003601 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003602 ;}
3603 break;
3604
3605 case 132:
3606#line 1362 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3607 {
3608 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer14310612006-12-31 05:40:51 +00003609 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003610 ;}
3611 break;
3612
3613 case 133:
3614#line 1370 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3615 {
3616 (yyval.TypeList) = new std::list<PATypeHolder>();
3617 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00003618 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003619 ;}
3620 break;
3621
3622 case 134:
3623#line 1375 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3624 {
3625 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003626 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003627 ;}
3628 break;
3629
3630 case 135:
3631#line 1386 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3632 { // Nonempty unsized arr
Reid Spencer6f407902007-01-13 05:00:46 +00003633 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003634 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3635 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003636 if (ATy == 0)
3637 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003638 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00003639 const Type *ETy = ATy->getElementType();
3640 int NumElements = ATy->getNumElements();
3641
3642 // Verify that we have the correct size...
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003643 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer6f407902007-01-13 05:00:46 +00003644 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003645 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer6f407902007-01-13 05:00:46 +00003646 itostr(NumElements) + "!");
3647
3648 // Verify all elements are correct type!
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003649 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3650 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003651 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3652 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003653 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer6f407902007-01-13 05:00:46 +00003654 }
3655
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003656 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3657 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer3da59db2006-11-27 01:05:10 +00003658 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003659 ;}
3660 break;
3661
3662 case 136:
3663#line 1414 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3664 {
Reid Spencer14310612006-12-31 05:40:51 +00003665 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003666 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3667 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003668 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003669 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003670 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003671
Andrew Lenharth6353e052006-12-08 18:07:09 +00003672 int NumElements = ATy->getNumElements();
3673 if (NumElements != -1 && NumElements != 0)
3674 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
3675 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003676 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3677 delete (yyvsp[-2].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00003678 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003679 ;}
3680 break;
3681
3682 case 137:
3683#line 1430 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3684 {
Reid Spencer6f407902007-01-13 05:00:46 +00003685 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003686 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3687 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003688 if (ATy == 0)
3689 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003690 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00003691
3692 int NumElements = ATy->getNumElements();
3693 const Type *ETy = ATy->getElementType();
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003694 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3695 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer6f407902007-01-13 05:00:46 +00003696 GEN_ERROR("Can't build string constant of size " +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003697 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencer6f407902007-01-13 05:00:46 +00003698 " when array has size " + itostr(NumElements) + "!");
3699 std::vector<Constant*> Vals;
3700 if (ETy == Type::Int8Ty) {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003701 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Reid Spencer6f407902007-01-13 05:00:46 +00003702 C != (unsigned char*)EndStr; ++C)
3703 Vals.push_back(ConstantInt::get(ETy, *C));
3704 } else {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003705 free((yyvsp[0].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003706 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
3707 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003708 free((yyvsp[0].StrVal));
3709 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3710 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003711 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003712 ;}
3713 break;
3714
3715 case 138:
3716#line 1459 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3717 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003718 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003719 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3720 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003721 if (PTy == 0)
3722 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003723 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00003724 const Type *ETy = PTy->getElementType();
3725 int NumElements = PTy->getNumElements();
Reid Spencer61c83e02006-08-18 08:43:06 +00003726
Reid Spencer6f407902007-01-13 05:00:46 +00003727 // Verify that we have the correct size...
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003728 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer6f407902007-01-13 05:00:46 +00003729 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003730 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer6f407902007-01-13 05:00:46 +00003731 itostr(NumElements) + "!");
3732
3733 // Verify all elements are correct type!
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003734 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3735 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003736 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3737 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003738 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003739 }
Reid Spencer6f407902007-01-13 05:00:46 +00003740
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003741 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3742 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003743 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003744 ;}
3745 break;
3746
3747 case 139:
3748#line 1487 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3749 {
3750 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003751 if (STy == 0)
3752 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003753 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003754
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003755 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer6f407902007-01-13 05:00:46 +00003756 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003757
Reid Spencer6f407902007-01-13 05:00:46 +00003758 // Check to ensure that constants are compatible with the type initializer!
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003759 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3760 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer6f407902007-01-13 05:00:46 +00003761 GEN_ERROR("Expected type '" +
3762 STy->getElementType(i)->getDescription() +
3763 "' for element #" + utostr(i) +
3764 " of structure initializer!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003765
Reid Spencer6f407902007-01-13 05:00:46 +00003766 // Check to ensure that Type is not packed
3767 if (STy->isPacked())
3768 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3769
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003770 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3771 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003772 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003773 ;}
3774 break;
3775
3776 case 140:
3777#line 1512 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3778 {
Reid Spencer6f407902007-01-13 05:00:46 +00003779 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003780 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3781 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003782 if (STy == 0)
3783 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003784 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003785
Reid Spencer6f407902007-01-13 05:00:46 +00003786 if (STy->getNumContainedTypes() != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00003787 GEN_ERROR("Illegal number of initializers for structure type!");
3788
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003789 // Check to ensure that Type is not packed
3790 if (STy->isPacked())
3791 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3792
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003793 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3794 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003795 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003796 ;}
3797 break;
3798
3799 case 141:
3800#line 1531 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3801 {
3802 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003803 if (STy == 0)
3804 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003805 (*(yyvsp[-5].TypeVal))->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003806
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003807 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003808 GEN_ERROR("Illegal number of initializers for structure type!");
3809
3810 // Check to ensure that constants are compatible with the type initializer!
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003811 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
3812 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003813 GEN_ERROR("Expected type '" +
3814 STy->getElementType(i)->getDescription() +
3815 "' for element #" + utostr(i) +
3816 " of structure initializer!");
3817
3818 // Check to ensure that Type is packed
3819 if (!STy->isPacked())
3820 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3821
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003822 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
3823 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003824 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003825 ;}
3826 break;
3827
3828 case 142:
3829#line 1556 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3830 {
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003831 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003832 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
3833 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003834 if (STy == 0)
3835 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003836 (*(yyvsp[-4].TypeVal))->getDescription() + "'!");
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003837
3838 if (STy->getNumContainedTypes() != 0)
3839 GEN_ERROR("Illegal number of initializers for structure type!");
3840
3841 // Check to ensure that Type is packed
3842 if (!STy->isPacked())
3843 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3844
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003845 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3846 delete (yyvsp[-4].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00003847 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003848 ;}
3849 break;
3850
3851 case 143:
3852#line 1575 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3853 {
Reid Spencer6f407902007-01-13 05:00:46 +00003854 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003855 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3856 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003857 if (PTy == 0)
3858 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003859 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00003860
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003861 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3862 delete (yyvsp[-1].TypeVal);
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003863 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003864 ;}
3865 break;
3866
3867 case 144:
3868#line 1587 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3869 {
Reid Spencer14310612006-12-31 05:40:51 +00003870 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003871 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3872 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3873 delete (yyvsp[-1].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003874 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003875 ;}
3876 break;
3877
3878 case 145:
3879#line 1594 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3880 {
Reid Spencer14310612006-12-31 05:40:51 +00003881 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003882 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3883 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003884 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003885 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003886
3887 // ConstExprs can exist in the body of a function, thus creating
3888 // GlobalValues whenever they refer to a variable. Because we are in
3889 // the context of a function, getValNonImprovising will search the functions
3890 // symbol table instead of the module symbol table for the global symbol,
3891 // which throws things all off. To get around this, we just tell
3892 // getValNonImprovising that we are at global scope here.
3893 //
3894 Function *SavedCurFn = CurFun.CurrentFunction;
3895 CurFun.CurrentFunction = 0;
3896
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003897 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003898 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003899
3900 CurFun.CurrentFunction = SavedCurFn;
3901
3902 // If this is an initializer for a constant pointer, which is referencing a
3903 // (currently) undefined variable, create a stub now that shall be replaced
3904 // in the future with the right type of variable.
3905 //
3906 if (V == 0) {
3907 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3908 const PointerType *PT = cast<PointerType>(Ty);
3909
3910 // First check to see if the forward references value is already created!
3911 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003912 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003913
3914 if (I != CurModule.GlobalRefs.end()) {
3915 V = I->second; // Placeholder already exists, use it...
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003916 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003917 } else {
3918 std::string Name;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003919 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003920
3921 // Create the forward referenced global.
3922 GlobalValue *GV;
3923 if (const FunctionType *FTy =
3924 dyn_cast<FunctionType>(PT->getElementType())) {
3925 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3926 CurModule.CurrentModule);
3927 } else {
3928 GV = new GlobalVariable(PT->getElementType(), false,
3929 GlobalValue::ExternalLinkage, 0,
3930 Name, CurModule.CurrentModule);
3931 }
3932
3933 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003934 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003935 V = GV;
3936 }
3937 }
3938
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003939 (yyval.ConstVal) = cast<GlobalValue>(V);
3940 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer6f407902007-01-13 05:00:46 +00003941 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003942 ;}
3943 break;
3944
3945 case 146:
3946#line 1657 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3947 {
Reid Spencer6f407902007-01-13 05:00:46 +00003948 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003949 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3950 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003951 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003952 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
3953 (yyval.ConstVal) = (yyvsp[0].ConstVal);
3954 delete (yyvsp[-1].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003955 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003956 ;}
3957 break;
3958
3959 case 147:
3960#line 1667 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3961 {
Reid Spencer14310612006-12-31 05:40:51 +00003962 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003963 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3964 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer6f407902007-01-13 05:00:46 +00003965 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3966 GEN_ERROR("Cannot create a null initialized value of this type!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003967 (yyval.ConstVal) = Constant::getNullValue(Ty);
3968 delete (yyvsp[-1].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003969 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003970 ;}
3971 break;
3972
3973 case 148:
3974#line 1677 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3975 { // integral constants
3976 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencer6f407902007-01-13 05:00:46 +00003977 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003978 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003979 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003980 ;}
3981 break;
3982
3983 case 149:
3984#line 1683 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3985 { // integral constants
3986 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencer14310612006-12-31 05:40:51 +00003987 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003988 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
Reid Spencer14310612006-12-31 05:40:51 +00003989 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003990 ;}
3991 break;
3992
3993 case 150:
3994#line 1689 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3995 { // Boolean constants
3996 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
3997 (yyval.ConstVal) = ConstantInt::getTrue();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003998 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003999 ;}
4000 break;
4001
4002 case 151:
4003#line 1694 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4004 { // Boolean constants
4005 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4006 (yyval.ConstVal) = ConstantInt::getFalse();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004007 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004008 ;}
4009 break;
4010
4011 case 152:
4012#line 1699 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4013 { // Float & Double constants
4014 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004015 GEN_ERROR("Floating point constant invalid for type!!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004016 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004017 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004018 ;}
4019 break;
4020
4021 case 153:
4022#line 1707 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4023 {
Reid Spencer14310612006-12-31 05:40:51 +00004024 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004025 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4026 Constant *Val = (yyvsp[-3].ConstVal);
4027 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4028 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
4029 GEN_ERROR("invalid cast opcode for cast from '" +
4030 Val->getType()->getDescription() + "' to '" +
4031 DestTy->getDescription() + "'!");
4032 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4033 delete (yyvsp[-1].TypeVal);
4034 ;}
4035 break;
4036
4037 case 154:
4038#line 1719 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4039 {
4040 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00004041 GEN_ERROR("GetElementPtr requires a pointer operand!");
4042
4043 const Type *IdxTy =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004044 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004045 if (!IdxTy)
4046 GEN_ERROR("Index list invalid for constant getelementptr!");
4047
4048 std::vector<Constant*> IdxVec;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004049 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4050 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Andrew Lenharth6353e052006-12-08 18:07:09 +00004051 IdxVec.push_back(C);
4052 else
4053 GEN_ERROR("Indices to constant getelementptr must be constants!");
4054
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004055 delete (yyvsp[-1].ValueList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004056
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004057 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
Reid Spencer6f407902007-01-13 05:00:46 +00004058 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004059 ;}
4060 break;
4061
4062 case 155:
4063#line 1740 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4064 {
4065 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00004066 GEN_ERROR("Select condition must be of boolean type!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004067 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00004068 GEN_ERROR("Select operand types must match!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004069 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004070 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004071 ;}
4072 break;
4073
4074 case 156:
4075#line 1748 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4076 {
4077 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00004078 GEN_ERROR("Binary operator types must match!");
4079 CHECK_FOR_ERROR;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004080 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4081 ;}
4082 break;
4083
4084 case 157:
4085#line 1754 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4086 {
4087 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004088 GEN_ERROR("Logical operator types must match!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004089 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4090 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
4091 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004092 GEN_ERROR("Logical operator requires integral operands!");
4093 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004094 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004095 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004096 ;}
4097 break;
4098
4099 case 158:
4100#line 1765 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4101 {
4102 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004103 GEN_ERROR("icmp operand types must match!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004104 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4105 ;}
4106 break;
4107
4108 case 159:
4109#line 1770 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4110 {
4111 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00004112 GEN_ERROR("fcmp operand types must match!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004113 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4114 ;}
4115 break;
4116
4117 case 160:
4118#line 1775 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4119 {
4120 if ((yyvsp[-1].ConstVal)->getType() != Type::Int8Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00004121 GEN_ERROR("Shift count for shift constant must be i8 type!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004122 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
Reid Spencer6f407902007-01-13 05:00:46 +00004123 GEN_ERROR("Shift constant expression requires integer operand!");
4124 CHECK_FOR_ERROR;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004125 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004126 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004127 ;}
4128 break;
4129
4130 case 161:
4131#line 1784 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4132 {
4133 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer6f407902007-01-13 05:00:46 +00004134 GEN_ERROR("Invalid extractelement operands!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004135 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004136 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004137 ;}
4138 break;
4139
4140 case 162:
4141#line 1790 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4142 {
4143 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer6f407902007-01-13 05:00:46 +00004144 GEN_ERROR("Invalid insertelement operands!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004145 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004146 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004147 ;}
4148 break;
4149
4150 case 163:
4151#line 1796 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4152 {
4153 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer6f407902007-01-13 05:00:46 +00004154 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004155 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004156 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004157 ;}
4158 break;
4159
4160 case 164:
4161#line 1805 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4162 {
4163 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004164 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004165 ;}
4166 break;
4167
4168 case 165:
4169#line 1809 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4170 {
4171 (yyval.ConstVector) = new std::vector<Constant*>();
4172 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004173 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004174 ;}
4175 break;
4176
4177 case 166:
4178#line 1817 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4179 { (yyval.BoolVal) = false; ;}
4180 break;
4181
4182 case 167:
4183#line 1817 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4184 { (yyval.BoolVal) = true; ;}
4185 break;
4186
4187 case 168:
4188#line 1828 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4189 {
4190 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer6f407902007-01-13 05:00:46 +00004191 CurModule.ModuleDone();
4192 CHECK_FOR_ERROR;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004193 ;}
4194 break;
4195
4196 case 169:
4197#line 1833 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4198 {
4199 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer14310612006-12-31 05:40:51 +00004200 CurModule.ModuleDone();
4201 CHECK_FOR_ERROR;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004202 ;}
4203 break;
4204
4205 case 172:
4206#line 1846 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4207 { CurFun.isDeclare = false ;}
4208 break;
4209
4210 case 173:
4211#line 1846 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4212 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004213 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004214 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004215 ;}
4216 break;
4217
4218 case 174:
4219#line 1850 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4220 { CurFun.isDeclare = true; ;}
4221 break;
4222
4223 case 175:
4224#line 1850 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4225 {
Reid Spencer6f407902007-01-13 05:00:46 +00004226 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004227 ;}
4228 break;
4229
4230 case 176:
4231#line 1853 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4232 {
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004233 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004234 ;}
4235 break;
4236
4237 case 177:
4238#line 1856 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4239 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004240 // Emit an error if there are any unresolved types left.
4241 if (!CurModule.LateResolveTypes.empty()) {
4242 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00004243 if (DID.Type == ValID::NameVal) {
4244 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4245 } else {
4246 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4247 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004248 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004249 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004250 ;}
4251 break;
4252
4253 case 178:
4254#line 1868 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4255 {
Reid Spencer14310612006-12-31 05:40:51 +00004256 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004257 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004258 // Eagerly resolve types. This is not an optimization, this is a
4259 // requirement that is due to the fact that we could have this:
4260 //
4261 // %list = type { %list * }
4262 // %list = type { %list * } ; repeated type decl
4263 //
4264 // If types are not resolved eagerly, then the two types will not be
4265 // determined to be the same type!
4266 //
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004267 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004268
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004269 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004270 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004271 // If this is a named type that is not a redefinition, add it to the slot
4272 // table.
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004273 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004274 }
Reid Spencera132e042006-12-03 05:46:11 +00004275
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004276 delete (yyvsp[0].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004277 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004278 ;}
4279 break;
Reid Spencer6f407902007-01-13 05:00:46 +00004280
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004281 case 179:
4282#line 1892 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4283 {
4284 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
4285
4286 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer6f407902007-01-13 05:00:46 +00004287 CHECK_FOR_ERROR
4288 // If this is a named type that is not a redefinition, add it to the slot
4289 // table.
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004290 CurModule.Types.push_back((yyvsp[0].PrimType));
Reid Spencer6f407902007-01-13 05:00:46 +00004291 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004292 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004293 ;}
4294 break;
4295
4296 case 180:
4297#line 1903 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4298 { /* "Externally Visible" Linkage */
4299 if ((yyvsp[0].ConstVal) == 0)
Reid Spencer6f407902007-01-13 05:00:46 +00004300 GEN_ERROR("Global value initializer is not a constant!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004301 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage,
4302 (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Reid Spencer14310612006-12-31 05:40:51 +00004303 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004304 ;}
4305 break;
4306
4307 case 181:
4308#line 1909 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4309 {
Reid Spencer6f407902007-01-13 05:00:46 +00004310 CurGV = 0;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004311 ;}
4312 break;
4313
4314 case 182:
4315#line 1912 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4316 {
4317 if ((yyvsp[0].ConstVal) == 0)
Reid Spencer6f407902007-01-13 05:00:46 +00004318 GEN_ERROR("Global value initializer is not a constant!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004319 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004320 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004321 ;}
4322 break;
4323
4324 case 183:
4325#line 1917 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4326 {
Reid Spencer6f407902007-01-13 05:00:46 +00004327 CurGV = 0;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004328 ;}
4329 break;
4330
4331 case 184:
4332#line 1920 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4333 {
Reid Spencer6f407902007-01-13 05:00:46 +00004334 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004335 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4336 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer6f407902007-01-13 05:00:46 +00004337 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004338 delete (yyvsp[0].TypeVal);
4339 ;}
4340 break;
4341
4342 case 185:
4343#line 1926 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4344 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004345 CurGV = 0;
4346 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004347 ;}
4348 break;
4349
4350 case 186:
4351#line 1930 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4352 {
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004353 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004354 ;}
4355 break;
4356
4357 case 187:
4358#line 1933 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4359 {
Reid Spencer218ded22007-01-05 17:07:23 +00004360 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004361 ;}
4362 break;
4363
4364 case 188:
4365#line 1939 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4366 {
Chris Lattner66316012006-01-24 04:14:29 +00004367 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004368 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4369 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4370 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004371
4372 if (AsmSoFar.empty())
4373 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4374 else
4375 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004376 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004377;}
4378 break;
4379
4380 case 189:
4381#line 1952 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4382 { (yyval.Endianness) = Module::BigEndian; ;}
4383 break;
4384
4385 case 190:
4386#line 1953 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4387 { (yyval.Endianness) = Module::LittleEndian; ;}
4388 break;
4389
4390 case 191:
4391#line 1955 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4392 {
4393 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
Reid Spencer6f407902007-01-13 05:00:46 +00004394 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004395 ;}
4396 break;
4397
4398 case 192:
4399#line 1959 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4400 {
4401 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer6f407902007-01-13 05:00:46 +00004402 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004403 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer6f407902007-01-13 05:00:46 +00004404 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4405 else
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004406 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004407 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004408 ;}
4409 break;
4410
4411 case 193:
4412#line 1968 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4413 {
4414 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4415 free((yyvsp[0].StrVal));
4416 ;}
4417 break;
4418
4419 case 194:
4420#line 1972 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4421 {
4422 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4423 free((yyvsp[0].StrVal));
4424 ;}
4425 break;
4426
4427 case 196:
4428#line 1979 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4429 {
4430 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4431 free((yyvsp[0].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004432 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004433 ;}
4434 break;
4435
4436 case 197:
4437#line 1984 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4438 {
4439 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4440 free((yyvsp[0].StrVal));
Reid Spencera54b7cb2007-01-12 07:05:14 +00004441 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004442 ;}
4443 break;
4444
4445 case 198:
4446#line 1989 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4447 {
Reid Spencera54b7cb2007-01-12 07:05:14 +00004448 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004449 ;}
4450 break;
4451
4452 case 202:
4453#line 1999 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4454 { (yyval.StrVal) = 0; ;}
4455 break;
4456
4457 case 203:
4458#line 2001 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4459 {
Reid Spencer14310612006-12-31 05:40:51 +00004460 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004461 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4462 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencer14310612006-12-31 05:40:51 +00004463 GEN_ERROR("void typed arguments are invalid!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004464 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4465 (yyval.ArgList) = (yyvsp[-4].ArgList);
4466 (yyvsp[-4].ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004467 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004468 ;}
4469 break;
4470
4471 case 204:
4472#line 2011 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4473 {
Reid Spencer14310612006-12-31 05:40:51 +00004474 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004475 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4476 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencer14310612006-12-31 05:40:51 +00004477 GEN_ERROR("void typed arguments are invalid!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004478 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4479 (yyval.ArgList) = new ArgListType;
4480 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004481 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004482 ;}
4483 break;
4484
4485 case 205:
4486#line 2022 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4487 {
4488 (yyval.ArgList) = (yyvsp[0].ArgList);
Reid Spencer6f407902007-01-13 05:00:46 +00004489 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004490 ;}
4491 break;
4492
4493 case 206:
4494#line 2026 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4495 {
4496 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer6f407902007-01-13 05:00:46 +00004497 struct ArgListEntry E;
4498 E.Ty = new PATypeHolder(Type::VoidTy);
4499 E.Name = 0;
4500 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004501 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004502 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004503 ;}
4504 break;
4505
4506 case 207:
4507#line 2035 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4508 {
4509 (yyval.ArgList) = new ArgListType;
Reid Spencer14310612006-12-31 05:40:51 +00004510 struct ArgListEntry E;
4511 E.Ty = new PATypeHolder(Type::VoidTy);
4512 E.Name = 0;
4513 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004514 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004515 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004516 ;}
4517 break;
4518
4519 case 208:
4520#line 2044 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4521 {
4522 (yyval.ArgList) = 0;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004523 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004524 ;}
4525 break;
4526
4527 case 209:
4528#line 2050 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4529 {
4530 UnEscapeLexed((yyvsp[-6].StrVal));
4531 std::string FunctionName((yyvsp[-6].StrVal));
4532 free((yyvsp[-6].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004533
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004534 // Check the function result for abstractness if this is a define. We should
4535 // have no abstract types at this point
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004536 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4537 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004538
Reid Spencer68a24bd2005-08-27 18:50:39 +00004539 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00004540 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004541 ParamAttrs.push_back((yyvsp[-2].ParamAttrs));
4542 if ((yyvsp[-4].ArgList)) { // If there are arguments...
4543 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004544 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004545 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4546 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004547 ParamTypeList.push_back(Ty);
4548 if (Ty != Type::VoidTy)
4549 ParamAttrs.push_back(I->Attrs);
4550 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004551 }
4552
4553 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4554 if (isVarArg) ParamTypeList.pop_back();
4555
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004556 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00004557 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004558 const PointerType *PFT = PointerType::get(FT);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004559 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004560
4561 ValID ID;
4562 if (!FunctionName.empty()) {
4563 ID = ValID::create((char*)FunctionName.c_str());
4564 } else {
4565 ID = ValID::create((int)CurModule.Values[PFT].size());
4566 }
4567
4568 Function *Fn = 0;
4569 // See if this function was forward referenced. If so, recycle the object.
4570 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4571 // Move the function to the end of the list, from whereever it was
4572 // previously inserted.
4573 Fn = cast<Function>(FWRef);
4574 CurModule.CurrentModule->getFunctionList().remove(Fn);
4575 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4576 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4577 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4578 // If this is the case, either we need to be a forward decl, or it needs
4579 // to be.
4580 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004581 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004582
4583 // Make sure to strip off any argument names so we can't get conflicts.
4584 if (Fn->isExternal())
4585 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4586 AI != AE; ++AI)
4587 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004588 } else { // Not already defined?
4589 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4590 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004591
Reid Spencer68a24bd2005-08-27 18:50:39 +00004592 InsertValue(Fn, CurModule.Values);
4593 }
4594
4595 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004596
4597 if (CurFun.isDeclare) {
4598 // If we have declaration, always overwrite linkage. This will allow us to
4599 // correctly handle cases, when pointer to function is passed as argument to
4600 // another function.
4601 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004602 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004603 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004604 Fn->setCallingConv((yyvsp[-8].UIntVal));
4605 Fn->setAlignment((yyvsp[0].UIntVal));
4606 if ((yyvsp[-1].StrVal)) {
4607 Fn->setSection((yyvsp[-1].StrVal));
4608 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004609 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004610
4611 // Add all of the arguments we parsed to the function...
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004612 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004613 if (isVarArg) { // Nuke the last entry
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004614 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0&&
Reid Spencera132e042006-12-03 05:46:11 +00004615 "Not a varargs marker!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004616 delete (yyvsp[-4].ArgList)->back().Ty;
4617 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004618 }
4619 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer14310612006-12-31 05:40:51 +00004620 unsigned Idx = 1;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004621 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004622 delete I->Ty; // Delete the typeholder...
4623 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004624 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004625 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004626 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004627 }
Reid Spencera132e042006-12-03 05:46:11 +00004628
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004629 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004630 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004631 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004632;}
4633 break;
4634
4635 case 212:
4636#line 2157 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4637 {
4638 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004639
4640 // Make sure that we keep track of the linkage type even if there was a
4641 // previous "declare".
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004642 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4643 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
4644;}
4645 break;
4646
4647 case 215:
4648#line 2168 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4649 {
4650 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004651 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004652;}
4653 break;
4654
4655 case 216:
4656#line 2173 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4657 {
4658 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4659 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
4660 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004661 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004662 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004663 ;}
4664 break;
4665
4666 case 217:
4667#line 2185 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4668 {
4669 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004670 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004671 ;}
4672 break;
4673
4674 case 218:
4675#line 2189 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4676 {
4677 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004678 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004679 ;}
4680 break;
4681
4682 case 219:
4683#line 2194 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4684 { // A reference to a direct constant
4685 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencer6f407902007-01-13 05:00:46 +00004686 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004687 ;}
4688 break;
4689
4690 case 220:
4691#line 2198 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4692 {
4693 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004694 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004695 ;}
4696 break;
4697
4698 case 221:
4699#line 2202 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4700 { // Perhaps it's an FP constant?
4701 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004702 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004703 ;}
4704 break;
4705
4706 case 222:
4707#line 2206 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4708 {
4709 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004710 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004711 ;}
4712 break;
4713
4714 case 223:
4715#line 2210 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4716 {
4717 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004718 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004719 ;}
4720 break;
4721
4722 case 224:
4723#line 2214 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4724 {
4725 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004726 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004727 ;}
4728 break;
4729
4730 case 225:
4731#line 2218 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4732 {
4733 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004734 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004735 ;}
4736 break;
4737
4738 case 226:
4739#line 2222 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4740 { // A vector zero constant.
4741 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004742 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004743 ;}
4744 break;
4745
4746 case 227:
4747#line 2226 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4748 { // Nonempty unsized packed vector
4749 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4750 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004751
4752 PackedType* pt = PackedType::get(ETy, NumElements);
4753 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004754 HandleUpRefs(
4755 PackedType::get(
4756 ETy,
4757 NumElements)
4758 )
4759 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004760
4761 // Verify all elements are correct type!
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004762 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4763 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004764 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004765 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004766 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004767 }
4768
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004769 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4770 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer6f407902007-01-13 05:00:46 +00004771 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004772 ;}
4773 break;
Reid Spencer6f407902007-01-13 05:00:46 +00004774
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004775 case 228:
4776#line 2251 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4777 {
4778 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004779 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004780 ;}
4781 break;
4782
4783 case 229:
4784#line 2255 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4785 {
4786 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4787 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4788 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4789 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4790 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4791 free((yyvsp[-2].StrVal));
4792 free((yyvsp[0].StrVal));
4793 CHECK_FOR_ERROR
4794 ;}
4795 break;
4796
4797 case 230:
4798#line 2269 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4799 { // Is it an integer reference...?
4800 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4801 CHECK_FOR_ERROR
4802 ;}
4803 break;
4804
4805 case 231:
4806#line 2273 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4807 { // Is it a named reference...?
4808 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4809 CHECK_FOR_ERROR
4810 ;}
4811 break;
4812
4813 case 234:
4814#line 2285 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4815 {
4816 if (!UpRefs.empty())
4817 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4818 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
4819 delete (yyvsp[-1].TypeVal);
4820 CHECK_FOR_ERROR
4821 ;}
4822 break;
4823
4824 case 235:
4825#line 2294 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4826 {
4827 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4828 CHECK_FOR_ERROR
4829 ;}
4830 break;
4831
4832 case 236:
4833#line 2298 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4834 { // Do not allow functions with 0 basic blocks
4835 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4836 CHECK_FOR_ERROR
4837 ;}
4838 break;
4839
4840 case 237:
4841#line 2307 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4842 {
4843 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4844 CHECK_FOR_ERROR
4845 InsertValue((yyvsp[0].TermInstVal));
4846
4847 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4848 InsertValue((yyvsp[-2].BasicBlockVal));
4849 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
4850 CHECK_FOR_ERROR
4851 ;}
4852 break;
4853
4854 case 238:
4855#line 2318 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4856 {
4857 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Reid Spencer6f407902007-01-13 05:00:46 +00004858 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4859 if (CI2->getParent() == 0)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004860 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
4861 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4862 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004863 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004864 ;}
4865 break;
4866
4867 case 239:
4868#line 2327 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4869 {
4870 (yyval.BasicBlockVal) = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004871 CHECK_FOR_ERROR
4872
4873 // Make sure to move the basic block to the correct location in the
4874 // function, instead of leaving it inserted wherever it was first
4875 // referenced.
4876 Function::BasicBlockListType &BBL =
4877 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004878 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004879 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004880 ;}
4881 break;
4882
4883 case 240:
4884#line 2339 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4885 {
4886 (yyval.BasicBlockVal) = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004887 CHECK_FOR_ERROR
4888
4889 // Make sure to move the basic block to the correct location in the
4890 // function, instead of leaving it inserted wherever it was first
4891 // referenced.
4892 Function::BasicBlockListType &BBL =
4893 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004894 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004895 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004896 ;}
4897 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00004898
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004899 case 241:
4900#line 2352 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4901 { // Return with a result...
4902 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4903 CHECK_FOR_ERROR
4904 ;}
4905 break;
4906
4907 case 242:
4908#line 2356 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4909 { // Return with no result...
4910 (yyval.TermInstVal) = new ReturnInst();
4911 CHECK_FOR_ERROR
4912 ;}
4913 break;
4914
4915 case 243:
4916#line 2360 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4917 { // Unconditional Branch...
4918 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
4919 CHECK_FOR_ERROR
4920 (yyval.TermInstVal) = new BranchInst(tmpBB);
4921 ;}
4922 break;
4923
4924 case 244:
4925#line 2365 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4926 {
4927 assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?");
4928 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
4929 CHECK_FOR_ERROR
4930 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
4931 CHECK_FOR_ERROR
4932 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
4933 CHECK_FOR_ERROR
4934 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4935 ;}
4936 break;
4937
4938 case 245:
4939#line 2375 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4940 {
4941 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
4942 CHECK_FOR_ERROR
4943 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
4944 CHECK_FOR_ERROR
4945 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
4946 (yyval.TermInstVal) = S;
4947
4948 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4949 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004950 for (; I != E; ++I) {
4951 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4952 S->addCase(CI, I->second);
4953 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004954 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004955 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004956 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00004957 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004958 ;}
4959 break;
4960
4961 case 246:
4962#line 2394 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4963 {
4964 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004965 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004966 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004967 CHECK_FOR_ERROR
4968 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004969 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004970 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004971 ;}
4972 break;
4973
4974 case 247:
4975#line 2404 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4976 {
Reid Spencer3822ff52006-11-08 06:47:33 +00004977
Reid Spencer14310612006-12-31 05:40:51 +00004978 // Handle the short syntax
4979 const PointerType *PFTy = 0;
4980 const FunctionType *Ty = 0;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004981 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004982 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4983 // Pull out the types of all of the arguments...
4984 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00004985 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004986 ParamAttrs.push_back((yyvsp[-6].ParamAttrs));
4987 for (ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004988 const Type *Ty = I->Val->getType();
4989 if (Ty == Type::VoidTy)
4990 GEN_ERROR("Short call syntax cannot be used with varargs");
4991 ParamTypes.push_back(Ty);
4992 ParamAttrs.push_back(I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004993 }
4994
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004995 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004996 PFTy = PointerType::get(Ty);
4997 }
4998
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004999 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005000 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005001 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005002 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005003 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005004 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005005
Reid Spencer14310612006-12-31 05:40:51 +00005006 // Check the arguments
5007 ValueList Args;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005008 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005009 // Make sure no arguments is a good thing!
5010 if (Ty->getNumParams() != 0)
5011 GEN_ERROR("No arguments passed to a function that "
5012 "expects arguments!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005013 } else { // Has arguments?
5014 // Loop through FunctionType's arguments and ensure they are specified
5015 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005016 FunctionType::param_iterator I = Ty->param_begin();
5017 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005018 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005019
Reid Spencer14310612006-12-31 05:40:51 +00005020 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5021 if (ArgI->Val->getType() != *I)
5022 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencera132e042006-12-03 05:46:11 +00005023 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00005024 Args.push_back(ArgI->Val);
5025 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005026
Reid Spencer14310612006-12-31 05:40:51 +00005027 if (Ty->isVarArg()) {
5028 if (I == E)
5029 for (; ArgI != ArgE; ++ArgI)
5030 Args.push_back(ArgI->Val); // push the remaining varargs
5031 } else if (I != E || ArgI != ArgE)
Reid Spencer61c83e02006-08-18 08:43:06 +00005032 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005033 }
Reid Spencer14310612006-12-31 05:40:51 +00005034
5035 // Create the InvokeInst
5036 InvokeInst *II = new InvokeInst(V, Normal, Except, Args);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005037 II->setCallingConv((yyvsp[-12].UIntVal));
5038 (yyval.TermInstVal) = II;
5039 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005040 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005041 ;}
5042 break;
5043
5044 case 248:
5045#line 2470 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5046 {
5047 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005048 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005049 ;}
5050 break;
5051
5052 case 249:
5053#line 2474 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5054 {
5055 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005056 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005057 ;}
5058 break;
5059
5060 case 250:
5061#line 2481 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5062 {
5063 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5064 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005065 CHECK_FOR_ERROR
5066 if (V == 0)
5067 GEN_ERROR("May only switch on a constant pool value!");
5068
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005069 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005070 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005071 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5072 ;}
5073 break;
5074
5075 case 251:
5076#line 2492 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5077 {
5078 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5079 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005080 CHECK_FOR_ERROR
5081
5082 if (V == 0)
5083 GEN_ERROR("May only switch on a constant pool value!");
5084
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005085 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005086 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005087 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5088 ;}
5089 break;
5090
5091 case 252:
5092#line 2505 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5093 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00005094 // Is this definition named?? if so, assign the name...
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005095 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005096 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005097 InsertValue((yyvsp[0].InstVal));
5098 (yyval.InstVal) = (yyvsp[0].InstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005099 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005100;}
5101 break;
5102
5103 case 253:
5104#line 2514 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5105 { // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00005106 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005107 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
5108 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5109 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005110 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005111 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005112 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005113 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5114 delete (yyvsp[-5].TypeVal);
5115 ;}
5116 break;
5117
5118 case 254:
5119#line 2525 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5120 {
5121 (yyval.PHIList) = (yyvsp[-6].PHIList);
5122 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005123 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005124 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005125 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005126 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5127 ;}
5128 break;
5129
5130 case 255:
5131#line 2535 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5132 {
Reid Spencer6f407902007-01-13 05:00:46 +00005133 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005134 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Reid Spencer6f407902007-01-13 05:00:46 +00005135 // Used for call and invoke instructions
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005136 (yyval.ValueRefList) = new ValueRefList();
5137 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5138 (yyval.ValueRefList)->push_back(E);
5139 ;}
5140 break;
5141
5142 case 256:
5143#line 2543 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5144 {
Reid Spencer14310612006-12-31 05:40:51 +00005145 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005146 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5147 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5148 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5149 (yyval.ValueRefList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005150 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005151 ;}
5152 break;
5153
5154 case 257:
5155#line 2551 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5156 { (yyval.ValueRefList) = new ValueRefList(); ;}
5157 break;
5158
5159 case 258:
5160#line 2554 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5161 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5162 break;
5163
5164 case 259:
5165#line 2555 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5166 {
5167 (yyval.ValueList) = (yyvsp[-2].ValueList);
5168 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer14310612006-12-31 05:40:51 +00005169 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005170 ;}
5171 break;
5172
5173 case 260:
5174#line 2562 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5175 {
5176 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005177 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005178 ;}
5179 break;
5180
5181 case 261:
5182#line 2566 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5183 {
5184 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005185 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005186 ;}
5187 break;
5188
5189 case 262:
5190#line 2571 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5191 {
Reid Spencer14310612006-12-31 05:40:51 +00005192 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005193 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5194 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5195 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005196 GEN_ERROR(
5197 "Arithmetic operator requires integer, FP, or packed operands!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005198 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) &&
5199 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5200 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5201 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005202 GEN_ERROR("U/S/FRem not supported on packed types!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005203 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005204 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005205 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005206 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005207 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
5208 if ((yyval.InstVal) == 0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00005209 GEN_ERROR("binary operator returned null!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005210 delete (yyvsp[-3].TypeVal);
5211 ;}
5212 break;
5213
5214 case 263:
5215#line 2592 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5216 {
Reid Spencer6f407902007-01-13 05:00:46 +00005217 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005218 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5219 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5220 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
5221 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Reid Spencer6f407902007-01-13 05:00:46 +00005222 GEN_ERROR("Logical operator requires integral operands!");
5223 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005224 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005225 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005226 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005227 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005228 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
5229 if ((yyval.InstVal) == 0)
Reid Spencer6f407902007-01-13 05:00:46 +00005230 GEN_ERROR("binary operator returned null!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005231 delete (yyvsp[-3].TypeVal);
5232 ;}
5233 break;
5234
5235 case 264:
5236#line 2609 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5237 {
Reid Spencer14310612006-12-31 05:40:51 +00005238 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005239 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5240 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencerac4a1dd2007-01-04 02:57:52 +00005241 GEN_ERROR("Packed types not supported by icmp instruction");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005242 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005243 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005244 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005245 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005246 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5247 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005248 GEN_ERROR("icmp operator returned null!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005249 ;}
5250 break;
5251
5252 case 265:
5253#line 2622 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5254 {
Reid Spencer14310612006-12-31 05:40:51 +00005255 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005256 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5257 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencerac4a1dd2007-01-04 02:57:52 +00005258 GEN_ERROR("Packed types not supported by fcmp instruction");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005259 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005260 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005261 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005262 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005263 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5264 if ((yyval.InstVal) == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005265 GEN_ERROR("fcmp operator returned null!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005266 ;}
5267 break;
5268
5269 case 266:
5270#line 2635 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5271 {
5272 if ((yyvsp[0].ValueVal)->getType() != Type::Int8Ty)
Reid Spencer14310612006-12-31 05:40:51 +00005273 GEN_ERROR("Shift amount must be i8 type!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005274 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
Andrew Lenharth6353e052006-12-08 18:07:09 +00005275 GEN_ERROR("Shift constant expression requires integer operand!");
5276 CHECK_FOR_ERROR;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005277 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005278 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005279 ;}
5280 break;
5281
5282 case 267:
5283#line 2644 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5284 {
Reid Spencer14310612006-12-31 05:40:51 +00005285 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005286 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5287 Value* Val = (yyvsp[-2].ValueVal);
5288 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5289 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
5290 GEN_ERROR("invalid cast opcode for cast from '" +
5291 Val->getType()->getDescription() + "' to '" +
5292 DestTy->getDescription() + "'!");
5293 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5294 delete (yyvsp[0].TypeVal);
5295 ;}
5296 break;
5297
5298 case 268:
5299#line 2656 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5300 {
5301 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00005302 GEN_ERROR("select condition must be boolean!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005303 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00005304 GEN_ERROR("select value types should match!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005305 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005306 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005307 ;}
5308 break;
5309
5310 case 269:
5311#line 2664 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5312 {
Reid Spencer6f407902007-01-13 05:00:46 +00005313 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005314 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5315 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5316 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005317 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005318 ;}
5319 break;
5320
5321 case 270:
5322#line 2671 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5323 {
5324 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer6f407902007-01-13 05:00:46 +00005325 GEN_ERROR("Invalid extractelement operands!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005326 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005327 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005328 ;}
5329 break;
5330
5331 case 271:
5332#line 2677 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5333 {
5334 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer6f407902007-01-13 05:00:46 +00005335 GEN_ERROR("Invalid insertelement operands!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005336 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005337 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005338 ;}
5339 break;
5340
5341 case 272:
5342#line 2683 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5343 {
5344 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer6f407902007-01-13 05:00:46 +00005345 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005346 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005347 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005348 ;}
5349 break;
5350
5351 case 273:
5352#line 2689 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5353 {
5354 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Reid Spencer6f407902007-01-13 05:00:46 +00005355 if (!Ty->isFirstClassType())
5356 GEN_ERROR("PHI node operands must be of first class type!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005357 (yyval.InstVal) = new PHINode(Ty);
5358 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5359 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5360 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00005361 GEN_ERROR("All elements of a PHI node must be of the same type!");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005362 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5363 (yyvsp[0].PHIList)->pop_front();
Reid Spencer6f407902007-01-13 05:00:46 +00005364 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005365 delete (yyvsp[0].PHIList); // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005366 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005367 ;}
5368 break;
5369
5370 case 274:
5371#line 2705 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5372 {
Reid Spencer14310612006-12-31 05:40:51 +00005373
5374 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005375 const PointerType *PFTy = 0;
5376 const FunctionType *Ty = 0;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005377 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005378 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5379 // Pull out the types of all of the arguments...
5380 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005381 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005382 ParamAttrs.push_back((yyvsp[0].ParamAttrs));
5383 for (ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005384 const Type *Ty = I->Val->getType();
5385 if (Ty == Type::VoidTy)
5386 GEN_ERROR("Short call syntax cannot be used with varargs");
5387 ParamTypes.push_back(Ty);
5388 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005389 }
5390
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005391 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005392 PFTy = PointerType::get(Ty);
5393 }
5394
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005395 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005396 CHECK_FOR_ERROR
5397
Reid Spencer14310612006-12-31 05:40:51 +00005398 // Check the arguments
5399 ValueList Args;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005400 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005401 // Make sure no arguments is a good thing!
5402 if (Ty->getNumParams() != 0)
5403 GEN_ERROR("No arguments passed to a function that "
5404 "expects arguments!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005405 } else { // Has arguments?
5406 // Loop through FunctionType's arguments and ensure they are specified
5407 // correctly!
5408 //
5409 FunctionType::param_iterator I = Ty->param_begin();
5410 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005411 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005412
Reid Spencer14310612006-12-31 05:40:51 +00005413 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5414 if (ArgI->Val->getType() != *I)
5415 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Andrew Lenharth6353e052006-12-08 18:07:09 +00005416 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00005417 Args.push_back(ArgI->Val);
5418 }
5419 if (Ty->isVarArg()) {
5420 if (I == E)
5421 for (; ArgI != ArgE; ++ArgI)
5422 Args.push_back(ArgI->Val); // push the remaining varargs
5423 } else if (I != E || ArgI != ArgE)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005424 GEN_ERROR("Invalid number of parameters detected!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005425 }
Reid Spencer14310612006-12-31 05:40:51 +00005426 // Create the call node
5427 CallInst *CI = new CallInst(V, Args);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005428 CI->setTailCall((yyvsp[-7].BoolVal));
5429 CI->setCallingConv((yyvsp[-6].UIntVal));
5430 (yyval.InstVal) = CI;
5431 delete (yyvsp[-2].ValueRefList);
Reid Spencer6f407902007-01-13 05:00:46 +00005432 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005433 ;}
5434 break;
5435
5436 case 275:
5437#line 2767 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5438 {
5439 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005440 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005441 ;}
5442 break;
5443
5444 case 276:
5445#line 2772 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5446 {
5447 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005448 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005449 ;}
5450 break;
5451
5452 case 277:
5453#line 2776 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5454 {
5455 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005456 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005457 ;}
5458 break;
5459
5460 case 278:
5461#line 2783 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5462 {
Reid Spencer14310612006-12-31 05:40:51 +00005463 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005464 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5465 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5466 delete (yyvsp[-1].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005467 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005468 ;}
5469 break;
5470
5471 case 279:
5472#line 2790 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5473 {
Reid Spencer6f407902007-01-13 05:00:46 +00005474 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005475 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5476 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005477 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005478 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5479 delete (yyvsp[-4].TypeVal);
5480 ;}
5481 break;
5482
5483 case 280:
5484#line 2798 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5485 {
Reid Spencer14310612006-12-31 05:40:51 +00005486 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005487 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5488 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5489 delete (yyvsp[-1].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005490 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005491 ;}
5492 break;
5493
5494 case 281:
5495#line 2805 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5496 {
Reid Spencer14310612006-12-31 05:40:51 +00005497 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005498 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5499 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005500 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005501 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5502 delete (yyvsp[-4].TypeVal);
5503 ;}
5504 break;
5505
5506 case 282:
5507#line 2813 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5508 {
5509 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Reid Spencer6f407902007-01-13 05:00:46 +00005510 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005511 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
5512 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005513 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005514 ;}
5515 break;
5516
5517 case 283:
5518#line 2821 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5519 {
Reid Spencer6f407902007-01-13 05:00:46 +00005520 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005521 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5522 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Reid Spencer6f407902007-01-13 05:00:46 +00005523 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005524 (*(yyvsp[-1].TypeVal))->getDescription());
5525 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Reid Spencer6f407902007-01-13 05:00:46 +00005526 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005527 (*(yyvsp[-1].TypeVal))->getDescription());
5528 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005529 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005530 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5531 delete (yyvsp[-1].TypeVal);
5532 ;}
5533 break;
5534
5535 case 284:
5536#line 2835 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5537 {
Reid Spencer14310612006-12-31 05:40:51 +00005538 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005539 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5540 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer6f407902007-01-13 05:00:46 +00005541 if (!PT)
5542 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005543 (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencer6f407902007-01-13 05:00:46 +00005544 const Type *ElTy = PT->getElementType();
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005545 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5546 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencer6f407902007-01-13 05:00:46 +00005547 "' into space of type '" + ElTy->getDescription() + "'!");
5548
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005549 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005550 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005551 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5552 delete (yyvsp[-1].TypeVal);
5553 ;}
5554 break;
5555
5556 case 285:
5557#line 2852 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5558 {
Reid Spencer14310612006-12-31 05:40:51 +00005559 if (!UpRefs.empty())
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005560 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5561 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005562 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005563
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005564 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005565 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005566 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
5567 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005568 CHECK_FOR_ERROR
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005569 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
5570 delete (yyvsp[-2].TypeVal);
5571 delete (yyvsp[0].ValueList);
5572 ;}
5573 break;
5574
5575
5576 default: break;
5577 }
5578
5579/* Line 1126 of yacc.c. */
5580#line 5581 "llvmAsmParser.tab.c"
Reid Spencer6f407902007-01-13 05:00:46 +00005581
5582 yyvsp -= yylen;
5583 yyssp -= yylen;
5584
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005585
5586 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005587
5588 *++yyvsp = yyval;
5589
5590
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005591 /* Now `shift' the result of the reduction. Determine what state
5592 that goes to, based on the state we popped back to and the rule
5593 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005594
5595 yyn = yyr1[yyn];
5596
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005597 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5598 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005599 yystate = yytable[yystate];
5600 else
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005601 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005602
5603 goto yynewstate;
5604
5605
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005606/*------------------------------------.
5607| yyerrlab -- here on detecting error |
5608`------------------------------------*/
5609yyerrlab:
5610 /* If not already recovering from an error, report this error. */
5611 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005612 {
5613 ++yynerrs;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005614#if YYERROR_VERBOSE
Reid Spencer6f407902007-01-13 05:00:46 +00005615 yyn = yypact[yystate];
Chris Lattner0fab59c2007-01-12 18:33:30 +00005616
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005617 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencer6f407902007-01-13 05:00:46 +00005618 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005619 int yytype = YYTRANSLATE (yychar);
5620 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5621 YYSIZE_T yysize = yysize0;
5622 YYSIZE_T yysize1;
5623 int yysize_overflow = 0;
5624 char *yymsg = 0;
5625# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5626 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5627 int yyx;
Reid Spencer6f407902007-01-13 05:00:46 +00005628
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005629#if 0
5630 /* This is so xgettext sees the translatable formats that are
5631 constructed on the fly. */
5632 YY_("syntax error, unexpected %s");
5633 YY_("syntax error, unexpected %s, expecting %s");
5634 YY_("syntax error, unexpected %s, expecting %s or %s");
5635 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5636 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5637#endif
5638 char *yyfmt;
5639 char const *yyf;
5640 static char const yyunexpected[] = "syntax error, unexpected %s";
5641 static char const yyexpecting[] = ", expecting %s";
5642 static char const yyor[] = " or %s";
5643 char yyformat[sizeof yyunexpected
5644 + sizeof yyexpecting - 1
5645 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5646 * (sizeof yyor - 1))];
5647 char const *yyprefix = yyexpecting;
5648
5649 /* Start YYX at -YYN if negative to avoid negative indexes in
5650 YYCHECK. */
5651 int yyxbegin = yyn < 0 ? -yyn : 0;
5652
5653 /* Stay within bounds of both yycheck and yytname. */
5654 int yychecklim = YYLAST - yyn;
5655 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5656 int yycount = 1;
5657
5658 yyarg[0] = yytname[yytype];
5659 yyfmt = yystpcpy (yyformat, yyunexpected);
5660
5661 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5662 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5663 {
5664 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5665 {
5666 yycount = 1;
5667 yysize = yysize0;
5668 yyformat[sizeof yyunexpected - 1] = '\0';
5669 break;
5670 }
5671 yyarg[yycount++] = yytname[yyx];
5672 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5673 yysize_overflow |= yysize1 < yysize;
5674 yysize = yysize1;
5675 yyfmt = yystpcpy (yyfmt, yyprefix);
5676 yyprefix = yyor;
5677 }
5678
5679 yyf = YY_(yyformat);
5680 yysize1 = yysize + yystrlen (yyf);
5681 yysize_overflow |= yysize1 < yysize;
5682 yysize = yysize1;
5683
5684 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5685 yymsg = (char *) YYSTACK_ALLOC (yysize);
5686 if (yymsg)
Reid Spencer6f407902007-01-13 05:00:46 +00005687 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005688 /* Avoid sprintf, as that infringes on the user's name space.
5689 Don't have undefined behavior even if the translation
5690 produced a string with the wrong number of "%s"s. */
5691 char *yyp = yymsg;
5692 int yyi = 0;
5693 while ((*yyp = *yyf))
Reid Spencer6f407902007-01-13 05:00:46 +00005694 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005695 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5696 {
5697 yyp += yytnamerr (yyp, yyarg[yyi++]);
5698 yyf += 2;
5699 }
5700 else
5701 {
5702 yyp++;
5703 yyf++;
5704 }
Reid Spencer6f407902007-01-13 05:00:46 +00005705 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005706 yyerror (yymsg);
5707 YYSTACK_FREE (yymsg);
Reid Spencer6f407902007-01-13 05:00:46 +00005708 }
5709 else
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005710 {
5711 yyerror (YY_("syntax error"));
5712 goto yyexhaustedlab;
5713 }
Reid Spencer6f407902007-01-13 05:00:46 +00005714 }
5715 else
5716#endif /* YYERROR_VERBOSE */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005717 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005718 }
5719
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005720
Reid Spencer68a24bd2005-08-27 18:50:39 +00005721
5722 if (yyerrstatus == 3)
5723 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005724 /* If just tried and failed to reuse look-ahead token after an
5725 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005726
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005727 if (yychar <= YYEOF)
5728 {
5729 /* Return failure if at end of input. */
5730 if (yychar == YYEOF)
5731 YYABORT;
5732 }
5733 else
5734 {
5735 yydestruct ("Error: discarding", yytoken, &yylval);
5736 yychar = YYEMPTY;
5737 }
5738 }
5739
5740 /* Else will try to reuse look-ahead token after shifting the error
5741 token. */
5742 goto yyerrlab1;
5743
5744
5745/*---------------------------------------------------.
5746| yyerrorlab -- error raised explicitly by YYERROR. |
5747`---------------------------------------------------*/
5748yyerrorlab:
5749
5750 /* Pacify compilers like GCC when the user code never invokes
5751 YYERROR and the label yyerrorlab therefore never appears in user
5752 code. */
5753 if (0)
5754 goto yyerrorlab;
5755
5756yyvsp -= yylen;
5757 yyssp -= yylen;
5758 yystate = *yyssp;
5759 goto yyerrlab1;
5760
5761
5762/*-------------------------------------------------------------.
5763| yyerrlab1 -- common code for both syntax error and YYERROR. |
5764`-------------------------------------------------------------*/
5765yyerrlab1:
5766 yyerrstatus = 3; /* Each real token shifted decrements this. */
5767
5768 for (;;)
5769 {
5770 yyn = yypact[yystate];
5771 if (yyn != YYPACT_NINF)
5772 {
5773 yyn += YYTERROR;
5774 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5775 {
5776 yyn = yytable[yyn];
5777 if (0 < yyn)
5778 break;
5779 }
5780 }
5781
5782 /* Pop the current state because it cannot handle the error token. */
5783 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005784 YYABORT;
5785
Reid Spencere4d87aa2006-12-23 06:05:41 +00005786
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005787 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5788 YYPOPSTACK;
5789 yystate = *yyssp;
5790 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005791 }
5792
5793 if (yyn == YYFINAL)
5794 YYACCEPT;
5795
Reid Spencer68a24bd2005-08-27 18:50:39 +00005796 *++yyvsp = yylval;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005797
5798
5799 /* Shift the error token. */
5800 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005801
Reid Spencer68a24bd2005-08-27 18:50:39 +00005802 yystate = yyn;
5803 goto yynewstate;
5804
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00005805
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005806/*-------------------------------------.
5807| yyacceptlab -- YYACCEPT comes here. |
5808`-------------------------------------*/
5809yyacceptlab:
5810 yyresult = 0;
5811 goto yyreturn;
5812
5813/*-----------------------------------.
5814| yyabortlab -- YYABORT comes here. |
5815`-----------------------------------*/
5816yyabortlab:
5817 yyresult = 1;
5818 goto yyreturn;
5819
5820#ifndef yyoverflow
5821/*-------------------------------------------------.
5822| yyexhaustedlab -- memory exhaustion comes here. |
5823`-------------------------------------------------*/
5824yyexhaustedlab:
5825 yyerror (YY_("memory exhausted"));
5826 yyresult = 2;
5827 /* Fall through. */
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00005828#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005829
5830yyreturn:
5831 if (yychar != YYEOF && yychar != YYEMPTY)
5832 yydestruct ("Cleanup: discarding lookahead",
5833 yytoken, &yylval);
5834 while (yyssp != yyss)
5835 {
5836 yydestruct ("Cleanup: popping",
5837 yystos[*yyssp], yyvsp);
5838 YYPOPSTACK;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00005839 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005840#ifndef yyoverflow
5841 if (yyss != yyssa)
5842 YYSTACK_FREE (yyss);
5843#endif
5844 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005845}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005846
5847
5848#line 2869 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005849
5850
Reid Spencer14310612006-12-31 05:40:51 +00005851// common code from the two 'RunVMAsmParser' functions
5852static Module* RunParser(Module * M) {
5853
5854 llvmAsmlineno = 1; // Reset the current line number...
5855 CurModule.CurrentModule = M;
5856#if YYDEBUG
5857 yydebug = Debug;
5858#endif
5859
5860 // Check to make sure the parser succeeded
5861 if (yyparse()) {
5862 if (ParserResult)
5863 delete ParserResult;
5864 return 0;
5865 }
5866
5867 // Check to make sure that parsing produced a result
5868 if (!ParserResult)
5869 return 0;
5870
5871 // Reset ParserResult variable while saving its value for the result.
5872 Module *Result = ParserResult;
5873 ParserResult = 0;
5874
5875 return Result;
5876}
5877
Reid Spencer61c83e02006-08-18 08:43:06 +00005878void llvm::GenerateError(const std::string &message, int LineNo) {
5879 if (LineNo == -1) LineNo = llvmAsmlineno;
5880 // TODO: column number in exception
5881 if (TheParseError)
5882 TheParseError->setError(CurFilename, message, LineNo);
5883 TriggerError = 1;
5884}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005885
5886int yyerror(const char *ErrorMsg) {
5887 std::string where
5888 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5889 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5890 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5891 if (yychar == YYEMPTY || yychar == 0)
5892 errMsg += "end-of-file.";
5893 else
5894 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005895 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005896 return 0;
5897}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005898